MoorDyn
MoorDyn2.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022, Matt Hall
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  * 1. Redistributions of source code must retain the above copyright notice,
8  * this list of conditions and the following disclaimer.
9  *
10  * 2. Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  *
14  * 3. Neither the name of the copyright holder nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28  * POSSIBILITY OF SUCH DAMAGE.
29  */
30 
35 #ifndef __MOORDYN2_H__
36 #define __MOORDYN2_H__
37 
38 #include "MoorDynAPI.h"
39 #include "Waves.h"
40 #include "Seafloor.h"
41 #include "Point.h"
42 #include "Rod.h"
43 #include "Line.h"
44 #include "Body.h"
45 #include <stdlib.h>
46 #include <stdint.h>
47 
48 #ifdef __cplusplus
49 extern "C"
50 {
51 #endif
52 
53 #ifdef WIN32
54 #include <windows.h>
55 #endif
56 
62 typedef struct __MoorDyn* MoorDyn;
63 
75 MoorDyn_Create(const char* infilename);
76 
84 int DECLDIR
85 MoorDyn_NCoupledDOF(MoorDyn system, unsigned int* n);
86 
99 int DECLDIR
100 MoorDyn_SetVerbosity(MoorDyn system, int verbosity);
101 
108 int DECLDIR
109 MoorDyn_SetLogFile(MoorDyn system, const char* log_path);
110 
124 int DECLDIR
125 MoorDyn_SetLogLevel(MoorDyn system, int verbosity);
126 
144 int DECLDIR
145 MoorDyn_Log(MoorDyn system, int level, const char* msg);
146 
163 int DECLDIR
164 MoorDyn_Init(MoorDyn system, const double* x, const double* xd);
165 
182 int DECLDIR
183 MoorDyn_Init_NoIC(MoorDyn system, const double* x, const double* xd);
184 
197 int DECLDIR
198 MoorDyn_Step(MoorDyn system,
199  const double* x,
200  const double* xd,
201  double* f,
202  double* t,
203  double* dt);
204 
210 int DECLDIR
211 MoorDyn_Close(MoorDyn system);
212 
221 MoorDyn_GetWaves(MoorDyn system);
222 
233 
239 
249 int DECLDIR
250 MoorDyn_ExternalWaveKinInit(MoorDyn system, unsigned int* n);
251 
262 int DECLDIR
263 MoorDyn_ExternalWaveKinGetN(MoorDyn system, unsigned int* n);
264 
277 int DECLDIR
279 
292 inline int DECLDIR DEPRECATED
294 {
295  return MoorDyn_ExternalWaveKinGetCoordinates(system, r);
296 }
297 
310 int DECLDIR
312  const double* U,
313  const double* Ud,
314  double t);
315 
330 inline int DECLDIR DEPRECATED
331 MoorDyn_SetWaveKin(MoorDyn system, const double* U, const double* Ud, double t)
332 {
333  return MoorDyn_ExternalWaveKinSet(system, U, Ud, t);
334 }
335 
337 
346 int DECLDIR
347 MoorDyn_GetNumberBodies(MoorDyn system, unsigned int* n);
348 
357 MoorDyn_GetBody(MoorDyn system, unsigned int b);
358 
367 int DECLDIR
368 MoorDyn_GetNumberRods(MoorDyn system, unsigned int* n);
369 
376 MoorDyn_GetRod(MoorDyn system, unsigned int r);
377 
386 int DECLDIR
387 MoorDyn_GetNumberPoints(MoorDyn system, unsigned int* n);
388 
395 MoorDyn_GetPoint(MoorDyn system, unsigned int c);
396 
405 int DECLDIR
406 MoorDyn_GetNumberLines(MoorDyn system, unsigned int* n);
407 
414 MoorDyn_GetLine(MoorDyn system, unsigned int l);
415 
430 int DECLDIR
432  const int* numLines,
433  float FairHTen[],
434  float FairVTen[],
435  float AnchHTen[],
436  float AnchVTen[]);
437 
444 int DECLDIR
445 MoorDyn_GetDt(MoorDyn system, double* dt);
446 
453 int DECLDIR
454 MoorDyn_SetDt(MoorDyn system, double dt);
455 
462 int DECLDIR
463 MoorDyn_GetCFL(MoorDyn system, double* cfl);
464 
471 int DECLDIR
472 MoorDyn_SetCFL(MoorDyn system, double cfl);
473 
481 int DECLDIR
482 MoorDyn_GetTimeScheme(MoorDyn system, char* name, size_t* name_len);
483 
490 int DECLDIR
491 MoorDyn_SetTimeScheme(MoorDyn system, const char* name);
492 
504 int DECLDIR
505 MoorDyn_SaveState(MoorDyn system, const char* filepath);
506 
518 int DECLDIR
519 MoorDyn_LoadState(MoorDyn system, const char* filepath);
520 
535 int DECLDIR
536 MoorDyn_Serialize(MoorDyn system, size_t* size, uint64_t* data);
537 
549 int DECLDIR
550 MoorDyn_Deserialize(MoorDyn system, const uint64_t* data);
551 
563 int DECLDIR
564 MoorDyn_Save(MoorDyn system, const char* filepath);
565 
577 int DECLDIR
578 MoorDyn_Load(MoorDyn system, const char* filepath);
579 
595 int DECLDIR
596 MoorDyn_SaveVTK(MoorDyn system, const char* filename);
597 
602 #ifdef __cplusplus
603 }
604 #endif
605 
606 #endif
#define DECLDIR
Prefix to export C functions on the compiled library.
Definition: MoorDynAPI.h:68
#define DEPRECATED
Prefix for deprecated functions that will be removed on a future version.
Definition: MoorDynAPI.h:85
struct __MoorDynSeafloor * MoorDynSeafloor
A 3D Seafloor instance.
Definition: Seafloor.h:14
int DECLDIR MoorDyn_SetLogFile(MoorDyn system, const char *log_path)
Set the instance log file.
Definition: MoorDyn2.cpp:2878
int DECLDIR DEPRECATED MoorDyn_SetWaveKin(MoorDyn system, const double *U, const double *Ud, double t)
Set the kinematics of the waves.
Definition: MoorDyn2.h:331
int DECLDIR MoorDyn_GetNumberBodies(MoorDyn system, unsigned int *n)
Get the number of bodies.
Definition: MoorDyn2.cpp:3029
int DECLDIR MoorDyn_Save(MoorDyn system, const char *filepath)
Save the system so it can be loaded afterwards.
Definition: MoorDyn2.cpp:3295
struct __MoorDynPoint * MoorDynPoint
A mooring point instance.
Definition: Point.h:50
struct __MoorDynWaves * MoorDynWaves
A mooring point instance.
Definition: Waves.h:53
int DECLDIR MoorDyn_Deserialize(MoorDyn system, const uint64_t *data)
Load the system from the serialized data before.
Definition: MoorDyn2.cpp:3273
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.
Definition: MoorDyn2.cpp:2917
int DECLDIR MoorDyn_SetTimeScheme(MoorDyn system, const char *name)
Set the time scheme by its name.
Definition: MoorDyn2.cpp:3190
int DECLDIR MoorDyn_ExternalWaveKinInit(MoorDyn system, unsigned int *n)
Initializes the external Wave kinematics.
Definition: MoorDyn2.cpp:2960
int DECLDIR MoorDyn_SaveVTK(MoorDyn system, const char *filename)
Save the whole system to a VTK (.vtm) file.
Definition: MoorDyn2.cpp:3329
int DECLDIR MoorDyn_Log(MoorDyn system, int level, const char *msg)
Log a message.
Definition: MoorDyn2.cpp:2894
struct __MoorDynRod * MoorDynRod
A mooring line instance.
Definition: Rod.h:48
int DECLDIR MoorDyn_SetLogLevel(MoorDyn system, int verbosity)
Set the instance log file printing level.
Definition: MoorDyn2.cpp:2886
int DECLDIR DEPRECATED MoorDyn_GetWaveKinCoordinates(MoorDyn system, double *r)
Get the points where the waves kinematics shall be provided.
Definition: MoorDyn2.h:293
MoorDynRod DECLDIR MoorDyn_GetRod(MoorDyn system, unsigned int r)
Get a rod.
Definition: MoorDyn2.cpp:3059
int DECLDIR MoorDyn_ExternalWaveKinGetN(MoorDyn system, unsigned int *n)
Get the number of points where the waves kinematics shall be provided.
Definition: MoorDyn2.cpp:2978
int DECLDIR MoorDyn_SetCFL(MoorDyn system, double cfl)
Set the model Courant–Friedrichs–Lewy factor.
Definition: MoorDyn2.cpp:3166
int DECLDIR MoorDyn_GetTimeScheme(MoorDyn system, char *name, size_t *name_len)
Get the current time scheme name.
Definition: MoorDyn2.cpp:3175
int DECLDIR MoorDyn_GetNumberPoints(MoorDyn system, unsigned int *n)
Get the number of points.
Definition: MoorDyn2.cpp:3073
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.
Definition: MoorDyn2.cpp:2924
MoorDynSeafloor DECLDIR MoorDyn_GetSeafloor(MoorDyn system)
Get the 3D seafloor instance.
Definition: MoorDyn2.cpp:2952
int DECLDIR MoorDyn_GetNumberRods(MoorDyn system, unsigned int *n)
Get the number of rods.
Definition: MoorDyn2.cpp:3051
int DECLDIR MoorDyn_GetCFL(MoorDyn system, double *cfl)
Get the current model Courant–Friedrichs–Lewy factor.
Definition: MoorDyn2.cpp:3158
int DECLDIR MoorDyn_ExternalWaveKinGetCoordinates(MoorDyn system, double *r)
Get the points where the waves kinematics shall be provided.
Definition: MoorDyn2.cpp:2986
MoorDynWaves DECLDIR MoorDyn_GetWaves(MoorDyn system)
Get the wave kinematics instance.
Definition: MoorDyn2.cpp:2944
int DECLDIR MoorDyn_Init(MoorDyn system, const double *x, const double *xd)
Compute the initial condition of a MoorDyn system.
Definition: MoorDyn2.cpp:2910
int DECLDIR MoorDyn_SetDt(MoorDyn system, double dt)
Set the model time step.
Definition: MoorDyn2.cpp:3149
MoorDynBody DECLDIR MoorDyn_GetBody(MoorDyn system, unsigned int b)
Get a rigid body.
Definition: MoorDyn2.cpp:3037
int DECLDIR MoorDyn_NCoupledDOF(MoorDyn system, unsigned int *n)
Get the number of coupled Degrees Of Freedom (DOFs)
Definition: MoorDyn2.cpp:2902
int DECLDIR MoorDyn_ExternalWaveKinSet(MoorDyn system, const double *U, const double *Ud, double t)
Set the kinematics of the waves.
Definition: MoorDyn2.cpp:3002
struct __MoorDynBody * MoorDynBody
A mooring line instance.
Definition: Body.h:48
int DECLDIR MoorDyn_Close(MoorDyn system)
Releases MoorDyn allocated resources.
Definition: MoorDyn2.cpp:2936
struct __MoorDynLine * MoorDynLine
A mooring line instance.
Definition: Line.h:48
struct __MoorDyn * MoorDyn
A mooring system instance.
Definition: MoorDyn2.h:62
int DECLDIR MoorDyn_GetDt(MoorDyn system, double *dt)
Get the current model time step.
Definition: MoorDyn2.cpp:3141
int DECLDIR MoorDyn_LoadState(MoorDyn system, const char *filepath)
Load and set a system state.
Definition: MoorDyn2.cpp:3233
int DECLDIR MoorDyn_Serialize(MoorDyn system, size_t *size, uint64_t *data)
Serialize the system to bytes.
Definition: MoorDyn2.cpp:3251
int DECLDIR MoorDyn_Load(MoorDyn system, const char *filepath)
Load the system saved before.
Definition: MoorDyn2.cpp:3312
MoorDynPoint DECLDIR MoorDyn_GetPoint(MoorDyn system, unsigned int c)
Get a point.
Definition: MoorDyn2.cpp:3081
MoorDyn DECLDIR MoorDyn_Create(const char *infilename)
Creates a MoorDyn instance.
Definition: MoorDyn2.cpp:2840
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.
Definition: MoorDyn2.cpp:3117
MoorDynLine DECLDIR MoorDyn_GetLine(MoorDyn system, unsigned int l)
Get a line instance.
Definition: MoorDyn2.cpp:3103
int DECLDIR MoorDyn_SaveState(MoorDyn system, const char *filepath)
Save the system state, so it can be loaded afterwards.
Definition: MoorDyn2.cpp:3215
int DECLDIR MoorDyn_GetNumberLines(MoorDyn system, unsigned int *n)
Get the number of lines.
Definition: MoorDyn2.cpp:3095
int DECLDIR MoorDyn_SetVerbosity(MoorDyn system, int verbosity)
Set the instance verbosity level.
Definition: MoorDyn2.cpp:2870