40 #include "Util/CFL.hpp"
41 #include "leanvtk/leanvtk.hpp"
49 typedef std::shared_ptr<Waves>
WavesRef;
90 ELASTIC_VISCO_CTE = 2,
92 ELASTIC_VISCO_MEAN = 3,
101 SYROPE_LINEAR_WC = 1,
103 SYROPE_QUADRATIC_WC = 2,
113 real getNonlinearEA(
real l_stretched,
real l_unstretched)
const;
119 real getNonlinearBA(
real ld_stretched,
real l_unstretched)
const;
124 real getNonlinearEI(
real curv)
const;
135 return seafloor ? seafloor->getDepthAt(x, y) : -env->WtrDpth;
141 inline real avgWaterDepth()
143 return seafloor ? seafloor->getAverageDepth() : -env->WtrDpth;
149 inline void setWorkingCurve(
real Tmax);
172 elastic_model ElasticMod;
190 std::vector<moordyn::real> dl_1;
192 std::vector<moordyn::real> ld_1;
234 unsigned int nEApoints;
236 std::vector<moordyn::real> stiffXs;
238 std::vector<moordyn::real> stiffYs;
241 std::vector<moordyn::real> stiffZs;
243 unsigned int nEIpoints;
245 std::vector<moordyn::real> bstiffXs;
247 std::vector<moordyn::real> bstiffYs;
249 unsigned int nBApoints;
251 std::vector<moordyn::real> dampXs;
253 std::vector<moordyn::real> dampYs;
256 std::vector<moordyn::real> stiffxs_;
258 std::vector<moordyn::real> stiffys_;
260 std::vector<moordyn::real> stiffzs_;
269 std::vector<moordyn::real> pin;
279 std::vector<vec> pvec;
283 std::vector<moordyn::real> l;
285 std::vector<moordyn::real> lstr;
287 std::vector<moordyn::real> ldstr;
289 std::vector<moordyn::real> Kurv;
294 std::vector<moordyn::real> V;
298 syrope_wc_formula syropeWCForm;
304 std::vector<moordyn::real> Tmax;
306 std::vector<moordyn::real> Tmean;
308 const unsigned int nEApointsWC = 30;
334 std::vector<vec> Fnet;
338 std::vector<moordyn::real> F;
350 const unsigned int n_m = 500;
354 std::vector<moordyn::real> phi;
356 std::vector<moordyn::real> phi_dot;
364 std::vector<moordyn::real> yd_rms_old;
366 std::vector<moordyn::real> ydd_rms_old;
368 std::vector<vec> rdd_old;
406 std::vector<std::vector<moordyn::real>> zetaTS;
408 std::vector<std::vector<moordyn::real>> FTS;
410 std::vector<std::vector<vec>> UTS;
412 std::vector<std::vector<vec>> UdTS;
414 unsigned int ntWater;
442 void setup(
int number,
447 shared_ptr<ofstream> outfile,
460 seafloor = seafloor_in;
487 if ((state.row(0).size() != 8 && Cl > 0 && ElasticMod != ELASTIC_CONSTANT) ||
488 (state.row(0).size() != 7 && ((Cl > 0) ^ (ElasticMod != ELASTIC_CONSTANT))) ||
489 (state.row(0).size() != 6 && Cl == 0 && ElasticMod == ELASTIC_CONSTANT)) {
490 LOGERR <<
"Invalid state.row size for Line " << number << endl;
491 throw moordyn::mem_error(
"Invalid state.row size");
496 if ((state.rows() != N && ElasticMod != ELASTIC_CONSTANT) ||
497 (state.rows() != N - 1 && ElasticMod == ELASTIC_CONSTANT)) {
498 LOGERR <<
"Invalid number of rows in state matrix for Line "
500 throw moordyn::mem_error(
"Invalid number of rows in state matrix");
505 for (
unsigned int i = 0; i < (ElasticMod != ELASTIC_CONSTANT ? N : N - 1); i++) {
508 state.row(i).head<3>() = r[i + 1];
509 state.row(i).segment<3>(3) = rd[i + 1];
511 if (ElasticMod != ELASTIC_CONSTANT)
512 state.row(i).tail<1>()[0] =
518 if (ElasticMod != ELASTIC_CONSTANT)
519 state.row(i).tail<2>()[0] =
523 state.row(i).tail<1>()[0] =
542 Tmean.assign(N, Tmean0);
555 inline unsigned int getN()
const {
return N; }
574 for (
unsigned int i = 0; i < N; i++) {
575 l[i] = UnstrLen / double(N);
602 UnstrLen0 = UnstrLen;
605 setUnstretchedLength(UnstrLen0 + dt * UnstrLend);
631 if (ElasticMod != ELASTIC_CONSTANT) {
632 LOGERR <<
"Cannot set constant EA for viscoelastic model" << endl;
633 throw moordyn::invalid_value_error(
634 "Cannot set constant EA for viscoelastic model");
649 LOGERR <<
"Asking node " << i <<
" of line " << number
650 <<
", which only has " << N + 1 <<
" nodes" << std::endl;
651 throw moordyn::invalid_value_error(
"Invalid node index");
653 if (isnan(r[i].sum())) {
655 s <<
"NaN detected" << endl
656 <<
"Line " << number <<
" node positions:" << endl;
657 for (
unsigned int j = 0; j <= N; j++)
658 s << j <<
" : " << r[j] <<
";" << endl;
659 throw moordyn::nan_error(s.str().c_str());
673 LOGERR <<
"Asking node " << i <<
" of line " << number
674 <<
", which only has " << N + 1 <<
" nodes" << std::endl;
675 throw moordyn::invalid_value_error(
"Invalid node index");
677 if (isnan(rd[i].sum())) {
679 s <<
"NaN detected" << endl
680 <<
"Line " << number <<
" node velocities:" << endl;
681 for (
unsigned int j = 0; j <= N; j++)
682 s << j <<
" : " << rd[j] <<
";" << endl;
683 throw moordyn::nan_error(s.str().c_str());
707 LOGERR <<
"Asking node " << i <<
" of line " << number
708 <<
", which only has " << N + 1 <<
" nodes" << std::endl;
709 throw moordyn::invalid_value_error(
"Invalid node index");
729 LOGERR <<
"Asking node " << i <<
" of line " << number
730 <<
", which only has " << N + 1 <<
" nodes" << std::endl;
731 throw moordyn::invalid_value_error(
"Invalid node index");
736 return T[N - 1] + Td[N - 1];
738 return (0.5 * (T[i] + T[i - 1] + Td[i] + Td[i - 1]));
754 LOGERR <<
"Asking node " << i <<
" of line " << number
755 <<
", which only has " << N + 1 <<
" nodes" << std::endl;
756 throw moordyn::invalid_value_error(
"Invalid node index");
770 LOGERR <<
"Asking node " << i <<
" of line " << number
771 <<
", which only has " << N + 1 <<
" nodes" << std::endl;
772 throw moordyn::invalid_value_error(
"Invalid node index");
786 LOGERR <<
"Asking node " << i <<
" of line " << number
787 <<
", which only has " << N + 1 <<
" nodes" << std::endl;
788 throw moordyn::invalid_value_error(
"Invalid node index");
790 return Dp[i] + Dq[i];
802 LOGERR <<
"Asking node " << i <<
" of line " << number
803 <<
", which only has " << N + 1 <<
" nodes" << std::endl;
804 throw moordyn::invalid_value_error(
"Invalid node index");
806 return Ap[i] + Aq[i];
820 LOGERR <<
"Asking node " << i <<
" of line " << number
821 <<
", which only has " << N + 1 <<
" nodes" << std::endl;
822 throw moordyn::invalid_value_error(
"Invalid node index");
839 LOGERR <<
"Asking node " << i <<
" of line " << number
840 <<
", which only has " << N + 1 <<
" nodes" << std::endl;
841 throw moordyn::invalid_value_error(
"Invalid node index");
855 LOGERR <<
"Asking node " << i <<
" of line " << number
856 <<
", which only has " << N + 1 <<
" nodes" << std::endl;
857 throw moordyn::invalid_value_error(
"Invalid node index");
877 float* AnchVTen)
const
879 *FairHTen = (float)(Fnet[N](Eigen::seqN(0, 2)).norm());
880 *FairVTen = (float)(Fnet[N][2] + M[N](0, 0) * (-env->g));
881 *AnchHTen = (float)(Fnet[0](Eigen::seqN(0, 2)).norm());
882 *AnchVTen = (float)(Fnet[0][2] + M[0](0, 0) * (-env->g));
901 Moment_out = endMomentB;
904 case ENDPOINT_BOTTOM:
906 Moment_out = endMomentA;
910 LOGERR <<
"Invalid end point qualifier: " << end_point << endl;
911 throw moordyn::invalid_value_error(
"Invalid end point");
939 void storeWaterKin(
real dt,
940 std::vector<std::vector<moordyn::real>> zeta,
941 std::vector<std::vector<moordyn::real>> f,
942 std::vector<std::vector<vec>> u,
943 std::vector<std::vector<vec>> ud);
955 real calcSubSeg(
unsigned int firstNodeIdx,
956 unsigned int secondNodeIdx,
962 inline std::pair<real, real>
getDrag()
const {
return make_pair(Cdn, Cdt); }
1012 void setPin(std::vector<real> p);
1084 if (ElasticMod != ELASTIC_CONSTANT)
1102 if (Cl > 0 && ElasticMod != ELASTIC_CONSTANT)
1105 else if ((Cl > 0) ^ (ElasticMod != ELASTIC_CONSTANT))
1121 std::vector<uint64_t> Serialize(
void);
1129 uint64_t* Deserialize(
const uint64_t* data);
1135 void saveVTK(
const char* filename);
1142 const leanvtk::VTPWriter*
getVTK()
const {
return &vtk; }
1145 leanvtk::VTPWriter vtk;
#define LOGERR
Log an error.
Definition: Log.hpp:69
#define DECLDIR
Prefix to export C functions on the compiled library.
Definition: MoorDynAPI.h:68
A generic instance.
Definition: Instance.hpp:55
A mooring line.
Definition: Line.hpp:71
void setInitialTmax(moordyn::real Tmax0)
Set the initial Tmax values.
Definition: Line.hpp:535
const vec getNodeFroudeKrilov(unsigned int i) const
Get the Froude-Krilov force acting on the node.
Definition: Line.hpp:799
const vec & getNodeForce(unsigned int i) const
Get the net force on a node.
Definition: Line.hpp:704
bool isConstantEA() const
Get whether the line is governed by a non-linear stiffness or a constant one.
Definition: Line.hpp:613
bool enabledPb() const
Check if pressure bending forces are considered.
Definition: Line.hpp:1001
void setUnstretchedLengthVel(const moordyn::real v)
Set the unstretched length rate of change of the line.
Definition: Line.hpp:584
void enablePb()
Enable the pressure bending forces (disabled by default)
Definition: Line.hpp:992
std::vector< vec > getNodeCoordinates() const
Get the array of coordinates of all nodes along the line.
Definition: Line.hpp:865
void getEndStuff(vec &Fnet_out, vec &Moment_out, mat &M_out, EndPoints end_point) const
Get the force, moment and mass at the line endpoint.
Definition: Line.hpp:893
const leanvtk::VTPWriter * getVTK() const
Get the VTK writer.
Definition: Line.hpp:1142
void setInitialTmean(moordyn::real Tmean0)
Set the initial mean tension values.
Definition: Line.hpp:540
const vec & getNodeVel(unsigned int i) const
Get the velocity of a node.
Definition: Line.hpp:670
void scaleDrag(real scaler)
Scale the drag coefficients.
Definition: Line.hpp:977
const vec & getNodePos(unsigned int i) const
Get the position of a node.
Definition: Line.hpp:646
void setWaves(moordyn::WavesRef waves_in, moordyn::SeafloorRef seafloor_in)
Set the environmental data.
Definition: Line.hpp:456
const real & getNodeCurv(unsigned int i) const
Get the line curvature at a node position.
Definition: Line.hpp:836
const vec & getNodeWeight(unsigned int i) const
Get the weight and bouyancy force acting on the node.
Definition: Line.hpp:767
size_t lineId
Definition: Line.hpp:427
std::pair< real, real > getDrag() const
Get the drag coefficients.
Definition: Line.hpp:962
const mat & getNodeM(unsigned int i) const
Get the mass and added mass matrix.
Definition: Line.hpp:852
void getFASTtens(float *FairHTen, float *FairVTen, float *AnchHTen, float *AnchVTen) const
Get the tensions at the fairlead and anchor in a FASTv7 friendly way.
Definition: Line.hpp:874
const vec & getNodeBendStiff(unsigned int i) const
Get the tension on a node, including the internal line damping.
Definition: Line.hpp:751
void setUnstretchedLength(const moordyn::real len)
Set the unstretched length of the line.
Definition: Line.hpp:571
moordyn::real getUnstretchedLength() const
Get the unstretched length of the line.
Definition: Line.hpp:560
void updateUnstretchedLength(const moordyn::real dt=0.0)
Update the unstretched length of the line, according to the velocity.
Definition: Line.hpp:597
void setTime(real time)
Set the line simulation time.
Definition: Line.hpp:1017
void setConstantEA(moordyn::real EA_in)
Set the constant stiffness of the line.
Definition: Line.hpp:629
void initialize(InstanceStateVarView state)
Sets the initial line state.
Definition: Line.hpp:478
const vec getNodeTen(unsigned int i) const
Get the tension on a node, including the internal line damping.
Definition: Line.hpp:726
const size_t stateN() const
Get the number of state variables required by this instance.
Definition: Line.hpp:1082
void disablePb()
Disable the pressure bending forces (disabled by default)
Definition: Line.hpp:996
int number
Line ID.
Definition: Line.hpp:424
unsigned int getN() const
Number of segments.
Definition: Line.hpp:555
const vec getNodeSeabedForce(unsigned int i) const
Get the sea bed reaction force acting on the node.
Definition: Line.hpp:817
void setDrag(real cdn, real cdt)
Set the drag coefficients.
Definition: Line.hpp:968
const size_t stateDims() const
Get the dimension of the state variable.
Definition: Line.hpp:1100
moordyn::real getConstantEA() const
Get the constant stiffness of the line.
Definition: Line.hpp:621
const vec getNodeDrag(unsigned int i) const
Get the drag force acting on the node.
Definition: Line.hpp:783
elastic_model getElasticModel() const
Get the elastic model used by the line.
Definition: Line.hpp:548
A Logging utility.
Definition: Log.hpp:149
MoorDyn2 C++ API namespace.
Definition: Body.cpp:27
vec3 vec
vec3 renaming
Definition: Misc.hpp:130
std::shared_ptr< Waves > WavesRef
Definition: Body.hpp:53
Eigen::Block< InstanceStateVar, Eigen::Dynamic > InstanceStateVarView
View of the State variables for a particular instance.
Definition: Misc.hpp:167
EndPoints
End point qualifiers.
Definition: Misc.hpp:570
double real
Real numbers wrapper. It is either double or float.
Definition: Misc.hpp:118
std::shared_ptr< Seafloor > SeafloorRef
Shared pointer.
Definition: Seafloor.hpp:109
mat3 mat
mat3 renaming
Definition: Misc.hpp:142
Definition: Misc.hpp:1146
Definition: Misc.hpp:1292