@@ -85,6 +85,18 @@ class DECLDIR Line final
8585 ~Line ();
8686
8787 private:
88+ // / @brief Elasticity models
89+ typedef enum
90+ {
91+ // / Constant EA
92+ ELASTIC_CONSTANT = 1 ,
93+ // / viscoelastic model with constant dynamic stiffness
94+ ELASTIC_VISCO_CTE = 2 ,
95+ // / mean load dependent dynamic stiffness
96+ ELASTIC_VISCO_MEAN = 3 ,
97+ } elastic_model;
98+
99+
88100 /* * @brief Get the non-linear stiffness. This is interpolated from a
89101 * curve provided in the input file.
90102 * @param l_stretched The actual length of the segment
@@ -142,9 +154,8 @@ class DECLDIR Line final
142154 moordyn::real d;
143155 // / line density (kg/m^3)
144156 moordyn::real rho;
145- // / Elasticity model flag (1: constant EA, 2: viscoelastic model with
146- // / constant dynamic stiffness, 3: mean load depenedent dynamic stiffness)
147- unsigned int ElasticMod;
157+ // / Elasticity model flag. See ::elastic_model
158+ elastic_model ElasticMod;
148159 // / line normal/static elasticity modulus * crosssectional area [N]
149160 moordyn::real EA;
150161 // / constant line dynamic stiffness modulus * area for viscoelastic stuff
@@ -158,8 +169,8 @@ class DECLDIR Line final
158169 moordyn::real vbeta;
159170 // / stiffness of spring 2 in viscoelastic model (dynamic stiffness). This is
160171 // / the spring in series with the parallel spring-dashpot. if ElasticMod =
161- // / 2 , EA_2 = EA_D. If ElasticMod = 3 , EA_2 is load dependent dynamic
162- // / stiffness.
172+ // / ELASTIC_VISCO_CTE , EA_2 = EA_D. If ElasticMod = ELASTIC_VISCO_MEAN , EA_2
173+ // / is load dependent dynamic stiffness.
163174 moordyn::real EA_2;
164175 // / segment stretch attributed to static stiffness portion [m] (deltaL_1)
165176 std::vector<moordyn::real> dl_1;
@@ -435,38 +446,38 @@ class DECLDIR Line final
435446 // Line::setState but flipped) ------ Error check for number of columns
436447 // (if VIV and Visco need row.size() = 8, if VIV xor Visco need
437448 // row.size() = 7, if not VIV need row.size() = 6)
438- if ((state.row (0 ).size () != 8 && Cl > 0 && ElasticMod > 1 ) ||
439- (state.row (0 ).size () != 7 && ((Cl > 0 ) ^ (ElasticMod > 1 ))) ||
440- (state.row (0 ).size () != 6 && Cl == 0 && ElasticMod == 1 )) {
449+ if ((state.row (0 ).size () != 8 && Cl > 0 && ElasticMod != ELASTIC_CONSTANT ) ||
450+ (state.row (0 ).size () != 7 && ((Cl > 0 ) ^ (ElasticMod != ELASTIC_CONSTANT ))) ||
451+ (state.row (0 ).size () != 6 && Cl == 0 && ElasticMod == ELASTIC_CONSTANT )) {
441452 LOGERR << " Invalid state.row size for Line " << number << endl;
442453 throw moordyn::mem_error (" Invalid state.row size" );
443454 }
444455
445456 // Error check for number of rows (if visco need N rows, if normal need
446457 // N-1 rows)
447- if ((state.rows () != N && ElasticMod > 1 ) ||
448- (state.rows () != N - 1 && ElasticMod == 1 )) {
458+ if ((state.rows () != N && ElasticMod != ELASTIC_CONSTANT ) ||
459+ (state.rows () != N - 1 && ElasticMod == ELASTIC_CONSTANT )) {
449460 LOGERR << " Invalid number of rows in state matrix for Line "
450461 << number << endl;
451462 throw moordyn::mem_error (" Invalid number of rows in state matrix" );
452463 }
453464
454465 // If using the viscoelastic model, iterate N rows, else iterate N-1
455466 // rows.
456- for (unsigned int i = 0 ; i < (ElasticMod > 1 ? N : N - 1 ); i++) {
467+ for (unsigned int i = 0 ; i < (ElasticMod != ELASTIC_CONSTANT ? N : N - 1 ); i++) {
457468 // node number is i+1
458469 // segment number is i
459470 state.row (i).head <3 >() = r[i + 1 ];
460471 state.row (i).segment <3 >(3 ) = rd[i + 1 ];
461472
462- if (ElasticMod > 1 )
473+ if (ElasticMod != ELASTIC_CONSTANT )
463474 state.row (i).tail <1 >()[0 ] =
464475 dl_1[i]; // [0] needed becasue tail<1> returns a one element
465476 // vector. Viscoelastic state is always the last
466477 // element in the row
467478
468479 if (Cl > 0 ) {
469- if (ElasticMod > 1 )
480+ if (ElasticMod != ELASTIC_CONSTANT )
470481 state.row (i).tail <2 >()[0 ] =
471482 phi[i + 1 ]; // if both VIV and viscoelastic second to
472483 // last element in the row
@@ -561,7 +572,7 @@ class DECLDIR Line final
561572 */
562573 inline void setConstantEA (moordyn::real EA_in)
563574 {
564- if (ElasticMod > 1 ) {
575+ if (ElasticMod != ELASTIC_CONSTANT ) {
565576 LOGERR << " Cannot set constant EA for viscoelastic model" << endl;
566577 throw moordyn::invalid_value_error (
567578 " Cannot set constant EA for viscoelastic model" );
@@ -1014,7 +1025,7 @@ class DECLDIR Line final
10141025 */
10151026 inline const size_t stateN () const
10161027 {
1017- if (ElasticMod > 1 )
1028+ if (ElasticMod != ELASTIC_CONSTANT )
10181029 return getN (); // N rows for viscoelastic case
10191030 else
10201031 return getN () - 1 ; // N-1 rows for other cases
@@ -1032,10 +1043,10 @@ class DECLDIR Line final
10321043 */
10331044 inline const size_t stateDims () const
10341045 {
1035- if (Cl > 0 && ElasticMod > 1 )
1046+ if (Cl > 0 && ElasticMod != ELASTIC_CONSTANT )
10361047 return 8 ; // 3 for position, 3 for velocity, 1 for VIV phase, 1 for
10371048 // viscoelasticity
1038- else if ((Cl > 0 ) ^ (ElasticMod > 1 ))
1049+ else if ((Cl > 0 ) ^ (ElasticMod != ELASTIC_CONSTANT ))
10391050 return 7 ; // 3 for position, 3 for velocity, 1 for VIV phase or
10401051 // viscoelasticity
10411052 else
0 commit comments