C API
- group new_c_api
External Wave Kinematics
The functions for setting external wave kinematics.
-
int DECLDIR MoorDyn_ExternalWaveKinInit(MoorDyn system, unsigned int *n)
Initializes the external Wave kinematics.
This is useless unless the WaveKin option is set to 1 in the input file. If that is the case, remember to call this function after MoorDyn_Init()
- Parameters:
system – The Moordyn system
n – The number of points where the wave kinematics shall be provided
- Returns:
MOORDYN_SUCESS If the external waves are correctly initialized, an error code otherwise (see Errors reported by MoorDyn)
-
int DECLDIR MoorDyn_ExternalWaveKinGetN(MoorDyn system, unsigned int *n)
Get the number of points where the waves kinematics shall be provided.
This is useless unless WaveKin option is set to 1 in the input file
See also
- Parameters:
system – The Moordyn system
n – The output number of points where the wave kinematics shall be provided
- Returns:
MOORDYN_SUCESS
-
int DECLDIR MoorDyn_ExternalWaveKinGetCoordinates(MoorDyn system, double *r)
Get the points where the waves kinematics shall be provided.
The kinematics on those points shall be provided just if WaveKin is set to 1 in the input file. The pointer r should be to an array with enough space for 3 * N doubles, where N is the value from MoorDyn_ExternalWaveKinGetN or MoorDyn_ExternalWaveKinInit.
See also
- Parameters:
system – The Moordyn system
r – The output coordinates (3 components per point)
- Returns:
MOORDYN_SUCESS If the data is correctly set, an error code otherwise (see Errors reported by MoorDyn)
- inline int DECLDIR DEPRECATED MoorDyn_GetWaveKinCoordinates (MoorDyn system, double *r)
Get the points where the waves kinematics shall be provided.
The kinematics on those points shall be provided just if WaveKin is set to 1 in the input file
- Deprecated:
This function has been renamed as MoorDyn_ExternalWaveKinGetCoordinates()
See also
- Parameters:
system – The Moordyn system
r – The output coordinates (3 components per point)
- Returns:
MOORDYN_SUCESS If the data is correctly set, an error code otherwise (see Errors reported by MoorDyn)
-
int DECLDIR MoorDyn_ExternalWaveKinSet(MoorDyn system, const double *U, const double *Ud, double t)
Set the kinematics of the waves.
Use this function if the WaveKin option is set to 1 in the input file
See also
- Parameters:
system – The Moordyn system
U – The velocities at the points (3 components per point)
Ud – The accelerations at the points (3 components per point)
t – Simulation time
- Returns:
MOORDYN_SUCCESS If the data is correctly set, an error code otherwise (see Errors reported by MoorDyn)
- inline int DECLDIR DEPRECATED MoorDyn_SetWaveKin (MoorDyn system, const double *U, const double *Ud, double t)
Set the kinematics of the waves.
Use this function if WaveKin option is set to 1 in the input file
- Deprecated:
This function has been renamed as MoorDyn_ExternalWaveKinSet()
See also
- Parameters:
system – The Moordyn system
U – The velocities at the points (3 components per point)
Ud – The accelerations at the points (3 components per point)
t – Simulation time
- Returns:
MOORDYN_SUCESS If the data is correctly set, an error code otherwise (see Errors reported by MoorDyn)
Typedefs
-
typedef struct __MoorDynBody *MoorDynBody
A mooring line instance.
-
typedef struct __MoorDynLine *MoorDynLine
A mooring line instance.
-
typedef struct __MoorDyn *MoorDyn
A mooring system instance.
-
typedef struct __MoorDynPoint *MoorDynPoint
A mooring point instance.
-
typedef struct __MoorDynRod *MoorDynRod
A mooring line instance.
-
typedef struct __MoorDynSeafloor *MoorDynSeafloor
A seafloor descriptor.
-
typedef struct __MoorDynWaves *MoorDynWaves
A mooring point instance.
Functions
-
int DECLDIR MoorDyn_GetBodyID(MoorDynBody b, int *id)
Get the body identifier.
- Parameters:
b – The Moordyn body
id – The output id
- Returns:
MOORDYN_INVALID_VALUE if a NULL point is provided, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_GetBodyType(MoorDynBody b, int *t)
Get the point type.
See also
Point::types
- Parameters:
b – The Moordyn body
t – The output type
- Returns:
MOORDYN_INVALID_VALUE if a NULL point is provided, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_GetBodyState(MoorDynBody b, double r[6], double rd[6])
Get the body state.
- Parameters:
b – The Moordyn body
r – The output position (6dof)
rd – The output velocity (6dof)
- Returns:
MOORDYN_INVALID_VALUE if a NULL body is provided, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_GetBodyPos(MoorDynBody b, double r[3])
Get the body position.
- Parameters:
b – The Moordyn body
r – The output position (3dof)
- Returns:
MOORDYN_INVALID_VALUE if a NULL body is provided, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_GetBodyAngle(MoorDynBody b, double r[3])
Get the body angle.
- Parameters:
b – The Moordyn body
r – The output angles (3dof)
- Returns:
MOORDYN_INVALID_VALUE if a NULL body is provided, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_GetBodyVel(MoorDynBody b, double rd[3])
Get the body velocity.
- Parameters:
b – The Moordyn body
rd – The output velocity (3dof)
- Returns:
MOORDYN_INVALID_VALUE if a NULL body is provided, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_GetBodyAngVel(MoorDynBody b, double rd[3])
Get the body angular velocity.
- Parameters:
b – The Moordyn body
rd – The output angular velocity (3dof)
- Returns:
MOORDYN_INVALID_VALUE if a NULL body is provided, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_GetBodyForce(MoorDynBody b, double f[6])
Get the body angular velocity.
- Parameters:
b – The Moordyn body
rd – The output angular velocity (3dof)
- Returns:
MOORDYN_INVALID_VALUE if a NULL body is provided, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_GetBodyM(MoorDynBody b, double m[6][6])
Get the body mass and intertia matrix.
- Parameters:
b – The Moordyn body
m – The output mass matrix
- Returns:
MOORDYN_INVALID_VALUE if a NULL body is provided, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_SaveBodyVTK(MoorDynBody b, const char *filename)
Save the point to a VTK (.vtp) file.
Note
If MoorDyn has been built without VTK support, this function will return a MOORDYN_NON_IMPLEMENTED error, but it will be still available anyway
- Parameters:
b – The Moordyn body
filename – The output maximum tension module
- Returns:
MOORDYN_SUCCESS if the file is correctly written, an error code otherwise
-
int DECLDIR MoorDyn_UseBodyVTK(MoorDynBody b, const char *filename)
Load the model that would represent the body.
The model can have one of the following formats:
VTK PolyData (.vtp)
Stereo Lithography (.stl)
Note
If MoorDyn has been built without VTK support, this function will return a MOORDYN_NON_IMPLEMENTED error, but it will be still available anyway
- Parameters:
b – The Moordyn body
filename – The output maximum tension module
- Returns:
MOORDYN_SUCCESS if the file is correctly written, an error code otherwise
-
int DECLDIR MoorDyn_GetLineID(MoorDynLine l, int *id)
Get the line identifier.
- Parameters:
l – The Moordyn line
id – The output id
- Returns:
MOORDYN_INVALID_VALUE if a NULL point is provided, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_GetLineN(MoorDynLine l, unsigned int *n)
Get the line number of segments.
The number of nodes is equal to this value plus 1
- Parameters:
l – The Moordyn line
n – The output number of nodes
- Returns:
MOORDYN_INVALID_VALUE if a NULL line is provided, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_GetLineNumberNodes(MoorDynLine l, unsigned int *n)
Get the line number of nodes.
See also
- Parameters:
l – The Moordyn line
n – The output number of nodes
- Returns:
MOORDYN_INVALID_VALUE if a NULL line is provided, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_GetLineUnstretchedLength(MoorDynLine l, double *ul)
Get the line unstretched length.
See also
- Parameters:
l – The Moordyn line
ul – The output length
- Returns:
MOORDYN_INVALID_VALUE if a NULL line is provided, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_SetLineUnstretchedLength(MoorDynLine l, double ul)
Set the line unstretched length.
See also
- Parameters:
l – The Moordyn line
ul – The new length
- Returns:
MOORDYN_INVALID_VALUE if a NULL line is provided, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_SetLineUnstretchedLengthVel(MoorDynLine l, double v)
Set the line unstretched length rate of change.
See also
See also
- Parameters:
l – The Moordyn line
v – The rate of change
- Returns:
MOORDYN_INVALID_VALUE if a NULL line is provided, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_IsLineConstantEA(MoorDynLine l, int *b)
Get whether the line is governed by a non-linear stiffness or a constant one.
See also
See also
- Parameters:
l – The Moordyn line
b – 1 if the stiffness of the line is constant, 0 if a non-linear stiffness has been set
- Returns:
MOORDYN_INVALID_VALUE if a NULL line is provided, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_GetLineConstantEA(MoorDynLine l, double *EA)
Get the constant stiffness of the line.
This value is useless if non-linear stiffness is considered
See also
See also
- Parameters:
l – The Moordyn line
EA – The constant stiffness EA value
- Returns:
MOORDYN_INVALID_VALUE if a NULL line is provided, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_SetLineConstantEA(MoorDynLine l, double EA)
Set the constant stiffness of the line.
This value is useless if non-linear stiffness is considered
See also
See also
- Parameters:
l – The Moordyn line
EA – The constant stiffness EA value
- Returns:
MOORDYN_INVALID_VALUE if a NULL line is provided, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_GetLineNodePos(MoorDynLine l, unsigned int i, double pos[3])
Get a line node position.
- Parameters:
l – The Moordyn line
i – The node index
pos – The output node position
- Returns:
MOORDYN_INVALID_VALUE if a NULL line is provided or if the node index is bigger than the number of segments, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_GetLineNodeVel(MoorDynLine l, unsigned int i, double vel[3])
Get a line node velocity.
- Parameters:
l – The Moordyn line
i – The node index
vel – The output node velocity
- Returns:
MOORDYN_INVALID_VALUE if a NULL line is provided or if the node index is bigger than the number of segments, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_GetLineNodeForce(MoorDynLine l, unsigned int i, double f[3])
Get a line node force.
To get the components of the force use MoorDyn_GetLineNodeTen() , MoorDyn_GetLineNodeBendStiff(), MoorDyn_GetLineNodeWeight() , MoorDyn_GetLineNodeDrag() , MoorDyn_GetLineNodeFroudeKrilov() and MoorDyn_GetLineNodeSeaBedForce()
Note
The net force is not the sum of all the components that you cat extract from the API. For instance, the tension contribution on the internal nodes is the difference between the tensions of the adjacent segments, while MoorDyn_GetLineNodeTen() is returning the averaged value.
- Parameters:
l – The Moordyn line
i – The node index
f – The output node net force
- Returns:
MOORDYN_INVALID_VALUE if a NULL line is provided or if the node index is bigger than the number of segments, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_GetLineNodeTen(MoorDynLine l, unsigned int i, double t[3])
Get a line node tension.
The node tension is the sum of the axial stiffness plus the internal damping
\[ \bar{T}(i) = E A \left( \frac{l(i) - l_0}{l_0} - \frac{\beta A}{l_0} \frac{\mathrm{d}l(i)}{\mathrm{d}t} \right) \bar{q}(i) \]with \(l(i)\) and \(l_0\) the stretched and unstretched segment lengths respectively, \(E\) the Young’s modulus, \(A\) the transversal area, \(\beta\) the internal damping coefficient and \(\bar{q}(i)\) the direction verctor of the segment.
As can be appreciated, the node tension is computed at each segment. So to get the node one the surrounding segments are averaged (in case of line-ends the associated ending segment tension is returned)
- Parameters:
l – The Moordyn line
i – The node index
t – The output node tension
- Returns:
MOORDYN_INVALID_VALUE if a NULL line is provided or if the node index is bigger than the number of segments, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_GetLineNodeBendStiff(MoorDynLine l, unsigned int i, double t[3])
Get a line node bending stiffness force.
The bending stiffness is computed at each segment as
\[ \bar{Bs}(i) = E I \frac{\bar{k}(i)}{l_0} \]with \(l_0\) the unstretched segment length, \(E\) the Young’s modulus, \(I\) the segment normal axis inertia, and \(\bar{k}\) the curvature vector.
To get the node bending stiffness forces the surrounding segments forces are accumulated
- Parameters:
l – The Moordyn line
i – The node index
t – The output node force
- Returns:
MOORDYN_INVALID_VALUE if a NULL line is provided or if the node index is bigger than the number of segments, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_GetLineNodeWeight(MoorDynLine l, unsigned int i, double f[3])
Get a line node weight and bouyancy.
This is computed at each segment as
\[ \bar{W}(i) = A l_0 \left(\rho - F(i) \rho_w \right) \bar{g} \]with \(l_0\) the unstretched segment length, \(A\) the transversal area, \(\rho\) the line material density, \(\rho_w\) the water density, \(F(i)\) the portion of the segment submerged and \(\bar{g}\) the gravity acceleration.
The weight and bounyancy force at any internal node is computed as the average of the surrounding segments, while on the line-ends half of the associated ending segment weight force is returned.
- Parameters:
l – The Moordyn line
i – The node index
f – The output node force
- Returns:
MOORDYN_INVALID_VALUE if a NULL line is provided or if the node index is bigger than the number of segments, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_GetLineNodeDrag(MoorDynLine l, unsigned int i, double f[3])
Get a line node drag force.
This is computed at each segment as
\[ \bar{D}(i) = \frac{1}{2} l_0 F(i) \rho_w \left( Cd_t \pi d \vert \bar{v}_t(i) \vert \bar{v}_t(i) + Cd_n d \vert \bar{v}_n(i) \vert \bar{v}_n(i) \right) \]with \(l_0\) the unstretched segment length, \(F(i)\) the portion of the segment submerged, \(\rho_w\) the water density, \(d\) the line diameter, \(Cd_t\) and \(Cd_n\) the normal and tangential drag coefficients, and \(\bar{v}_t\) and \(\bar{v}_n\) the tangential and normal velocities:
\[ \bar{v}_t = (\bar{v} - \bar{U}) \cdot \bar{q} \]\[ \bar{v}_n = (\bar{v} - \bar{U}) - \bar{v}_t \]with \(\bar{v}\) the velocity, \(\bar{U}\) the flow velocity and \(\bar{q}\) the direction verctor of the segment
The drag at any internal node is computed as the average of the surrounding segments, while on the line-ends half of the associated ending segment drag force is returned.
- Parameters:
l – The Moordyn line
i – The node index
f – The output node force
- Returns:
MOORDYN_INVALID_VALUE if a NULL line is provided or if the node index is bigger than the number of segments, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_GetLineNodeFroudeKrilov(MoorDynLine l, unsigned int i, double f[3])
Get a line node Froude Krilov force.
This is computed at each segment as
\[ \bar{Fk}(i) = V(i) F(i) \rho_w \left( (1 + Ca_t) \frac{\mathrm{d} \bar{v}_t}{\mathrm{d} t} + (1 + Ca_n) \frac{\mathrm{d} \bar{v}_n}{\mathrm{d} t} \right) \]with \(V(i)\) the segment volume, \(F(i)\) the portion of the segment submerged, \(\rho_w\) the water density, \(Cd_t\) and \(Cd_n\) the normal and tangential drag coefficients, and \(\frac{\mathrm{d} \bar{v}_t}{\mathrm{d} t}\) and \(\frac{\mathrm{d} \bar{v}_n}{\mathrm{d} t}\) the tangential and normal accelerations:
\[ \frac{\mathrm{d} \bar{v}_t}{\mathrm{d} t} = \frac{\mathrm{d} \bar{v}}{\mathrm{d} t} \cdot \bar{q}(i) \]\[ \frac{\mathrm{d} \bar{v}_n}{\mathrm{d} t} = \frac{\mathrm{d} \bar{v}}{\mathrm{d} t} - \frac{\mathrm{d} \bar{v}_t}{\mathrm{d} t} \]with \(\bar{q}(i)\) the direction verctor of the segment
The force at any internal node is computed as the average of the surrounding segments, while on the line-ends half of the associated ending segment Froude-Krylov force is returned.
- Parameters:
l – The Moordyn line
i – The node index
f – The output node force
- Returns:
MOORDYN_INVALID_VALUE if a NULL line is provided or if the node index is bigger than the number of segments, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_GetLineNodeSeabedForce(MoorDynLine l, unsigned int i, double f[3])
Get a line node seabed reaction.
This is computed at each segment as
\[ \bar{B}(i) = l_0 d \left( Kb (\bar{r}_b - \bar{r}(i)) \cdot \bar{k} Cb \bar{v} \cdot \bar{k} + \right) \bar{k} \]with \(l_0\) the unstretched segment length, \(d\) the line diameter \(Kb\) and \(Cb\) the bottom stiff and drag coefficients, \(\bar{r}_b\) the seabed position, \(\bar{r}\) the position, \(\bar{v}\) the velocity and \(\bar{k}\) the upward direction vector.
If bottom friction is configured, the force is added to this magnitude as well.
The reaction force at any internal node is computed as the average of the surrounding segments, while on the line-ends half of the associated ending segment weight force is returned.
- Parameters:
l – The Moordyn line
i – The node index
f – The output node force
- Returns:
MOORDYN_INVALID_VALUE if a NULL line is provided or if the node index is bigger than the number of segments, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_GetLineNodeCurv(MoorDynLine l, unsigned int i, double *c)
Get a line curvature at a node.
Note
The curvature is only computed if bending stiffness (moordyn::Line::EI) is not zero. Otherwise the curvature of every single node will be zero.
- Parameters:
l – The Moordyn line
i – The node index
c – The output line curvature
- Returns:
MOORDYN_INVALID_VALUE if a NULL line is provided or if the node index is bigger than the number of segments, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_GetLineNodeM(MoorDynLine l, unsigned int i, double m[3][3])
Get a line node mass matrix.
The mass matrix includes the node mass as well as the added mass
- Parameters:
l – The Moordyn line
i – The node index
m – The output mass matrix
- Returns:
MOORDYN_INVALID_VALUE if a NULL line is provided or if the node index is bigger than the number of segments, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_GetLineFairTen(MoorDynLine l, double *t)
Get the tension module at the end point B (the fairlead)
- Parameters:
l – The Moordyn line
t – The output node tension module
- Returns:
MOORDYN_INVALID_VALUE if a NULL line is provided, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_GetLineMaxTen(MoorDynLine l, double *t)
Get the maximum tension module.
- Parameters:
l – The Moordyn line
t – The output maximum tension module
- Returns:
MOORDYN_INVALID_VALUE if a NULL line is provided, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_SaveLineVTK(MoorDynLine l, const char *filename)
Save the line to a VTK (.vtp) file.
Note
If MoorDyn has been built without VTK support, this function will return a MOORDYN_NON_IMPLEMENTED error, but it will be still available anyway
- Parameters:
l – The Moordyn line
filename – The output maximum tension module
- Returns:
MOORDYN_SUCCESS if the file is correctly written, an error code otherwise
-
MoorDyn DECLDIR MoorDyn_Create(const char *infilename)
Creates a MoorDyn instance.
At the time of creating a new MoorDyn instance, the input file is read and all the objects and structures are created. You must call afterwards MoorDyn_Init() to compute the initial conditions
- Parameters:
infilename – The input file, if either NULL or “”, then “Mooring/lines.txt” will be considered
- Returns:
The mooring instance, NULL if errors happened
-
int DECLDIR MoorDyn_NCoupledDOF(MoorDyn system, unsigned int *n)
Get the number of coupled Degrees Of Freedom (DOFs)
The number of components for some parameters in MoorDyn_Init() and MoorDyn_Step() can be known using this function
- Returns:
MOORDYN_INVALID_VALUE if
system
is NULL, MOORDYN_SUCESS otherwise
-
int DECLDIR MoorDyn_SetVerbosity(MoorDyn system, int verbosity)
Set the instance verbosity level.
- Parameters:
system – The Moordyn system
verbosity – The verbosity level. It can take the following values
MOORDYN_DBG_LEVEL Every single message will be printed
MOORDYN_MSG_LEVEL Messages specially designed to help debugging the code will be omitted
MOORDYN_WRN_LEVEL Just errors and warnings will be reported
MOORDYN_ERR_LEVEL Just errors will be reported
MOORDYN_NO_OUTPUT No info will be reported
- Returns:
MOORDYN_SUCESS If the verbosity level is correctly set, an error code otherwise (see Errors reported by MoorDyn)
-
int DECLDIR MoorDyn_SetLogFile(MoorDyn system, const char *log_path)
Set the instance log file.
- Parameters:
system – The Moordyn system
log_path – The file path to print the log file
- Returns:
MOORDYN_SUCESS If the log file is correctly set, an error code otherwise (see Errors reported by MoorDyn)
-
int DECLDIR MoorDyn_SetLogLevel(MoorDyn system, int verbosity)
Set the instance log file printing level.
- Parameters:
system – The Moordyn system
verbosity – The log file print level. It can take the following values
MOORDYN_DBG_LEVEL Every single message will be printed
MOORDYN_MSG_LEVEL Messages specially designed to help debugging the code will be omitted
MOORDYN_WRN_LEVEL Just errors and warnings will be reported
MOORDYN_ERR_LEVEL Just errors will be reported
MOORDYN_NO_OUTPUT No info will be reported
- Returns:
MOORDYN_SUCESS If the printing level is correctly set, an error code otherwise (see Errors reported by MoorDyn)
-
int DECLDIR MoorDyn_Log(MoorDyn system, int level, const char *msg)
Log a message.
Note
This messages are subjected to the same rules than the inner messages, i.e. if
level
is lower than the threshold levels set with MoorDyn_SetVerbosity() and MoorDyn_SetLogLevel(), the message will not be logged in the terminal and the log file respectivelyNote
This function will not log the file, line and function where it is called from, not even in case of warnings or errors
- Parameters:
system – The Moordyn system
level – The message level. It can take the following values
MOORDYN_DBG_LEVEL for debugging messages
MOORDYN_MSG_LEVEL for regular information messages
MOORDYN_WRN_LEVEL for warnings
MOORDYN_ERR_LEVEL for errors
msg – The message to log
- Returns:
MOORDYN_SUCESS If the printing level is correctly set, an error code otherwise (see Errors reported by MoorDyn)
-
int DECLDIR MoorDyn_Init(MoorDyn system, const double *x, const double *xd)
Compute the initial condition of a MoorDyn system.
At the time of creating a new MoorDyn instance, the input file is read and all the objects and structures are created. You must call afterwards MoorDyn_Init() to compute the initial conditions
Note
MoorDyn_NCoupledDOF() can be used to know the number of components required for
x
andxd
- Parameters:
system – The Moordyn system
x – Position vector (6 components per coupled body or cantilevered rod and 3 components per pinned rod or coupled point)
xd – Velocity vector (6 components per coupled body or cantilevered rod and 3 components per pinned rod or coupled point)
- Returns:
MOORDYN_SUCESS If the mooring system is correctly initialized, an error code otherwise (see Errors reported by MoorDyn)
-
int DECLDIR MoorDyn_Init_NoIC(MoorDyn system, const double *x, const double *xd)
The same than MoorDyn_Init(), but the initial condition is not computed at all.
This is of use when you are loading a state file afterwards with Moordyn_Load()
Note
MoorDyn_NCoupledDOF() can be used to know the number of components required for
x
andxd
- Parameters:
system – The Moordyn system
x – Position vector (6 components per coupled body or cantilevered rod and 3 components per pinned rod or coupled point)
xd – Velocity vector (6 components per coupled body or cantilevered rod and 3 components per pinned rod or coupled point)
- Returns:
MOORDYN_SUCESS If the mooring system is correctly initialized, an error code otherwise (see Errors reported by MoorDyn)
-
int DECLDIR MoorDyn_Step(MoorDyn system, const double *x, const double *xd, double *f, double *t, double *dt)
Runs a time step of the MoorDyn system.
Note
MoorDyn_NCoupledDOF() can be used to know the number of components required for
x
,xd
andf
- Parameters:
system – The Moordyn system
x – Position vector
xd – Velocity vector
f – Output forces
t – Simulation time
dt – Time step
- Returns:
MOORDYN_SUCESS if the mooring system has correctly evolved, an error code otherwise (see Errors reported by MoorDyn)
-
int DECLDIR MoorDyn_Close(MoorDyn system)
Releases MoorDyn allocated resources.
- Parameters:
system – The Moordyn system
- Returns:
MOORDYN_SUCESS If the mooring system is correctly destroyed, an error code otherwise (see Errors reported by MoorDyn)
-
MoorDynWaves DECLDIR MoorDyn_GetWaves(MoorDyn system)
Get the wave kinematics instance.
The wave kinematics instance is only useful if WaveKin option is set to 2 in the input file.
- Parameters:
system – The Moordyn system
- Returns:
The waves instance, NULL if errors happened
-
MoorDynSeafloor DECLDIR MoorDyn_GetSeafloor(MoorDyn system)
Get the 3D seafloor instance.
The seafloor instance is only not null if a SeafloorPath was given as an option.
- Parameters:
system – The Moordyn system
- Returns:
The Seafloor instance, NULL if errors happened or there is no 3D seafloor
-
int DECLDIR MoorDyn_GetNumberBodies(MoorDyn system, unsigned int *n)
Get the number of bodies.
Remember that the first body index is 1
- Parameters:
system – The Moordyn system
n – The output number of bodies
- Returns:
MOORDYN_SUCESS If the number is successfully got, an error code otherwise (see Errors reported by MoorDyn)
-
MoorDynBody DECLDIR MoorDyn_GetBody(MoorDyn system, unsigned int b)
Get a rigid body.
Remember that the first body index is 1
- Parameters:
system – The Moordyn system
b – The body index
- Returns:
The body instance, NULL if errors happened
-
int DECLDIR MoorDyn_GetNumberRods(MoorDyn system, unsigned int *n)
Get the number of rods.
Remember that the first rod index is 1
- Parameters:
system – The Moordyn system
n – The output number of rods
- Returns:
MOORDYN_SUCESS If the number is successfully got, an error code otherwise (see Errors reported by MoorDyn)
-
MoorDynRod DECLDIR MoorDyn_GetRod(MoorDyn system, unsigned int r)
Get a rod.
- Parameters:
system – The Moordyn system
r – The rod
- Returns:
The rod instance, NULL if errors happened
-
int DECLDIR MoorDyn_GetNumberPoints(MoorDyn system, unsigned int *n)
Get the number of points.
Remember that the first point index is 1
- Parameters:
system – The Moordyn system
n – The output number of points
- Returns:
MOORDYN_SUCESS If the number is successfully got, an error code otherwise (see Errors reported by MoorDyn)
-
MoorDynPoint DECLDIR MoorDyn_GetPoint(MoorDyn system, unsigned int c)
Get a point.
- Parameters:
system – The Moordyn system
c – The point
- Returns:
The point instance, NULL if errors happened
-
int DECLDIR MoorDyn_GetNumberLines(MoorDyn system, unsigned int *n)
Get the number of lines.
Remember that the first line index is 1
- Parameters:
system – The Moordyn system
n – The output number of lines
- Returns:
MOORDYN_SUCESS If the number is successfully got, an error code otherwise (see Errors reported by MoorDyn)
-
MoorDynLine DECLDIR MoorDyn_GetLine(MoorDyn system, unsigned int l)
Get a line instance.
- Parameters:
system – The Moordyn system
l – The line identifier (from 1 to the number of lines)
- Returns:
The line instance, NULL if errors happened
-
int DECLDIR MoorDyn_GetFASTtens(MoorDyn system, const int *numLines, float FairHTen[], float FairVTen[], float AnchHTen[], float AnchVTen[])
Function for providing FASTv7 customary line tension quantities.
- Parameters:
system – The Moordyn system
numLines – The number of lines
FairHTen – Allocated memory for the
numLines
horizontal forces at the fairleadFairVTen – Allocated memory for the
numLines
vertical forces at the fairleadAnchHTen – Allocated memory for the
numLines
horizontal forces at the anchorAnchVTen – Allocated memory for the
numLines
vertical forces at the anchor
- Returns:
MOORDYN_SUCESS If the data is correctly set, an error code otherwise (see Errors reported by MoorDyn)
-
int DECLDIR MoorDyn_Serialize(MoorDyn system, size_t *size, uint64_t *data)
Serialize the system to bytes.
Typically you want to call this function twice. A first call to know the amount of memory to be allocated for the bytes array and a second one to actually get the bytes array
The returned bytes can be used afterwards to restore the model calling to MoorDyn_Deserialize()
- Parameters:
system – The Moordyn system
size – Output size of the bytes array. It can be null
data – Allocated memory for the output bytes array. It can be null
- Returns:
MOORDYN_SUCESS If the data is correctly set, an error code otherwise (see Errors reported by MoorDyn)
-
int DECLDIR MoorDyn_Deserialize(MoorDyn system, const uint64_t *data)
Load the system from the serialized data before.
You can restore the system to a previous state retrieved calling MoorDyn_Serialize()
See also
See also
- Parameters:
system – The Moordyn system
data – Bytes array
- Returns:
MOORDYN_SUCESS If the data is correctly set, an error code otherwise (see Errors reported by MoorDyn)
-
int DECLDIR MoorDyn_Save(MoorDyn system, const char *filepath)
Save the system so it can be loaded afterwards.
At the time of loading the system, it is still required to create the system reading the same definition file and calling MoorDyn_Init_NoIC()
See also
See also
- Parameters:
system – The Moordyn system
filepath – The path of the file to write
- Returns:
MOORDYN_SUCESS If the data is correctly set, an error code otherwise (see Errors reported by MoorDyn)
-
int DECLDIR MoorDyn_Load(MoorDyn system, const char *filepath)
Load the system saved before.
You must still call MoorDyn_Create() and MoorDyn_Init_NoIC() before calling this function
See also
See also
- Parameters:
system – The Moordyn system
filepath – The path of the MoorDyn saved system
- Returns:
MOORDYN_SUCESS If the data is correctly set, an error code otherwise (see Errors reported by MoorDyn)
-
int DECLDIR MoorDyn_DrawWithGL(MoorDyn system)
Draw the lines and points in the active OpenGL context.
The OpenGL context is assumed to be created by the caller before calling this function
- Parameters:
system – The Moordyn system
- Returns:
MOORDYN_SUCESS If the data is correctly set, an error code otherwise (see Errors reported by MoorDyn)
-
int DECLDIR MoorDyn_SaveVTK(MoorDyn system, const char *filename)
Save the whole system to a VTK (.vtm) file.
In general it is more convenient to handle each object independently, using MoorDyn_SaveLineVTK() and MoorDyn_SaveRodVTK() functions. However, if the number of subinstances is large, that would not be an option anymore. In that case you can use this function to pack everything together in a single file
Note
If MoorDyn has been built without VTK support, this function will return a MOORDYN_NON_IMPLEMENTED error, but it will be still available anyway
- Parameters:
system – The Moordyn system
filename – The output maximum tension module
- Returns:
MOORDYN_SUCCESS if the file is correctly written, an error code otherwise
-
int DECLDIR MoorDyn_GetPointID(MoorDynPoint point, int *id)
Get the point identifier.
- Parameters:
point – The Moordyn point
id – The output id
- Returns:
MOORDYN_INVALID_VALUE if a NULL point is provided, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_GetPointType(MoorDynPoint point, int *t)
Get the point type.
See also
Point::types
- Parameters:
point – The Moordyn point
t – The output type
- Returns:
MOORDYN_INVALID_VALUE if a NULL point is provided, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_GetPointPos(MoorDynPoint point, double pos[3])
Get the position of a point.
- Parameters:
point – The Moordyn point
pos – The output position
- Returns:
MOORDYN_SUCCESS If the data is correctly set, an error code otherwise (see Errors reported by MoorDyn)
-
int DECLDIR MoorDyn_GetPointVel(MoorDynPoint point, double v[3])
Get the velocity of a point.
- Parameters:
point – The Moordyn point
v – The output velocity
- Returns:
MOORDYN_SUCCESS If the data is correctly set, an error code otherwise (see Errors reported by MoorDyn)
-
int DECLDIR MoorDyn_GetPointForce(MoorDynPoint point, double f[3])
Get the force at a point.
- Parameters:
point – The Moordyn point
f – The output force
- Returns:
MOORDYN_SUCCESS If the data is correctly set, an error code otherwise (see Errors reported by MoorDyn)
-
int DECLDIR MoorDyn_GetPointM(MoorDynPoint point, double m[3][3])
Get the point mass matrix.
- Parameters:
point – The Moordyn point
f – The output force
- Returns:
MOORDYN_SUCCESS If the data is correctly set, an error code otherwise (see Errors reported by MoorDyn)
-
int DECLDIR MoorDyn_GetPointNAttached(MoorDynPoint point, unsigned int *n)
Get the number of connected lines.
- Parameters:
point – The Moordyn point
n – The output number of connected lines
- Returns:
MOORDYN_SUCCESS If the data is correctly set, an error code otherwise (see Errors reported by MoorDyn)
-
int DECLDIR MoorDyn_GetPointAttached(MoorDynPoint point, unsigned int i, MoorDynLine *l, int *e)
Get the number of connected lines.
- Parameters:
point – The Moordyn point
i – The index of the attached line
l – The output attached line
e – The output endpoint, see moordyn::EndPoints
- Returns:
MOORDYN_SUCCESS If the data is correctly set, an error code otherwise (see Errors reported by MoorDyn)
-
int DECLDIR MoorDyn_SavePointVTK(MoorDynPoint point, const char *filename)
Save the point to a VTK (.vtp) file.
Note
If MoorDyn has been built without VTK support, this function will return a MOORDYN_NON_IMPLEMENTED error, but it will be still available anyway
- Parameters:
point – The Moordyn point
filename – The output maximum tension module
- Returns:
MOORDYN_SUCCESS if the file is correctly written, an error code otherwise
-
int DECLDIR MoorDyn_GetRodID(MoorDynRod l, int *id)
Get the line identifier.
- Parameters:
l – The Moordyn rod
id – The output id
- Returns:
MOORDYN_INVALID_VALUE if a NULL point is provided, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_GetRodType(MoorDynRod l, int *t)
Get the line type.
- Parameters:
l – The Moordyn rod
t – The output type
- Returns:
MOORDYN_INVALID_VALUE if a NULL point is provided, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_GetRodForce(MoorDynRod l, double f[6])
Get the net force acting on the rod, as well as the moment at end point A if the node is not pinned.
- Parameters:
l – The Moordyn rod
f – The output force
- Returns:
MOORDYN_INVALID_VALUE if a NULL point is provided, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_GetRodM(MoorDynRod l, double m[6][6])
Get the total rod mass matrix.
- Parameters:
l – The Moordyn rod
m – The output mass matrix
- Returns:
MOORDYN_INVALID_VALUE if a NULL point is provided, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_GetRodN(MoorDynRod l, unsigned int *n)
Get the line number of segments.
The number of nodes is equal to this value plus 1
- Parameters:
l – The Moordyn rod
n – The output number of nodes
- Returns:
MOORDYN_INVALID_VALUE if a NULL line is provided, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_GetRodNumberNodes(MoorDynRod l, unsigned int *n)
Get the line number of nodes.
See also
- Parameters:
l – The Moordyn rod
n – The output number of nodes
- Returns:
MOORDYN_INVALID_VALUE if a NULL line is provided, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_GetRodNodePos(MoorDynRod l, unsigned int i, double pos[3])
Get a rod node position.
- Parameters:
l – The Moordyn rod
i – The node index
pos – The output node position
- Returns:
MOORDYN_INVALID_VALUE if a NULL line is provided or if the node index is bigger than the number of segments, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_GetRodNodeVel(MoorDynRod l, unsigned int i, double vel[3])
Get a rod node velocity.
- Parameters:
l – The Moordyn rod
i – The node index
vel – The output node velocity
- Returns:
MOORDYN_INVALID_VALUE if a NULL line is provided or if the node index is bigger than the number of segments, MOORDYN_SUCCESS otherwise
-
int DECLDIR MoorDyn_SaveRodVTK(MoorDynRod l, const char *filename)
Save the line to a VTK (.vtp) file.
Note
If MoorDyn has been built without VTK support, this function will return a MOORDYN_NON_IMPLEMENTED error, but it will be still available anyway
- Parameters:
l – The Moordyn rod
filename – The output maximum tension module
- Returns:
MOORDYN_SUCCESS if the file is correctly written, an error code otherwise
-
int DECLDIR MoorDyn_GetWavesKin(MoorDynWaves waves, double x, double y, double z, double U[3], double Ud[3], double *zeta, double *PDyn, MoorDynSeafloor seafloor)
Get the velocity, acceleration, wave height and dynamic pressure at a specific positon and time.
- Parameters:
waves – The Waves instance
x – The point x coordinate
y – The point y coordinate
z – The point z coordinate
U – The output velocity
Ud – The output acceleration
zeta – The output wave height
PDyn – The output dynamic pressure
seafloor – The seafloor instance, see MoorDyn_GetSeafloor()
- Returns:
0 If the data is correctly set, an error code otherwise (see Errors reported by MoorDyn)
-
double DECLDIR WaveNumber(double Omega, double g, double h)
Compute the wave number.
Note
credit: FAST source
- Parameters:
Omega – The wave angular frequency
g – The gravity acceleration
h – The water depth
- Returns:
The wave number
-
int DECLDIR MoorDyn_ExternalWaveKinInit(MoorDyn system, unsigned int *n)