DOLFIN User Manual - FEniCS Project
DOLFIN User Manual - FEniCS Project DOLFIN User Manual - FEniCS Project
DOLFIN User ManualHoffman, Jansson, Logg, Wellsuint M = 100;uint N = 100;Matrix A(M,N);Similarly, the vector class Vector allows for a simple initialization of a Mvector:Vector b(M);Further, wrappers for some basic linear algebra functionality, such as matrixvector multiplication, norms etc., are provided with an intentionally simpleinterface, for example, matrix vector multiplication is defined by:Vector Ax;A.mult(b,Ax);For more advanced operations, a pointer to the PETSc matrix and vector isaccessed by mat() and vec() respectively.3.2 Matrix-free matricesThe DOLFIN class VirtualMatrix represents a matrix-free matrix of dimensionM × M. The matrix-free matrix is a simple wrapper for a PETScshell matrix. The interface is intentionally simple, and for advanced usagethe PETSc Mat pointer is accessed by the function mat().The class VirtualMatrix enables the use of Krylov subspace methods forlinear systems Ax = b, without having to explicitly store the matrix A. Allthat is needed is that the user-defined VirtualMatrix implements multiplicationwith vectors. Note that the multiplication operator needs to bedefined in terms of PETSc data structures (Vec), since it will be called fromPETSc.26
DOLFIN User ManualHoffman, Jansson, Logg, Wells3.3 Linear solversA general interface to all linear solvers for systems of the form Ax = b isprovided through the class LinearSolver.In particular, wrappers for a direct LU solver and an iterative Krylov GMRESsolver are implemented in the classes LU and GMRES.To solve the linear system Ax = b using GMRES in DOLFIN, simply write:Vec x;GMRES solver;solver.solve(A,x,b);DOLFIN also provides a wrapper for an eigenvalue solver in PETSc. Thefollowing code computes the eigenvalues of the matrix A,Vector er, ec;EigenvalueSolver esolver;esolver.eigen(A,er,ec);The real components of the eigenvalues are returned in the vector er andthe complex components of the eigenvalues are returned in the vector ec.The procedure for computing the eigenvalues of a matrix is computationallyintensive and should only be used for relatively small matrices.3.4 PreconditioningThe Preconditioner class specifies the interface for user-defined Krylovmethod preconditioners. To implement our own preconditioner we only needto supply a function that approximately solves the linear system given aright-hand side.27
- Page 1 and 2: DOLFIN User ManualFebruary 24, 2006
- Page 3 and 4: ContentsAbout this manual 91 Introd
- Page 5 and 6: DOLFIN User ManualHoffman, Jansson,
- Page 7: DOLFIN User ManualHoffman, Jansson,
- Page 12 and 13: DOLFIN User ManualHoffman, Jansson,
- Page 14 and 15: DOLFIN User ManualHoffman, Jansson,
- Page 16 and 17: DOLFIN User ManualHoffman, Jansson,
- Page 18 and 19: DOLFIN User ManualHoffman, Jansson,
- Page 20 and 21: DOLFIN User ManualHoffman, Jansson,
- Page 22 and 23: DOLFIN User ManualHoffman, Jansson,
- Page 25: Chapter 3Linear algebra◮ Develope
- Page 29 and 30: Chapter 4The mesh◮ Developer’s
- Page 31 and 32: DOLFIN User ManualHoffman, Jansson,
- Page 33 and 34: Chapter 5Functions◮ Developer’s
- Page 35 and 36: DOLFIN User ManualHoffman, Jansson,
- Page 37 and 38: DOLFIN User ManualHoffman, Jansson,
- Page 39 and 40: DOLFIN User ManualHoffman, Jansson,
- Page 41 and 42: DOLFIN User ManualHoffman, Jansson,
- Page 43: Chapter 6Ordinary differential equa
- Page 46 and 47: DOLFIN User ManualHoffman, Jansson,
- Page 48 and 49: DOLFIN User ManualHoffman, Jansson,
- Page 50 and 51: DOLFIN User ManualHoffman, Jansson,
- Page 53 and 54: Chapter 8Nonlinear solver◮ Develo
- Page 55: DOLFIN User ManualHoffman, Jansson,
- Page 58 and 59: DOLFIN User ManualHoffman, Jansson,
- Page 60 and 61: DOLFIN User ManualHoffman, Jansson,
- Page 62 and 63: DOLFIN User ManualHoffman, Jansson,
- Page 65 and 66: Chapter 10The log systemDOLFIN prov
- Page 67 and 68: DOLFIN User ManualHoffman, Jansson,
- Page 69 and 70: DOLFIN User ManualHoffman, Jansson,
- Page 71: DOLFIN User ManualHoffman, Jansson,
- Page 74 and 75: DOLFIN User ManualHoffman, Jansson,
<strong>DOLFIN</strong> <strong>User</strong> <strong>Manual</strong>Hoffman, Jansson, Logg, Wells3.3 Linear solversA general interface to all linear solvers for systems of the form Ax = b isprovided through the class LinearSolver.In particular, wrappers for a direct LU solver and an iterative Krylov GMRESsolver are implemented in the classes LU and GMRES.To solve the linear system Ax = b using GMRES in <strong>DOLFIN</strong>, simply write:Vec x;GMRES solver;solver.solve(A,x,b);<strong>DOLFIN</strong> also provides a wrapper for an eigenvalue solver in PETSc. Thefollowing code computes the eigenvalues of the matrix A,Vector er, ec;EigenvalueSolver esolver;esolver.eigen(A,er,ec);The real components of the eigenvalues are returned in the vector er andthe complex components of the eigenvalues are returned in the vector ec.The procedure for computing the eigenvalues of a matrix is computationallyintensive and should only be used for relatively small matrices.3.4 PreconditioningThe Preconditioner class specifies the interface for user-defined Krylovmethod preconditioners. To implement our own preconditioner we only needto supply a function that approximately solves the linear system given aright-hand side.27