-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
67 lines (52 loc) · 1.58 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "../source/MoorDyn2.h"
#include <stdexcept>
#include <iostream>
//#include <algorithm>
using namespace std;
int main(int argc, char* argv[])
{
MoorDyn system = MoorDyn_Create(argv[1]);
if (!system)
{
cerr << "Failure Creating the Mooring system" << endl;
return 1;
}
const unsigned int n_dof = MoorDyn_NCoupledDOF(system);
if (n_dof){
cerr << "No coupled Degrees Of Freedom were expected, but " << n_dof
<< "were reported" << endl;
MoorDyn_Close(system);
return 2;
}
int err;
// double x[3], dx[3];
// err = MoorDyn_GetConnectPos(system,2,x);
// if (err != MOORDYN_SUCCESS) {
// cerr << "Failure retrieving the fairlead " << 4
// << " position: " << err << endl;
// MoorDyn_Close(system);
// return 1;
// }
err = MoorDyn_Init(system, NULL, NULL);
if (err != MOORDYN_SUCCESS){
cerr << "Failure during the mooring initialization: " << err << endl;
MoorDyn_Close(system);
return 3;
}
//double dt = 0.00016;
//const unsigned int nts = 1000000;
double dt = 0.0001;
const unsigned int nts = 30000;
for (unsigned int i = 0; i < nts; i++){
double t = i * dt;
err = MoorDyn_Step(system, NULL, NULL, NULL, &t, &dt);
if (err != MOORDYN_SUCCESS) {
cerr << "Failure during the mooring step " << i << ": "
<< err << endl;
MoorDyn_Close(system);
return 4;
}
}
err = MoorDyn_Close(system);
return 0;
}