v0.14.0
Tutorials

The tutorials contain a number of basic programs that are built on top of each other. Those with the full source code has the following structure:

  1. Introduction: Problem being solved, mathematical equations and derivations leading to finite element implementation
  2. Implementation: Detailed explanation of the source code where tasks are separated in different functions
  3. Results: How to run the program, output, visualisation, interpretation and comments, possible extensions.
  4. Plain program: Full source code without extended comments

If you install MoFEM using either instructions in Installation with Docker - JupyterHub or the script provided in Installation with Spack (Scripts) the source code and corresponding binary files of the tutorials are located in the following directories:

  • Source code: $HOME/mofem_install/mofem-cephas/mofem/users_modules/tutorials
  • Binary files (build directory): $HOME/mofem_install/mofem-cephas/mofem/users_modules/um-build-Release-5sehreo/tutorials/

In the build directory described above, 5sehreo is the hash of the particular build, and it may be different on your machine.

Each tutorial in this page includes code name and keywords for quick reference and search within the browser.

Note
You do not need to go through all the tutorials in the order they are listed in this page before jumping into the topic in which you are interested. However, we do recommend you to have a look at the first few tutorials solving scalar-field problems to have a general idea how the finite element implementation is done in MoFEM. We also make a recommendation at the beginning of each tutorial regarding which tutorial(s) you should read (prerequisites) before continuing with the one you are most excited about.


Note
The tutorials are under development. Send us your feedback on Q&A regarding the tutorials that already done and the missing ones that you most prefer to see.

Source code Source code    Description Description    Jupyter Notebook Jupyter Notebook

Fundamentals

MoFEM Interfaces   Description

Brief introduction about MoFEM interfaces which enable users to implement the codes with different level of complexity.
Keywords: Design

How to compile a program   Description

Brief introduction about compiling MoFEM - Developer version
Keywords: Compilation

How to add a new module and program   Description

Tutorial on adding a new MoFEM module (you might want to skip this tutorial for now and return after reading other tutorials)
Keywords: modules

FUN-0: Hello world   Description

Creating Simple problem, and pushing operators to pipelines
Keywords: UDOs, pipelines

FUN-1: Integration on finite element mesh   Description

Numerical integration is essential for most of the numerical methods employed to solve partial differential equations (PDEs)
Keywords: UDOs and integration

FUN-2: Hierarchical approximation   Description

Introduce elementary concepts of the Finite Element Method (FEM) with hierarchical shape functions and their implementation in MoFEM
Keywords: Hierarchical approximation

Mesh creation

MSH-1: Create a 2D mesh from Gmsh   Description

This document shows how to create a MoFEM-compatible 2D input mesh from Gmsh
Keywords: Gmsh, block definition, config file, read_med

MSH-2: Create a 3D mesh from Gmsh   Description

This document shows how to create a MoFEM-compatible 3D input mesh from Gmsh
Keywords: Gmsh, block definition, config file, read_med

Scalar-field problems

SCL-0: Least square approximaton   Source code

Solve the least square problem to approximate scalar function
Keywords: Simple Interface, KSP solver, mofem_part, mbconvert, 3D extension

SCL-1: Poisson's equation (homogeneous BC)   Description

Solve the Poisson's equation with zero value boundary conditions
Keywords: Simple Interface, KSP solver, mofem_part, mbconvert, 3D extension

SCL-2: Poisson's equation (non-homogeneous BC)   Description

An expansion of previous tutorial to cover non-homogeneous (non-zero value) boundary condition of Poisson's equation
Keywords: Least square approximation

SCL-3: Poisson's equation (Lagrange multiplier)    Source code

Solve the Poisson's equation using Lagrange multiplier for the non-homogeneous boundary condition
Keywords: PCFIELDSPLIT block solver

SCL-4: Nonlinear Poisson's equation   Source code

Solve nonlinear Poisson's equation using Newton iterative scheme
Keywords: SNES solver

SCL-5: Minimal surface equation   Source code

A variant of the nonlinear Poisson's equation
Keywords: SNES solver

SCL-6: Heat equation   Source code

This is the first tutorial to solve a time-dependent problem with first-order time derivative
Keywords: TS solver, implicit scheme, remove dofs on skin

SCL-7: Wave equation   Source code

Time-dependent problem with second-order time derivative
Keywords: TS solver, implicit scheme, non-homegenous time dependent boundaru condition

SCL-8: Radiation boundary conditions   Source code

Nonlinear problem at the boundary
Keywords: axisymmetric problem, linearisation

SCL-9: Heat method   Source code

Finding geodesic distance with heat method
Keywords: face elements embedded in 3d space

SCL-10: Photon diffusion   Source code

Photon diffusion equation
Keywords: inital boundary conditions, parabolic equation, adding user element, postprocessing on skin, initial vector

SCL-11: Discontinuous Galerkin for Poisson problem   Source code

Discontinuous Galerkin for Poisson problem
Keywords: integartion on skeleton

Problems with complex variable fields

CLX-0: Helmholtz problem   Description

Helmholtz problem for acoustics
Keywords: complex variable, linear solver, boundary markers, remove dofs on skin

Vector-field problems

VEC-0: Linear elasticity   Description

Linear elasticity
Keywords: Hooke equation

VEC-1: Eigen elastic   Source code

Eigen elastic
Keywords: eigen values, SLEPC

VEC-2: Nonlinear elastic   Source code

Nonlinear elastic with Hencky material
Keywords: nonlinear problem, SNES

VEC-3: Nonlinear dynamic elastic   Source code

Time-dependent nonlinear elastic (dynamics)
Keywords: Alpha2 method

VEC-4: Shallow wave equation on sphere   Source code

Shallow wave equation on mainfold (atmospheric processes)
Keywords: Alpha method, initail conditions, hyperbolic equation, sphere approximation, explicit/implicit time integration, restart vector

VEC-5: Phase field model and Navier-Stokes   Source code

Phase field model and Navier-Sokes equations
Keywords: phase field, Navier-Stokes, hyberbolic equation, inital boundary condition

VEC-6: Discontinuous Galerkin for Kirchoff-Love Plate   Source code

Solving forth order eliptic equation describing plate bending
Keywords: discontinuous Galerkin method, plate theroy

VEC-7: Automatic Differentiation for Plasticity

Automatic differentiation for elato-plasticity
Keywords: ADOL-C, plasticity, nonlinear problem, dg projection, user module

Mixed field problems

MIX-0: Mixed formulation of Poisson equation   Description

A mixed problem
Keywords: H-div space, homogenous boundary conditions by DOFs removal

MIX-1: Retrive phase solving transport-of-intensity equation.   Source code

A mixed problem for transport intensity equation
Keywords: Hetergenous paramterers and source function

Maxwell problems

MAX-0: Magnetostatics   Source code

Magnetostatics
Keywords:

MAX-1: Lorenz force   Source code

Lorenz force
Keywords:

Advanced topics

ADV-0: Plastic problem   Source code

Plasticity problem
Keywords: Nonlinear problem, linearisation, L2 space, boundary markers, displacement control, force control

ADV-1: Contact problem   Source code

Contact problem
Keywords: H-curl/H-div space, mix formulations

ADV-2: Thermo-elastic example   Source code

Solve thermo-elasto-plastic probelm
Keywords: Keywords: multi-physics

ADV-3: DG Upwind for advection problem or level set   Source code

Upwind Discontinuous Galerkin for Level-Set
Keywords: Keywords: upwind dg, level set

ADV-5: Seepage in elsatic body example   Source code

Seepgae problem in deformable porous media
Keywords: Keywords: multi-physiscs

Tutorials using core interfaces or low level implementation

COR-0: Mixed formulation and integration on skeleton (h-adaptivity)   Description

Mix formulation for transport problem
Keywords: h-adaptivity and error estimator

COR-1: Time dependent nonlinear mix formulation (unsaturated flow)   Description

Mix formulation for capillary flow
Keywords: capillary flow, unsaturated soil, nonlinear mix-formulation

COR-2: Solving the Poisson equation   Description

Poison equation again with different implementations
Keywords: Poisson problem

COR-3: Implementing operators for the Poisson equation   Description

Poison equation implementation of differentiation operators
Keywords: Poisson problem

COR-4: Using fieldsplit solver and DM sub problem.   Description

Poison equation implementation of differentiation operators
Keywords: Using subproblems and nested matrices

COR-5: A nonlinear Poisson equation   Description

Poison nonlinear equation again
Keywords: SNES solver and linearisation

COR-6: Solid elasticity   Description

Older implementation of elastic problem
Keywords: Operators and low level implementation

COR-7: Mixed formulation for incompressible elasticity   Description

Older implementation of mixed elastic problem
Keywords: pressure field, incompressibility

COR-8: Implementation of spring element   Description

Implementation of boundary element with springs
Keywords: face element, spring, user data operators

COR-9: Reaction-diffusion equation   Description

Reaction-diffusion Fisher's equation
Keywords: time solver, monitor, nonlinearity

COR-10: Navier-Stokes equation   Description

Navier-Stokes equations
Keywords: viscous fluid flow, mixed formulation, drag force computation

COR-11: Mixed formulation of nonlinear elasticity   Source code

Mixed formulation for large strain elasticity
Keywords: H-div space, Schur complement, ADOL-C (automatic differentiation)

Tutorials implemented as a separate module

MOD-0: Soap film spanned on wire   Description

Soap film as an external module
Keywords: Module implementations