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

A cylindrical rod. More...

#include <Rod.hpp>

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

Public Types

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

Public Member Functions

 Rod (moordyn::Log *log, size_t rodId)
 Costructor. More...
 
 ~Rod ()
 Destructor.
 
void setup (int number, types type, RodProps *props, vec6 endCoords, unsigned int n, EnvCondRef env_in, shared_ptr< ofstream > outfile, string channels)
 Setup a rod. More...
 
void addLine (Line *line, EndPoints line_end_point, EndPoints rod_end_point)
 Attach a line endpoint to the rod end point A. More...
 
EndPoints removeLine (EndPoints end_point, Line *line)
 Dettach a line. More...
 
void setWaves (moordyn::WavesRef waves_in, moordyn::SeafloorRef seafloor_in)
 Set the environmental data. More...
 
void openoutput ()
 Opens rod output file.
 
std::pair< XYZQuat, vec6initialize ()
 Initialize the rod state. More...
 
void initialize (InstanceStateVarView r)
 Initialize a free instance. More...
 
unsigned int getN () const
 Number of segments. More...
 
vec getNodePos (unsigned int i) const
 Get the position of a node. More...
 
vec getNodeVel (unsigned int i) const
 Get the velocity of a node. More...
 
real GetRodOutput (OutChanProps outChan)
 Get rod output. More...
 
std::pair< real, realgetDrag () const
 Get the drag coefficients. More...
 
void setDrag (real cdn, real cdt)
 Set the drag coefficients. More...
 
void scaleDrag (real scaler)
 Scale the drag coefficients. More...
 
void setTime (real time)
 Set the line simulation time. More...
 
void getState (XYZQuat &pos, vec6 &vel) const
 Get the body kinematics. More...
 
std::pair< XYZQuat, vec6getState () const
 Get the body kinematics. 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

size_t rodId
 Rod ID.
 
int number
 Rod number.
 
types type
 Rod type.
 
real roll
 The roll angle (useful for output)
 
real pitch
 The pitch angle (useful for output)
 
void setState (const InstanceStateVarView r)
 Set the rod state. More...
 
void initiateStep (vec6 r, vec6 rd, vec6 rdd)
 Called at the beginning of each coupling step to update the boundary conditions (rod kinematics) for the proceeding time steps. More...
 
vec6 getUnfreeVel () const
 Get the last setted velocity for an unfree rod. More...
 
void updateFairlead (real time)
 Sets the kinematics. More...
 
void setKinematics (vec6 r, vec6 rd)
 Take the kinematics from the fairlead information. More...
 
void setDependentStates ()
 Set the end kinematics then set the states (positions and velocities) of any line ends attached to this rod. More...
 
void getStateDeriv (InstanceStateVarView drdt)
 calculate the forces and state derivatives of the rod More...
 
const vec6 getFnet () const
 Get the net force on rod (and possibly moment at end A if it's not pinned) More...
 
const mat6 getM () const
 Get the rod mass matrix. More...
 
void getNetForceAndMass (vec6 &Fnet_out, mat6 &M_out, vec rBody, vec6 vBody)
 Calculate the force and mass contributions of the point on the parent body. More...
 
void getNetForceAndMass (vec6 &Fnet_out, mat6 &M_out)
 Calculate the force and mass contributions of the point on the parent body. More...
 
void doRHS ()
 This is the big function that calculates the forces on the rod, including from attached lines. More...
 
void Output (real)
 
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 rod 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 cylindrical rod.

Rod are cylindrical structures with much more complete dynamics than moordyn::Body.

Each end point of the rod can be fixed or pinned to another object, let free or control it externally

Member Enumeration Documentation

◆ types

Types of rods.

Enumerator
COUPLED 

Is attached rigidly to a coupling point (6dof)

CPLDPIN 

Is pinned to a coupling point (3dof)

FREE 

Is free to move, controlled by MoorDyn.

PINNED 

Is pinned to a fixed point (or a body/ptfm, in which case added to list?)

FIXED 

Is attached rigidly to a fixed point (or a body/ptfm, in which case added to list?)

Constructor & Destructor Documentation

◆ Rod()

moordyn::Rod::Rod ( moordyn::Log log,
size_t  rodId 
)

Costructor.

Parameters
logLogging handler
rodIdUnique identifier of this rod

Member Function Documentation

◆ addLine()

void moordyn::Rod::addLine ( Line line,
EndPoints  line_end_point,
EndPoints  rod_end_point 
)

Attach a line endpoint to the rod end point A.

Parameters
lineThe line to be attached
line_end_pointThe line endpoint
rod_end_pointThe rod endpoint
Exceptions
moordyn::invalid_value_errorIf the end points are not valid
Here is the call graph for this function:

◆ Deserialize()

uint64_t * moordyn::Rod::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::Rod::doRHS ( )

This is the big function that calculates the forces on the rod, including from attached lines.

(-z1lo+Rodzeta(I))/abs(sinPhi) ! distance from node to waterline cross at same axial location [m]

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

◆ getDrag()

std::pair<real, real> moordyn::Rod::getDrag ( ) const
inline

Get the drag coefficients.

Returns
The normal (transversal) and tangential (axial) drag coefficients

◆ getFnet()

const vec6 moordyn::Rod::getFnet ( ) const

Get the net force on rod (and possibly moment at end A if it's not pinned)

Returns
The net force
Exceptions
moordyn::invalid_value_errorIf the rod is not of type moordyn::Rod::COUPLED or moordyn::Rod::CPLDPIN
Here is the caller graph for this function:

◆ getM()

const mat6 moordyn::Rod::getM ( ) const
inline

Get the rod mass matrix.

Returns
The net force
Exceptions
moordyn::invalid_value_errorIf the rod is not of type moordyn::Rod::COUPLED or moordyn::Rod::CPLDPIN

◆ getN()

unsigned int moordyn::Rod::getN ( ) const
inline

Number of segments.

The number of nodes can be computed as moordyn::Rod::getN() + 1

Returns
The number of segments, moordyn::Rod::N
Here is the caller graph for this function:

◆ getNetForceAndMass() [1/2]

void moordyn::Rod::getNetForceAndMass ( vec6 Fnet_out,
mat6 M_out 
)
inline

Calculate the force and mass contributions of the point on the parent body.

Parameters
Fnet_outOutput Force about body ref point
M_outOutput Mass matrix about body ref point

◆ getNetForceAndMass() [2/2]

void moordyn::Rod::getNetForceAndMass ( vec6 Fnet_out,
mat6 M_out,
vec  rBody,
vec6  vBody 
)

Calculate the force and mass contributions of the point on the parent body.

Parameters
Fnet_outOutput Force about body ref point
M_outOutput Mass matrix about body ref point
rBodyThe body position
vBodyThe body velocity
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getNodePos()

vec moordyn::Rod::getNodePos ( unsigned int  i) const
inline

Get the position of a node.

Parameters
iThe line node index
Returns
The position
Exceptions
invalid_value_errorIf the node index i is bigger than the number of nodes, moordyn::Line::N + 1

◆ getNodeVel()

vec moordyn::Rod::getNodeVel ( unsigned int  i) const
inline

Get the velocity of a node.

Parameters
iThe line node index
Returns
The velocity
Exceptions
invalid_value_errorIf the node index i is bigger than the number of nodes, moordyn::Line::N + 1

◆ GetRodOutput()

real moordyn::Rod::GetRodOutput ( OutChanProps  outChan)

Get rod output.

This funtion is useful when outputs are set in the rod properties

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:

◆ getState() [1/2]

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

Get the body kinematics.

Returns
Position and velocity

◆ getState() [2/2]

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

Get the body kinematics.

Parameters
posThe output position
velThe output velocity

◆ getStateDeriv()

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

calculate the forces and state derivatives of the rod

Parameters
drdtThe velocity quaternion and the linear and angular accelerations
Exceptions
nan_errorIf nan values are detected in any node position
Note
The returned linear velocity and accelerations for pinned rods should be ignored

Implements moordyn::Instance.

Here is the call graph for this function:

◆ getUnfreeVel()

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

Get the last setted velocity for an unfree rod.

For free rods the behaviour is undetermined

Returns
The velocity (6 dof)

◆ getVTK()

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

Get the VTK writer.

This function is useful for writing multiblock .vtm files

Returns
The VTK .vtp writer

◆ initialize() [1/2]

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

Initialize the rod state.

Parameters
rThe output state variable
Returns
The position and orientation angles (first) and the linear and angular velocity (second)
Note
moordyn::Rod::r6 and moordyn::Rod::v6 must already be set
ground- or body-pinned rods have already had moordyn::Rod::setKinematics() called
In the case of pinned rods, just the rod directions and angular velocites shall be considered
Here is the call graph for this function:

◆ initialize() [2/2]

void moordyn::Rod::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.

◆ initiateStep()

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

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

Parameters
rThe input position
rdThe input velocity
rddThe input acceleration
Exceptions
moordyn::invalid_value_errorIf the rod is not of type moordyn::Rod::COUPLED or moordyn::Rod::CPLDPIN
Note
If the rod is of type moordyn::Rod::CPLDPIN, then just 3 components of r and rd are considered
Here is the call graph for this function:

◆ removeLine()

EndPoints moordyn::Rod::removeLine ( EndPoints  end_point,
Line line 
)

Dettach a line.

Parameters
end_pointThe rod end point where the line is attached
lineThe line
Returns
The line end point that was attached to the rod
Exceptions
moordyn::invalid_value_errorIf there is no an attached line with the provided lineID
Here is the call graph for this function:

◆ saveVTK()

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

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

Parameters
filenameThe output file name
Exceptions
output_file_errorIf the file cannot be saved
Here is the call graph for this function:

◆ scaleDrag()

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

Scale the drag coefficients.

Parameters
scalerThe drag coefficients scale factor

◆ Serialize()

std::vector< uint64_t > moordyn::Rod::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::Rod::setDependentStates ( )

Set the end kinematics then set the states (positions and velocities) of any line ends attached to this rod.

This also determines the orientation of zero-length rods.

Here is the caller graph for this function:

◆ setDrag()

void moordyn::Rod::setDrag ( real  cdn,
real  cdt 
)
inline

Set the drag coefficients.

Parameters
cdnNormal (transversal) coefficient
cdttangential (axial) coefficient

◆ setKinematics()

void moordyn::Rod::setKinematics ( vec6  r,
vec6  rd 
)

Take the kinematics from the fairlead information.

set kinematics for Rods ONLY if they are attached to a body (including a coupled body) (otherwise shouldn't be called)

Parameters
rPosition
rdVelocity
Exceptions
moordyn::invalid_value_errorIf the rod is not of type moordyn::Rod::FIXED or moordyn::Rod::PINNED
Note
If the rod is of type moordyn::Rod::PINNED, then just 3 components of r and rd are considered
Here is the call graph for this function:

◆ setState()

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

Set the rod state.

for a free Rod, there are 12 states: [x, y, z velocity of end A, then rate of change of u/v/w coordinates of unit vector pointing toward end B, then x, y, z coordinate of end A, u/v/w coordinates of unit vector pointing toward end B]

for a pinned Rod, there are 6 states (rotational only): [rate of change of u/v/w coordinates of unit vector pointing toward end B, then u/v/w coordinates of unit vector pointing toward end B]

Parameters
rThe rod states
Exceptions
invalid_value_errorIf the rod is not of type FREE, CPLDPIN or PINNED

Implements moordyn::Instance.

Here is the call graph for this function:

◆ setTime()

void moordyn::Rod::setTime ( real  time)
inline

Set the line simulation time.

Parameters
timeSimulation time

◆ setup()

void moordyn::Rod::setup ( int  number,
types  type,
RodProps props,
vec6  endCoords,
unsigned int  n,
EnvCondRef  env_in,
shared_ptr< ofstream >  outfile,
string  channels 
)

Setup a rod.

Parameters
numberRod ID
typeRod type
propsRod properties
endCoordsThe coordinates of both end points
nNumber of segments
env_inGlobal struct that holds environmental settings
outfileThe outfile where information shall be witten
channelsThe channels/fields that shall be printed in the file
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setWaves()

void moordyn::Rod::setWaves ( moordyn::WavesRef  waves_in,
moordyn::SeafloorRef  seafloor_in 
)
inline

Set the environmental data.

Parameters
waves_inGlobal Waves object
seafloor_inGlobal Seafloor object

◆ stateDims()

const size_t moordyn::Rod::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::Rod::stateN ( ) const
inlinevirtual

Get the number of state variables required by this instance.

Returns
1

Reimplemented from moordyn::Instance.

◆ TypeName()

static string moordyn::Rod::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::Rod::updateFairlead ( real  time)

Sets the kinematics.

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 rod is not of type moordyn::Rod::COUPLED or moordyn::Rod::CPLDPIN
Here is the call graph for this function:

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