Does the OpenFOAM adapter support implicit coupling?

The OpenFOAM adapter has the form of an OpenFOAM function object. This mechanism is commonly used only for post-processing, so a reasonable question is:

Does the OpenFOAM adapter also take care of the checkpointing? In other words, can a function object go back in time?

Good news: yes! You don’t need to implement anything else, the official OpenFOAM adapter is really meant to be a plugin, fully compatible with all the features of preCICE.

But how can a function object travel back in time?

So, you are ready to dive into the code. Let’s have a look into the method preciceAdapter::Adapter::readCheckpoint():

The first thing that this method does is to overwrite the time value, restoring it to the checkpointed value, using the setTime() method of OpenFOAM:

const_cast<Time&>(runTime_).setTime(couplingIterationTimeValue_, couplingIterationTimeIndex_);

Good practices dictate that we should avoid using const_cast at all cost. However, since we don’t want to modify any line of OpenFOAM itself or of the solver, this is our only solution.

What else is checkpointed?

After restoring the time value, the mesh points are moved to their previous locations, in a similar manner:

const_cast<fvMesh&>(mesh_).movePoints(meshPoints_);

Afterwards, every object of type volScalarField, volVectorField, surfaceScalarField, surfaceVectorField, pointScalarField, pointVectorField, volTensorField, surfaceTensorField, pointTensorField, volSymmTensorField is reloaded.

The respective methods have grown quite a while since the adapter was first written and a redesign is due, as described in https://github.com/precice/openfoam-adapter/issues/55.

For more details, you can have a look in my thesis (section 5.3.4):
G. Chourdakis: A general OpenFOAM adapter for the coupling library preCICE [PDF][BibTeX][MediaTum], Master’s thesis, Technical University of Munich, Department of Informatics, October 2017.