MoorDyn
Public Member Functions | List of all members
moordyn::Instance Class Referenceabstract

A generic instance. More...

#include <Instance.hpp>

Inheritance diagram for moordyn::Instance:
Inheritance graph
[legend]
Collaboration diagram for moordyn::Instance:
Collaboration graph
[legend]

Public Member Functions

 Instance (moordyn::Log *log)
 Costructor. More...
 
virtual ~Instance ()=default
 Destructor.
 
const size_t id () const
 Get the unique identifier of this instance. More...
 
virtual void initialize (InstanceStateVarView r)=0
 Initialize a free instance. More...
 
virtual void setState (const InstanceStateVarView r)=0
 Set the state. More...
 
virtual void getStateDeriv (InstanceStateVarView drdt)=0
 Calculate forces and get the derivative of the states. More...
 
virtual const size_t stateN () const
 Get the number of state variables required by this instance. More...
 
virtual const size_t stateDims () const
 Get the dimension of the state variable. More...
 
- Public Member Functions inherited from moordyn::io::IO
 IO (moordyn::Log *log)
 Costructor. More...
 
virtual ~IO ()=default
 Destructor.
 
void Save (const std::string filepath)
 Save the entity into a file. More...
 
void Load (const std::string filepath)
 Loads the entity from a file. More...
 
virtual std::vector< uint64_t > Serialize (void)=0
 Produce the packed data to be saved. More...
 
virtual uint64_t * Deserialize (const uint64_t *data)=0
 Unpack the data to restore the Serialized information. More...
 
- Public Member Functions inherited from moordyn::LogUser
 LogUser (Log *log=NULL)
 Constructor. More...
 
 ~LogUser ()
 Destructor.
 
void SetLogger (Log *log)
 Set the log handler. More...
 
LogGetLogger () const
 Get the log handler. More...
 

Additional Inherited Members

- Protected Member Functions inherited from moordyn::io::IO
ofstream MakeFile (const std::string filepath) const
 Create an output file and write the MoorDyn magic header. More...
 
std::tuple< uint64_t, uint64_t * > LoadFile (const std::string filepath) const
 Open an input file and load the data. More...
 
uint64_t Serialize (const uint64_t &i)
 Pack an unsigned integer to make it writable. More...
 
uint64_t Serialize (const int64_t &i)
 Pack an integer to make it writable. More...
 
uint64_t Serialize (const real &f)
 Pack a float to make it writable. More...
 
std::vector< uint64_t > Serialize (const vec &m)
 Pack a 3D vector to make it writable. More...
 
std::vector< uint64_t > Serialize (const vec6 &m)
 Pack a 6D vector to make it writable. More...
 
std::vector< uint64_t > Serialize (const mat &m)
 Pack a 3x3 matrix to make it writable. More...
 
std::vector< uint64_t > Serialize (const mat6 &m)
 Pack a 6x6 matrix to make it writable. More...
 
std::vector< uint64_t > Serialize (const quaternion &m)
 Pack a quaternion to make it writable. More...
 
std::vector< uint64_t > Serialize (const XYZQuat &m)
 Pack an XYZQuat to make it writable. More...
 
std::vector< uint64_t > Serialize (const std::vector< real > &l)
 Pack a list of floating point numbers to make it writable. More...
 
std::vector< uint64_t > Serialize (const std::vector< vec > &l)
 Pack a list of 3D vectors to make it writable. More...
 
std::vector< uint64_t > Serialize (const std::vector< vec6 > &l)
 Pack a list of 6D vectors to make it writable. More...
 
std::vector< uint64_t > Serialize (const std::vector< mat > &l)
 Pack a list of 3x3 matrices to make it writable. More...
 
std::vector< uint64_t > Serialize (const std::vector< mat6 > &l)
 Pack a list of 6x6 matrices to make it writable. More...
 
std::vector< uint64_t > Serialize (const Eigen::Matrix< real, Eigen::Dynamic, Eigen::Dynamic > &l)
 Pack an arbitrarily large matrix. More...
 
template<typename T >
std::vector< uint64_t > Serialize (const std::vector< std::vector< T >> &l)
 Pack a list of lists to make it writable This function might act recursively. More...
 
uint64_t * Deserialize (const uint64_t *in, uint64_t &out)
 Unpack a loaded unsigned integer. More...
 
uint64_t * Deserialize (const uint64_t *in, int64_t &out)
 Unpack a loaded integer. More...
 
uint64_t * Deserialize (const uint64_t *in, real &out)
 Unpack a loaded floating point number. More...
 
uint64_t * Deserialize (const uint64_t *in, vec &out)
 Unpack a loaded 3D vector. More...
 
uint64_t * Deserialize (const uint64_t *in, vec6 &out)
 Unpack a loaded 6D vector. More...
 
uint64_t * Deserialize (const uint64_t *in, mat &out)
 Unpack a loaded 3x3 matrix. More...
 
uint64_t * Deserialize (const uint64_t *in, mat6 &out)
 Unpack a loaded 6x6 matrix. More...
 
uint64_t * Deserialize (const uint64_t *in, quaternion &out)
 Unpack a loaded quaternion. More...
 
uint64_t * Deserialize (const uint64_t *in, XYZQuat &out)
 Unpack a loaded XYZQuat. More...
 
uint64_t * Deserialize (const uint64_t *in, std::vector< real > &out)
 Unpack a loaded list of floating point numbers. More...
 
uint64_t * Deserialize (const uint64_t *in, std::vector< vec > &out)
 Unpack a loaded list of 3D vectors. More...
 
uint64_t * Deserialize (const uint64_t *in, std::vector< vec6 > &out)
 Unpack a loaded list of 6D vectors. More...
 
uint64_t * Deserialize (const uint64_t *in, std::vector< mat > &out)
 Unpack a loaded list of 3x3 matrices. More...
 
uint64_t * Deserialize (const uint64_t *in, std::vector< mat6 > &out)
 Unpack a loaded list of 6x6 matrices. More...
 
uint64_t * Deserialize (const uint64_t *in, Eigen::Matrix< real, Eigen::Dynamic, Eigen::Dynamic > &out)
 Unpack an arbitrarily large matrix. More...
 
template<typename T >
uint64_t * Deserialize (const uint64_t *in, std::vector< std::vector< T >> &out)
 Unpack a loaded list of lists. More...
 
- Protected Attributes inherited from moordyn::LogUser
Log_log
 The log handler.
 

Detailed Description

A generic instance.

Constructor & Destructor Documentation

◆ Instance()

moordyn::Instance::Instance ( moordyn::Log log)

Costructor.

Parameters
logLogging handler defining where/how results should be logged.

Member Function Documentation

◆ getStateDeriv()

virtual void moordyn::Instance::getStateDeriv ( InstanceStateVarView  drdt)
pure virtual

Calculate forces and get the derivative of the states.

Parameters
drdtOutput state derivatives
Exceptions
nan_errorIf nan values are detected in any node position

Implemented in moordyn::Rod, moordyn::Point, moordyn::Line, and moordyn::Body.

◆ id()

const size_t moordyn::Instance::id ( ) const
inline

Get the unique identifier of this instance.

The unique identifier is a growing index which identifies every single created instance. Even if an instance is removed, the index will remain taken. That applies even for multiple instances generation.

Returns
The unique identifier
Warning
It cannot be assumed that the first taken index will be 0
It cannot be assumed that consequtive ids will be assigned
Here is the caller graph for this function:

◆ initialize()

virtual void moordyn::Instance::initialize ( InstanceStateVarView  r)
pure virtual

Initialize a free instance.

Parameters
rThe output state variable
Exceptions
moordyn::invalid_value_errorIf the instance does not have free states. e.g. a coupled body controlled from outside

Implemented in moordyn::Line, moordyn::Rod, moordyn::Point, and moordyn::Body.

◆ setState()

virtual void moordyn::Instance::setState ( const InstanceStateVarView  r)
pure virtual

Set the state.

Parameters
rThe state variable

Implemented in moordyn::Rod, moordyn::Point, moordyn::Line, and moordyn::Body.

◆ stateDims()

virtual const size_t moordyn::Instance::stateDims ( ) const
inlinevirtual

Get the dimension of the state variable.

This can be seen as the number of columns on the state variables holder.

Returns
The dimension of the state variable

Reimplemented in moordyn::Rod, moordyn::Point, moordyn::Line, and moordyn::Body.

Here is the caller graph for this function:

◆ stateN()

virtual const size_t moordyn::Instance::stateN ( ) const
inlinevirtual

Get the number of state variables required by this instance.

This can be seen as the number of rows on the state variables holder.

Returns
The number of state variables

Reimplemented in moordyn::Rod, moordyn::Point, moordyn::Line, and moordyn::Body.

Here is the caller graph for this function:

The documentation for this class was generated from the following files: