Overview of an OpenFLUID simulator

Table of Contents

Technically speaking, an OpenFLUID simulator is made of two main parts: The signature and a C++ class containing the computational code. These two parts have to be developped in a C++ file (.cpp). They must be compiled before using it in the OpenFLUID environment.

Simulator signature

The signature of a simulator contains meta-informations about the simulator. These informations will be mainly used for automatic coupling and consistency checking of simulators. To get more informations about the simulators signatures, see part Declaration of the simulator signature.

Simulator C++ class

The computational part of a simulator is defined by a class, inherited from the openfluid::ware::PluggableSimulator class. The simulation code have to be written into the different methods provided by the openfluid::ware::PluggableSimulator class. You can also develop other methods in order to organize your source code.
To get more information about the C++ class of a simulator, see part Creation of an empty simulator.

Constructor and destructor

The constructor of the simulator is called when the simulator is loaded. You may put here the initialization of your private members.
The destructor of the simulator is called when the simulator is released after simulation, at the end of the execution of the OpenFLUID application. You may put here instruction to free the memory you allocated for the needs of the computational code (other objects, pointed vars, ...).

Mandatory methods to be defined

The class of a simulator must define the following methods:


The initParams method should be used to retreive the parameters of the simulator, read from the model.fluidx file or filled from the OpenFLUID-Builder interface (See Model section). Once read, the values should be stored into private attributes to be accessed by other methods.

The prepareData method should be used to do data pre-processing before the consistency checking.

The checkConsistency method is called during the global consistency checking phase. It should be used to add specific consistency checking for the simulator.

The initializeRun method must be used for initialization of simulation variables, or to compute initialization data.

The runStep method is called at each exchange time step. It should contain the computational code.

The finalizeRun method should be used to do post-processing after simulation. It is the last method ran.