FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
CableElBasics.h
1
9
10#ifndef CCableElBasics_H
11#define CCableElBasics_H
12
13// Includes
14#include <string>
15
16#include <fhsim_environment/hydrodynamics/CylinderHydro.h>
17#include <fhsim_environment/hydrodynamics/WetCylinderLaw.h>
18
19#include <assert.h>
20#include <fhsim/Exceptions.h>
21#include <string>
22
23#ifdef FH_VISUALIZATION
24# undef ATTACH_SPHERE
25// #define SIMPLE_LINE_RENDERING
26# pragma warning(push)
27# pragma warning(disable : 4251)
28# include <Ogre.h>
29# pragma warning(pop)
30# include "sfh/ogre/CDynamicLines.h"
31#endif
32
33// kMaxCompressionSpeedSaturation, kMinLengthSaturation and kMaxLengthSaturation: CalcFoundation bounds
34// the stored length (the drag uses it too) and compression speed with them.
35#include "cable/subroutines/CableAxialLaw.h"
36
37// Class definition
38
40{
41public:
44
47
49 virtual void AddEndForces(
50 const double adPosA[3],
51 const double adVelA[3],
52 const double adPosB[3],
53 const double adVelB[3],
54 const double adFluidVel[3],
55 const double rhoWater,
56 double adForceA[3],
57 double adForceB[3]);
58
60 virtual void SetConstants();
61
63 virtual void CalcMassAndWeight();
64
66 virtual bool CheckAndInitialize();
67
69 const std::string& FailedCheck() const { return m_failedCheck; }
70
72 double GetDampingCoeff() const { return ma_dDampingCoeff; }
73
75 virtual void UpdateLength(double newLength);
76
77 double GetLength();
78#ifdef FH_VISUALIZATION
80 virtual void RenderInit(Ogre::Root* ogreRoot);
81
83 virtual void RenderUpdate(const double adPosA[3], const double adPosB[3]);
84
85 const double* const GetDirection() { return ma_adDirection; }
86#endif
87 unsigned long m_iD;
88 std::string m_cableName;
89 double m_dL0;
90 double m_dD;
91 double m_dE;
92 double m_rho;
96 double m_rhoWater;
97 double m_rhoWaterFull = 1025.0;
98 double m_rhoAir = 1.2;
99
107 void SetSurfaceElevation(double etaA, double etaB)
108 {
109 m_surfaceElevation[0] = etaA;
110 m_surfaceElevation[1] = etaB;
111 }
112
114 virtual double SurfaceHalfSize() const { return 0.5 * m_dD; }
115
120 void SetWaveAcceleration(const double acceleration[3])
121 {
122 for (int k = 0; k < 3; k++)
123 m_waveAcceleration[k] = acceleration[k];
124 }
125
129
131 double InertiaShare() const;
132
143 void WaveExcitationPositionJacobian(const double posA[3], const double posB[3], const double acceleration[3], double dF_dpB[9]) const;
144
158 const double posA[3], const double posB[3],
159 const double velA[3], const double velB[3],
160 const double vFluid[3], double rhoWater,
161 double dFA_dvA[9], double dFA_dvB[9],
162 double dFB_dvA[9], double dFB_dvB[9]) const;
163
176 const double posA[3], const double posB[3],
177 const double velA[3], const double velB[3],
178 const double vFluid[3], double rhoWater,
179 double dFA_dpA[9], double dFA_dpB[9],
180 double dFB_dpA[9], double dFB_dpB[9]) const;
181
190 double BlendedFluidDensity(const double posA[3], const double posB[3]) const;
191 double m_minLength;
194
195 // Calculated properties.
196 double m_eA;
197 double m_dA;
198 double m_weightInWater[2];
199 double m_massInWater[2];
202#ifdef FH_VISUALIZATION
203 std::string m_materialName;
204 unsigned short m_cableFaces;
205 double m_drawScale;
206#endif
207protected:
209 bool Require(bool passed, const std::string& requirement, double value);
210
211 std::string m_failedCheck;
212
214 virtual bool AppendagesNearTheSurface() { return false; }
215
216 double m_surfaceElevation[2] = {0.0, 0.0};
217 double m_submergence[2] = {1e10, 1e10};
218 double m_axisVertical = 0.0;
219 double m_wetFraction = 1.0;
220 double m_waveAcceleration[3] = {0.0, 0.0, 0.0};
221
229 double WetFractionAt(const double posA[3], const double posB[3], double submergence[2], double& axisVertical) const;
230
232 void AddWaveExcitationCable(double adForceA[3], double adForceB[3]) const;
233
236 void CalcFoundation(const double adPosA[3],
237 const double adVelA[3],
238 const double adPosB[3],
239 const double adVelB[3],
240 const double adFluidVel[3],
241 const double rhoWater);
242
245 virtual void AddStructuralForces(double adForceA[3], double adForceB[3]) = 0;
246
248 void AddGravityBuoyancy(double adForceA[3], double adForceB[3], const double adPosA[3], const double adPosB[3]);
249
251 void AddHydroForcesCable(double adForceA[3], double adForceB[3]);
252
253
254 // For computational efficiency.
255 double ma_adDirection[3];
257 double ma_adVel[3];
258 double ma_dVelAmp;
259 double ma_adVt[3];
260 double ma_dVtAmp;
261 double ma_adVn[3];
262 double ma_dVnAmp;
263 double ma_adVn_A[3];
264 double ma_adVn_B[3];
265 double ma_dVnAmp_A;
266 double ma_dVnAmp_B;
267 double ma_adVt_A[3];
268 double ma_adVt_B[3];
269 double ma_dVtAmp_A;
270 double ma_dVtAmp_B;
271 double ma_dLength;
273
274#ifdef FH_VISUALIZATION
275 Ogre::Root* m_ogreRoot;
276 Ogre::SceneManager* m_sceneMgr;
277 Ogre::Entity* m_renderElement;
278 Ogre::SceneNode* m_renderNode;
279 CDynamicLines* m_lines;
280 Ogre::ManualObject* m_cableRenderObj;
281 double m_drawDiam;
282# ifdef ATTACH_SPHERE
283 Ogre::Entity* m_renderSphere;
284 Ogre::SceneNode* m_renderNodeSphere;
285# endif
286
287#endif
288};
289
290
291#endif
Class containing a fundamental cable element object.
Definition CableElBasics.h:40
virtual double SurfaceHalfSize() const
The half-size the surface gate needs: the element's radius; larger with floats (NetCableElement).
Definition CableElBasics.h:114
double ma_dDampingCoeff
A intermediate damping calculation to increase the computational efficiency.
Definition CableElBasics.h:256
double m_waveAcceleration[3]
The water particle acceleration at the element (SetWaveAcceleration) [m/s²].
Definition CableElBasics.h:220
void AddHydroForcesCable(double adForceA[3], double adForceB[3])
Calculates the hydrodynamic forces on the cable and the spheres and disks attached to it....
double ma_dVnAmp_A
The scalar hydrodynamic normal velocity of the end A (saturated with the vector).
Definition CableElBasics.h:265
double m_submergence[2]
z + η at the ends at the last CalcFoundation [m]; deep before the first.
Definition CableElBasics.h:217
~CableElBasics()
The destructor.
void SetSurfaceElevation(double etaA, double etaB)
Definition CableElBasics.h:107
double m_rhoWaterFull
The water density the owner passed, unblended [kg/m³]; also that of the stiffness factor (CableElDynS...
Definition CableElBasics.h:97
double InertiaShare() const
The inertia force factor of one end node: half of (1 + Ca) rho V f (environment::cylinder_hydro::Iner...
CableElBasics()
The constructor.
double ma_adVt_B[3]
The hydrodynamic axial velocity of the end B.
Definition CableElBasics.h:268
double ma_dCompressionSpeed
The speed at which the distance between the two ends decreases.
Definition CableElBasics.h:272
double ma_adVt_A[3]
The hydrodynamic axial velocity of the end A: its own velocity against the water, the part along the ...
Definition CableElBasics.h:267
double m_rhoWater
The density of the surrounding fluid: the water density blended with the air density by the submerged...
Definition CableElBasics.h:96
double ma_dVtAmp_A
The speed of the hydrodynamic axial velocity of the end A (unsigned, saturated with the vector).
Definition CableElBasics.h:269
const std::string & FailedCheck() const
The first check of the last CheckAndInitialize that failed, naming the property and its value; empty ...
Definition CableElBasics.h:69
double ma_dVelAmp
The scalar average hydrodynamic velocity of the element.
Definition CableElBasics.h:258
double m_surfaceElevation[2]
η above the ends [m] (SetSurfaceElevation).
Definition CableElBasics.h:216
double ma_dVnAmp
The scalar average normal hydrodynamic velocity of the element.
Definition CableElBasics.h:262
double m_dE
The Young modulus of the element.
Definition CableElBasics.h:91
double WetFractionAt(const double posA[3], const double posB[3], double submergence[2], double &axisVertical) const
double m_wetFraction
The element's wet fraction at the last CalcFoundation (CylinderWetFraction).
Definition CableElBasics.h:219
void DragPositionJacobian(const double posA[3], const double posB[3], const double velA[3], const double velB[3], const double vFluid[3], double rhoWater, double dFA_dpA[9], double dFA_dpB[9], double dFB_dpA[9], double dFB_dpB[9]) const
double m_rhoAir
The air density, kg/m³; the owner sets the environment's (cable_air::EnvironmentAirDensity,...
Definition CableElBasics.h:98
double m_normalDragCoeff
The normal drag coefficient of the cable element.
Definition CableElBasics.h:95
double ma_dVtAmp_B
The speed of the hydrodynamic axial velocity of the end B.
Definition CableElBasics.h:270
double ma_adDirection[3]
Memory allocation to increase the computational efficiency.
Definition CableElBasics.h:255
double BlendedFluidDensity(const double posA[3], const double posB[3]) const
double m_massInWaterPerMeter[2]
The mass in water distributed to each node, per meter cable.
Definition CableElBasics.h:201
double ma_adVel[3]
The average hydrodynamic velocity of the element.
Definition CableElBasics.h:257
std::string m_failedCheck
See FailedCheck().
Definition CableElBasics.h:211
double m_dD
The diameter of the element.
Definition CableElBasics.h:90
double ma_adVt[3]
The average tangential hydrodynamic velocity of the element.
Definition CableElBasics.h:259
double m_weightInWaterPerMeter[2]
The weight in water distributed to each node, per meter cable.
Definition CableElBasics.h:200
void AddWaveExcitationCable(double adForceA[3], double adForceB[3]) const
Adds the rope's Froude-Krylov and added-mass wave excitation (owner rulings R67, R104)....
void SetWaveAcceleration(const double acceleration[3])
Definition CableElBasics.h:120
virtual void UpdateLength(double newLength)
Upates the length of the cable element, and its dependant properties.
double ma_dVnAmp_B
The scalar hydrodynamic normal velocity of the end B.
Definition CableElBasics.h:266
double m_minLength
The minimum length of the element.
Definition CableElBasics.h:191
virtual bool CheckAndInitialize()
Does the initialization and checking to make sure that the element is ready for simulation.
virtual bool AppendagesNearTheSurface()
True when a float on the element is near the surface, so its weight must be recomputed every call; no...
Definition CableElBasics.h:214
void CalcFoundation(const double adPosA[3], const double adVelA[3], const double adPosB[3], const double adVelB[3], const double adFluidVel[3], const double rhoWater)
double m_addedWeightInWater
The weight in water added to the element.
Definition CableElBasics.h:93
double m_weightInWater[2]
The weight in water distributed to each node.
Definition CableElBasics.h:198
double m_eA
The linear stiffness of the element.
Definition CableElBasics.h:196
bool Require(bool passed, const std::string &requirement, double value)
Returns passed; when it is false and no earlier check failed, records "@p requirement (is @p value)" ...
double ma_adVn_B[3]
The hydrodynamic normal velocity of the end B.
Definition CableElBasics.h:264
double ma_dLength
The actual distance between the ends.
Definition CableElBasics.h:271
double m_maxTension
The maximum tension in the element.
Definition CableElBasics.h:192
virtual void AddStructuralForces(double adForceA[3], double adForceB[3])=0
double m_dL0
The relaxed length of the element.
Definition CableElBasics.h:89
double m_axisVertical
The vertical component of the unit axis A→B at the last CalcFoundation.
Definition CableElBasics.h:218
double m_dA
The cross sectional area of the cable.
Definition CableElBasics.h:197
virtual void AddEndForces(const double adPosA[3], const double adVelA[3], const double adPosB[3], const double adVelB[3], const double adFluidVel[3], const double rhoWater, double adForceA[3], double adForceB[3])
Calculates the end forces on the cable element.
double ma_adVn_A[3]
The hydrodynamic normal velocity of the end A: its own velocity against the water,...
Definition CableElBasics.h:263
double ma_dVtAmp
The scalar average tangential hydrodynamic velocity of the element.
Definition CableElBasics.h:260
double m_massInWater[2]
The mass in water distributed to each node.
Definition CableElBasics.h:199
double ma_adVn[3]
The average normal hydrodynamic velocity of the element.
Definition CableElBasics.h:261
unsigned long m_iD
The ID of the element.
Definition CableElBasics.h:87
virtual void CalcMassAndWeight()
Calculates the mass and weight of the element in water.
void AddGravityBuoyancy(double adForceA[3], double adForceB[3], const double adPosA[3], const double adPosB[3])
Adds the forces from gravity and buoyancy to the nodes. CalcFoundation must be run first.
void WaveExcitationPositionJacobian(const double posA[3], const double posB[3], const double acceleration[3], double dF_dpB[9]) const
void DragVelocityJacobian(const double posA[3], const double posB[3], const double velA[3], const double velB[3], const double vFluid[3], double rhoWater, double dFA_dvA[9], double dFA_dvB[9], double dFB_dvA[9], double dFB_dvB[9]) const
virtual void SetConstants()
Calculates parameters and sets physical constants.
double m_tangentialFrictionCoeff
The tangential drag coefficient of the cable element.
Definition CableElBasics.h:94
double GetDampingCoeff() const
Returns the structural damping coefficient (negative value: -2*dampRatio*area*sqrt(E*rho)).
Definition CableElBasics.h:72
double m_rho
The density of the element material.
Definition CableElBasics.h:92
std::string m_cableName
The name of the parent cable.
Definition CableElBasics.h:88
double m_dampingRatio
The relative damping ratio of the cable.
Definition CableElBasics.h:193