Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
| fenics:2017 [2018/06/27 14:43] – admin | fenics:2017 [2018/06/28 09:29] (Version actuelle) – [Batch Mode with SGE] admin | ||
|---|---|---|---|
| Ligne 19: | Ligne 19: | ||
| Or simply run: | Or simply run: | ||
| < | < | ||
| - | $ $SING_SPOOL/ | + | $ $SING_SPOOL/ |
| </ | </ | ||
| - | < | + | < |
| + | Since Fenics | ||
| + | |||
| + | '' | ||
| + | was unable | ||
| + | |||
| + | Module: OpenFabrics (openib) | ||
| + | Host: mesoshared | ||
| + | |||
| + | Another transport will be used instead, although this may result in | ||
| + | lower performance. | ||
| + | '' | ||
| </ | </ | ||
| + | |||
| + | |||
| =====Batch Mode with SGE ===== | =====Batch Mode with SGE ===== | ||
| - | Example of sGE SGE script to use. | + | Example of SGE script to use. |
| <code bash> | <code bash> | ||
| #!/bin/bash | #!/bin/bash | ||
| Ligne 38: | Ligne 51: | ||
| module load tools/ | module load tools/ | ||
| - | export | + | export |
| singularity exec $SING_SPOOL/ | singularity exec $SING_SPOOL/ | ||
| Ligne 46: | Ligne 59: | ||
| $ qsub script.sge | $ qsub script.sge | ||
| </ | </ | ||
| + | |||
| + | ===== Program Example (poisson.py) ===== | ||
| + | |||
| + | < | ||
| + | """ | ||
| + | FEniCS tutorial demo program: Poisson equation with Dirichlet conditions. | ||
| + | Test problem is chosen to give an exact solution at all nodes of the mesh. | ||
| + | |||
| + | -Laplace(u) = f in the unit square | ||
| + | u = u_D on the boundary | ||
| + | |||
| + | u_D = 1 + x^2 + 2y^2 | ||
| + | f = -6 | ||
| + | """ | ||
| + | |||
| + | from __future__ import print_function | ||
| + | from fenics import * | ||
| + | |||
| + | # Create mesh and define function space | ||
| + | mesh = UnitSquareMesh(8, | ||
| + | V = FunctionSpace(mesh, | ||
| + | |||
| + | # Define boundary condition | ||
| + | u_D = Expression(' | ||
| + | |||
| + | def boundary(x, on_boundary): | ||
| + | return on_boundary | ||
| + | |||
| + | bc = DirichletBC(V, | ||
| + | |||
| + | # Define variational problem | ||
| + | u = TrialFunction(V) | ||
| + | v = TestFunction(V) | ||
| + | f = Constant(-6.0) | ||
| + | a = dot(grad(u), | ||
| + | L = f*v*dx | ||
| + | |||
| + | # Compute solution | ||
| + | u = Function(V) | ||
| + | solve(a == L, u, bc) | ||
| + | |||
| + | # Plot solution and mesh | ||
| + | plot(u) | ||
| + | plot(mesh) | ||
| + | |||
| + | # Save solution to file in VTK format | ||
| + | vtkfile = File(' | ||
| + | vtkfile << u | ||
| + | |||
| + | # Compute error in L2 norm | ||
| + | error_L2 = errornorm(u_D, | ||
| + | |||
| + | # Compute maximum error at vertices | ||
| + | vertex_values_u_D = u_D.compute_vertex_values(mesh) | ||
| + | vertex_values_u = u.compute_vertex_values(mesh) | ||
| + | import numpy as np | ||
| + | error_max = np.max(np.abs(vertex_values_u_D - vertex_values_u)) | ||
| + | |||
| + | # Print errors | ||
| + | print(' | ||
| + | print(' | ||
| + | |||
| + | # Hold plot | ||
| + | # interactive() //OLD methode to plot | ||
| + | |||
| + | import matplotlib.pyplot as plt | ||
| + | plot(u) | ||
| + | plt.show() | ||
| + | |||
| + | </ | ||