|
MoorDyn
|
A rigid body. More...
#include <Body.hpp>


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, vec6 > | getState () 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 mat6 & | getM () 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, vec6 > | initialize () |
| 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... | |
| Log * | GetLogger () 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< vec > | rPointRel |
| Attachment points of each point. | |
| std::vector< vec6 > | r6RodRel |
| 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. | |
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
| enum moordyn::Body::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. |
| moordyn::Body::Body | ( | moordyn::Log * | log, |
| size_t | id | ||
| ) |
Costructor.
| log | Logging handler defining where/how results should be logged. |
| id | U nique identifier of this body |
| void moordyn::Body::addPoint | ( | moordyn::Point * | point, |
| vec | coords | ||
| ) |
Attach a point to the body.
| point | The point |
| coords | The fixation point |
| moordyn::invalid_value_error | If point is NULL |
Attach a rod to the body.
| rod | The rod |
| coords | vector indicating start (vals 0-2) and end (valse 3-5) of rod in the body reference frame |
| moordyn::invalid_value_error | If rod is NULL |

|
virtual |
Unpack the data to restore the Serialized information.
This is the inverse of Serialize(void)
| data | The packed data |
Implements moordyn::io::IO.

| void moordyn::Body::doRHS | ( | ) |
calculates the forces on the body
| moordyn::invalid_value_error | If the body is of type moordyn::Body::FREE |


|
inline |
Get the body Euler XYZ angles.
|
inline |
Get the body angular velocity.
| real moordyn::Body::GetBodyOutput | ( | OutChanProps | outChan | ) |
Get body output.
This funtion is useful when output options are set in the system
| outChan | The output channel/field |

| const vec6 moordyn::Body::getFnet | ( | ) | const |
Get the forces and moments exerted over the body.

|
inline |
Get the mass and intertia matrix.
|
inline |
Get the body position.
Get the body kinematics.
Get the body kinematics.
| pos | The output position |
| vel | The output velocity |
|
virtual |
calculate the forces and state derivatives of the body
This function is only meant for free bodies
| drdt | The states derivatives, i.e. the velocity and the acceleration |
| moordyn::invalid_value_error | If the body is of type moordyn::Body::FREE |
Implements moordyn::Instance.

|
inline |
Get the last setted velocity for an unfree body.
For free bodies the behaviour is undetermined
|
inline |
Get the body velocity.
|
inline |
Get the VTK writer.
This function is useful for writing multiblock .vtm files
Initialize a free instance.
| r | The output state variable |
| moordyn::invalid_value_error | If the instance does not have free states. e.g. a coupled body controlled from outside |
| moordyn::output_file_error | If an outfile has been provided, but it cannot be written |

|
inlinevirtual |
Initialize a free instance.
| r | The output state variable |
| moordyn::invalid_value_error | If the instance does not have free states. e.g. a coupled body controlled from outside |
Implements moordyn::Instance.
Initialize the free body.
Those are the bodies with type moordyn::Body::FREE
| r | The position (6 dof) |
| rd | The velocity (6 dof) |
| moordyn::invalid_value_error | If the body is not of type moordyn::Body::FREE |
| moordyn::output_file_error | If an outfile has been provided, but it cannot be written |
| 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
| r | The position (6 dof) |
| rd | The velocity (6 dof) |
| rdd | The acceleration (6 dof) |
| moordyn::invalid_value_error | If the body is of type moordyn::Body::FREE |

Called at the beginning of each coupling step to update the boundary conditions (body kinematics) for the proceeding time steps.
| r | The input position |
| rd | The input velocity |
| rdd | The input acceleration |
| moordyn::invalid_value_error | If the body is not of type moordyn::Body::COUPLED or moordyn::Body::FIXED |

| void moordyn::Body::saveVTK | ( | const char * | filename | ) |
Save the body on a VTK (.vtp) file.
| filename | The output file name |
| output_file_error | If the file cannot be saved |
|
inline |
Scale the drag coefficients.
| scaler | The drag coefficients scale factor |
|
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
Implements moordyn::io::IO.

| void moordyn::Body::setDependentStates | ( | ) |
set the states (positions and velocities) to all the attached entities
| moordyn::invalid_value_error | If a non FIXED point is tried to be edited |


|
virtual |
Set the states to the body to the position r and velocity rd.
| r | The body state |
Implements moordyn::Instance.

| 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.
| number | Body number |
| type | Body type |
| r6 | 6dof position |
| rCG | Center of gravity position |
| M | Mass |
| V | Volume |
| I | Inertia (diagonal matrix components) |
| CdA | Drag coefficient |
| Ca | Added mass coefficient |
| env_in | Global struct that holds environmental settings |
| outfile | The outfile where information shall be witten |


|
inline |
Set the environmental data.
| waves_in | Global Waves object |
|
inlinevirtual |
Get the dimension of the state variable.
Reimplemented from moordyn::Instance.
|
inlinevirtual |
Get the number of state variables required by this instance.
Reimplemented from moordyn::Instance.
|
inlinestatic |
Return a string with the name of a type.
This tool is useful mainly for debugging

| 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
| time | Local time within the time step (from 0 to dt) |
| moordyn::invalid_value_error | If the body is not of type moordyn::Body::COUPLED or moordyn::Body::FIXED |


| mat6 moordyn::Body::M0 |
starting mass and added mass matrix (6x6) of body without any rod elements in inertial orientation
| mat moordyn::Body::OrMat |
orientation matrix of body (rotation matrix that gets it to its current orientation)