Marine systems simulation
Exercise: Creating simple SimObjects

This tutorial is an exercise which aims at adding two simple SimObjects to the fhsim_tutorial.

Goal

In this exercise you will create two new SimObjects. For simplicity it is suggested to work directly in the fhsim_tutorial.

General steps:

  1. Making the source code for the two SimObjects
  2. Referencing them in the CMakeLists.txt file
  3. Including their header files fhsim_tutorial.h
  4. Adding references to them in fhsim_tutorial.cpp (ADD_SIMOBJECT_REF)
  5. Building the install target
  6. Creating the input file
  7. Running a simulation including the new SimObjects

Implement a linear spring with damping in 3D

  1. Copy the file CLinearSpring.h and CLinearSpring.cpp to e.g. CDampedSpring.h and CDampedSpring.cpp, respectively.
  2. Replace all "CLinearSpring" with "CDampedSpring" in CDampedSpring.h and CDampedSpring.cpp.
  3. Implement the additional functionality.
  4. Do step 2-4 from the list "General steps" above.

Implement a mass object which can take a variable number of forces as input (enough to include translations to begin with)

  1. Copy the file CMass.h and CMass.cpp to e.g. CMultiPortMass.h and CMultiPortMass.cpp, respectively.
  2. Replace all "CMass" with "CMultiPortMass" in CMultiPortMass.h and CMultiPortMass.cpp.
  3. Implement the additional functionality.
  4. Do step 2-4 from the list "General steps" above.

Build the install target

  • Visual Studio: Right click the target and select build.
  • Command line: Run cd build && conan build ..

Create the input file

It is recommended to copy the existing input file as a template when creating a new input file. The rest is to a large extent offered as an exercise. Although, remember that:

  • every input port must be connected
  • every state must be initialized (almost true).
  • the sizes of input and output ports must match.
  • the SimObject type is the name matching the reference given in fhsim_tutorial.cpp.

Run the simulation

See Running a compiled SimObject.