Internal function status and data

Persistance of simulation function status (internal data)

In order to keep the status of the simulation function between calls (from the a time step to the next one), internal variables can be stored as class attributes. The class attributes are persistant during the whole life of the simulation function.
To store distributed values, data structures are available to associate a unit ID to a value. These data structures exists for different types of data:

declaration of the ID-map structure in the .h file :

class MyFunction : public openfluid::base::PluggableFunction

    openfluid::core::IDScalarValueMap m_LastValue;

    // rest of the declaration of the class 


usage of the ID-map structure in the .cpp file :

bool MyFunction::runStep(const openfluid::base::SimulationStatus* SimStatus)
  int ID;
  openfluid::core::ScalarValue TmpValue;
  openfluid::core::Unit* SU;


    ID = SU->getID();

    TmpValue = TmpValue + m_LastValue[ID]


    m_LastValue[ID] = TmpValue;


  return true;

Generated using Doxygen 1.6.3
Creative Commons License Creative Commons By-NC-ND license