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
{
  private:

    openfluid::core::IDScalarValueMap m_LastValue;

  public:
  
    // 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;


  DECLARE_UNITS_ORDERED_LOOP(7);
  BEGIN_UNITS_ORDERED_LOOP(7,"SU",SU)

    ID = SU->getID();

    TmpValue = TmpValue + m_LastValue[ID]

    OPENFLUID_AppendVariable(SU,"MyVar",TmpValue);

    m_LastValue[ID] = TmpValue;

  END_LOOP

  return true;
}

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