FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
CableBranched.h
1#pragma once
2
220#include "cable/subroutines/InternalCableWithBottomContact.h"
221
222#include "sfh/timers/StopWatch.h"
223
224#include <fhsim/simobject/SimObject.h>
225#include <fhsim_environment/EnvironmentProvider.h>
226#include <fhsim_environment/SeafloorForcesInterface.h>
227#include <mutex>
228#include <string>
229
230#ifdef FH_VISUALIZATION
231# ifdef USE_BILLBOARD_LABELS
232# include "CMovableText.h"
233# endif
234#endif
235
236// Class definition
237class CableBranched : public SimObject
238{
239public:
241 CableBranched(std::string simObjectName, ISimObjectCreator* creator);
242 CableBranched(std::string simObjectName)
243 : SimObject(simObjectName)
244 { }
245 virtual void aFunction(std::string simObjectName, ISimObjectCreator* creator);
248
249 // Member functions
250 virtual void OdeFcn(const double dT, const double* const adX, double* const adXDot) const;
252 void PreOdeFcn(double T, const double* X, IStateUpdater* updater) override;
253 bool HasJacobians() const override;
254 void OdeJacobian(double T, const double* X, double* J, int nStates) override;
255 int GetJacobianSparsity(int nStates, int* rowPtr, int* colIdx) override;
256 void FinalSetup(const double dT, const double* const adX, ISimObjectCreator* const creator);
257 void InitialConditionSetup(const double dT, const double* const adCurrentIC, double* const adUpdatedIC, ISimObjectCreator* const creator);
258#ifdef FH_VISUALIZATION
260 void RenderInit(Ogre::Root* const ogreRoot, ISimObjectCreator* const creator);
261
263 void RenderUpdate(const double dT, const double* const adX);
264#endif
265
266protected:
267 virtual void CreateStates(ISimObjectCreator* creator);
268 void CalcOutput(const double dT, const double* const adX) const;
270 void UpdateSectionLength(int element, double dT, const double* adX) const;
275 virtual void PrepareSections(double /*dT*/, const double* /*adX*/) const { }
276 void OutputExternalConnForces(double dT, const double* adX);
277 void GetPosAndVelPointer(
278 int node,
279 double dT,
280 const double* const adX,
281 const double** const padPos,
282 const double** const padVel) const;
283
284 const double* GetPosPointer(
285 int node,
286 double dT,
287 const double* const adX) const;
288
289
291 virtual void AddBottomForces(double dT, const double* const adX) const;
292 virtual void CreateDataStructures();
293 virtual void CreateInputports(ISimObjectCreator* creator);
294 virtual void CreateOutputports(ISimObjectCreator* creator);
295
296
298 void CheckNodeNumber(int nodeNumber, std::string nodeDescription, ISimObjectCreator* creator);
299
300 ISignalPort** m_inVel;
301 ISignalPort** m_inPos;
302 ISignalPort** m_inLength;
303 ICommonComputation* m_commonCalc;
304 const double* ExternalForce(const double dT, const double* const adX, int i);
305 const double* ExternalTension(const double dT, const double* const adX, int i);
306 const double* SectionLength(const double dT, const double* const adX, int i);
310 int m_iStateBase = 0;
311 mutable bool m_inBottomContact = false;
312
319 int LocalIndex(int globalStateIndex) const { return globalStateIndex - m_iStateBase; }
327
328 // int* m_numAEndsToExt; ///< The number of elements with the A node connected to each external node.
329 // int* m_numBEndsToExt; ///< The number of elements with the B node connected to each external node.
330 // int** m_aaiAEndsToExt; ///< The elements with the A node connected to each external node.
331 // int** m_aaiBEndsToExt; ///< The elements with the B node connected to each external node.
332
333 // int* m_numElementsPerSection;
337 double m_maxStep;
339 double* m_stiffness;
344 double* m_density;
345 double* m_dE;
346 double* m_diameter;
347 double* m_maxTension;
349 // double* m_inertiaA; ///< The inertia of the connected end A of each eleemnt.
350 // double* m_inertiaB; ///< The inertia of the connected end B of each eleemnt.
351 double* m_nodeForce;
352 double* m_outNodeForce = nullptr;
353 double* m_outNodeInertia = nullptr;
354
358 mutable std::mutex m_sectionMutex;
359 // double* m_forceA; ///< The force on the A nodes.
360 // double* m_forceB; ///< The force on the B nodes.
361 double* m_lengths;
362 double* m_outLengths = nullptr;
363 std::string m_materialName;
364 double m_drawScale;
365 double* m_externalTensions;
367
368 const double* m_padVelWater;
369 environment::EnvironmentProvider* m_environment;
370 environment::SeafloorForcesInterface* m_seafloor;
371 // bool m_outputFcnCalled;
372#ifdef FH_VISUALIZATION
373# ifdef USE_BILLBOARD_LABELS
374 Ogre::SceneNode** m_renderNode;
375 Ogre::CMovableText** m_bBTxt;
376 double m_txtSize;
377# endif
378#endif
379};
Definition CableBranched.h:238
virtual void PrepareSections(double, const double *) const
Definition CableBranched.h:275
double m_drawScale
The scale for which to draw the cable diameter.
Definition CableBranched.h:364
InternalCable ** m_cableSections
An array holding the cable sections.
Definition CableBranched.h:366
int * m_iStateVel
An array of indices to the node velocity states.
Definition CableBranched.h:308
double * m_relaxedLength
The relaxed length of the cable.
Definition CableBranched.h:340
bool m_inBottomContact
Whether a node or an element touched the seabed at the last OdeFcn state.
Definition CableBranched.h:311
CableBranched(std::string simObjectName, ISimObjectCreator *creator)
The constructor sets the pointer to the output object and the parser object.
int * m_iStatePos
An array of indices to the node position states.
Definition CableBranched.h:307
int m_cableFaces
The number of faces of the cable visuaization.
Definition CableBranched.h:326
int m_numExternalConn
The number of external connections.
Definition CableBranched.h:324
ISignalPort ** m_inPos
The position input ports.
Definition CableBranched.h:301
int m_iStateBase
Global index of this SimObject's first state, set in CreateStates().
Definition CableBranched.h:310
virtual void AddBottomForces(double dT, const double *const adX) const
Adds the bottom forces to the main nodes, and sets m_inBottomContact if any of them got one.
double * m_dE
The stiffness of the cable material.
Definition CableBranched.h:345
double * m_density
The density of the cable material.
Definition CableBranched.h:344
int m_numNodesCalc
The number of nodes of the cable between the cable elements.
Definition CableBranched.h:321
double * m_stiffness
The linear stiffness of the cable.
Definition CableBranched.h:339
int * m_nodeConnections
The nodes connected to each cable section.
Definition CableBranched.h:325
double m_eAdaptationPeriod
The time constant of the adaptation of the mean tension.
Definition CableBranched.h:335
double * m_diameter
The diameter of the cable.
Definition CableBranched.h:346
double m_maxLengthChangeSpeed
The maximum speed of the cable length change.
Definition CableBranched.h:342
double * m_lengths
The lengths of the cable elements.
Definition CableBranched.h:361
double * m_outLengths
As m_lengths, as CalcOutput found it for the Length ports.
Definition CableBranched.h:362
~CableBranched()
The destructor deletes dynamically allocated memory.
int LocalIndex(int globalStateIndex) const
Definition CableBranched.h:319
double m_stepSafetyFactor
The safety factor when calculating the Young modulus of the element.
Definition CableBranched.h:334
void UpdateSectionLength(int element, double dT, const double *adX) const
Reads the Length input of a cable section and applies it to the section (MARE-0037).
std::mutex m_sectionMutex
Definition CableBranched.h:358
double m_maxStep
The maximum steplength of the simulation.
Definition CableBranched.h:337
double * m_maxTension
The maximum tension in the cable.
Definition CableBranched.h:347
int m_numCableSections
The number of cable sections in the branched cable, where each section may be comprised of one or mor...
Definition CableBranched.h:322
double * m_dampingRatio
The damping ratio to specify the internal damping.
Definition CableBranched.h:343
double * m_nodeForce
The force on the calculation nodes belonging to this simObject, as OdeFcn found it.
Definition CableBranched.h:351
double m_numericalDamping
The numerical damping of the cable.
Definition CableBranched.h:336
double * m_outNodeForce
As m_nodeForce, as CalcOutput found it for the Force and Tension ports.
Definition CableBranched.h:352
int m_numElements
The number of elements to divide the cable into.
Definition CableBranched.h:320
int * m_iStateCable
An array of indices to the cable sections states.
Definition CableBranched.h:309
double * m_meanTension
The mean tension of the cable.
Definition CableBranched.h:338
ISignalPort ** m_inLength
The cable sections length port.
Definition CableBranched.h:302
double * m_outNodeInertia
As m_nodeInertia, as CalcOutput found it.
Definition CableBranched.h:353
int m_numNodesGlobal
The number of nodes of the branched cable used for conecting the internal cable sections.
Definition CableBranched.h:323
double * m_nodeInertia
The inertia of the calculation nodes belonging to this simObject.
Definition CableBranched.h:348
ICommonComputation * m_commonCalc
Calculations necessary for more than one output port.
Definition CableBranched.h:303
std::string m_materialName
The material name of the cable;.
Definition CableBranched.h:363
double * m_relaxedLength_d
The desired relaxed length of the cable.
Definition CableBranched.h:341
ISignalPort ** m_inVel
The velocity input port s.
Definition CableBranched.h:300
void PreOdeFcn(double T, const double *X, IStateUpdater *updater) override
Applies the Length inputs and advances the sections' mean tension from the step's start state (MARE-0...
void CheckNodeNumber(int nodeNumber, std::string nodeDescription, ISimObjectCreator *creator)
Checks to see if a specified nodenumber is ok.
Definition InternalCable.h:189