FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
Cable.h
1#pragma once
99#include <fhsim_environment/hydrodynamics/CylinderHydro.h>
100
101#include <Eigen/Eigen>
102#include <cmath>
103
104#include "CableJointMoment.h"
105#include "cable/GaussPointDrag.h"
106#include "ElementInertia.h"
107
108#include <fhsim/PrintDuringExec.h>
109#include <fhsim/simobject/SimObject.h>
110#include <fhsim_environment/EnvironmentProvider.h>
111#include <fhsim_environment/SeafloorForcesInterface.h>
112#include <fhsim_environment/ElementFlowInteraction.h>
113#ifdef FH_VISUALIZATION
114# include "sfh/ogre/C3DLine.h"
115#endif
116
117namespace RbCable
118{
128inline bool IsBelowSurface(double z, double surfaceElevation)
129{
130 return z + surfaceElevation > 0.0;
131}
132
214class CableRM : public SimObject
215{
216public:
228 CableRM(const std::string& simObjectName, ISimObjectCreator* const creator);
229 ~CableRM();
239 void OdeFcn(const double T, const double* const X, double* const XDot) const;
240
241 void InitialConditionSetup(const double T, const double* const currentIC, double* const updatedIC, ISimObjectCreator* const creator);
242 void FinalSetup(const double T, const double* const X, ISimObjectCreator* const creator);
244 void PreOdeFcn(const double T, const double* const X) override;
245
255 const double* forceA(const double T, const double* const X);
265 const double* forceB(const double T, const double* const X);
276 void calculations(const double T, const double* const X);
277
284 void BuildChain(wet_cylinder_water::ChainJoints& chain, const double* X, int firstElement, int numElements) const;
285 void QueryJointWater(const double T, const double* const X);
286 void calculationsCommon(const double T, const double* const X) const;
287
288#ifdef FH_VISUALIZATION
289 void RenderInit(Ogre::Root* const ogreRoot, ISimObjectCreator* const creator);
290 void RenderUpdate(const double T, const double* const X);
291#endif
292
293protected:
294 typedef Eigen::Matrix<double, 3, 3> mat3;
295 typedef Eigen::Matrix<double, 3, 1> vec3;
296
305 void DistributeCatenary(Eigen::Matrix<double, 3, 1> P1, Eigen::Matrix<double, 3, 1> P2, double L, double lengthA, double lengthB, const double* currentIC, double* states, int i1, int i2);
306
309 void DistributeOnArcMidpoints(const vec3& P1, const Eigen::Matrix<double, 2, 1>& CatenaryU, double HorizontalDistance, double VerticalDifference, double L, const double* currentIC, double* states, int i1, int i2);
310
313 void SetElementUnlessUserSet(int i, const vec3& centre, double angle, const Eigen::Matrix<double, 2, 1>& CatenaryU, const double* currentIC, double* states);
314
319 [[noreturn]] void ReportError(const std::string& message) const;
320
321 PrintDuringExec* m_print;
322 environment::SeafloorForcesInterface* m_seafloor = nullptr;
323 environment::wake::ElementFlowInteraction m_flow;
324
325 int m_numElements;
326 double m_totalLength;
327 double m_radius;
328 double m_weight;
329 double m_alphaN;
330 double m_betaN;
331 double m_epsilonN;
332
334
335 // double m_rho;
336 // double m_surfacePosZ;
337 // double m_rhoWater;
338 // double m_Ct; // tangential damping coefficient
339 // double m_Cn; // normal damping coefficient
340
341 double m_length;
342 double m_mass;
343 double m_Ixy;
344 double m_Iz;
345 // bool TEMP_BOOL_VAR__ISMAJORTIMESTEP;
346
347 // Sugar kelp rope application - start
348 bool m_kelp; // 1 if used as a kelp rope, 0 otherwise
349 double m_wKelp; // Biomass of kelp per meter rope/cable in Newtons
350 // Sugar kelp rope application - end
351
352 bool m_gaussPointDrag = true;
355
356 struct element
357 {
358 int p;
359 int q;
360 int v;
361 int w;
362 mat3 Mi;
363 mat3 MiT;
364 vec3 k;
365 vec3 eDot;
366 double nuDot;
367 };
368 element* m_el;
369
370 ISignalPort* m_posA;
371 ISignalPort* m_posB;
372 ISignalPort* m_velA;
373 ISignalPort* m_velB;
374 ISignalPort* m_retractedLengthA;
375 ISignalPort* m_retractedLengthB;
376 ISignalPort* m_retractedSpeedA;
377 ISignalPort* m_retractedSpeedB;
378
379 int m_retractedNodesA;
380 int m_retractedNodesB;
381 int m_numFreeNodes;
382
385 {
386 double lengthA;
387 double lengthB;
388 double speedA;
389 double speedB;
390 int nodesA;
391 int nodesB;
392 };
393
407 Retraction ClampRetraction(double lengthA, double lengthB, double speedA, double speedB) const;
408
409 vec3 m_ka;
410 vec3 m_kb;
411
412 ICommonComputation* m_calcDynamics;
413 Eigen::Matrix<double, Eigen::Dynamic, 1> m_lambda;
414 Eigen::Matrix<double, Eigen::Dynamic, 1> m_F_MDotV; //< external force F, minus Coriolis term dM/dt*V
415 Eigen::Matrix<double, Eigen::Dynamic, 1> m_B; //< right-hand side of the constraint system in OdeFcn; a member so that OdeFcn does not allocate it
416
417 double m_forceA[3];
418 double m_forceB[3];
419
420#ifdef FH_VISUALIZATION
421 double m_scale;
422 Ogre::SceneNode** m_ManualObjectNodes;
423#endif
424};
425} // namespace RbCable
Definition Cable.h:215
bool m_gaussPointDrag
Gauss-point drag with the water at the joints (MARE-0396).
Definition Cable.h:352
void ReportError(const std::string &message) const
void BuildChain(wet_cylinder_water::ChainJoints &chain, const double *X, int firstElement, int numElements) const
Builds chain from elements firstElement ... firstElement + numElements - 1 at the state X.
Retraction ClampRetraction(double lengthA, double lengthB, double speedA, double speedB) const
CableRM(const std::string &simObjectName, ISimObjectCreator *const creator)
Reads parameters, registers states, input/output ports and shared resources.
environment::wake::ElementFlowInteraction m_flow
The flow at the element centres, the other objects' wakes taken per step (MARE-0223); the Environment...
Definition Cable.h:323
wet_cylinder_water::ChainJoints m_takeJoints
The joints of all elements, where the wakes are taken (PreOdeFcn); buffers kept from call to call.
Definition Cable.h:354
void SetElementUnlessUserSet(int i, const vec3 &centre, double angle, const Eigen::Matrix< double, 2, 1 > &CatenaryU, const double *currentIC, double *states)
PrintDuringExec * m_print
Null if the creator has no printer (fhsim::kSimMgrKeyPrinter), as in a unit test.
Definition Cable.h:321
void DistributeOnArcMidpoints(const vec3 &P1, const Eigen::Matrix< double, 2, 1 > &CatenaryU, double HorizontalDistance, double VerticalDifference, double L, const double *currentIC, double *states, int i1, int i2)
void PreOdeFcn(const double T, const double *const X) override
Takes the other objects' wakes at the centres of all elements for the step (MARE-0223).
void DistributeCatenary(Eigen::Matrix< double, 3, 1 > P1, Eigen::Matrix< double, 3, 1 > P2, double L, double lengthA, double lengthB, const double *currentIC, double *states, int i1, int i2)
JointLaw m_joint
The bending and twist moments of the joints between the elements (MARE-0395).
Definition Cable.h:333
const double * forceB(const double T, const double *const X)
Output port. Returns current force in endpoint B of cable.
const double * forceA(const double T, const double *const X)
Output port. Returns current force in endpoint A of cable.
environment::SeafloorForcesInterface * m_seafloor
The shared SeafloorForces, from FinalSetup: the soil load of each element, a rigid cylinder.
Definition Cable.h:322
void calculations(const double T, const double *const X)
Performs a series of computations within the cable object.
void OdeFcn(const double T, const double *const X, double *const XDot) const
Computes object derivatives as a function of time, states and input ports.
wet_cylinder_water::ChainJoints m_chainJoints
The joints of the free elements and the water at them; buffers kept from call to call.
Definition Cable.h:353
Definition GaussPointDrag.h:58
The retraction of the two ends as the model uses it at one instant (ClampRetraction).
Definition Cable.h:385
int nodesB
Whole elements retracted at end B.
Definition Cable.h:391
double lengthB
Retracted length at end B [m], after the limits.
Definition Cable.h:387
int nodesA
Whole elements retracted at end A.
Definition Cable.h:390
double speedA
Retraction speed at end A [m/s]; 0 where the length was limited.
Definition Cable.h:388
double speedB
Retraction speed at end B [m/s]; 0 where the length was limited.
Definition Cable.h:389
double lengthA
Retracted length at end A [m], after the limits.
Definition Cable.h:386
Definition Cable.h:357
mat3 MiT
The inverse of the translational inertia with the added mass normal to the axis, global frame (MARE-0...
Definition Cable.h:363
mat3 Mi
The inverse of the rotational inertia, global frame.
Definition Cable.h:362
Definition CableJointMoment.h:26