FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
Cable.h
1#pragma once
134#include <fhsim_environment/hydrodynamics/CylinderHydro.h>
135
136#include <Eigen/Eigen>
137#include <cmath>
138
139#include <fhsim/PrintDuringExec.h>
140#include <fhsim/simobject/SimObject.h>
141#include <fhsim_environment/EnvironmentProvider.h>
142#ifdef FH_VISUALIZATION
143# include "sfh/ogre/C3DLine.h"
144#endif
145
146namespace RbCable
147{
157inline bool IsBelowSurface(double z, double surfaceElevation)
158{
159 return z + surfaceElevation > 0.0;
160}
161
164{
165 double normal;
166 double tangential;
167 double torsional;
168};
169
188inline DragCoefficients ElementDragCoefficients(double crossFlowReynolds, double reynolds)
189{
190 DragCoefficients c {};
191 c.normal = environment::cylinder_hydro::NormalDragCoefficient(crossFlowReynolds);
192 c.tangential = environment::cylinder_hydro::TangentialDragCoefficient(reynolds);
193 c.torsional = reynolds < environment::cylinder_hydro::kCriticalReynolds ? environment::cylinder_hydro::NormalDragCoefficient(reynolds) : 0.1;
194 return c;
195}
196
266class CableRM : public SimObject
267{
268public:
280 CableRM(const std::string& simObjectName, ISimObjectCreator* const creator);
281 ~CableRM();
291 void OdeFcn(const double T, const double* const X, double* const XDot) const;
292
293 void InitialConditionSetup(const double T, const double* const currentIC, double* const updatedIC, ISimObjectCreator* const creator);
294 void FinalSetup(const double T, const double* const X, ISimObjectCreator* const creator);
295
305 const double* forceA(const double T, const double* const X);
315 const double* forceB(const double T, const double* const X);
326 void calculations(const double T, const double* const X);
327 void calculationsCommon(const double T, const double* const X) const;
328
329#ifdef FH_VISUALIZATION
330 void RenderInit(Ogre::Root* const ogreRoot, ISimObjectCreator* const creator);
331 void RenderUpdate(const double T, const double* const X);
332#endif
333
334protected:
335 typedef Eigen::Matrix<double, 3, 3> mat3;
336 typedef Eigen::Matrix<double, 3, 1> vec3;
337
338 void DistributeCatenary(Eigen::Matrix<double, 3, 1> P1, Eigen::Matrix<double, 3, 1> P2, double L, double* states, int i1, int i2, ISimObjectCreator* creator);
339
340 PrintDuringExec* m_print;
341 environment::EnvironmentProvider* m_environment;
342
343 int m_numElements;
344 double m_totalLength;
345 double m_radius;
346 double m_weight;
347 double m_alphaN;
348 double m_betaN;
349 double m_epsilonN;
350 double m_alphaM;
351 double m_betaM;
352 double m_epsilonM;
353 double m_alphaT;
354 double m_betaT;
355 double m_epsilonT;
356
357 double m_bending_epsilon[3];
358
359 // double m_rho;
360 // double m_surfacePosZ;
361 // double m_rhoWater;
362 // double m_Ct; // tangential damping coefficient
363 // double m_Cn; // normal damping coefficient
364
365 double m_length;
366 double m_mass;
367 double m_Ixy;
368 double m_Iz;
369 // bool TEMP_BOOL_VAR__ISMAJORTIMESTEP;
370
371 // Sugar kelp rope application - start
372 bool m_kelp; // 1 if used as a kelp rope, 0 otherwise
373 double m_wKelp; // Biomass of kelp per meter rope/cable in Newtons
374 // Sugar kelp rope application - end
375
376 struct element
377 {
378 int p;
379 int q;
380 int v;
381 int w;
382 mat3 Mi;
383 vec3 k;
384 mat3 K;
385 vec3 eDot;
386 double nuDot;
387 };
388 element* m_el;
389
390 ISignalPort* m_posA;
391 ISignalPort* m_posB;
392 ISignalPort* m_velA;
393 ISignalPort* m_velB;
394 ISignalPort* m_retractedLengthA;
395 ISignalPort* m_retractedLengthB;
396 ISignalPort* m_retractedSpeedA;
397 ISignalPort* m_retractedSpeedB;
398
399 int m_retractedNodesA;
400 int m_retractedNodesB;
401 int m_numFreeNodes;
402
403 vec3 m_ka;
404 vec3 m_kb;
405
406 ICommonComputation* m_calcDynamics;
407 Eigen::Matrix<double, Eigen::Dynamic, 1> m_lambda;
408 Eigen::Matrix<double, Eigen::Dynamic, 1> m_F_MDotV; //< external force F, minus Coriolis term dM/dt*V
409 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
410
411 double m_forceA[3];
412 double m_forceB[3];
413
414#ifdef FH_VISUALIZATION
415 double m_scale;
416 Ogre::SceneNode** m_ManualObjectNodes;
417#endif
418};
419} // namespace RbCable
Definition Cable.h:267
CableRM(const std::string &simObjectName, ISimObjectCreator *const creator)
Reads parameters, registers states, input/output ports and shared resources.
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.
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.
Definition Cable.h:377
The drag coefficients of a CableRM element.
Definition Cable.h:164
double normal
Cd, on the flow normal to the axis.
Definition Cable.h:165
double torsional
The coefficient of the torsional drag on the spin about the axis.
Definition Cable.h:167
double tangential
Ct, the skin friction on the flow along the axis (owner ruling R68).
Definition Cable.h:166