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 real getNonlinearEA(
real l_stretched,
real l_unstretched)
const;
107 real getNonlinearBA(
real ld_stretched,
real l_unstretched)
const;
112 real getNonlinearEI(
real curv)
const;
123 return seafloor ? seafloor->getDepthAt(x, y) : -env->WtrDpth;
129 inline real avgWaterDepth()
131 return seafloor ? seafloor->getAverageDepth() : -env->WtrDpth;
154 elastic_model ElasticMod;
172 std::vector<moordyn::real> dl_1;
174 std::vector<moordyn::real> ld_1;
216 unsigned int nEApoints;
218 std::vector<moordyn::real> stiffXs;
220 std::vector<moordyn::real> stiffYs;
222 unsigned int nEIpoints;
224 std::vector<moordyn::real> bstiffXs;
226 std::vector<moordyn::real> bstiffYs;
228 unsigned int nBApoints;
230 std::vector<moordyn::real> dampXs;
232 std::vector<moordyn::real> dampYs;
241 std::vector<moordyn::real> pin;
251 std::vector<vec> pvec;
255 std::vector<moordyn::real> l;
257 std::vector<moordyn::real> lstr;
259 std::vector<moordyn::real> ldstr;
261 std::vector<moordyn::real> Kurv;
266 std::vector<moordyn::real> V;
292 std::vector<vec> Fnet;
296 std::vector<moordyn::real> F;
308 const unsigned int n_m = 500;
312 std::vector<moordyn::real> phi;
314 std::vector<moordyn::real> phi_dot;
322 std::vector<moordyn::real> yd_rms_old;
324 std::vector<moordyn::real> ydd_rms_old;
326 std::vector<vec> rdd_old;
364 std::vector<std::vector<moordyn::real>> zetaTS;
366 std::vector<std::vector<moordyn::real>> FTS;
368 std::vector<std::vector<vec>> UTS;
370 std::vector<std::vector<vec>> UdTS;
372 unsigned int ntWater;
400 void setup(
int number,
405 shared_ptr<ofstream> outfile,
418 seafloor = seafloor_in;
445 if ((state.row(0).size() != 8 && Cl > 0 && ElasticMod != ELASTIC_CONSTANT) ||
446 (state.row(0).size() != 7 && ((Cl > 0) ^ (ElasticMod != ELASTIC_CONSTANT))) ||
447 (state.row(0).size() != 6 && Cl == 0 && ElasticMod == ELASTIC_CONSTANT)) {
448 LOGERR <<
"Invalid state.row size for Line " << number << endl;
449 throw moordyn::mem_error(
"Invalid state.row size");
454 if ((state.rows() != N && ElasticMod != ELASTIC_CONSTANT) ||
455 (state.rows() != N - 1 && ElasticMod == ELASTIC_CONSTANT)) {
456 LOGERR <<
"Invalid number of rows in state matrix for Line "
458 throw moordyn::mem_error(
"Invalid number of rows in state matrix");
463 for (
unsigned int i = 0; i < (ElasticMod != ELASTIC_CONSTANT ? N : N - 1); i++) {
466 state.row(i).head<3>() = r[i + 1];
467 state.row(i).segment<3>(3) = rd[i + 1];
469 if (ElasticMod != ELASTIC_CONSTANT)
470 state.row(i).tail<1>()[0] =
476 if (ElasticMod != ELASTIC_CONSTANT)
477 state.row(i).tail<2>()[0] =
481 state.row(i).tail<1>()[0] =
495 inline unsigned int getN()
const {
return N; }
514 for (
unsigned int i = 0; i < N; i++) {
515 l[i] = UnstrLen / double(N);
542 UnstrLen0 = UnstrLen;
545 setUnstretchedLength(UnstrLen0 + dt * UnstrLend);
571 if (ElasticMod != ELASTIC_CONSTANT) {
572 LOGERR <<
"Cannot set constant EA for viscoelastic model" << endl;
573 throw moordyn::invalid_value_error(
574 "Cannot set constant EA for viscoelastic model");
589 LOGERR <<
"Asking node " << i <<
" of line " << number
590 <<
", which only has " << N + 1 <<
" nodes" << std::endl;
591 throw moordyn::invalid_value_error(
"Invalid node index");
593 if (isnan(r[i].sum())) {
595 s <<
"NaN detected" << endl
596 <<
"Line " << number <<
" node positions:" << endl;
597 for (
unsigned int j = 0; j <= N; j++)
598 s << j <<
" : " << r[j] <<
";" << endl;
599 throw moordyn::nan_error(s.str().c_str());
613 LOGERR <<
"Asking node " << i <<
" of line " << number
614 <<
", which only has " << N + 1 <<
" nodes" << std::endl;
615 throw moordyn::invalid_value_error(
"Invalid node index");
617 if (isnan(rd[i].sum())) {
619 s <<
"NaN detected" << endl
620 <<
"Line " << number <<
" node velocities:" << endl;
621 for (
unsigned int j = 0; j <= N; j++)
622 s << j <<
" : " << rd[j] <<
";" << endl;
623 throw moordyn::nan_error(s.str().c_str());
647 LOGERR <<
"Asking node " << i <<
" of line " << number
648 <<
", which only has " << N + 1 <<
" nodes" << std::endl;
649 throw moordyn::invalid_value_error(
"Invalid node index");
669 LOGERR <<
"Asking node " << i <<
" of line " << number
670 <<
", which only has " << N + 1 <<
" nodes" << std::endl;
671 throw moordyn::invalid_value_error(
"Invalid node index");
676 return T[N - 1] + Td[N - 1];
678 return (0.5 * (T[i] + T[i - 1] + Td[i] + Td[i - 1]));
694 LOGERR <<
"Asking node " << i <<
" of line " << number
695 <<
", which only has " << N + 1 <<
" nodes" << std::endl;
696 throw moordyn::invalid_value_error(
"Invalid node index");
710 LOGERR <<
"Asking node " << i <<
" of line " << number
711 <<
", which only has " << N + 1 <<
" nodes" << std::endl;
712 throw moordyn::invalid_value_error(
"Invalid node index");
726 LOGERR <<
"Asking node " << i <<
" of line " << number
727 <<
", which only has " << N + 1 <<
" nodes" << std::endl;
728 throw moordyn::invalid_value_error(
"Invalid node index");
730 return Dp[i] + Dq[i];
742 LOGERR <<
"Asking node " << i <<
" of line " << number
743 <<
", which only has " << N + 1 <<
" nodes" << std::endl;
744 throw moordyn::invalid_value_error(
"Invalid node index");
746 return Ap[i] + Aq[i];
760 LOGERR <<
"Asking node " << i <<
" of line " << number
761 <<
", which only has " << N + 1 <<
" nodes" << std::endl;
762 throw moordyn::invalid_value_error(
"Invalid node index");
779 LOGERR <<
"Asking node " << i <<
" of line " << number
780 <<
", which only has " << N + 1 <<
" nodes" << std::endl;
781 throw moordyn::invalid_value_error(
"Invalid node index");
795 LOGERR <<
"Asking node " << i <<
" of line " << number
796 <<
", which only has " << N + 1 <<
" nodes" << std::endl;
797 throw moordyn::invalid_value_error(
"Invalid node index");
817 float* AnchVTen)
const
819 *FairHTen = (float)(Fnet[N](Eigen::seqN(0, 2)).norm());
820 *FairVTen = (float)(Fnet[N][2] + M[N](0, 0) * (-env->g));
821 *AnchHTen = (float)(Fnet[0](Eigen::seqN(0, 2)).norm());
822 *AnchVTen = (float)(Fnet[0][2] + M[0](0, 0) * (-env->g));
841 Moment_out = endMomentB;
844 case ENDPOINT_BOTTOM:
846 Moment_out = endMomentA;
850 LOGERR <<
"Invalid end point qualifier: " << end_point << endl;
851 throw moordyn::invalid_value_error(
"Invalid end point");
879 void storeWaterKin(
real dt,
880 std::vector<std::vector<moordyn::real>> zeta,
881 std::vector<std::vector<moordyn::real>> f,
882 std::vector<std::vector<vec>> u,
883 std::vector<std::vector<vec>> ud);
895 real calcSubSeg(
unsigned int firstNodeIdx,
896 unsigned int secondNodeIdx,
902 inline std::pair<real, real>
getDrag()
const {
return make_pair(Cdn, Cdt); }
952 void setPin(std::vector<real> p);
1024 if (ElasticMod != ELASTIC_CONSTANT)
1042 if (Cl > 0 && ElasticMod != ELASTIC_CONSTANT)
1045 else if ((Cl > 0) ^ (ElasticMod != ELASTIC_CONSTANT))
1061 std::vector<uint64_t> Serialize(
void);
1069 uint64_t* Deserialize(
const uint64_t* data);
1075 void saveVTK(
const char* filename);
1082 const leanvtk::VTPWriter*
getVTK()
const {
return &vtk; }
1085 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
const vec getNodeFroudeKrilov(unsigned int i) const
Get the Froude-Krilov force acting on the node.
Definition: Line.hpp:739
const vec & getNodeForce(unsigned int i) const
Get the net force on a node.
Definition: Line.hpp:644
bool isConstantEA() const
Get whether the line is governed by a non-linear stiffness or a constant one.
Definition: Line.hpp:553
bool enabledPb() const
Check if pressure bending forces are considered.
Definition: Line.hpp:941
void setUnstretchedLengthVel(const moordyn::real v)
Set the unstretched length rate of change of the line.
Definition: Line.hpp:524
void enablePb()
Enable the pressure bending forces (disabled by default)
Definition: Line.hpp:932
std::vector< vec > getNodeCoordinates() const
Get the array of coordinates of all nodes along the line.
Definition: Line.hpp:805
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:833
const leanvtk::VTPWriter * getVTK() const
Get the VTK writer.
Definition: Line.hpp:1082
const vec & getNodeVel(unsigned int i) const
Get the velocity of a node.
Definition: Line.hpp:610
void scaleDrag(real scaler)
Scale the drag coefficients.
Definition: Line.hpp:917
const vec & getNodePos(unsigned int i) const
Get the position of a node.
Definition: Line.hpp:586
void setWaves(moordyn::WavesRef waves_in, moordyn::SeafloorRef seafloor_in)
Set the environmental data.
Definition: Line.hpp:414
const real & getNodeCurv(unsigned int i) const
Get the line curvature at a node position.
Definition: Line.hpp:776
const vec & getNodeWeight(unsigned int i) const
Get the weight and bouyancy force acting on the node.
Definition: Line.hpp:707
size_t lineId
Definition: Line.hpp:385
std::pair< real, real > getDrag() const
Get the drag coefficients.
Definition: Line.hpp:902
const mat & getNodeM(unsigned int i) const
Get the mass and added mass matrix.
Definition: Line.hpp:792
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:814
const vec & getNodeBendStiff(unsigned int i) const
Get the tension on a node, including the internal line damping.
Definition: Line.hpp:691
void setUnstretchedLength(const moordyn::real len)
Set the unstretched length of the line.
Definition: Line.hpp:511
moordyn::real getUnstretchedLength() const
Get the unstretched length of the line.
Definition: Line.hpp:500
void updateUnstretchedLength(const moordyn::real dt=0.0)
Update the unstretched length of the line, according to the velocity.
Definition: Line.hpp:537
void setTime(real time)
Set the line simulation time.
Definition: Line.hpp:957
void setConstantEA(moordyn::real EA_in)
Set the constant stiffness of the line.
Definition: Line.hpp:569
void initialize(InstanceStateVarView state)
Sets the initial line state.
Definition: Line.hpp:436
const vec getNodeTen(unsigned int i) const
Get the tension on a node, including the internal line damping.
Definition: Line.hpp:666
const size_t stateN() const
Get the number of state variables required by this instance.
Definition: Line.hpp:1022
void disablePb()
Disable the pressure bending forces (disabled by default)
Definition: Line.hpp:936
int number
Line ID.
Definition: Line.hpp:382
unsigned int getN() const
Number of segments.
Definition: Line.hpp:495
const vec getNodeSeabedForce(unsigned int i) const
Get the sea bed reaction force acting on the node.
Definition: Line.hpp:757
void setDrag(real cdn, real cdt)
Set the drag coefficients.
Definition: Line.hpp:908
const size_t stateDims() const
Get the dimension of the state variable.
Definition: Line.hpp:1040
moordyn::real getConstantEA() const
Get the constant stiffness of the line.
Definition: Line.hpp:561
const vec getNodeDrag(unsigned int i) const
Get the drag force acting on the node.
Definition: Line.hpp:723
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:1288