MoorDyn
Classes | Typedefs | Enumerations | Functions | Variables
moordyn Namespace Reference

MoorDyn2 C++ API namespace. More...

Classes

class  Body
 A rigid body. More...
 
class  Instance
 A generic instance. More...
 
class  Line
 A mooring line. More...
 
class  null_out_buf
 Null buffer to avoid printing on screen. More...
 
class  MultiStream
 Streamer able to redirect the output to several substreams. More...
 
class  Log
 A Logging utility. More...
 
class  LogUser
 A helper for the entities to use the logger. More...
 
struct  XYZQuat
 Joint of a point and a quaternion. More...
 
struct  _FailProps
 Failure conditions. More...
 
class  MoorDyn
 A Mooring system. More...
 
class  Point
 A point for a line endpoint. More...
 
class  Rod
 A cylindrical rod. More...
 
class  Seafloor
 Bathymetry description for MoorDyn. More...
 
struct  SeafloorProvider
 Helper for moordyn::AbstractCurrentKin. More...
 
class  AbstractCurrentKin
 An abstract class representing the capability of providing water current data at some point and time. More...
 
class  AbstractWaveKin
 An abstract class representing having the capability of providing wave kinematics data. More...
 
class  SpectrumKinWrapper
 Wrapper around waves::SpectrumKin to make it adhere to the AbstractWaveKin interface. More...
 
class  GridXYZT
 A rectilinear grid with x, y, z, and t axes. More...
 
class  WaveGrid
 Contains the data and functionality for the Wave grid kinematics modes. More...
 
class  CurrentGrid
 Contains grid based current data. More...
 
class  Waves
 Class that handles wave and current kinematics. More...
 

Typedefs

typedef std::shared_ptr< WavesWavesRef
 
typedef double real
 Real numbers wrapper. It is either double or float.
 
typedef Eigen::Vector2d vec2
 2-D vector of real numbers
 
typedef Eigen::Vector3d vec3
 3-D vector of real numbers
 
typedef Eigen::Vector4d vec4
 4-D vector of real numbers
 
typedef Eigen::Vector6d vec6
 6-D vector of real numbers
 
typedef Eigen::Vector7d vec7
 7-D vector of real numbers
 
typedef vec3 vec
 vec3 renaming
 
typedef Eigen::Matrix2d mat2
 2x2 matrix of real numbers
 
typedef Eigen::Matrix3d mat3
 3x3 matrix of real numbers
 
typedef Eigen::Matrix4d mat4
 4x4 matrix of real numbers
 
typedef Eigen::Matrix6d mat6
 6x6 matrix of real numbers
 
typedef Eigen::Matrix7d mat7
 7x7 matrix of real numbers
 
typedef mat3 mat
 mat3 renaming
 
typedef Eigen::Quaterniond quaternion
 Quaternion of real numbers.
 
typedef Eigen::Matrix< real, Eigen::Dynamic, 1 > list
 A resizable list of reals.
 
typedef Eigen::Vector2i ivec2
 2-D vector of integers
 
typedef Eigen::Vector3i ivec3
 3-D vector of integers
 
typedef Eigen::Vector4i ivec4
 4-D vector of integers
 
typedef Eigen::Vector6i ivec6
 6-D vector of integers
 
typedef Eigen::Vector7i ivec7
 7-D vector of integers
 
typedef ivec3 ivec
 Renaming of ivec3.
 
typedef std::complex< realcomplex
 Complex numbers.
 
typedef Eigen::Matrix< real, Eigen::Dynamic, Eigen::Dynamic > InstanceStateVar
 State variables for a particular instance.
 
typedef Eigen::Block< InstanceStateVar, Eigen::Dynamic > InstanceStateVarView
 View of the State variables for a particular instance.
 
typedef Eigen::Matrix< InstanceStateVar, Eigen::Dynamic, 1 > StateVar
 State variable.
 
typedef Eigen::VectorBlock< StateVar, Eigen::Dynamic > StateVarView
 View of the State variable.
 
typedef int error_id
 Error identifier.
 
typedef struct moordyn::_FailProps FailProps
 Failure conditions.
 
typedef std::shared_ptr< SeafloorSeafloorRef
 Shared pointer.
 
template<class T >
using Vec2D = std::vector< std::vector< T > >
 STL std::vector of 2 dimensions.
 
template<class T >
using Vec3D = std::vector< std::vector< std::vector< T > >>
 STL std::vector of 3 dimensions.
 
template<class T >
using Vec4D = std::vector< std::vector< std::vector< std::vector< T > >> >
 STL std::vector of 4 dimensions.
 

Enumerations

enum  EndPoints { ENDPOINT_A = 0 , ENDPOINT_B = 1 , ENDPOINT_BOTTOM = ENDPOINT_A , ENDPOINT_TOP = ENDPOINT_B }
 End point qualifiers. More...
 
enum  seafloor_settings { SEAFLOOR_FLAT = 0 , SEAFLOOR_3D = 1 }
 

Functions

std::atomic< size_t > __instances_counter (0)
 
void reset_instance_ids ()
 Reset the instances Ids, so they will be assigned again starting from 0.
 
std::string log_level_name (int level)
 Name the log level. More...
 
template<class T >
MultiStreamoperator<< (MultiStream &st, T val)
 Streaming to the log file and the terminal.
 
vec6 solveMat6 (const mat6 &mat, const vec6 &vec)
 Solves a 6x6 system of equations M * a = b. More...
 
mat6 translateMass (vec r, mat M)
 Compute the mass matrix on an offset point. More...
 
mat6 translateMass6 (vec r, mat6 M)
 Compute the mass matrix on an offset point. More...
 
mat6 rotateMass6 (mat R, mat6 M)
 rotation to a 6x6 mass/inertia tensor More...
 
void transformKinematics (const vec &rRelBody, const mat &M, const vec &r, const vec6 &rd, vec &rOut, vec &rdOut)
 calculate position and velocity of point based on its position relative to moving 6DOF body More...
 
std::pair< real, realorientationAngles (vec q)
 Get the spherical angles for a vector. More...
 
moordyn::real GetCurvature (moordyn::real length, const vec &q1, const vec &q2)
 Convenience function to calculate curvature based on adjacent segments' direction vectors and their combined length. More...
 
bool EqualRealNos (const real a1, const real a2)
 This function compares two real numbers and determines if they are "almost" equal. More...
 
vec3 canonicalEulerAngles (const quaternion &quat, int a0, int a1, int a2)
 
vec3 Quat2Euler (const quaternion &q)
 
quaternion Euler2Quat (const vec3 &angles)
 
const complex i1 (0., 1.)
 The imaginary unit.
 
template<typename T >
void vec2array (const vec &v, T *a)
 Convert a vector to a C-ish array. More...
 
template<typename T >
void array2vec (const T *a, vec &v)
 Convert a C-ish array to a vector. More...
 
template<typename T >
void vec62array (const vec6 &v, T *a)
 Convert a vector to a C-ish array. More...
 
template<typename T >
void array2vec6 (const T *a, vec6 &v)
 Convert a C-ish array to a vector. More...
 
template<typename T >
void mat2array (const mat &v, T a[3][3])
 Convert a matrix to a C-ish array. More...
 
template<typename T >
void array2mat (const T a[3][3], mat &v)
 Convert a C-ish array to a matrix. More...
 
template<typename T >
void mat62array (const mat6 &v, T a[6][6])
 Convert a matrix to a C-ish array. More...
 
template<typename T >
void array2mat6 (const T a[6][6], mat6 &v)
 Convert a C-ish array to a matrix. More...
 
template<typename T >
std::vector< T > vector_slice (std::vector< T > const &v, unsigned int m, unsigned int n)
 
template<typename T >
std::vector< T > vector_slice (std::vector< T > const &v, unsigned int n)
 
template<typename T >
void vector_extend (std::vector< T > &v, std::vector< T > const &v_prime)
 
template<typename T , int NROWS, int NCOLS>
std::vector< T > flatten (std::vector< Eigen::Matrix< T, NROWS, NCOLS >> const &v)
 Flatten a list of vectors or matrices. More...
 
char end_point_name (EndPoints p)
 Gives an character representation of the end point. More...
 
moordyn::real unitvector (vec &u, const vec &r1, const vec &r2)
 Normalized direction vector. More...
 
template<typename T >
void scalevector (const vec &u, T newlength, vec &y)
 Compute a vector with the same direction but different length. More...
 
mat getH (vec r)
 Produce alternator matrix. More...
 
mat rotateMass (mat R, mat M)
 rotation to a 3x3 mass matrix or any other second order tensor More...
 
mat RotX (real rads)
 Rotation matrix around x axis. More...
 
mat RotY (real rads)
 Rotation matrix around y axis. More...
 
mat RotZ (real rads)
 Rotation matrix around z axis. More...
 
std::atomic< size_t > __systems_counter (0)
 
real calcSubSeg (vec p1, vec p2, real surface_height, real diameter)
 
unsigned int calcInsertIndex (std::vector< real > &list, real value)
 
std::vector< realgridAxisCoords (Waves::coordtypes coordtype, vector< string > &entries)
 Compute the coordinates from a grid definition entry line. More...
 

Variables

null_out_buf __cnul_buff
 The buffer to nowhere. More...
 
std::ostream & cnul = __cnul
 
const real pi = 3.141592653589793238462643383279502884197169399375105820974944
 Pi constant.
 
const real rad2deg = 180.0 / pi
 Constant to convert radians into degrees.
 
const real deg2rad = pi / 180.0
 Constant to convert degrees into radians.
 
const char * UnitList []
 The list of units for the output. More...
 

Detailed Description

MoorDyn2 C++ API namespace.

Typedef Documentation

◆ WavesRef

typedef std::shared_ptr< Waves > moordyn::WavesRef

Renaming the shared pointer to be a little more ergonomic

Enumeration Type Documentation

◆ EndPoints

End point qualifiers.

Used for both lines and rods

Enumerator
ENDPOINT_A 

Bottom of the line.

ENDPOINT_B 

Top of the line.

Function Documentation

◆ array2mat()

template<typename T >
void moordyn::array2mat ( const T  a[3][3],
mat v 
)
inline

Convert a C-ish array to a matrix.

Parameters
aThe input array
vThe output matrix
Here is the call graph for this function:
Here is the caller graph for this function:

◆ array2mat6()

template<typename T >
void moordyn::array2mat6 ( const T  a[6][6],
mat6 v 
)
inline

Convert a C-ish array to a matrix.

Parameters
aThe input array
vThe output matrix
Here is the call graph for this function:
Here is the caller graph for this function:

◆ array2vec()

template<typename T >
void moordyn::array2vec ( const T *  a,
vec v 
)
inline

Convert a C-ish array to a vector.

Parameters
aThe input array
vThe output vector
Here is the call graph for this function:
Here is the caller graph for this function:

◆ array2vec6()

template<typename T >
void moordyn::array2vec6 ( const T *  a,
vec6 v 
)
inline

Convert a C-ish array to a vector.

Parameters
aThe input array
vThe output vector
Here is the call graph for this function:
Here is the caller graph for this function:

◆ end_point_name()

char moordyn::end_point_name ( EndPoints  p)
inline

Gives an character representation of the end point.

Returns
The endpoint char
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EqualRealNos()

bool moordyn::EqualRealNos ( const real  a1,
const real  a2 
)
inline

This function compares two real numbers and determines if they are "almost" equal.

"almost" equal means equal within some relative tolerance (basically ignoring the last 2 significant digits) (see "Safe Comparisons" suggestion from http://www.lahey.com/float.htm)

Parameters
a1The first real number to compare
a2The second real number to compare
Returns
true if and only if the numbers are almost equal, false otherwise
Note
The numbers are added together in this routine, so overflow can result if comparing two "huge" numbers.
Use this function instead of directly calling a specific routine in the generic interface.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ flatten()

template<typename T , int NROWS, int NCOLS>
std::vector<T> moordyn::flatten ( std::vector< Eigen::Matrix< T, NROWS, NCOLS >> const &  v)

Flatten a list of vectors or matrices.

This function produced a flattened version ready for saving on VTK arrays

Parameters
vThe list of vectors or matrices
Returns
The flattened list of values
Here is the call graph for this function:
Here is the caller graph for this function:

◆ gridAxisCoords()

std::vector< real > moordyn::gridAxisCoords ( Waves::coordtypes  coordtype,
vector< string > &  entries 
)

Compute the coordinates from a grid definition entry line.

Parameters
coordtypeThe type of coordinates input
entriesNothing if coordtype is 0; the list of coordinates if coordtype is 1 and minimum limit; the maximum limit and the number of points if coordtype is 2
Returns
The list of coordinates
Warning
Memory will be allocated in coordarray. The user is responsible of deallocating it afterwards
Here is the call graph for this function:
Here is the caller graph for this function:

◆ log_level_name()

std::string moordyn::log_level_name ( int  level)

Name the log level.

Parameters
levelThe log level
See also
Moordyn_log

◆ mat2array()

template<typename T >
void moordyn::mat2array ( const mat v,
a[3][3] 
)
inline

Convert a matrix to a C-ish array.

Parameters
vThe input matrix
aThe output array
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mat62array()

template<typename T >
void moordyn::mat62array ( const mat6 v,
a[6][6] 
)
inline

Convert a matrix to a C-ish array.

Parameters
vThe input matrix
aThe output array
Here is the call graph for this function:
Here is the caller graph for this function:

◆ solveMat6()

vec6 DECLDIR moordyn::solveMat6 ( const mat6 mat,
const vec6 vec 
)

Solves a 6x6 system of equations M * a = b.

Uses Eigen::ColPivHouseholderQR which means it doesn't have any particular constraints on the matrix properties. Has high accuracy and good speed.

Parameters
mat6x6 Matrix (M in M * a = b)
vec6x1 Vector (b in M * a = b)
Returns
vec6 Resulting solution (a in M * a = b)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vec2array()

template<typename T >
void moordyn::vec2array ( const vec v,
T *  a 
)
inline

Convert a vector to a C-ish array.

Parameters
vThe input vector
aThe output array
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vec62array()

template<typename T >
void moordyn::vec62array ( const vec6 v,
T *  a 
)
inline

Convert a vector to a C-ish array.

Parameters
vThe input vector
aThe output array
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vector_extend()

template<typename T >
void moordyn::vector_extend ( std::vector< T > &  v,
std::vector< T > const &  v_prime 
)

Extend a C++ vector

Parameters
vThe vector to slice
v_primeThe vector to be concatenated
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vector_slice() [1/2]

template<typename T >
std::vector<T> moordyn::vector_slice ( std::vector< T > const &  v,
unsigned int  m,
unsigned int  n 
)

Slice a C++ vector

Parameters
vThe vector to slice
mThe first element to consider
nThe number of elements
Returns
The sliced vector
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vector_slice() [2/2]

template<typename T >
std::vector<T> moordyn::vector_slice ( std::vector< T > const &  v,
unsigned int  n 
)

Slice a C++ vector

Parameters
vThe vector to slice
nThe number of elements
Returns
The sliced vector
Here is the call graph for this function:

Variable Documentation

◆ __cnul_buff

std::ostream __cnul & moordyn::__cnul_buff

The buffer to nowhere.

Stream to nowhere.

◆ cnul

std::ostream& moordyn::cnul = __cnul

Stream to nowhere, used when verbosity is not large enough to print the message

◆ UnitList

const char* moordyn::UnitList[]
Initial value:
= {
"s",
"m", "m", "m",
"deg", "deg", "deg",
"m/s", "m/s", "m/s",
"deg/s", "deg/s", "deg/s",
"m/s^2", "m/s^2", "m/s^2",
"deg/s^2", "deg/s^2", "deg/s^2",
"N",
"N", "N", "N",
"N*m", "N*m", "N*m",
"(frac)"
}

The list of units for the output.