Marine systems simulation
|
A SimObject can implement a range of methods. Some of these are optional, some are required. Their calling sequence is given in the figure below.
SimObject(const string& simObjectName);
[in] | simObjectName | -> The name of the simobject |
The constructor performs all initial setup for a SimObject. It is responsible for reading the parameters belonging to the SimObject from the input file and defining the interface of the SimObject, in terms of:
A list of methods used in the constructor is found here
void InitialConditionSetup(const double T, const double* const currentIC, double* const updatedIC, ISimObjectCreator* const creator);
[in] | T | The time at the beginning of the simulation. Usually but not necessarily zero |
[in] | currentIC | Array of initial conditions. If the value is QNAN, the value is not set yet and can be set by the SimObject, otherwise the value is set, and can not be changed. Trying to change an already set value will trigger an error |
[out] | updatedIC | Array of ONAN. Any initial condition that are ready to be set, should be written to this array. |
[in] | creator | Pointer to creator class |
Method for SimObjects that wants to set it's own initial conditions based on the value of it's input ports. SimObjects that wants to use this feature overrides the method, and it will be called if the SimObject has unspecified initial conditions after the values from the SimObject constructor, and the input file are set.
The following service contract applies to SimObjects that wishes to override this method:
virtual void FinalSetup(double T, const double* X, ISimObjectCreator* creator);
[in] | T | -> Current simulation time |
[in] | X | -> Current simulation state |
[in] | creator | -> Retrieve shared resources |
Make final preparations before simulation starts. Mainly for retrieving shared resources registered during construction phase. Note: Called before RenderInit. Simobjects that wish to exchange shared resources through GetSharedResource/SetSharedResource may not retrieve said resources inside the constructor due to unpredictable order of construction.
void RenderInit(Ogre::Root* ogreRoot, ISimObjectCreator* creator);
[in] | ogreRoot | -> Register visualization resources |
[in] | creator | -> Retrieve parameters. |
Sets up visualization resources.
void PreOdeFcn(double T, const double* X, IStateUpdater* updater);
[in] | T | -> Current simulation time |
[in] | X | -> Current simulation state |
[in] | updater | -> Callback class for updating states |
Pre ode-function pass for handling discontinuous/discrete states. Called once before the start of every major timestep.
void OdeFcn(double T, const double* X, double* XDot, bool IsMajorTimeStep) = 0;
[in] | T | -> Current simulation time |
[in] | X | -> Current simulation state |
[out] | XDot | -> State derivatives |
[in] | IsMajorTimeStep | -> Is this a major time step? |
This method is responsible for calculating the derivative of the states of the SimObject as a function of time, states and input ports.
void RenderUpdate(double T, const double* X);
[in] | T | -> Current simulation time |
[in] | X | -> Current simulation state |
Updates visualization resources to reflect current state