FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
Cable.h
1#pragma once
114#include "cable/subroutines/CableElDynStiff.h"
115#include "cable/subroutines/InternalCableWithBottomContact.h"
116
117#include "sfh/timers/Timer.h"
118
119#include <fhsim/simobject/SimObject.h>
120#include <memory>
121#include <mutex>
122#include <string>
123
124// Class definition
125class Cable : public SimObject
126{
127public:
129 Cable(std::string simObjectName, ISimObjectCreator* creator);
130
133
134 // Member functions
135 void OdeFcn(const double dT, const double* const adX, double* const adXDot) const;
137 void PreOdeFcn(double T, const double* X) override;
138 void InitialConditionSetup(const double dT, const double* const adCurrentIC, double* const adUpdatedIC, ISimObjectCreator* const creator);
139 void FinalSetup(const double dT, const double* const adX, ISimObjectCreator* const creator);
140 void CalcOutput(const double dT, const double* const adX) const;
141
143 bool HasJacobians() const override;
144 void OdeJacobian(double T, const double* X, double* J, int nStates) override;
145 int GetJacobianSparsity(int nStates, int* rowPtr, int* colIdx) override;
146
147 const double* OutForceA(const double dT, const double* const adX);
148 const double* OutForceB(const double dT, const double* const adX);
149 const double* OutPosA(const double dT, const double* const adX);
150 const double* OutPosB(const double dT, const double* const adX);
151
152#ifdef FH_VISUALIZATION
153
155 void RenderInit(Ogre::Root* const ogreRoot, ISimObjectCreator* const creator);
156
158 void RenderUpdate(const double dT, const double* const adX);
159#endif
160protected:
161 void UpdateLength(double newLength, double deltaT);
162
164 void UpdateStiffness(const double* const adForceA, const double* const adForceB);
165
168
169
170 ISignalPort* m_inLength;
171 ISignalPort* m_inVelA;
172 ISignalPort* m_inVelB;
173 ISignalPort* m_inPosA;
174 ISignalPort* m_inPosB;
176 ICommonComputation* m_commonCalc;
179 mutable std::mutex m_cableMutex;
180
181 // Member variables
184
185 double m_inertiaA;
186 double m_inertiaB;
187 mutable double m_forceA[3];
188 mutable double m_forceB[3];
189 double* m_lengths;
190 std::string m_cableName;
191
192 std::unique_ptr<InternalCableWithBottomContact> m_internalCable;
194};
Definition Cable.h:126
double * m_lengths
The lengths of the cable elements.
Definition Cable.h:189
ISignalPort * m_inLength
The cable length input port.
Definition Cable.h:170
ISignalPort * m_inPosB
The position B input port.
Definition Cable.h:174
std::string m_cableName
The identification name of the cable;.
Definition Cable.h:190
void InitialConditionSetup(const double dT, const double *const adCurrentIC, double *const adUpdatedIC, ISimObjectCreator *const creator)
functionality for setting initialconditions based on input port results.
bool HasJacobians() const override
False while an element was in seabed contact at the last OdeFcn (MARE-0391); FhSim then differences t...
double m_inertiaB
The inertia of the end B.
Definition Cable.h:186
int m_IStates
The index to the internal states of the cable.
Definition Cable.h:175
std::mutex m_cableMutex
Definition Cable.h:179
~Cable()
The destructor deletes dynamically allocated memory.
std::unique_ptr< InternalCableWithBottomContact > m_internalCable
The cable calculations; owned (it was never deleted, MARE-0427).
Definition Cable.h:192
void PreOdeFcn(double T, const double *X) override
Applies the Length input and advances the elements' mean tension from the step's start state (MARE-03...
ICommonComputation * m_commonCalc
Definition Cable.h:176
Cable(std::string simObjectName, ISimObjectCreator *creator)
The constructor sets the pointer to the output object and the parser object.
double m_forceB[3]
The force on the end B.
Definition Cable.h:188
int m_numElements
The number of elements to divide the cable into.
Definition Cable.h:182
ISignalPort * m_inVelB
The velocity B input port.
Definition Cable.h:172
void UpdateInertia()
Updates the inertia of the cable according to the changing length.
void UpdateStiffness(const double *const adForceA, const double *const adForceB)
Updates the stiffness of the cable to ensure that this is not too large.
double m_inertiaA
The inertia of the end A.
Definition Cable.h:185
ISignalPort * m_inPosA
The position A input port.
Definition Cable.h:173
int m_numNodes
The number of nodes of the cable.
Definition Cable.h:183
SCableSpec m_CableSpec
The cable specification.
Definition Cable.h:193
double m_forceA[3]
The force on the end A.
Definition Cable.h:187
ISignalPort * m_inVelA
The velocity A input port.
Definition Cable.h:171
Contains some specifications used for simulating cables.
Definition InternalCable.h:36