A FEniCS Tutorial - FEniCS Project

A FEniCS Tutorial - FEniCS Project A FEniCS Tutorial - FEniCS Project

fenicsproject.org
from fenicsproject.org More from this publisher
19.06.2015 Views

Figure 1: Plot of the solution in the first FEniCS example. Figure 2: Plot of the mesh in the first FEniCS example. 14

solution during program development. More in-depth visual investigations of finite element solutions will normally benefit from using highly professional tools such as ParaView and VisIt. The next three sections deal with some technicalities about specifying the solution method for linear systems (so that you can solve large problems) and examining array data from the computed solution (so that you can check that theprogramiscorrect). Thesetechnicalitiesarescatteredaroundinforthcoming programs. However, the impatient reader who is more interested in seeing the previous program being adapted to a real physical problem, and play around withsomeinterestingvisualizations, cansafelyjumptoSection1.7. Information in the intermediate sections can be studied on demand. 1.4 Controlling the Solution Process Sparse LU decomposition (Gaussian elimination) is used by default to solve linear systems of equations in FEniCS programs. This is a very robust and recommended method for a few thousand unknowns in the equation system, and may hence be the method of choice in many 2D and smaller 3D problems. However, sparse LU decomposition becomes slow and memory demanding in large problems. This fact forces the use of iterative methods, which are faster and require much less memory. Preconditioned Krylov solvers is a type of popular iterative methods that are easily accessible in FEniCS programs. The Poisson equation results in a symmetric, positive definite coefficient matrix, for which the optimal Krylov solver is the Conjugate Gradient (CG) method. Incomplete LU factorization (ILU) is a popular and robust all-round preconditioner, so let us try the CG– ILU pair: solve(a == L, u, bc) solver_parameters={’linear_solver’: ’cg’, ’preconditioner’: ’ilu’}) # Alternative syntax solve(a == L, u, bc, solver_parameters=dict(linear_solver=’cg’, preconditioner=’ilu’)) Section 7.4 lists the most popular choices of Krylov solvers and preconditioners available in FEniCS The actual CG and ILU implementations that are brought into action depends on the choice of linear algebra package. FEniCS interfaces several linear algebra packages, called linear algebra backends in FEniCS terminology. PETSc is the default choice if DOLFIN is compiled with PETSc, otherwise uBLAS. Epetra (Trilinos) and MTL4 are two other supported backends. Which backend to apply can be controlled by setting parameters[’linear_algebra_backend’] = backendname 15

Figure 1: Plot of the solution in the first <strong>FEniCS</strong> example.<br />

Figure 2: Plot of the mesh in the first <strong>FEniCS</strong> example.<br />

14

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!