How to run oomph-lib codes in MercuryDPM

Tutorial

Before we can do coupled simulations, it's good to learn how to run oomph-lib simulations in the framework of MercuryDPM.

The first step is to include oomph-lib into the MercuryDPM compilation; this is done via a cmake; just run cmake with one additional argument:

cmake . -DMERCURYDPM_OOMPH_COUPLING=ON

This will clone the oomph-lib repository into your MercuryDPM source directory, and it will compile the oomphlib source files when you type make.

Now you can include oomph-lib source files into your Driver codes. A good example of this is SolidBeamDemo.cpp:

int main()
{
// Defines a SolidProblem of element type RefineableQDPVDElement<3,2>.
// Sets up the problem
problem.setName("SolidBeamUnitTest");
problem.setElasticModulus(1e8);
problem.setDensity(2500);
problem.setSolidCubicMesh(20, 2, 2, 0, 0.2, 0, 0.02, 0, 0.02);
problem.pinBoundary(problem.Boundary::X_MIN);
problem.setBodyForceAsGravity();
problem.setNewtonSolverTolerance(3e-8);
problem.prepareForSolve();
// Solve the problem
problem.solveSteady();
return 0;
}
Array< double, 1, 3 > e(1./3., 0.5, 2.)
int main(int argc, char *argv[])
Definition: T_protectiveWall.cpp:194
Definition: SolidProblem.h:60
Constructor for SteadyAxisymAdvectionDiffusion problem
Definition: steady_axisym_advection_diffusion.cc:213

This code includes the class SolidProblem, which is derived from the oomph-lib Problem class. This class is defined in the MercuryDPM kernel, and is specifically designed to solve problems with elastic bodies. As you can see, the driver code defines a class of type SolidProblem, with the element type RefineableQDPVDElement<3,2>, sets the properties of the elastic solid, then calls solveSteady to solve the linear algebra problem.

You can visualize the results by opening the resulting vtk files in ParaView:

To do coupled simulations, see Surface coupling with oomph-lib.

Further test cases

We have implemented the following test cases:

SolidBeamUnitTest.cpp

A simple uncoupled simulation of a beam bending under gravity. A steady-state solver is used. the amount of bending is compared to an analytical solution.

SolidBeamUnsteady.cpp

A simple uncoupled simulation of a beam bending under gravity. This time, an unsteady solver is used.


The gravitational, elastic and kinetic energies are plotted to check energy conservation.

ElementAnalysis.cpp

A simple code returning the values of the shape functions, jacobian, weights, etc. This is useful to understand what the different oomph-lib functions do.