← Back to team overview

dolfin team mailing list archive

Introduce a global Time class

 

Hello!

I am implementing a general RKSolver in DOLFIN which takes any
ButcherTablau. The need from DOLFIN is essentially a vector of forms.
This vector has to be generated from a UFL/Python layer.

The quasi C++ syntax could then be:

class RKSolver
{
public:

 RKSolver(vector<Form> forms, vector<Function> stage_solutions,
          vector<BoundaryConditions> bcs);

 // Step solver dt
 void step(double t, double dt);

 // Solution at start of time step
 Function u0();

 // Solution at end of time step
 Function u1();

};

The vector of forms together with the stage solutions and boundary
conditions could preferably be embedded in a RKProblemSolver class.

What is problematic with a closed time integrators like this is to alter
time dependent Expressions. In multi stage RK methods the time need to
be updated for each stage. In Python one could for example do

  if hasattr(coefficient, "t"):
      coefficient.t = t

There are no straightforward way to do this in the C++ interface of DOLFIN.

One way to solve this is to introduce a global singleton Time class,
which kept track of the time. The time could then be accessed through
out DOLFIN by:

  const Constant& Time::t();

  double Time::t();

  void Time::update(double t);

The first method could be used in the Python interface to include time
directly in forms.

Would this be something worth adding to DOLFIN?

For the record: I have looked at the gryphonproject and found some
interesting ideas. In contrast to the gryphonproject, which focused on a
subset of RK solvers and was Python only, I intend this Solver interface
to be more lightweight, more general and available from C++ too. If this
is of general interest it will eventually end up in DOLFIN too :)

Johan



Follow ups