MoorDyn
Classes | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
moordyn::time::SchemeBase< NSTATE, NDERIV > Class Template Reference

A generic abstract integration scheme. More...

#include <Time.hpp>

Inheritance diagram for moordyn::time::SchemeBase< NSTATE, NDERIV >:
Inheritance graph
[legend]
Collaboration diagram for moordyn::time::SchemeBase< NSTATE, NDERIV >:
Collaboration graph
[legend]

Classes

struct  _mask
 A mask to determine which entities shall be computed. More...
 

Public Member Functions

virtual ~SchemeBase ()
 Destructor.
 
virtual void AddLine (Line *obj)
 Add a line. More...
 
virtual unsigned int RemoveLine (Line *obj)
 Remove a line. More...
 
virtual void AddPoint (Point *obj)
 Add a point. More...
 
virtual unsigned int RemovePoint (Point *obj)
 Remove a point. More...
 
virtual void AddRod (Rod *obj)
 Add a rod. More...
 
virtual unsigned int RemoveRod (Rod *obj)
 Remove a rod. More...
 
virtual void AddBody (Body *obj)
 Add a body. More...
 
virtual unsigned int RemoveBody (Body *obj)
 Remove a body. More...
 
virtual void Init ()
 Create an initial state for all the entities. More...
 
virtual void Step (real &dt)
 Run a time step. More...
 
virtual void SetState (const state::State &state, unsigned int i=0)
 Resume the simulation from the stationary solution. More...
 
virtual void SaveState (const std::string filepath, unsigned int i=0)
 Save the system state on a file. More...
 
virtual void LoadState (const std::string filepath, unsigned int i=0)
 Load the system state from a file. More...
 
state::Staterd (unsigned int i=0)
 Get the state derivative. More...
 
virtual std::vector< uint64_t > Serialize (void)
 Produce the packed data to be saved. More...
 
virtual uint64_t * Deserialize (const uint64_t *data)
 Unpack the data to restore the Serialized information. More...
 
state::Stater (unsigned int i=0)
 Get the state. More...
 
state::State GetState (unsigned int i=0)
 Get the state variable. More...
 
- Public Member Functions inherited from moordyn::time::Scheme
virtual ~Scheme ()
 Destructor.
 
void SetGround (Body *obj)
 Set the ground body. More...
 
std::string GetName () const
 Get the name of the scheme. More...
 
real GetTime () const
 Get the simulation time. More...
 
void SetTime (const real &time)
 Set the simulation time. More...
 
real GetCFL () const
 Get the CFL factor. More...
 
void SetCFL (const real &cfl)
 Set the CFL factor. More...
 
void Next ()
 Prepare everything for the next outer time step. 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...
 
- 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...
 

Protected Types

typedef struct moordyn::time::SchemeBase::_mask mask
 A mask to determine which entities shall be computed. More...
 

Protected Member Functions

 SchemeBase (moordyn::Log *log, moordyn::WavesRef waves)
 Constructor. More...
 
void Update (real t_local, unsigned int substep=0)
 Update all the entities to set the state. More...
 
void CalcStateDeriv (unsigned int substep=0)
 Compute the time derivatives and store them. More...
 
- Protected Member Functions inherited from moordyn::time::Scheme
 Scheme (moordyn::Log *log)
 Constructor. More...
 
- 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

std::array< moordyn::state::State *, NSTATE > _r
 The list of states.
 
std::array< moordyn::state::State *, NDERIV > _rd
 The list of state derivatives.
 
std::shared_ptr< Waveswaves
 The waves instance.
 
mask _calc_mask
 The SchemeBase::CalcStateDeriv() mask.
 
- Protected Attributes inherited from moordyn::time::Scheme
Bodyground
 The ground body.
 
std::vector< Line * > lines
 The lines.
 
std::vector< Point * > points
 The points.
 
std::vector< Rod * > rods
 The rods.
 
std::vector< Body * > bodies
 The bodies.
 
std::string name
 The scheme name.
 
real t
 The simulation time.
 
real t_local
 The local time, within the outer time step.
 
real cfl
 Maximum CFL factor.
 
- Protected Attributes inherited from moordyn::LogUser
Log_log
 The log handler.
 

Detailed Description

template<unsigned int NSTATE, unsigned int NDERIV>
class moordyn::time::SchemeBase< NSTATE, NDERIV >

A generic abstract integration scheme.

This class can be later overloaded to implement a plethora of time schemes

Member Typedef Documentation

◆ mask

template<unsigned int NSTATE, unsigned int NDERIV>
typedef struct moordyn::time::SchemeBase::_mask moordyn::time::SchemeBase< NSTATE, NDERIV >::mask
protected

A mask to determine which entities shall be computed.

Useful for local time steps

Constructor & Destructor Documentation

◆ SchemeBase()

template<unsigned int NSTATE, unsigned int NDERIV>
moordyn::time::SchemeBase< NSTATE, NDERIV >::SchemeBase ( moordyn::Log log,
moordyn::WavesRef  waves 
)
inlineprotected

Constructor.

Parameters
logLogging handler
wavesThe simulation waves object, needed so that we can tell it about substeps

Member Function Documentation

◆ AddBody()

template<unsigned int NSTATE, unsigned int NDERIV>
virtual void moordyn::time::SchemeBase< NSTATE, NDERIV >::AddBody ( Body obj)
inlinevirtual

Add a body.

Parameters
objThe body
Exceptions
moordyn::invalid_value_errorIf it has been already registered

Reimplemented from moordyn::time::Scheme.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddLine()

template<unsigned int NSTATE, unsigned int NDERIV>
virtual void moordyn::time::SchemeBase< NSTATE, NDERIV >::AddLine ( Line obj)
inlinevirtual

Add a line.

Parameters
objThe line
Exceptions
moordyn::invalid_value_errorIf it has been already registered

Reimplemented from moordyn::time::Scheme.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddPoint()

template<unsigned int NSTATE, unsigned int NDERIV>
virtual void moordyn::time::SchemeBase< NSTATE, NDERIV >::AddPoint ( Point obj)
inlinevirtual

Add a point.

Parameters
objThe point
Exceptions
moordyn::invalid_value_errorIf it has been already registered

Reimplemented from moordyn::time::Scheme.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddRod()

template<unsigned int NSTATE, unsigned int NDERIV>
virtual void moordyn::time::SchemeBase< NSTATE, NDERIV >::AddRod ( Rod obj)
inlinevirtual

Add a rod.

Parameters
objThe rod
Exceptions
moordyn::invalid_value_errorIf it has been already registered

Reimplemented from moordyn::time::Scheme.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CalcStateDeriv()

template<unsigned int NSTATE, unsigned int NDERIV>
void moordyn::time::SchemeBase< NSTATE, NDERIV >::CalcStateDeriv ( unsigned int  substep = 0)
protected

Compute the time derivatives and store them.

Parameters
substepThe index within moordyn::SchemeBase::rd where the info will be saved
Here is the caller graph for this function:

◆ Deserialize()

template<unsigned int NSTATE, unsigned int NDERIV>
virtual uint64_t* moordyn::time::SchemeBase< NSTATE, NDERIV >::Deserialize ( const uint64_t *  data)
inlinevirtual

Unpack the data to restore the Serialized information.

This is the function that each inherited class must implement, and should be the inverse of Serialize(void)

Parameters
dataThe packed data
Returns
A pointer to the end of the file, for debugging purposes

Implements moordyn::io::IO.

Reimplemented in moordyn::time::ABScheme< order, local >.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetState()

template<unsigned int NSTATE, unsigned int NDERIV>
state::State moordyn::time::SchemeBase< NSTATE, NDERIV >::GetState ( unsigned int  i = 0)
inlinevirtual

Get the state variable.

Parameters
iThe index of the state variable to take
Returns
The state variable

Implements moordyn::time::Scheme.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Init()

template<unsigned int NSTATE, unsigned int NDERIV>
virtual void moordyn::time::SchemeBase< NSTATE, NDERIV >::Init ( )
inlinevirtual

Create an initial state for all the entities.

Note
Just the first state is written. None of the following states nor the derivatives are initialized in any way.
It is assumed that the coupled entities were already initialized

Implements moordyn::time::Scheme.

Reimplemented in moordyn::time::LocalSchemeBase< NSTATE, NDERIV >, moordyn::time::LocalSchemeBase< 1, 1 >, and moordyn::time::LocalSchemeBase< 1, 5 >.

Here is the caller graph for this function:

◆ LoadState()

template<unsigned int NSTATE, unsigned int NDERIV>
virtual void moordyn::time::SchemeBase< NSTATE, NDERIV >::LoadState ( const std::string  filepath,
unsigned int  i = 0 
)
inlinevirtual

Load the system state from a file.

Parameters
filepathThe output file path
iThe index of the state variable to overwrite
Exceptions
moordyn::invalid_value_errorif the i index is greater or equal than the number of states
moordyn::mem_errorif the expected size of the serialized data is not met

Reimplemented from moordyn::time::Scheme.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ r()

template<unsigned int NSTATE, unsigned int NDERIV>
state::State* moordyn::time::SchemeBase< NSTATE, NDERIV >::r ( unsigned int  i = 0)
inline

Get the state.

Parameters
iThe index of the state variable to take
Returns
The state variable
Exceptions
moordyn::invalid_value_errorif the i index is greater or equal than the number of states
Here is the caller graph for this function:

◆ rd()

template<unsigned int NSTATE, unsigned int NDERIV>
state::State* moordyn::time::SchemeBase< NSTATE, NDERIV >::rd ( unsigned int  i = 0)
inline

Get the state derivative.

Parameters
iThe index of the state derivative to take
Returns
The state derivative
Exceptions
moordyn::invalid_value_errorif the i index is greater or equal than the number of state derivatives
Here is the caller graph for this function:

◆ RemoveBody()

template<unsigned int NSTATE, unsigned int NDERIV>
virtual unsigned int moordyn::time::SchemeBase< NSTATE, NDERIV >::RemoveBody ( Body obj)
inlinevirtual

Remove a body.

Parameters
objThe body
Returns
The index of the removed entity
Exceptions
moordyn::invalid_value_errorIf the body has not been registered, or it was already removed

Reimplemented from moordyn::time::Scheme.

Here is the call graph for this function:

◆ RemoveLine()

template<unsigned int NSTATE, unsigned int NDERIV>
virtual unsigned int moordyn::time::SchemeBase< NSTATE, NDERIV >::RemoveLine ( Line obj)
inlinevirtual

Remove a line.

Parameters
objThe line
Returns
The index of the removed entity
Exceptions
moordyn::invalid_value_errorIf the line has not been registered, or it was already removed

Reimplemented from moordyn::time::Scheme.

Here is the call graph for this function:

◆ RemovePoint()

template<unsigned int NSTATE, unsigned int NDERIV>
virtual unsigned int moordyn::time::SchemeBase< NSTATE, NDERIV >::RemovePoint ( Point obj)
inlinevirtual

Remove a point.

Parameters
objThe point
Returns
The index of the removed entity
Exceptions
moordyn::invalid_value_errorIf the point has not been registered, or it was already removed

Reimplemented from moordyn::time::Scheme.

Here is the call graph for this function:

◆ RemoveRod()

template<unsigned int NSTATE, unsigned int NDERIV>
virtual unsigned int moordyn::time::SchemeBase< NSTATE, NDERIV >::RemoveRod ( Rod obj)
inlinevirtual

Remove a rod.

Parameters
objThe rod
Returns
The index of the removed entity
Exceptions
moordyn::invalid_value_errorIf the rod has not been registered, or it was already removed

Reimplemented from moordyn::time::Scheme.

Here is the call graph for this function:

◆ SaveState()

template<unsigned int NSTATE, unsigned int NDERIV>
virtual void moordyn::time::SchemeBase< NSTATE, NDERIV >::SaveState ( const std::string  filepath,
unsigned int  i = 0 
)
inlinevirtual

Save the system state on a file.

Parameters
filepathThe output file path
iThe index of the state variable to serialize
Exceptions
moordyn::invalid_value_errorif the i index is greater or equal than the number of states

Reimplemented from moordyn::time::Scheme.

Here is the call graph for this function:

◆ Serialize()

template<unsigned int NSTATE, unsigned int NDERIV>
virtual std::vector<uint64_t> moordyn::time::SchemeBase< NSTATE, NDERIV >::Serialize ( void  )
inlinevirtual

Produce the packed data to be saved.

The produced data can be used afterwards to restore the saved information afterwards calling Deserialize(void).

Returns
The packed data

Implements moordyn::io::IO.

Reimplemented in moordyn::time::ABScheme< order, local >.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetState()

template<unsigned int NSTATE, unsigned int NDERIV>
virtual void moordyn::time::SchemeBase< NSTATE, NDERIV >::SetState ( const state::State state,
unsigned int  i = 0 
)
inlinevirtual

Resume the simulation from the stationary solution.

Parameters
stateThe stationary solution
iThe index of the state variable to take
Exceptions
moordyn::invalid_value_errorif the i index is greater or equal than the number of states

Reimplemented from moordyn::time::Scheme.

Reimplemented in moordyn::time::LocalSchemeBase< NSTATE, NDERIV >, moordyn::time::LocalSchemeBase< 1, 1 >, and moordyn::time::LocalSchemeBase< 1, 5 >.

Here is the caller graph for this function:

◆ Step()

template<unsigned int NSTATE, unsigned int NDERIV>
virtual void moordyn::time::SchemeBase< NSTATE, NDERIV >::Step ( real dt)
inlinevirtual

Run a time step.

This function is the one that must be specialized on each time scheme, but remember to call it at the end of the inherited function to increment Scheme::t_local

Parameters
dtTime step

Reimplemented from moordyn::time::Scheme.

Reimplemented in moordyn::time::ImplicitWilsonScheme, moordyn::time::ImplicitNewmarkScheme, moordyn::time::ImplicitEulerScheme, moordyn::time::ABScheme< order, local >, moordyn::time::RK4Scheme, moordyn::time::RK2Scheme, moordyn::time::HeunScheme, moordyn::time::LocalEulerScheme, moordyn::time::EulerScheme, and moordyn::time::StationaryScheme.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Update()

template<unsigned int NSTATE, unsigned int NDERIV>
void moordyn::time::SchemeBase< NSTATE, NDERIV >::Update ( real  t_local,
unsigned int  substep = 0 
)
protected

Update all the entities to set the state.

Parameters
substepThe index within moordyn::SchemeBase::r that will be applied to set the states
t_localThe local time, within the inner time step (from 0 to dt)
Note
This is only affecting to the free entities
See also
Scheme::Next()
Scheme::Step()
Here is the caller graph for this function:

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