File boutmain.hxx



Main function for legacy interface

The user provides two standalone functions, physics_init and physics_run. This header defines a class LegacyModel, which inherits from PhysicsModel. This class is used by Solver, and forwards calls to the user standalone functions.

It is recommended that users define a model by interiting from PhysicsModel directly, rather than using this header.

Note: This header file implements a main() function, so should only be included once, and cannot be combined with a user-defined main().


int physics_init(bool restarting)

Initialise the model. Called once at the start

zero on success, non-zero error code
  • restarting: True if the simulation is restarting

int physics_run(BoutReal t)

Calculate the time derivative

zero on success, non-zero error code
  • t: Simulation time

template<class T>
void bout_solve(T &var, const char *name)

Global functions used by some legacy models.

bool bout_constrain(Field3D &var, Field3D &F_var, const char *name)

Add a contraint variable

int main(int argc, char **argv)

Main function.


Solver *solver

Need a global Solver pointer, which is the same as the PhysicsModel solver

class LegacyModel : public PhysicsModel
#include <boutmain.hxx>

Class interface to Solvers, which emulates the older standalone function interface

Protected Functions

int init(bool restarting)


int rhs(BoutReal t)

Calculate time derivatives.