A simulation function is defined by a class, inherited from the openfluid::base::PluggableFunction class. The code have to be written into the different methods provided by the PluggableFunction class. You can also develop other methods in order to structure your source code. To see how the source code is globally structured, see part Creating an empty simulation function.
The constructor of the simulation function is called when the function is loaded. You may put here the initialization of you class attributes.
The destructor of the simulation function is called when the function is freed, at the end of the execution of the OpenFLUID application. You may put here instruction to free the memory you allocate for the needs of the simulation function (objects, pointed vars, ...).
The class defining a simulation function must compound the following methods:
The initParams method should be used to retreive function parameters, read from the model.xml file (See Access to function parameters). Once read, the values should be stored into class 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 function own consistency checking.
The initializeRun method should be used to do data initialization, or to compute values that do not change during simulation.
The runStep method is called at each exchange time step. it should contain the computation code.
The finalizeRun method should be used to do post-processing after simulation. it is the last method ran.