dolfin
play

DOLFIN Dynamic Object-oriented Library for FINite element - PowerPoint PPT Presentation

DOLFIN Dynamic Object-oriented Library for FINite element computation Johan Hoffman and Anders Logg hoffman@math.chalmers.se logg@math.chalmers.se Chalmers Finite Element Center CAM Seminar April 12 2002 DOLFIN p.1/48 Introduction An


  1. DOLFIN Dynamic Object-oriented Library for FINite element computation Johan Hoffman and Anders Logg hoffman@math.chalmers.se logg@math.chalmers.se Chalmers Finite Element Center CAM Seminar April 12 2002 DOLFIN – p.1/48

  2. Introduction An adaptive finite element solver for PDEs Written by people at the Department of Computational Mathematics (Hoffman/Logg) Written in C++ Highly modularized DOLFIN is a solver. No grid generation. No visualisation. Licensed under the GNU GPL http://www.phi.chalmers.se/dolfin CAM Seminar April 12 2002 DOLFIN – p.2/48

  3. GNU and the GPL Makes the software free for all users “Free” as in “free speech”, not “free beer” Free to modify, change, copy, redistribute Derived work must also use the GPL license Enables sharing of code Simplifies distribution of the program Linux is distributed under the GPL license See http://www.gnu.org CAM Seminar April 12 2002 DOLFIN – p.3/48

  4. Features 3D or 2D Automatic assembling Tetrahedrons or triangles Linear elements Algebraic solvers: LU, GMRES, CG Missing: mesh refinement, adaptivity, multi-grid CAM Seminar April 12 2002 DOLFIN – p.4/48

  5. DOLFIN examples Start movie 1 (driven cavity, solution) Start movie 2 (driven cavity, dual) Start movie 3 (driven cavity, dual) Start movie 4 (bluff body, solution) Start movie 5 (bluff body, dual) Start movie 6 (jet, solution) Start movie 7 (transition to turbulence) CAM Seminar April 12 2002 DOLFIN – p.5/48

  6. Internal structure Grid Discretiser Equation Problem EquationPoisson equation; Solvers Discretiser(grid,equation); SparseMatrix A; Linear algebra Vector u,b; KrylovSolver solver; discretiser−>AssembleLHS(&A) discretiser−>AssembleRHS(&b) solver−>Solve(A,u,b); Input/output File formats FEM CAM Seminar April 12 2002 DOLFIN – p.6/48

  7. The finite element Following Ciarlet and Brenner-Scott a finite element ( K, P , N ) is defined by 1. A domain K ⊆ R N with piecewise smooth boundary, typically a triangle or a tetrahedron; 2. A finite-dimensional space P of functions on K together with a set of basis functions (the shape functions ); 3. A basis N = { N 1 , N 2 , . . . , N k } for the dual space P ∗ (the degrees of freedom ). CAM Seminar April 12 2002 DOLFIN – p.7/48

  8. The finite element: implementation The finite element , containing geometry and the FiniteElement local function space. A finite-dimensional space of functions on the FunctionSpace domain of a fi nite element. Sub-classes derived from FunctionSpace . TriLinSpace, TetLinSpace Member of the basis for a local function space. ShapeFunction Sub-classes derived from ShapeFunction . TriLinFunction, TetLinFunction A member of the local function space on the do- LocalField main of a fi nite element, i.e. a linear combination of shape functions. Can also be viewed as the restriction of a GlobalField to the domain of a fi nite element. A function (possibly vector-valued) de fi ned on GlobalField the whole of the computational domain. CAM Seminar April 12 2002 DOLFIN – p.8/48

  9. Automatic assembling Automatic assembling is handled by operator overloading . The symmetric binary operator ’ * ’ is defined for the following classes: ∗ : ShapeFunction × ShapeFunction → real ∗ : ShapeFunction × real → real ∗ : ShapeFunction × LocalField → real ∗ : LocalField × LocalField → real ∗ : LocalField × real → real CAM Seminar April 12 2002 DOLFIN – p.9/48

  10. Automatic assembling For two ShapeFunction s v and w , representing two shape functions v and w on K , the operator ’ * ’ is defined by 1 � v · w dx, v * w = (1) | K | K 1 � α · v dx, a * v = (2) | K | K where | K | is the volume (area) of the domain K and a represents the real number α . CAM Seminar April 12 2002 DOLFIN – p.10/48

  11. Automatic assembling u − ∇ · ( c ∇ u ) = f ˙ � U n − U n − 1 � � � � c ( · , t n ) ∇ U n · ∇ v dx = v dx + f ( · , t n ) v dx k n Ω Ω Ω (u*v-up*v)/k + c*(u.dx*v.dx+u.dy*v.dy+u.dz*v.dz) f*v CAM Seminar April 12 2002 DOLFIN – p.11/48

  12. Automatic assembling Exact evaluation of integrals for linear elements on triangles and tetrahedrons: 1 2 · m 1 ! m 2 ! m 3 ! � λ m 1 1 λ m 2 2 λ m 3 dx = 3 | K | ( m 1 + m 2 + m 3 + 2)! K 1 � a * v = αλ i dx = α/ 3 | K | K 1 � 3! · m 1 ! m 2 ! m 3 ! m 4 ! λ m 1 1 λ m 2 2 λ m 3 3 λ m 4 dx = 4 | K | ( m 1 + m 2 + m 3 + m 4 + 3)! K 1 � a * v = αλ i dx = α/ 4 | K | K CAM Seminar April 12 2002 DOLFIN – p.12/48

  13. Three levels Simple C/C++ interface for the user who just wants to solve an equation with specified geometry and boundary conditions. New algorithms are added at module level by the developer or advanced user. Core features are added at kernel level . CAM Seminar April 12 2002 DOLFIN – p.13/48

  14. Poisson’s equation: user level #include <dolfin.h> int main(int argc, char **argv) { dolfin_set_problem("poisson"); dolfin_set_parameter("output file", "poisson.dx"); dolfin_set_parameter("grid file", "tetgrid.inp"); dolfin_set_parameter("space dimension", 2) dolfin_set_boundary_conditions(my_bc); dolfin_set_function("source",f); dolfin_init(argc,argv); dolfin_solve(); dolfin_end(); return 0; } CAM Seminar April 12 2002 DOLFIN – p.14/48

  15. Poisson’s equation: module level class EquationPoisson: public Equation{ public: EquationPoisson():Equation(3){ AllocateFields(1); field[0] = &f; } real IntegrateLHS(ShapeFunction &u, ShapeFunction &v){ return ( u.dx*v.dx + u.dy*v.dy + u.dz*v.dz ); } real IntegrateRHS(ShapeFunction &v){ return ( f * v ); } private: LocalField f; }; CAM Seminar April 12 2002 DOLFIN – p.15/48

  16. Poisson’s equation: module level void ProblemPoisson::Solve() { EquationPoisson equation; SparseMatrix A; Vector x,b; KrylovSolver solver; GlobalField u(grid,&x); GlobalField f(grid,"source"); Discretiser discretiser(grid,equation); equation.AttachField(0,&f); discretiser.Assemble(&A,&b); solver.Solve(&A,&x,&b); u.SetLabel("u","temperature"); u.Save(); } CAM Seminar April 12 2002 DOLFIN – p.16/48

  17. Poisson’s equation: kernel level class Equation{ public: Equation(int nsd); ˜Equation(); virtual real IntegrateLHS(ShapeFunction &u, ShapeFunction &v) virtual real IntegrateRHS(ShapeFunction &v) = 0; void UpdateLHS(FiniteElement *element); void UpdateRHS(FiniteElement *element); void AttachField(int i, GlobalField *globalfield); ... CAM Seminar April 12 2002 DOLFIN – p.17/48

  18. Input / output The solver (DOLFIN) is the key part in the larger system containing also pre- and post-processing: Mesh generation h s e m l a i t i n I DOLFIN n o i t u l o S Visualisation CAM Seminar April 12 2002 DOLFIN – p.18/48

  19. Input / output OpenDX: free open-source visualisation program based on IBM:s Visualization Data Explorer . MATLAB: commercial software (2000 Euros) GiD: commercial software (570 Euros) CAM Seminar April 12 2002 DOLFIN – p.19/48

  20. Input / output: examples Poisson’s equation: − ∆ u ( x ) = f ( x ) , x ∈ Ω , (3) on the unit square Ω = (0 , 1) × (0 , 1) with the source term f localised to the middle of the domain. Grid generation with GiD and visualisation using the pdesurf command in MATLAB . CAM Seminar April 12 2002 DOLFIN – p.20/48

  21. Input / output: examples 7 6 5 4 3 2 1 1 0 0.8 1 0.8 0.6 0.6 0.4 0.4 0.2 0.2 0 0 CAM Seminar April 12 2002 DOLFIN – p.21/48

  22. Input / output: examples Convection–diffusion: u + b · ∇ u − ∇ · ( ǫ ∇ u ) = f, ˙ (4) with b = ( − 10 , 0) , f = 0 and ǫ = 0 . 1 around a warm dolphin. Grid generation with MATLAB and visualisation using contour lines in GiD . CAM Seminar April 12 2002 DOLFIN – p.22/48

  23. Input / output: examples CAM Seminar April 12 2002 DOLFIN – p.23/48

  24. Input / output: examples Incompressible Navier–Stokes: u + u · ∇ u − ν ∆ u + ∇ p = f, ˙ (5) ∇ · u = 0 , Visualisation in OpenDX of the isosurface for the velocity in a computation of transition to turbulence in shear flow on a mesh consisting of 1,600,000 tetrahedral elements. CAM Seminar April 12 2002 DOLFIN – p.24/48

  25. Input / output: examples CAM Seminar April 12 2002 DOLFIN – p.25/48

  26. Web page www.phi.chalmers.se/dolfin www.freshmeat.net/projects/dolfin CAM Seminar April 12 2002 DOLFIN – p.26/48

  27. Organisation of the code doc src/io src/la src/fem src/grid src/init src/test src/utils src/common src/config src/modules/navier-stokes src/modules/poisson src/problems/navier-stokes/benchmark src/problems/navier-stokes/jet src/problems/navier-stokes/... src/problems/poisson data/grids CAM Seminar April 12 2002 DOLFIN – p.27/48

  28. src/io Display Terminal Curses Value Input Output inp.h opendx.h matlab.h gid.h « CAM Seminar April 12 2002 DOLFIN – p.28/48

  29. src/la Vector DenseMatrix SparseMatrix DirectSolver SISolver KrylovSolver « CAM Seminar April 12 2002 DOLFIN – p.29/48

  30. src/fem Discretiser Equation EquationSystem FiniteElement FunctionSpace GlobalField LocalField Problem ShapeFunction TetLinFunction TetLinSpace TriLinFunction TriLinSpace « CAM Seminar April 12 2002 DOLFIN – p.30/48

More recommend