Marine systems simulation
|
SimObjects are time domain simulation models which are loaded by FhSim at runtime. Herein, a sketch of the procedure for creating a new SimObject is presented. It is practical to use existing implementations as starting point for new developments.
Suppose you have an existing SimObject library and want to add a new SimObject. To create new SimObject, simply inherit from the SimObject class and implement necessary functions:
SimObject
class, and the header file should include <SimObject.h>
.CMakeLists.txt
with the new file names.ADD_SIMOBJECT_REF(<Class name>, <Object reference name>);
or ADD_SIMOBJECT_REF3(<Namespace>, <Class name>, <Object reference name>);
in the getSimObject
function of the corresponding cpp
file.Compile and load its configuration using your newly defined object reference name. Build with either cmake --build . --config Release
, conan build .
, or via your IDE.
DEVELOPING.md
file on the project root that contains a step-by-step cheat sheet.A SimObject can implement a range of methods, some optional and some required:
SimObject(const string& simObjectName) void OdeFcn(double T, const double* X, double* XDot, bool IsMajorTimeStep) void InitialConditionSetup(const double T, const double* const currentIC, double* const updatedIC, ISimObjectCreator* const creator) void FinalSetup(double T, const double* X, ISimObjectCreator* creator) void PreOdeFcn(double T, const double* X, IStateUpdater* updater) void RenderInit(Ogre::Root* ogreRoot, ISimObjectCreator* creator) void RenderUpdate(double T, const double* X)
Their calling sequence is given in the figure below.
Detailed information about these methods and their use is found in:
To better understand the implementation of SimObjects, view the implementation of a linear spring and a mass object. The following files are disclosed: