40 #include "Util/CFL.hpp"
41 #include "leanvtk/leanvtk.hpp"
50 typedef std::shared_ptr<Waves>
WavesRef;
87 typedef struct _attachment
96 std::vector<attachment> attachedA;
99 std::vector<attachment> attachedB;
151 std::vector<moordyn::real> l;
156 std::vector<moordyn::real> V;
189 std::vector<vec> Fnet;
193 std::vector<moordyn::real> VOF;
226 return seafloor ? seafloor->getDepthAt(x, y) : -env->WtrDpth;
296 void setup(
int number,
302 shared_ptr<ofstream> outfile,
330 seafloor = seafloor_in;
335 inline void openoutput();
347 std::pair<XYZQuat, vec6> initialize();
351 const auto [pos, vel] = initialize();
352 r.row(0).head<7>() = pos.toVec7();
353 r.row(0).tail<6>() = vel;
364 inline unsigned int getN()
const {
return N; }
375 LOGERR <<
"Asking node " << i <<
" of rod " << number
376 <<
", which only has " << N + 1 <<
" nodes" << std::endl;
377 throw moordyn::invalid_value_error(
"Invalid node index");
379 if (isnan(r[i].sum())) {
381 s <<
"NaN detected" << endl
382 <<
"Rod " << number <<
" node positions:" << endl;
383 for (
unsigned int j = 0; j <= N; j++)
384 s << j <<
" : " << r[j] <<
";" << endl;
385 throw moordyn::nan_error(s.str().c_str());
399 LOGERR <<
"Asking node " << i <<
" of rod " << number
400 <<
", which only has " << N + 1 <<
" nodes" << std::endl;
401 throw moordyn::invalid_value_error(
"Invalid node index");
417 inline std::pair<real, real>
getDrag()
const {
return make_pair(Cdn, Cdt); }
436 CdEnd = CdEnd * scaler;
459 return std::make_pair(r7, v6);
508 void updateFairlead(
real time);
521 void setKinematics(
vec6 r,
vec6 rd);
528 void setDependentStates();
545 const vec6 getFnet()
const;
561 void getNetForceAndMass(
vec6& Fnet_out,
mat6& M_out,
vec rBody,
vec6 vBody);
570 getNetForceAndMass(Fnet_out, M_out, r[0], vec6::Zero());
583 inline const size_t stateN()
const {
return 1; }
601 std::vector<uint64_t> Serialize(
void);
609 uint64_t* Deserialize(
const uint64_t* data);
615 void saveVTK(
const char* filename);
622 const leanvtk::VTPWriter*
getVTK()
const {
return &vtk; }
626 leanvtk::VTPWriter vtk;
633 inline vec getCentripetalForce(
vec r,
vec w)
const
639 for (
unsigned int i = 0; i <= N; i++) {
640 F -= M[i] * (w.cross(w.cross(this->r[i] - r)));
#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
A Logging utility.
Definition: Log.hpp:149
A cylindrical rod.
Definition: Rod.hpp:65
const size_t stateDims() const
Get the dimension of the state variable.
Definition: Rod.hpp:590
void getNetForceAndMass(vec6 &Fnet_out, mat6 &M_out)
Calculate the force and mass contributions of the point on the parent body.
Definition: Rod.hpp:568
size_t rodId
Rod ID.
Definition: Rod.hpp:275
unsigned int getN() const
Number of segments.
Definition: Rod.hpp:364
const mat6 getM() const
Get the rod mass matrix.
Definition: Rod.hpp:552
std::pair< real, real > getDrag() const
Get the drag coefficients.
Definition: Rod.hpp:417
static string TypeName(types t)
Return a string with the name of a type.
Definition: Rod.hpp:257
void setDrag(real cdn, real cdt)
Set the drag coefficients.
Definition: Rod.hpp:423
void initialize(InstanceStateVarView r)
Initialize a free instance.
Definition: Rod.hpp:349
real roll
The roll angle (useful for output)
Definition: Rod.hpp:282
const size_t stateN() const
Get the number of state variables required by this instance.
Definition: Rod.hpp:583
void getState(XYZQuat &pos, vec6 &vel) const
Get the body kinematics.
Definition: Rod.hpp:448
void scaleDrag(real scaler)
Scale the drag coefficients.
Definition: Rod.hpp:432
types type
Rod type.
Definition: Rod.hpp:279
vec getNodePos(unsigned int i) const
Get the position of a node.
Definition: Rod.hpp:372
void setTime(real time)
Set the line simulation time.
Definition: Rod.hpp:442
real pitch
The pitch angle (useful for output)
Definition: Rod.hpp:284
void setWaves(moordyn::WavesRef waves_in, moordyn::SeafloorRef seafloor_in)
Set the environmental data.
Definition: Rod.hpp:326
vec6 getUnfreeVel() const
Get the last setted velocity for an unfree rod.
Definition: Rod.hpp:499
vec getNodeVel(unsigned int i) const
Get the velocity of a node.
Definition: Rod.hpp:396
int number
Rod number.
Definition: Rod.hpp:277
types
Types of rods.
Definition: Rod.hpp:233
const leanvtk::VTPWriter * getVTK() const
Get the VTK writer.
Definition: Rod.hpp:622
std::pair< XYZQuat, vec6 > getState() const
Get the body kinematics.
Definition: Rod.hpp:457
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
Eigen::Vector6d vec6
6-D vector of real numbers
Definition: Misc.hpp:126
Eigen::Matrix6d mat6
6x6 matrix of real numbers
Definition: Misc.hpp:138
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
Definition: Misc.hpp:1292
Definition: Misc.hpp:1188
Joint of a point and a quaternion.
Definition: Misc.hpp:304