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#include <string>
104
105#include "CableJointMoment.h"
106#include "cable/GaussPointDrag.h"
107#include "ElementInertia.h"
108
109#include <fhsim/PrintDuringExec.h>
110#include <fhsim/simobject/SimObject.h>
111#include <fhsim_environment/EnvironmentProvider.h>
112#include <fhsim_environment/SeafloorForcesInterface.h>
113#include <fhsim_environment/ElementFlowInteraction.h>
114#ifdef FH_VISUALIZATION
115# include "sfh/ogre/C3DLine.h"
116#endif
117
118namespace RbCable
119{
129inline bool IsBelowSurface(double z, double surfaceElevation)
130{
131 return z + surfaceElevation > 0.0;
132}
133
215class CableRM : public SimObject
216{
217public:
229 CableRM(const std::string& simObjectName, ISimObjectCreator* const creator);
230 ~CableRM();
240 void OdeFcn(const double T, const double* const X, double* const XDot) const;
241
242 void InitialConditionSetup(const double T, const double* const currentIC, double* const updatedIC, ISimObjectCreator* const creator);
243 void FinalSetup(const double T, const double* const X, ISimObjectCreator* const creator);
245 void PreOdeFcn(const double T, const double* const X) override;
246
256 const double* forceA(const double T, const double* const X);
266 const double* forceB(const double T, const double* const X);
277 void calculations(const double T, const double* const X);
278
285 void BuildChain(wet_cylinder_water::ElementGaussPoints& chain, const double* X, int firstElement, int numElements) const;
286 void QueryGaussPointWater(const double T, const double* const X);
287 void calculationsCommon(const double T, const double* const X) const;
288
289#ifdef FH_VISUALIZATION
290 void RenderInit(Ogre::Root* const ogreRoot, ISimObjectCreator* const creator);
291 void RenderUpdate(const double T, const double* const X);
292#endif
293
294protected:
295 typedef Eigen::Matrix<double, 3, 3> mat3;
296 typedef Eigen::Matrix<double, 3, 1> vec3;
297
306 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);
307
310 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);
311
314 void SetElementUnlessUserSet(int i, const vec3& centre, double angle, const Eigen::Matrix<double, 2, 1>& CatenaryU, const double* currentIC, double* states);
315
320 [[noreturn]] void ReportError(const std::string& message) const;
321
322 PrintDuringExec* m_print;
323 environment::SeafloorForcesInterface* m_seafloor = nullptr;
324 environment::wake::ElementFlowInteraction m_flow;
325
326 int m_numElements;
327 double m_totalLength;
328 double m_radius;
329 double m_weight;
330 double m_alphaN;
331 double m_betaN;
332 double m_epsilonN;
333
335
336 // double m_rho;
337 // double m_surfacePosZ;
338 // double m_rhoWater;
339 // double m_Ct; // tangential damping coefficient
340 // double m_Cn; // normal damping coefficient
341
342 double m_length;
343 double m_mass;
344 double m_Ixy;
345 double m_Iz;
346 // bool TEMP_BOOL_VAR__ISMAJORTIMESTEP;
347
348 // Sugar kelp rope application - start
349 bool m_kelp; // 1 if used as a kelp rope, 0 otherwise
350 double m_wKelp; // Biomass of kelp per meter rope/cable in Newtons
351 // Sugar kelp rope application - end
352
353 bool m_gaussPointDrag = true;
356
357 struct element
358 {
359 int p;
360 int q;
361 int v;
362 int w;
363 mat3 Mi;
364 mat3 MiT;
365 vec3 k;
366 vec3 eDot;
367 double nuDot;
368 };
369 element* m_el;
370
371 ISignalPort* m_posA;
372 ISignalPort* m_posB;
373 ISignalPort* m_velA;
374 ISignalPort* m_velB;
375 ISignalPort* m_retractedLengthA;
376 ISignalPort* m_retractedLengthB;
377 ISignalPort* m_retractedSpeedA;
378 ISignalPort* m_retractedSpeedB;
379
380 int m_retractedNodesA;
381 int m_retractedNodesB;
382 int m_numFreeNodes;
383
386 {
387 double lengthA;
388 double lengthB;
389 double speedA;
390 double speedB;
391 int nodesA;
392 int nodesB;
393 };
394
408 Retraction ClampRetraction(double lengthA, double lengthB, double speedA, double speedB) const;
409
410 vec3 m_ka;
411 vec3 m_kb;
412
413 ICommonComputation* m_calcDynamics;
414 Eigen::Matrix<double, Eigen::Dynamic, 1> m_lambda;
415 Eigen::Matrix<double, Eigen::Dynamic, 1> m_F_MDotV; //< external force F, minus Coriolis term dM/dt*V
416 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
417
418 double m_forceA[3];
419 double m_forceB[3];
420
421#ifdef FH_VISUALIZATION
422 double m_scale;
423 Ogre::SceneNode** m_ManualObjectNodes;
424#endif
425};
426} // namespace RbCable
Definition Cable.h:216
bool m_gaussPointDrag
Gauss-point drag with the water at the Gauss points (MARE-0396).
Definition Cable.h:353
wet_cylinder_water::ElementGaussPoints m_gaussPoints
The Gauss points of the free elements and the water at them; buffers kept from call to call.
Definition Cable.h:354
void ReportError(const std::string &message) const
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:324
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:322
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:334
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.
wet_cylinder_water::ElementGaussPoints m_takeGaussPoints
The Gauss points of all elements, where the wakes are taken (PreOdeFcn); buffers kept from call to ca...
Definition Cable.h:355
environment::SeafloorForcesInterface * m_seafloor
The shared SeafloorForces, from FinalSetup: the soil load of each element, a rigid cylinder.
Definition Cable.h:323
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.
void BuildChain(wet_cylinder_water::ElementGaussPoints &chain, const double *X, int firstElement, int numElements) const
Builds chain from elements firstElement ... firstElement + numElements - 1 at the state X.
Definition GaussPointDrag.h:56
The retraction of the two ends as the model uses it at one instant (ClampRetraction).
Definition Cable.h:386
int nodesB
Whole elements retracted at end B.
Definition Cable.h:392
double lengthB
Retracted length at end B [m], after the limits.
Definition Cable.h:388
int nodesA
Whole elements retracted at end A.
Definition Cable.h:391
double speedA
Retraction speed at end A [m/s]; 0 where the length was limited.
Definition Cable.h:389
double speedB
Retraction speed at end B [m/s]; 0 where the length was limited.
Definition Cable.h:390
double lengthA
Retracted length at end A [m], after the limits.
Definition Cable.h:387
Definition Cable.h:358
mat3 MiT
The inverse of the translational inertia with the added mass normal to the axis, global frame (MARE-0...
Definition Cable.h:364
mat3 Mi
The inverse of the rotational inertia, global frame.
Definition Cable.h:363
Definition CableJointMoment.h:26