OpenFAST
Wind turbine multiphysics simulator
map.h
1 /****************************************************************
2  * Copyright (C) 2014 mdm *
3  * map[dot]plus[dot]plus[dot]help[at]gmail *
4  * *
5  * Licensed to the Apache Software Foundation (ASF) under one *
6  * or more contributor license agreements. See the NOTICE file *
7  * distributed with this work for additional information *
8  * regarding copyright ownership. The ASF licenses this file *
9  * to you under the Apache License, Version 2.0 (the *
10  * "License"); you may not use this file except in compliance *
11  * with the License. You may obtain a copy of the License at *
12  * *
13  * http://www.apache.org/licenses/LICENSE-2.0 *
14  * *
15  * Unless required by applicable law or agreed to in writing, *
16  * software distributed under the License is distributed on an *
17  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
18  * KIND, either express or implied. See the License for the *
19  * specific language governing permissions and limitations *
20  * under the License. *
21  ****************************************************************/
22 
23 
24 #ifndef _MAP_H
25 #define _MAP_H
26 
27 
28 #include "mapsys.h"
29 
30 #include "simclist/simclist.h"
31 
32 #include "bstring/bstrlib.h"
33 
34 #include "cminpack/cminpack.h"
35 #include "cminpack/cminpackP.h"
36 #include "cminpack/minpack.h"
37 
38 #include "MAP_Types.h"
39 #include "maperror.h"
40 #include "lmroutines.hpp"
41 
42 #ifdef WITH_LAPACK
43 # include "lapack/lapacke.h"
44 #endif // WITH_LAPACK
45 
56 typedef enum NodeType_enum {
57  NONE,
58  FIX,
59  CONNECT,
60  VESSEL
61 } NodeType;
62 
63 
68 typedef enum FdType_enum {
69  BACKWARD_DIFFERENCE,
70  CENTRAL_DIFFERENCE,
71  FORWARD_DIFFERENCE
72 } FdType;
73 
74 
85 typedef enum SolveType_enum {
86  MONOLITHIC,
87  PARTITIONED,
88  LUMPED_MASS
89 } SolveType;
90 
91 
96 struct Fd_t {
97  double* fx;
98  double* fy;
99  double* fz;
100  double* mx;
101  double* my;
102  double* mz;
103 }; typedef struct Fd_t Fd;
104 
105 
112 struct VarType_t {
115  double value;
116  bool is_fixed;
119  int id;
120 }; typedef struct VarType_t VarType;
121 
122 
128 struct VarTypePtr_t {
131  double* value;
132  bool is_fixed;
134  int id;
135 }; typedef struct VarTypePtr_t VarTypePtr;
136 
137 
138 struct Vector_t {
139  double x;
140  double y;
141  double z;
142 }; typedef struct Vector_t Vector;
143 
144 
145 struct Point_t {
146  VarType x;
147  VarType y;
148  VarType z;
149 }; typedef struct Point_t Point;
150 
151 
152 struct PointPtr_t {
153  VarTypePtr x;
154  VarTypePtr y;
155  VarTypePtr z;
156 }; typedef struct PointPtr_t PointPtr;
157 
158 
159 struct EulerAngle_t {
160  VarType phi;
161  VarType the;
162  VarType psi;
163 }; typedef struct EulerAngle_t EulerAngle;
164 
165 
166 struct Force_t {
167  VarType fx;
168  VarType fy;
169  VarType fz;
170 }; typedef struct Force_t Force;
171 
172 
173 struct ForcePtr_t {
174  VarTypePtr fx;
175  VarTypePtr fy;
176  VarTypePtr fz;
177 }; typedef struct ForcePtr_t ForcePtr;
178 
179 
181  VarTypePtr* x;
182  VarTypePtr* y;
183  VarTypePtr* z;
184 }; typedef struct ReferencePoint_t ReferencePoint;
185 
186 
191 struct Vessel_t {
192  EulerAngle orientation;
193  double* xi;
194  double* yi;
195  double* zi;
196  Point displacement;
197  Point ref_origin;
200 }; typedef struct Vessel_t Vessel;
201 
202 
203 
215 }; typedef struct OutputList_t OutputList;
216 
217 
218 typedef struct {
219  bool gx_pos_flag;
220  bool gy_pos_flag;
221  bool gz_pos_flag;
222  bool gx_anchor_pos_flag;
223  bool gy_anchor_pos_flag;
224  bool gz_anchor_pos_flag;
225  bool gx_force_flag;
226  bool gy_force_flag;
227  bool gz_force_flag;
228  bool H_flag;
229  bool V_flag;
230  bool V_anchor_flag;
231  bool H_anchor_flag;
232  bool fairlead_tension_flag;
233  bool anchor_tension_flag;
234  bool horizontal_excursion_flag;
235  bool vertical_excursion_flag;
236  bool azimuth_flag;
237  bool altitude_flag;
238  bool altitude_anchor_flag;
239  bool line_tension_flag;
240  bool omit_contact;
241  bool lay_length_flag;
242  bool damage_time_flag;
243  bool diagnostics_flag;
245 } LineOptions;
246 
247 
252  double diam;
253  double mass_density;
254  double EA;
255  double omega;
256  double a;
257  double cb;
258  double cd_i;
259  double ca;
260  double cd_n;
261  double cd_t;
263 }; typedef struct CableLibrary_t CableLibrary;
264 
265 
266 struct Node_t {
267  PointPtr acceleration;
268  PointPtr velocity;
269  PointPtr position_ptr;
270  NodeType type;
271  ForcePtr sum_force_ptr;
272  VarType M_applied;
273  VarType B_applied;
274  Force external_force;
275 }; typedef struct Node_t Node;
276 
277 
278 // struct LMAttributes {
279 // void* lm_container; /**< container struct in lmroutines.hpp */
280 // double* FlineS; /**< retains last solution for when this is called with dT = 0 */ //
281 // double** rFairtS; /**< fairlead locations ON TURBINE */ // <--------- will be mapped to a Node_t list
282 // double** rFairRel; /**< fairlead locations relative to platform center */ // <--------- will be mapped to a Node_t list
283 // double** rFairi; /**< inertial Fairlead Locations */ // <--------- will be mapped to a Node_t list
284 // double** rdFairi; /**< inertial Fairlead Velocities */ // <--------- will be mapped to a Node_t list
285 //
286 // // static vectors to hold line and connection objects!
287 // // vector< LineProps > LinePropList; // to hold line library types <--------- Moved to the Line_t struct
288 // // vector< Line > LineList; // global and persistent? <--------- Moved to a container struct in lmroutines.hpp to isolate c++ and c
289 // // vector< Connection > ConnectList; <--------- Moved to a container struct in lmroutines.hpp to isolate c++ and c
290 // int nConnects;
291 // int nLines;
292 //
293 // // state vector and stuff
294 // double* states; /**< pointer to array comprising global state vector */
295 // double* newstates;
296 // int Nx; /**< size of state vector array */
297 //
298 // // more state vector things for rk4 integration
299 // double* f0;
300 // double* f1;
301 // double* f2;
302 // double* f3;
303 // double* xt;
304 //
305 // int* lineStateIs; /** vector of line starting indices in "states" array */ // vector< int > LineStateIs;
306 // int closed; // initialize to 0
307 // double dt; // FAST time step, @rm
308 // double dts; /**< mooring line time step */
309 // }; typedef struct LMAttributes_t LMAttributes;
310 
311 
312 struct Line_t {
314  // LMAttributes* lm_attributes; /**< Preserves information of the LM model from previous time steps */
320  double* line_tension;
321  double psi;
322  double alpha;
324  double l;
325  double Lb;
326  double h;
327  double H_at_anchor;
328  double V_at_anchor;
329  double T;
330  double T_at_anchor;
331  double damage_time;
332  double residual_norm;
333  double fx_fairlead;
334  double fy_fairlead;
335  double fz_fairlead;
336  double fx_anchor;
337  double fy_anchor;
338  double fz_anchor;
342  int segment_size;
344  int evals;
346  int converge_reason; /* - info=0 : improper input parameters.
347  * - info=1 : both actual and predicted relative reductions in the sum of squares are at most ftol.
348  * - info=2 : relative error between two consecutive iterates is at most xtol.
349  * - info=3 : conditions for info = 1 and info = 2 both hold.
350  * - info=4 : the cosine of the angle between fvec and any column of the Jacobian is at most gtol in absolute value.
351  * - info=5 : number of calls to fcn has reached or exceeded maxfev.
352  * - info=6 : ftol is too small. No further reduction in the sum of squares is possible.
353  * - info=7 : xtol is too small. No further improvement in the approximate solution x is possible.
354  * - info=8 : gtol is too small. fvec is orthogonal to the columns of the Jacobian to machine precision.
355  */
356 }; typedef struct Line_t Line;
357 
358 
359 struct Element_t {
360  double l;
361  Node* r1;
362  Node* r2;
363 }; typedef struct Element_t Element;
364 
365 
367  double** node_jac;
368  double f_tol;
369  double g_tol;
370  double x_tol;
371  double x[2];
372  double fvec[2];
373  double fjac[4];
374  double wa1[2];
375  double wa2[2];
376  double wa3[2];
377  double wa4[2];
378  double diag[2];
379  double qtf[2];
380  double factor;
381  int max_its;
382  int ldfjac;
383  int mode;
384  int nprint;
385  int info;
386  int ipvt[2];
387  int m;
388  int n;
390 
391 
392 
394  FdType fd;
395  double** AV;
396  double** V;
397  double* av;
398  double** jac;
399  double** l;
400  double** u;
401  double* b;
402  double* C;
403  double* w;
404  double* q;
405  double* x;
406  double* y;
407  double ds;
408  double d;
409  double epsilon;
410  double norm_error;
411  double tol;
412  double coef;
413  bool pg;
414  bool krylov_accelerator;
415  bool powell;
416  int max_krylov_its;
417  int max_its;
418  int iteration_count;
420 
421 
423  double* repeat_angle;
424  double integration_dt;
425  double kb_lm;
426  double cb_lm;
428  bool lm_model;
429  int repeat_angle_size;
430 }; typedef struct DomainOptions_t DomainOptions;
431 
432 
433 struct Domain_t {
445  void* HEAD_U_TYPE;
446 }; typedef struct Domain_t Domain;
447 
448 
462 }; typedef struct InitializationData_t InitializationData;
463 
464 
465 #endif /* _MAP_H */
double diam
Cable diameter, [m].
Definition: map.h:252
bool user_initial_guess
if user_initial_guess = true, the user has supplied an initial guess
Definition: map.h:117
Node * r2
lower node
Definition: map.h:362
double ca
Added mass coefficient [non-dimensional].
Definition: map.h:259
list_t u_update_list
List to update the references in VarType-associated u_type&#39;s in UpdateStates.
Definition: map.h:444
list object
Definition: simclist.h:185
double ** l
lower triangle matrix in LU
Definition: map.h:399
double integration_dt
Integration time step [sec].
Definition: map.h:424
double * zi
initial node connection point in body frame This is equal to uType->z at initialization [m] ...
Definition: map.h:195
struct bstrList * node_input_string
raw (non-expanded) node input string.
Definition: map.h:456
double cb_lm
Seabed damping parameter [N-s/m].
Definition: map.h:426
VarTypePtr V
Vertical fairlead force in the local cable elemenet frame.
Definition: map.h:317
double l
| {r}_{1}-{r}_{2} |
Definition: map.h:360
Finite-difference structure.
Definition: map.h:96
double alpha_at_anchor
angle of inclication at anchor [deg]
Definition: map.h:323
bstring label
reference a pre-defined property in the line dictionary
Definition: map.h:319
double T
Tension magnitude [N].
Definition: map.h:329
Definition: map.h:138
int m
number of functions
Definition: map.h:387
int evals
number of function evaluations
Definition: map.h:344
Serves the same function as VarType, but treats value as a pointer.
Definition: map.h:128
InnerSolveAttributes inner_loop
Inner-loop (line level) solver options.
Definition: map.h:434
C implementaion of bstring functions.
double kb_lm
Seabed stiffeness coefficient [N/m].
Definition: map.h:425
Point ref_origin
Center of rotation origin.
Definition: map.h:197
bstring name
name of the variable.
Definition: map.h:130
double damage_time
time to damage this line and return zero force to the glue code
Definition: map.h:331
DomainOptions model_options
Contains global model options.
Definition: map.h:436
CableLibrary * line_property
line properties
Definition: map.h:313
double * av
for the Krylov accelerator, rown-major storage for AV
Definition: map.h:397
double ** AV
for the Krylov accelerator
Definition: map.h:395
Definition: map.h:180
double ** u
upper triangle matrix in LU
Definition: map.h:400
Definition: map.h:173
bstring units
units for printing information to a summary file or output buffer
Definition: map.h:129
Central point where all &#39;VESSEL&#39; nodes can be displaced.
Definition: map.h:191
Point displacement
User-specified vessel displacement.
Definition: map.h:196
ForcePtr sum_force_ptr
this is a Ptr because it points to a fortran type
Definition: map.h:271
VarType Lu
unstretched cable length [m]
Definition: map.h:318
double ** V
for the Krylov accelerator
Definition: map.h:396
PointPtr acceleration
Node accelration; integrated quantity [m/s^2]; used for LM model.
Definition: map.h:267
int ldfjac
number of columns in fjac
Definition: map.h:382
double * C
for the Krylov accelerator
Definition: map.h:402
struct bstrList * expanded_line_input_string
full line input string duplicating information in nodeLineString when the &#39;repeat&#39; flag is used ...
Definition: map.h:460
double cd_i
Internal (structural) damping coefficient [non-dimensional].
Definition: map.h:258
Node * fairlead
Fairlead node.
Definition: map.h:341
Defines cable properties for a line.
Definition: map.h:251
int njac_evals
number of function evaluations
Definition: map.h:345
int id
node or line this value is attached to
Definition: map.h:119
Definition: map.h:312
list_t line
Line link list.
Definition: map.h:442
double H_at_anchor
Horizontal anchor force in the local cable elemenet frame.
Definition: map.h:327
bool lm_model
use the lumped-mass model when true
Definition: map.h:428
bstring units
units for printing information to a summary file or output buffer
Definition: map.h:113
double * xi
initial node connection point in body frame.This is equal to uType->x at initialization [m] ...
Definition: map.h:193
SolveType MAP_SOLVE_TYPE
Identifies the solver type: single line, partitioned (multisegmented), and lumped-mass/FEA.
Definition: map.h:438
Node * r1
upper node
Definition: map.h:361
double omega
cable weight per length in seawater [N/m]
Definition: map.h:255
Definition: map.h:145
int ref_counter
for ensuring the variable is assigned to one of: input, param, or constraint
Definition: map.h:118
double mass_density
Cable density in air [kg/m].
Definition: map.h:253
Definition: bstrlib.h:726
Definition: map.h:159
int id
node or line this value is attached to
Definition: map.h:134
list_t node
Node link list.
Definition: map.h:443
struct bstrList * library_input_string
library property string from input file.
Definition: map.h:455
double * b
this is the force vector used in x += ([J]^-1)*b
Definition: map.h:401
list_t out_list_ptr
Outputs associated with VarTypePtr.
Definition: map.h:214
Fundamental MAP type.
Definition: map.h:112
double h
vertical cable excursion [m]
Definition: map.h:326
PointPtr velocity
Node velocity [m/s]; used for LM model.
Definition: map.h:268
PointPtr position_ptr
this is a Ptr because it points to a fortran type
Definition: map.h:269
References a list of VarType&#39;s (in the case of out_list) and VarTypePtr&#39;s (in the case of out_list_pt...
Definition: map.h:212
Definition: map.h:454
Definition: map.h:266
Definition: map.h:218
EulerAngle orientation
Vessel orientation [deg].
Definition: map.h:192
bstring label
Provides the string a recognizable name (such as &#39;nylon&#39; or &#39;steel&#39;)
Definition: map.h:262
LineOptions options
run-time options flag
Definition: map.h:315
double cb
Cable/seabed friction coefficient [non-dimensional].
Definition: map.h:257
Definition: map.h:366
void * HEAD_U_TYPE
Checks if the reference to MAP_InputType_t changes.
Definition: map.h:445
bool linear_spring
treat the elastic catenary as a uncompressible linear springs when true
Definition: map.h:244
bstring name
name of the variable.
Definition: map.h:114
Definition: map.h:393
double EA
Line stiffness [N].
Definition: map.h:254
list_t out_list
Outputs associated with VarType.
Definition: map.h:213
Set internally.
Definition: map.h:359
VarTypePtr H
Horizontal fairlead force in the local cable elemenet frame.
Definition: map.h:316
list_t library
Cable library link list; stores cable properties, e.g.,.
Definition: map.h:441
struct bstrList * line_input_string
raw (non-expanded) line input string(MAP does not read contents from input string; must be done by ca...
Definition: map.h:457
double Lb
length of line touching the seabed [m]
Definition: map.h:325
Definition: map.h:166
int ref_counter
For ensuring the variable is assigned to one of: input, param, or constraint.
Definition: map.h:133
double T_at_anchor
Tension magnitude at anchor [N].
Definition: map.h:330
bool wave_kinematics
Enable wave kinematics o calculated relative flui velcity.
Definition: map.h:427
Node * anchor
Anchor node.
Definition: map.h:340
Vessel vessel
Vessel for the mooring instance.
Definition: map.h:440
double alpha
angle of inclication [deg]
Definition: map.h:322
OutputList * y_list
Output stream.
Definition: map.h:437
double * q
for the Krylov accelerator
Definition: map.h:404
double * w
for the Krylov accelerator
Definition: map.h:403
bool is_fixed
if is_fixed = true, then we are not solving for this variable
Definition: map.h:116
double cd_t
Tangential drag oefficient [non-dimensional].
Definition: map.h:261
Force line_sum_force
Sum force of all nodes connecting to the vessel [N].
Definition: map.h:199
double * value
the value
Definition: map.h:131
Definition: map.h:152
double psi
angle of roation between global X and local x axis [deg]
Definition: map.h:321
double cd_n
Quadtradice drag coefficient in the cable cross-flow direction [non-dimensional]. ...
Definition: map.h:260
double l
horizontal cable excursion [m]
Definition: map.h:324
Definition: map.h:422
double V_at_anchor
Vertical anchor force in the local cable elemenet frame.
Definition: map.h:328
list_t elements
LM model elements.
Definition: map.h:339
OuterSolveAttributes outer_loop
Outer-loop (node level) solver options.
Definition: map.h:435
Definition: bstrlib.h:80
double a
cross-sectional area [m^2]
Definition: map.h:256
double * yi
initial node connection point in body frame This is equal to uType->y at initialization [m] ...
Definition: map.h:194
Definition: map.h:433
struct bstrList * solver_options_string
model poptions input string
Definition: map.h:458
int n
number of variables
Definition: map.h:388
int diagnostic_type
none=0, first iteration only=2, all iterations otherwise
Definition: map.h:343
struct bstrList * expanded_node_input_string
full node input string duplicating information in node_input_string when the &#39;repeat&#39; flag is used ...
Definition: map.h:459
double * line_tension
array of line tension along &#39;s&#39; [N]
Definition: map.h:320
double value
the value
Definition: map.h:115
bstring summary_file_name
summary file name.
Definition: map.h:461
bool is_fixed
If is_fixed = true, then we are not solving for this variable.
Definition: map.h:132