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.setNewtonSolverTolerance(3e-8);
problem.prepareForSolve();
// Solve the problem
problem.solveSteady();
return 0;
}
int main(int argc, char *argv[])
Definition: T_protectiveWall.cpp:215
Definition: SolidProblem.h:80
void setElasticModulus(double elasticModulus)
set function for elasticModulus_
Definition: SolidProblem.h:153
void setName(const std::string &name)
set function for name_
Definition: SolidProblem.h:140
void prepareForSolve()
Definition: SolidProblem.h:322
void setSolidCubicMesh(const unsigned &nx, const unsigned &ny, const unsigned &nz, const double &xMin, const double &xMax, const double &yMin, const double &yMax, const double &zMin, const double &zMax)
Definition: SolidProblem.h:546
void pinBoundary(unsigned b)
Definition: SolidProblem.h:227
void setDensity(double density)
set function for density_
Definition: SolidProblem.h:192
void setBodyForceAsGravity(double gravity=9.8)
set function for body_force_pt
Definition: SolidProblem.h:205
void solveSteady()
Definition: SolidProblem.h:411
void setNewtonSolverTolerance(double Newton_solver_tolerance)
set function for Newton_solver_tolerance
Definition: SolidProblem.h:257

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.