FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
Cable.h
1#pragma once
158
159#include "cable/subroutines/CableElDynStiff.h"
160#include "cable/subroutines/InternalCableWithBottomContact.h"
161
162#include "sfh/timers/Timer.h"
163
164#include <fhsim/simobject/SimObject.h>
165#include <string>
166
167// Class definition
168class Cable : public SimObject
169{
170public:
172 Cable(std::string simObjectName, ISimObjectCreator* creator);
173
176
177 // Member functions
178 void OdeFcn(const double dT, const double* const adX, double* const adXDot) const;
179 void InitialConditionSetup(const double dT, const double* const adCurrentIC, double* const adUpdatedIC, ISimObjectCreator* const creator);
180 void FinalSetup(const double dT, const double* const adX, ISimObjectCreator* const creator);
181 void CalcOutput(const double dT, const double* const adX) const;
182
183 bool HasJacobians() const override;
184 void OdeJacobian(double T, const double* X, double* J, int nStates) override;
185 int GetJacobianSparsity(int nStates, int* rowPtr, int* colIdx) override;
186
187 const double* OutForceA(const double dT, const double* const adX);
188 const double* OutForceB(const double dT, const double* const adX);
189 const double* OutPosA(const double dT, const double* const adX);
190 const double* OutPosB(const double dT, const double* const adX);
191
192#ifdef FH_VISUALIZATION
193
195 void RenderInit(Ogre::Root* const ogreRoot, ISimObjectCreator* const creator);
196
198 void RenderUpdate(const double dT, const double* const adX);
199#endif
200protected:
201 void UpdateLength(double newLength, double deltaT);
202
204 void UpdateStiffness(const double* const adForceA, const double* const adForceB);
205
208
209
210 ISignalPort* m_inLength;
211 ISignalPort* m_inVelA;
212 ISignalPort* m_inVelB;
213 ISignalPort* m_inPosA;
214 ISignalPort* m_inPosB;
216 ICommonComputation* m_commonCalc;
217
218 // Member variables
221
222 double m_inertiaA;
223 double m_inertiaB;
224 mutable double m_forceA[3];
225 mutable double m_forceB[3];
226 double* m_lengths;
227 std::string m_cableName;
228
229 InternalCableWithBottomContact* m_internalCable; //< The cable calculations.
231};
Definition Cable.h:169
double * m_lengths
The lengths of the cable elements.
Definition Cable.h:226
ISignalPort * m_inLength
The cable length input port.
Definition Cable.h:210
ISignalPort * m_inPosB
The position B input port.
Definition Cable.h:214
std::string m_cableName
The identification name of the cable;.
Definition Cable.h:227
void InitialConditionSetup(const double dT, const double *const adCurrentIC, double *const adUpdatedIC, ISimObjectCreator *const creator)
functionality for setting initialconditions based on input port results.
double m_inertiaB
The inertia of the end B.
Definition Cable.h:223
int m_IStates
The index to the internal states of the cable.
Definition Cable.h:215
~Cable()
The destructor deletes dynamically allocated memory.
ICommonComputation * m_commonCalc
Calculations necessary for more than one output port.
Definition Cable.h:216
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:225
int m_numElements
The number of elements to divide the cable into.
Definition Cable.h:219
ISignalPort * m_inVelB
The velocity B input port.
Definition Cable.h:212
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:222
ISignalPort * m_inPosA
The position A input port.
Definition Cable.h:213
int m_numNodes
The number of nodes of the cable.
Definition Cable.h:220
SCableSpec m_CableSpec
The cable specification.
Definition Cable.h:230
double m_forceA[3]
The force on the end A.
Definition Cable.h:224
ISignalPort * m_inVelA
The velocity A input port.
Definition Cable.h:211
Class containing a cable object to be part of other structures.
Definition InternalCableWithBottomContact.h:21
Contains some specifications used for simulating cables.
Definition InternalCable.h:33