Examples and tutorials

Examples utilizing the Rodin library.

Variational methods and weak formulations

The Variational module is used when dealing with variational problems of the form:

\[ \text{Find} \quad u \in U \quad \text{ s.t. } \quad \forall v \in V \quad a(u, v) = b(v) \ . \]

See the variational formulations guide for the mathematical background, the notation reference for the symbols used, and the solvers guide for choosing a solver.

Solving PDEs

Rodin can be used to solve partial differential equations of many types. To start solving PDEs with Rodin, we recommend taking a look at the simplest example which is how to solve the Poisson equation.

EquationLink to example
$ - \Delta u = f $ Solving the Poisson equation
$ - \nabla \cdot \sigma (u ) = 0 $ Solving the elasticity equation
$ - \Delta u - k^2 u = f $ Solving the Helmholtz equation
$ -\nu \Delta \mathbf{u} + (\mathbf{u} \cdot \nabla)\mathbf{u} + \nabla p = \mathbf{f} $ Solving the Navier-Stokes equations
$ - \Delta u = f $ (periodic)Poisson equation with periodic boundary conditions
$ - \Delta_\Gamma u + u = f $ (surface)Solving PDEs on surface meshes

Input/Output

Rodin supports several I/O formats for meshes, grid functions, and simulation data. The supported formats are MFEM, MEDIT, and HDF5. The XDMF format is recommended for exporting results for visualization in ParaView:

Mesh Geometry

The Geometry module provides mesh creation, topological connectivity, and geometric operations:

Working with MMG

The MMG module has a wide variety of uses which ranges from optimization of the mesh, to implicit domain meshing. It provides many C++ wrappers to execute the functionality of the Mmg Platform:

Density optimization examples

Shape optimization examples

Solid Mechanics

The Solid module provides hyperelastic constitutive laws and nonlinear integrators for large-deformation solid mechanics. The LinearElasticityIntegral covers the small-deformation (linearized) case, while the Solid module handles finite-strain problems with constitutive laws such as NeoHookean, Saint-Venant-Kirchhoff, and Mooney-Rivlin:

ProblemConstitutive LawExample
Linear cantilever beam $ \sigma = \lambda(\operatorname{tr}\varepsilon)I + 2\mu\varepsilon $ Solving the elasticity equation
Hyperelastic cantilever (NeoHookean, transient) $ W = \frac{\mu}{2}(I_1-d) - \mu\ln J + \frac{\lambda}{2}(\ln J)^2 $ examples/Solid/CantileverBeam.cpp

Distance and Eikonal

The Eikonal module solves $ |\nabla u| = F(x) $ via the Fast Marching Method, and the Distance module wraps several distance-function computation strategies:

MethodDescriptionExample
FMMExact distance on unstructured meshesexamples/Models/Eikonal/FMM.cpp
Spalding-TuckerBoundary-layer wall distanceexamples/Models/Distance/SpaldingTucker.cpp

PETSc Examples

The PETSc module enables distributed solvers and multi-field block systems. Examples include:

ProblemDescriptionExample
Sequential PoissonPETSc CG solver on local meshexamples/PETSc/PDEs/Seq_Poisson.cpp
MPI PoissonDistributed mesh + PETSc KSPexamples/PETSc/PDEs/MPI_Poisson.cpp
Sequential StokesMulti-field (velocity-pressure-Lagrange)examples/PETSc/PDEs/Seq_Stokes.cpp
Oseen flowTransient Picard/Oseen linearizationexamples/PETSc/PDEs/Seq_OseenFlow.cpp
Oseen lid-driven cavityTransient cavity with Picard/Oseen linearizationexamples/PETSc/PDEs/Seq_OseenLidDrivenCavity.cpp
Navier-StokesTransient nonlinear lid-driven cavity with PETSc SNESexamples/PETSc/PDEs/Seq_NavierStokes.cpp

Discontinuous Galerkin

The DG example solves the Poisson equation using the Symmetric Interior Penalty (SIP) method with DG-specific operators (Jump, Average, FaceIntegral, InterfaceIntegral):

EquationMethodExample
$ -\Delta u = f $ SIP-DGexamples/DG/Poisson.cpp

Integral Equations

The Potential operator enables integral equation formulations (boundary element methods). The kernel $ K(\mathbf{x}, \mathbf{y}) $ is convolved with the solution on the mesh:

ProblemKernelExample
Newtonian potential $ \frac{1}{4\pi\|\mathbf{x}-\mathbf{y}\|} $ examples/IntegralEquations/NewtonianPotential.cpp
Elastic distributionNavier 3×3 kernelexamples/IntegralEquations/ElasticDistribution.cpp

Surface Evolution

The surface evolution examples demonstrate conormal advection — moving domain boundaries along their outward normal direction using level-set methods with MMG implicit-domain meshing:

ProblemDescriptionExample
Conormal advectionMove boundary along conormalexamples/SurfaceEvolution/ConormalAdvection/Main.cpp
Convergence studyParametric sweep over resolution and CFLexamples/SurfaceEvolution/ConormalAdvection/Test.cpp
Plane evolutionPlanar surface motionexamples/SurfaceEvolution/ConormalAdvection/Plane.cpp

Boundary Optimization

Advanced shape and topology optimization examples that combine complex-valued PDE solvers, adjoint methods, Hilbert space regularization, and MMG remeshing:

ProblemDescriptionExample
Acoustic cloakingComplex Helmholtz + adjoint-based shape gradient + conormal advectionexamples/BoundaryOptimization/AcousticCloaking.cpp