MoorDyn
Public Member Functions | Protected Member Functions | List of all members
moordyn::MoorDyn Class Referencefinal

A Mooring system. More...

#include <MoorDyn2.hpp>

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

Public Member Functions

DECLDIR MoorDyn (const char *infilename=NULL, int log_level=MOORDYN_MSG_LEVEL)
 Constructor. More...
 
DECLDIR ~MoorDyn ()
 Destructor.
 
moordyn::error_id DECLDIR Init (const double *x, const double *xd, bool skip_ic=false)
 Initializes Moordyn, reading the input file and setting up the mooring lines. More...
 
moordyn::error_id DECLDIR Step (const double *x, const double *xd, double *f, double &t, double &dt)
 Runs a time step of the MoorDyn system. More...
 
vector< Body * > GetBodies () const
 Get the points.
 
vector< Rod * > GetRods () const
 Get the points.
 
vector< Point * > GetPoints () const
 Get the points.
 
vector< Line * > GetLines () const
 Get the lines.
 
void SetDisableOutput (bool disable)
 Set whether console and file output is disabled. More...
 
unsigned int NCoupledDOF () const
 Return the number of coupled Degrees Of Freedom (DOF) More...
 
moordyn::WavesRef DECLDIR GetWaves () const
 Get the wave kinematics instance. More...
 
moordyn::SeafloorRef GetSeafloor () const
 Get the 3D seafloor instance. More...
 
unsigned int ExternalWaveKinInit ()
 Initializes the external Wave kinetics. More...
 
unsigned int ExternalWaveKinGetN () const
 Get the number of points where the waves kinematics shall be provided. More...
 
moordyn::error_id DEPRECATED GetWaveKinCoordinates (double *r) const
 Get the points where the waves kinematics shall be provided. More...
 
std::vector< vecExternalWaveKinGetPoints () const
 Get the points where the waves kinematics shall be provided. More...
 
void DEPRECATED SetWaveKin (std::vector< vec > const &U, std::vector< vec > const &Ud, double t)
 Set the kinematics of the waves. More...
 
void ExternalWaveKinSet (std::vector< vec > const &U, std::vector< vec > const &Ud, double t)
 Set the kinematics of the waves. More...
 
std::vector< uint64_t > Serialize (void)
 Produce the packed data to be saved. More...
 
uint64_t * Deserialize (const uint64_t *data)
 Unpack the data to restore the Serialized information. More...
 
void saveVTK (const char *filename) const
 Save the whole system on a VTK (.vtm) file. More...
 
real GetDt () const
 Get the model time step. More...
 
void SetDt (real dt)
 Set the model time step. More...
 
real GetCFL () const
 Get the model Courant–Friedrichs–Lewy factor. More...
 
void SetCFL (real cfl)
 Set the model Courant–Friedrichs–Lewy factor. More...
 
time::SchemeGetTimeScheme () const
 Get the current time integrator. More...
 
void SetTimeScheme (time::Scheme *tscheme)
 Set the current time integrator. 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 Member Functions

moordyn::error_id ReadInFile ()
 Read the input file, setting up all the required objects and their relationships. More...
 
moordyn::error_id readFileIntoBuffers (vector< string > &in_txt)
 Read the input file and store it as a set of strings, one per line. More...
 
int findStartOfSection (vector< string > &in_txt, vector< string > sectionName)
 Get the file line index where a section starts. More...
 
LinePropsreadLineProps (string inputText, int lineNum)
 Helper function to read a new line property given a line from the input file. More...
 
RodPropsreadRodProps (string inputText, int lineNum)
 Helper function to read a new rod property given a line from the input file. More...
 
RodreadRod (string inputText, int lineNum)
 Helper function to read a new rod given a line from the input file. More...
 
BodyreadBody (string inputText, int lineNum)
 Helper function to read a new body given a line from the input file. More...
 
void readOptionsLine (vector< string > &in_txt, int index)
 Helper function to read an option given a line from the input file. More...
 
bool checkNumberOfEntriesInLine (vector< string > entries, int supposedNumberOfEntries, int lineNum)
 Check that the provided entries match the expected ones. More...
 
moordyn::error_id icStationary ()
 Compute an initial condition using the stationary solver. More...
 
moordyn::error_id icLegacy ()
 Compute an initial condition using the legacy upscaled drag dynamic solver. More...
 
moordyn::error_id GetForces (double *f) const
 Get the forces. 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...
 

Additional Inherited Members

- Protected Attributes inherited from moordyn::LogUser
Log_log
 The log handler.
 

Detailed Description

A Mooring system.

This class contains everything required to hold a whole mooring system, making everything thread-friendly easier

Constructor & Destructor Documentation

◆ MoorDyn()

moordyn::MoorDyn::MoorDyn ( const char *  infilename = NULL,
int  log_level = MOORDYN_MSG_LEVEL 
)

Constructor.

Remember to call Init() to initialize the mooring system

Parameters
infilenameThe input file, if either NULL or "", then "Mooring/lines.txt" will be considered
log_levelThe logging level. It can be changed afterwards
Here is the call graph for this function:

Member Function Documentation

◆ checkNumberOfEntriesInLine()

bool moordyn::MoorDyn::checkNumberOfEntriesInLine ( vector< string >  entries,
int  supposedNumberOfEntries,
int  lineNum 
)
protected

Check that the provided entries match the expected ones.

If a wrong number of entries is provided an error is printed out

Parameters
entriesProvided entries
supposedNumberOfEntriesExpected number of entries
lineNumthe file line number for error messages

◆ Deserialize()

uint64_t * moordyn::MoorDyn::Deserialize ( const uint64_t *  data)
virtual

Unpack the data to restore the Serialized information.

This is 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.

Here is the call graph for this function:

◆ ExternalWaveKinGetN()

unsigned int moordyn::MoorDyn::ExternalWaveKinGetN ( ) const
inline

Get the number of points where the waves kinematics shall be provided.

If env.WaveKin is not WAVES_EXTERNAL, this will return 0

Returns
The number of evaluation points
See also
MoorDyn::ExternalWaveKinInit()
MoorDyn::GetWaves()

◆ ExternalWaveKinGetPoints()

std::vector<vec> moordyn::MoorDyn::ExternalWaveKinGetPoints ( ) const
inline

Get the points where the waves kinematics shall be provided.

The kinematics are provided in those points just if env.WaveKin is WAVES_EXTERNAL. Otherwise moordyn::Waves is used

Returns
The points where the wave kinematics shall be evaluated
See also
MoorDyn::ExternalWaveKinInit()
MoorDyn::GetWaves()
Here is the caller graph for this function:

◆ ExternalWaveKinInit()

unsigned int moordyn::MoorDyn::ExternalWaveKinInit ( )
inline

Initializes the external Wave kinetics.

This is only used if env.WaveKin = WAVES_EXTERNAL

Returns
The number of points where the wave kinematics shall be provided

◆ ExternalWaveKinSet()

void moordyn::MoorDyn::ExternalWaveKinSet ( std::vector< vec > const &  U,
std::vector< vec > const &  Ud,
double  t 
)
inline

Set the kinematics of the waves.

Use this function if env.WaveKin = 1

Parameters
UThe velocities at the points
UdThe accelerations at the points
tSimulation time
Exceptions
moordyn::invalid_value_errorIf the size of U and Ud is not the same than the one reported by MoorDyn::ExternalWaveKinInit()
See also
MoorDyn_InitExtWaves()
MoorDyn_GetWavesCoords()
Here is the caller graph for this function:

◆ findStartOfSection()

int moordyn::MoorDyn::findStartOfSection ( vector< string > &  in_txt,
vector< string >  sectionName 
)
protected

Get the file line index where a section starts.

Parameters
in_txtThe list of strings that contains the input file lines
sectionNameThe valid section name strings
Returns
The line index, -1 if the section cannot be found
See also
::ReadInFile()
::readFileIntoBuffers()

◆ GetCFL()

real moordyn::MoorDyn::GetCFL ( ) const
inline

Get the model Courant–Friedrichs–Lewy factor.

Returns
The CFL

◆ GetDt()

real moordyn::MoorDyn::GetDt ( ) const
inline

Get the model time step.

Returns
The model time step

◆ GetForces()

moordyn::error_id moordyn::MoorDyn::GetForces ( double *  f) const
inlineprotected

Get the forces.

Parameters
fThe forces array
Returns
MOORDYN_SUCCESS If the forces are correctly set, an error code otherwise (see Errors reported by MoorDyn)
Note
You can know the number of components required for f with the function MoorDyn::NCoupledDOF()
Here is the call graph for this function:

◆ GetSeafloor()

moordyn::SeafloorRef moordyn::MoorDyn::GetSeafloor ( ) const
inline

Get the 3D seafloor instance.

The Seafloor instance is used to represent a floor of varying depth over a rectilinear grid. It allows for finding the seafloor height at any (x, y) point which it calculated using a bilinear interpolation.

◆ GetTimeScheme()

time::Scheme* moordyn::MoorDyn::GetTimeScheme ( ) const
inline

Get the current time integrator.

Returns
The time integrator
Here is the caller graph for this function:

◆ GetWaveKinCoordinates()

moordyn::error_id DEPRECATED moordyn::MoorDyn::GetWaveKinCoordinates ( double *  r) const
inline

Get the points where the waves kinematics shall be provided.

The kinematics are provided in those points just if env.WaveKin is WAVES_EXTERNAL. Otherwise moordyn::Waves is used

Parameters
rThe output coordinates
Returns
MOORDYN_SUCCESS If the data is correctly set, an error code otherwise (see Errors reported by MoorDyn)
Deprecated:
Use MoorDyn::GetWaveKinPoints() instead
See also
MoorDyn::ExternalWaveKinInit()
MoorDyn::GetWaves()
Here is the call graph for this function:

◆ GetWaves()

moordyn::WavesRef DECLDIR moordyn::MoorDyn::GetWaves ( ) const
inline

Get the wave kinematics instance.

The wave kinematics instance is used if env.WaveKin is one of WAVES_FFT_GRID, WAVES_GRID, WAVES_FFT_NODE, WAVES_NODE or if env.Currents is not CURRENTS_NONE

Returns
The wave knematics instance
Here is the caller graph for this function:

◆ icLegacy()

moordyn::error_id moordyn::MoorDyn::icLegacy ( )
protected

Compute an initial condition using the legacy upscaled drag dynamic solver.

See also
::ICgenDynamic

◆ icStationary()

moordyn::error_id moordyn::MoorDyn::icStationary ( )
protected

Compute an initial condition using the stationary solver.

See also
::ICgenDynamic
Here is the call graph for this function:

◆ Init()

moordyn::error_id moordyn::MoorDyn::Init ( const double *  x,
const double *  xd,
bool  skip_ic = false 
)

Initializes Moordyn, reading the input file and setting up the mooring lines.

Parameters
xPosition vector
xdVelocity vector
skip_ictrue to skip computing the initial condition, false otherwise. You might be interested on skipping the initial condition computation if for install you plan to load a previously saved simulation state
Note
You can know the number of components required for x and xd with the function MoorDyn::NCoupledDOF()
Returns
MOORDYN_SUCCESS If the mooring system is correctly initialized, an error code otherwise (see Errors reported by MoorDyn)
Here is the call graph for this function:

◆ NCoupledDOF()

unsigned int moordyn::MoorDyn::NCoupledDOF ( ) const
inline

Return the number of coupled Degrees Of Freedom (DOF)

This should match with the number of components of the positions and velocities passed to MoorDyn::Init() and MoorDyn::Step()

The number of coupled DOF is computed as

$n_{dof} = 6 * n_{body} + 3 * n_{point} + 6 * n_{rod} + 3 * n_{pinn}$

with $n_{body}$ the number of coupled bodies, $n_{point}$ the number of coupled points, $n_{rod}$ the number of cantilevered coupled rods, and $n_{pinn}$ the number of pinned coupled rods

Returns
The number of coupled DOF
Here is the caller graph for this function:

◆ readBody()

Body * moordyn::MoorDyn::readBody ( string  inputText,
int  lineNum 
)
protected

Helper function to read a new body given a line from the input file.

Parameters
inputTexta string from the Body List section of input file
lineNumthe file line number for error messages
Returns
The body object
Here is the call graph for this function:

◆ readFileIntoBuffers()

moordyn::error_id moordyn::MoorDyn::readFileIntoBuffers ( vector< string > &  in_txt)
protected

Read the input file and store it as a set of strings, one per line.

Parameters
in_txtThe output list of strings
Returns
MOORDYN_SUCCESS If the input file is correctly loaded and all the objects are consistently set, an error code otherwise (see Errors reported by MoorDyn)
See also
::ReadInFile()

◆ ReadInFile()

moordyn::error_id moordyn::MoorDyn::ReadInFile ( )
protected

Read the input file, setting up all the required objects and their relationships.

This function is called from the constructor, so this information is ready when MoorDyn::Init() is called

Returns
MOORDYN_SUCCESS If the input file is correctly loaded and all the objects are consistently set, an error code otherwise (see Errors reported by MoorDyn)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ readLineProps()

LineProps * moordyn::MoorDyn::readLineProps ( string  inputText,
int  lineNum 
)
protected

Helper function to read a new line property given a line from the input file.

Parameters
inputTexta string from the Line Properties section of input file
lineNumthe file line number for error messages
Returns
The line properties

◆ readOptionsLine()

void moordyn::MoorDyn::readOptionsLine ( vector< string > &  in_txt,
int  index 
)
protected

Helper function to read an option given a line from the input file.

Parameters
in_txtThe list of strings that contains the input file lines
indexThe option line index

◆ readRod()

Rod * moordyn::MoorDyn::readRod ( string  inputText,
int  lineNum 
)
protected

Helper function to read a new rod given a line from the input file.

Parameters
inputTexta string from the Rod List section of input file
lineNumthe file line number for error messages
Returns
The rod object
Here is the call graph for this function:

◆ readRodProps()

RodProps * moordyn::MoorDyn::readRodProps ( string  inputText,
int  lineNum 
)
protected

Helper function to read a new rod property given a line from the input file.

Parameters
inputTexta string from the Rod Properties section of input file
lineNumthe file line number for error messages
Returns
The rod properties

◆ saveVTK()

void moordyn::MoorDyn::saveVTK ( const char *  filename) const

Save the whole system on a VTK (.vtm) file.

Many times, it is more convenient for the user to save each instance in a separate file. However, if the number of subinstances is too large, that would not be an option anymore. Then you can use this function to save the whole system in a multiblock VTK file

Parameters
filenameThe output file name
Exceptions
output_file_errorIf the VTM file, or any of the subentities VTU files, cannot be saved
See also
moordyn::Body::saveVTK()
moordyn::Line::saveVTK()
moordyn::Point::saveVTK()
moordyn::Rod::saveVTK()

◆ Serialize()

std::vector< uint64_t > moordyn::MoorDyn::Serialize ( void  )
virtual

Produce the packed data to be saved.

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

Thus, this function is not processing the information that is extracted from the definition file

Returns
The packed data

Implements moordyn::io::IO.

Here is the call graph for this function:

◆ SetCFL()

void moordyn::MoorDyn::SetCFL ( real  cfl)
inline

Set the model Courant–Friedrichs–Lewy factor.

Parameters
cflThe CFL
Note
The time step will be changed accordingly

◆ SetDisableOutput()

void moordyn::MoorDyn::SetDisableOutput ( bool  disable)
inline

Set whether console and file output is disabled.

Parameters
disable

◆ SetDt()

void moordyn::MoorDyn::SetDt ( real  dt)
inline

Set the model time step.

Parameters
dtThe model time step
Note
The CFL will be changed accordingly

◆ SetTimeScheme()

void moordyn::MoorDyn::SetTimeScheme ( time::Scheme tscheme)
inline

Set the current time integrator.

Returns
The time integrator
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetWaveKin()

void DEPRECATED moordyn::MoorDyn::SetWaveKin ( std::vector< vec > const &  U,
std::vector< vec > const &  Ud,
double  t 
)
inline

Set the kinematics of the waves.

Use this function if env.WaveKin = 1

Parameters
UThe velocities at the points
UdThe accelerations at the points
tSimulation time
Exceptions
moordyn::invalid_value_errorIf the size of U and Ud is not the same than the one reported by MoorDyn::ExternalWaveKinInit()
See also
MoorDyn_InitExtWaves()
MoorDyn_GetWavesCoords()
Here is the call graph for this function:

◆ Step()

moordyn::error_id DECLDIR moordyn::MoorDyn::Step ( const double *  x,
const double *  xd,
double *  f,
double &  t,
double &  dt 
)

Runs a time step of the MoorDyn system.

Parameters
xPosition vector
xdVelocity vector
fOutput forces
tSimulation time
dtTime step
Returns
MOORDYN_SUCCESS If the mooring system is correctly evolved, an error code otherwise (see Errors reported by MoorDyn)
Note
You can know the number of components required for x, xd and f with the function MoorDyn::NCoupledDOF()
Here is the call graph for this function:

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