MoorDyn
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
moordyn::Body Class Referencefinal

A rigid body. More...

#include <Body.hpp>

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

Public Types

enum  types {
  COUPLED = -1 , FREE = 0 , FIXED = 1 , CPLDPIN = 2 ,
  VESSEL = COUPLED , ANCHOR = FIXED
}
 Types of bodies. More...
 

Public Member Functions

 Body (moordyn::Log *log, size_t id)
 Costructor. More...
 
 ~Body ()
 Destructor.
 
void setup (int number, types type, vec6 r6, vec rCG, real M, real V, vec I, vec6 CdA, vec6 Ca, EnvCondRef env_in, shared_ptr< ofstream > outfile)
 Setup/initialize a rigid body. Called after instantiating a new Body in MoorDyn2.cpp. More...
 
void addPoint (moordyn::Point *point, vec coords)
 Attach a point to the body. More...
 
void addRod (Rod *rod, vec6 coords)
 Attach a rod to the body. More...
 
void initializeUnfreeBody (vec6 r=vec6::Zero(), vec6 rd=vec6::Zero(), vec6 rdd=vec6::Zero())
 Initialize the body that aren't free i.e. don't have states. More...
 
vec6 getUnfreeVel () const
 Get the last setted velocity for an unfree body. More...
 
void initializeBody (XYZQuat r=XYZQuat::Zero(), vec6 rd=vec6::Zero())
 Initialize the free body. More...
 
void setWaves (moordyn::WavesRef waves_in)
 Set the environmental data. More...
 
void setDependentStates ()
 set the states (positions and velocities) to all the attached entities More...
 
void getState (XYZQuat &pos, vec6 &vel) const
 Get the body kinematics. More...
 
std::pair< XYZQuat, vec6getState () const
 Get the body kinematics. More...
 
const vec getPosition () const
 Get the body position. More...
 
const vec getAngles () const
 Get the body Euler XYZ angles. More...
 
const vec getVelocity () const
 Get the body velocity. More...
 
const vec getAngularVelocity () const
 Get the body angular velocity. More...
 
const vec6 getFnet () const
 Get the forces and moments exerted over the body. More...
 
const mat6getM () const
 Get the mass and intertia matrix. More...
 
real GetBodyOutput (OutChanProps outChan)
 Get body output. More...
 
void scaleDrag (real scaler)
 Scale the drag coefficients. More...
 
void initiateStep (vec6 r, vec6 rd, vec6 rdd)
 Called at the beginning of each coupling step to update the boundary conditions (body kinematics) for the proceeding time steps. More...
 
void updateFairlead (real time)
 Sets the kinematics based on the position and velocity of the fairlead. More...
 
std::pair< XYZQuat, vec6initialize ()
 Initialize a free instance. More...
 
void initialize (InstanceStateVarView r)
 Initialize a free instance. More...
 
- Public Member Functions inherited from moordyn::Instance
 Instance (moordyn::Log *log)
 Costructor. More...
 
virtual ~Instance ()=default
 Destructor.
 
const size_t id () const
 Get the unique identifier of this instance. 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...
 

Static Public Member Functions

static string TypeName (types t)
 Return a string with the name of a type. More...
 

Public Attributes

EnvCondRef env
 Global struct that holds environmental settings.
 
WavesRef waves
 global Waves object
 
std::vector< moordyn::Point * > attachedP
 Points attached to this body.
 
std::vector< Rod * > attachedR
 Rods attached to this body.
 
std::vector< vecrPointRel
 Attachment points of each point.
 
std::vector< vec6r6RodRel
 Attachment points of each rod.
 
vec6 body_r6
 The reference point.
 
vec body_rCG
 The center of gravity.
 
real bodyM
 The mass.
 
real bodyV
 The volume.
 
vec bodyI
 The inertia diagonal components.
 
vec6 bodyCdA
 The product of the drag coefficient and the frontal area (m^2)
 
vec6 bodyCa
 The added mass coefficients.
 
XYZQuat r7
 body 6dof position [x/y/z]
 
vec6 v6
 body 6dof velocity[x/y/z]
 
vec6 a6
 body 6dof acceleration[x/y/z]
 
vec6 r_ves
 fairlead position for coupled bodies [x/y/z]
 
vec6 rd_ves
 fairlead velocity for coupled bodies [x/y/z]
 
vec6 rdd_ves
 fairlead acceleration for coupled bodies [x/y/z]
 
vec6 F6net
 total force and moment vector on body
 
mat6 M
 total body mass + added mass matrix including all elements
 
mat6 M0
 
mat OrMat
 
ofstream * outfile
 Pointer to moordyn::MoorDyn::outfileMain.
 
size_t bodyId
 Body ID.
 
int number
 Body number.
 
types type
 Type of body.
 
void setState (const InstanceStateVarView r)
 Set the states to the body to the position r and velocity rd. More...
 
void getStateDeriv (InstanceStateVarView drdt)
 calculate the forces and state derivatives of the body More...
 
void doRHS ()
 calculates the forces on the body More...
 
void Output (real time)
 
const size_t stateN () const
 Get the number of state variables required by this instance. More...
 
const size_t stateDims () const
 Get the dimension of the state variable. 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)
 Save the body on a VTK (.vtp) file. More...
 
const leanvtk::VTPWriter * getVTK () const
 Get the VTK writer. 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 rigid body.

Some really basic dynamics are implemented for rigid bodies out of the box, which can be extended through the usage of coupled ones.

In the configuration file the options are:

Name/ID, X0, Y0, Z0, Xcg, Ycg, Zcg, M, V, IX, IY, IZ, CdA-x,y,z Ca-x,y,z

Member Enumeration Documentation

◆ types

Types of bodies.

Enumerator
COUPLED 

Is coupled, i.e. is controlled by the user.

FREE 

Is free to move, controlled by MoorDyn.

FIXED 

Is fixed, either to a location or to another moving entity.

CPLDPIN 

Is coupled pinned, i.e. translational dof are controlled by the user.

Constructor & Destructor Documentation

◆ Body()

moordyn::Body::Body ( moordyn::Log log,
size_t  id 
)

Costructor.

Parameters
logLogging handler defining where/how results should be logged.
idU nique identifier of this body

Member Function Documentation

◆ addPoint()

void moordyn::Body::addPoint ( moordyn::Point point,
vec  coords 
)

Attach a point to the body.

Parameters
pointThe point
coordsThe fixation point
Exceptions
moordyn::invalid_value_errorIf point is NULL

◆ addRod()

void moordyn::Body::addRod ( Rod rod,
vec6  coords 
)

Attach a rod to the body.

Parameters
rodThe rod
coordsvector indicating start (vals 0-2) and end (valse 3-5) of rod in the body reference frame
Exceptions
moordyn::invalid_value_errorIf rod is NULL
Here is the call graph for this function:

◆ Deserialize()

uint64_t * moordyn::Body::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:

◆ doRHS()

void moordyn::Body::doRHS ( )

calculates the forces on the body

Exceptions
moordyn::invalid_value_errorIf the body is of type moordyn::Body::FREE
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAngles()

const vec moordyn::Body::getAngles ( ) const
inline

Get the body Euler XYZ angles.

Returns
The body Euler XYZ angles

◆ getAngularVelocity()

const vec moordyn::Body::getAngularVelocity ( ) const
inline

Get the body angular velocity.

Returns
The body angular velocity

◆ GetBodyOutput()

real moordyn::Body::GetBodyOutput ( OutChanProps  outChan)

Get body output.

This funtion is useful when output options are set in the system

Parameters
outChanThe output channel/field
Returns
The output value, 0.0 if a non-valid field is set
Here is the call graph for this function:

◆ getFnet()

const vec6 moordyn::Body::getFnet ( ) const

Get the forces and moments exerted over the body.

Returns
The net force
Here is the caller graph for this function:

◆ getM()

const mat6& moordyn::Body::getM ( ) const
inline

Get the mass and intertia matrix.

Returns
The mass and inertia matrix

◆ getPosition()

const vec moordyn::Body::getPosition ( ) const
inline

Get the body position.

Returns
The body position

◆ getState() [1/2]

std::pair<XYZQuat, vec6> moordyn::Body::getState ( ) const
inline

Get the body kinematics.

Returns
Position and velocity

◆ getState() [2/2]

void moordyn::Body::getState ( XYZQuat pos,
vec6 vel 
) const
inline

Get the body kinematics.

Parameters
posThe output position
velThe output velocity

◆ getStateDeriv()

void moordyn::Body::getStateDeriv ( InstanceStateVarView  drdt)
virtual

calculate the forces and state derivatives of the body

This function is only meant for free bodies

Parameters
drdtThe states derivatives, i.e. the velocity and the acceleration
Exceptions
moordyn::invalid_value_errorIf the body is of type moordyn::Body::FREE

Implements moordyn::Instance.

Here is the call graph for this function:

◆ getUnfreeVel()

vec6 moordyn::Body::getUnfreeVel ( ) const
inline

Get the last setted velocity for an unfree body.

For free bodies the behaviour is undetermined

Returns
The velocity (6 dof)

◆ getVelocity()

const vec moordyn::Body::getVelocity ( ) const
inline

Get the body velocity.

Returns
The body velocity

◆ getVTK()

const leanvtk::VTPWriter* moordyn::Body::getVTK ( ) const
inline

Get the VTK writer.

This function is useful for writing multiblock .vtm files

Returns
The VTK .vtu writer

◆ initialize() [1/2]

std::pair< XYZQuat, vec6 > moordyn::Body::initialize ( )

Initialize a free instance.

Parameters
rThe output state variable
Returns
The 6-dof position (first) and the 6-dof velocity (second)
Exceptions
moordyn::invalid_value_errorIf the instance does not have free states. e.g. a coupled body controlled from outside
moordyn::output_file_errorIf an outfile has been provided, but it cannot be written
Here is the call graph for this function:

◆ initialize() [2/2]

void moordyn::Body::initialize ( InstanceStateVarView  r)
inlinevirtual

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

Implements moordyn::Instance.

◆ initializeBody()

void moordyn::Body::initializeBody ( XYZQuat  r = XYZQuat::Zero(),
vec6  rd = vec6::Zero() 
)

Initialize the free body.

Those are the bodies with type moordyn::Body::FREE

Parameters
rThe position (6 dof)
rdThe velocity (6 dof)
Exceptions
moordyn::invalid_value_errorIf the body is not of type moordyn::Body::FREE
moordyn::output_file_errorIf an outfile has been provided, but it cannot be written

◆ initializeUnfreeBody()

void moordyn::Body::initializeUnfreeBody ( vec6  r = vec6::Zero(),
vec6  rd = vec6::Zero(),
vec6  rdd = vec6::Zero() 
)

Initialize the body that aren't free i.e. don't have states.

Those are the bodies with types moordyn::Body::COUPLED and moordyn::Body::FIXED

Parameters
rThe position (6 dof)
rdThe velocity (6 dof)
rddThe acceleration (6 dof)
Exceptions
moordyn::invalid_value_errorIf the body is of type moordyn::Body::FREE
Here is the call graph for this function:

◆ initiateStep()

void moordyn::Body::initiateStep ( vec6  r,
vec6  rd,
vec6  rdd 
)

Called at the beginning of each coupling step to update the boundary conditions (body kinematics) for the proceeding time steps.

Parameters
rThe input position
rdThe input velocity
rddThe input acceleration
Exceptions
moordyn::invalid_value_errorIf the body is not of type moordyn::Body::COUPLED or moordyn::Body::FIXED
Here is the caller graph for this function:

◆ saveVTK()

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

Save the body on a VTK (.vtp) file.

Parameters
filenameThe output file name
Exceptions
output_file_errorIf the file cannot be saved

◆ scaleDrag()

void moordyn::Body::scaleDrag ( real  scaler)
inline

Scale the drag coefficients.

Parameters
scalerThe drag coefficients scale factor

◆ Serialize()

std::vector< uint64_t > moordyn::Body::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:

◆ setDependentStates()

void moordyn::Body::setDependentStates ( )

set the states (positions and velocities) to all the attached entities

Exceptions
moordyn::invalid_value_errorIf a non FIXED point is tried to be edited
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setState()

void moordyn::Body::setState ( const InstanceStateVarView  r)
virtual

Set the states to the body to the position r and velocity rd.

Parameters
rThe body state

Implements moordyn::Instance.

Here is the call graph for this function:

◆ setup()

void moordyn::Body::setup ( int  number,
types  type,
vec6  r6,
vec  rCG,
real  M,
real  V,
vec  I,
vec6  CdA,
vec6  Ca,
EnvCondRef  env_in,
shared_ptr< ofstream >  outfile 
)

Setup/initialize a rigid body. Called after instantiating a new Body in MoorDyn2.cpp.

Parameters
numberBody number
typeBody type
r66dof position
rCGCenter of gravity position
MMass
VVolume
IInertia (diagonal matrix components)
CdADrag coefficient
CaAdded mass coefficient
env_inGlobal struct that holds environmental settings
outfileThe outfile where information shall be witten
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setWaves()

void moordyn::Body::setWaves ( moordyn::WavesRef  waves_in)
inline

Set the environmental data.

Parameters
waves_inGlobal Waves object

◆ stateDims()

const size_t moordyn::Body::stateDims ( ) const
inlinevirtual

Get the dimension of the state variable.

Returns
7 components for position quaternion and 6 components for linear and angular velocities, i.e. 13 components
Warning
This function shall be called after ::setup()

Reimplemented from moordyn::Instance.

◆ stateN()

const size_t moordyn::Body::stateN ( ) const
inlinevirtual

Get the number of state variables required by this instance.

Returns
1

Reimplemented from moordyn::Instance.

◆ TypeName()

static string moordyn::Body::TypeName ( types  t)
inlinestatic

Return a string with the name of a type.

This tool is useful mainly for debugging

Here is the caller graph for this function:

◆ updateFairlead()

void moordyn::Body::updateFairlead ( real  time)

Sets the kinematics based on the position and velocity of the fairlead.

This function is meant only for coupled or fixed bodies

Parameters
timeLocal time within the time step (from 0 to dt)
Exceptions
moordyn::invalid_value_errorIf the body is not of type moordyn::Body::COUPLED or moordyn::Body::FIXED
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ M0

mat6 moordyn::Body::M0

starting mass and added mass matrix (6x6) of body without any rod elements in inertial orientation

◆ OrMat

mat moordyn::Body::OrMat

orientation matrix of body (rotation matrix that gets it to its current orientation)


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