19.06.2015 Views

A FEniCS Tutorial - FEniCS Project

A FEniCS Tutorial - FEniCS Project

A FEniCS Tutorial - FEniCS Project

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

solution during program development. More in-depth visual investigations of finite<br />

element solutions will normally benefit from using highly professional tools<br />

such as ParaView and VisIt.<br />

The next three sections deal with some technicalities about specifying the<br />

solution method for linear systems (so that you can solve large problems) and<br />

examining array data from the computed solution (so that you can check that<br />

theprogramiscorrect). Thesetechnicalitiesarescatteredaroundinforthcoming<br />

programs. However, the impatient reader who is more interested in seeing the<br />

previous program being adapted to a real physical problem, and play around<br />

withsomeinterestingvisualizations, cansafelyjumptoSection1.7. Information<br />

in the intermediate sections can be studied on demand.<br />

1.4 Controlling the Solution Process<br />

Sparse LU decomposition (Gaussian elimination) is used by default to solve<br />

linear systems of equations in <strong>FEniCS</strong> programs. This is a very robust and<br />

recommended method for a few thousand unknowns in the equation system,<br />

and may hence be the method of choice in many 2D and smaller 3D problems.<br />

However, sparse LU decomposition becomes slow and memory demanding in<br />

large problems. This fact forces the use of iterative methods, which are faster<br />

and require much less memory.<br />

Preconditioned Krylov solvers is a type of popular iterative methods that<br />

are easily accessible in <strong>FEniCS</strong> programs. The Poisson equation results in a<br />

symmetric, positive definite coefficient matrix, for which the optimal Krylov<br />

solver is the Conjugate Gradient (CG) method. Incomplete LU factorization<br />

(ILU) is a popular and robust all-round preconditioner, so let us try the CG–<br />

ILU pair:<br />

solve(a == L, u, bc)<br />

solver_parameters={’linear_solver’: ’cg’,<br />

’preconditioner’: ’ilu’})<br />

# Alternative syntax<br />

solve(a == L, u, bc,<br />

solver_parameters=dict(linear_solver=’cg’,<br />

preconditioner=’ilu’))<br />

Section 7.4 lists the most popular choices of Krylov solvers and preconditioners<br />

available in <strong>FEniCS</strong><br />

The actual CG and ILU implementations that are brought into action depends<br />

on the choice of linear algebra package. <strong>FEniCS</strong> interfaces several linear<br />

algebra packages, called linear algebra backends in <strong>FEniCS</strong> terminology. PETSc<br />

is the default choice if DOLFIN is compiled with PETSc, otherwise uBLAS.<br />

Epetra (Trilinos) and MTL4 are two other supported backends. Which backend<br />

to apply can be controlled by setting<br />

parameters[’linear_algebra_backend’] = backendname<br />

15

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

Saved successfully!

Ooh no, something went wrong!