FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
Cable.h
1#pragma once
111#include "cable/subroutines/CableElDynStiff.h"
112#include "cable/subroutines/InternalCableWithBottomContact.h"
113
114#include "sfh/timers/Timer.h"
115
116#include <fhsim/simobject/SimObject.h>
117#include <mutex>
118#include <string>
119
120// Class definition
121class Cable : public SimObject
122{
123public:
125 Cable(std::string simObjectName, ISimObjectCreator* creator);
126
129
130 // Member functions
131 void OdeFcn(const double dT, const double* const adX, double* const adXDot) const;
133 void PreOdeFcn(double T, const double* X, IStateUpdater* updater) override;
134 void InitialConditionSetup(const double dT, const double* const adCurrentIC, double* const adUpdatedIC, ISimObjectCreator* const creator);
135 void FinalSetup(const double dT, const double* const adX, ISimObjectCreator* const creator);
136 void CalcOutput(const double dT, const double* const adX) const;
137
138 bool HasJacobians() const override;
139 void OdeJacobian(double T, const double* X, double* J, int nStates) override;
140 int GetJacobianSparsity(int nStates, int* rowPtr, int* colIdx) override;
141
142 const double* OutForceA(const double dT, const double* const adX);
143 const double* OutForceB(const double dT, const double* const adX);
144 const double* OutPosA(const double dT, const double* const adX);
145 const double* OutPosB(const double dT, const double* const adX);
146
147#ifdef FH_VISUALIZATION
148
150 void RenderInit(Ogre::Root* const ogreRoot, ISimObjectCreator* const creator);
151
153 void RenderUpdate(const double dT, const double* const adX);
154#endif
155protected:
156 void UpdateLength(double newLength, double deltaT);
157
159 void UpdateStiffness(const double* const adForceA, const double* const adForceB);
160
163
164
165 ISignalPort* m_inLength;
166 ISignalPort* m_inVelA;
167 ISignalPort* m_inVelB;
168 ISignalPort* m_inPosA;
169 ISignalPort* m_inPosB;
171 ICommonComputation* m_commonCalc;
174 mutable std::mutex m_cableMutex;
175
176 // Member variables
179
180 double m_inertiaA;
181 double m_inertiaB;
182 mutable double m_forceA[3];
183 mutable double m_forceB[3];
184 double* m_lengths;
185 std::string m_cableName;
186
187 InternalCableWithBottomContact* m_internalCable; //< The cable calculations.
189};
Definition Cable.h:122
double * m_lengths
The lengths of the cable elements.
Definition Cable.h:184
ISignalPort * m_inLength
The cable length input port.
Definition Cable.h:165
ISignalPort * m_inPosB
The position B input port.
Definition Cable.h:169
std::string m_cableName
The identification name of the cable;.
Definition Cable.h:185
void InitialConditionSetup(const double dT, const double *const adCurrentIC, double *const adUpdatedIC, ISimObjectCreator *const creator)
functionality for setting initialconditions based on input port results.
void PreOdeFcn(double T, const double *X, IStateUpdater *updater) override
Applies the Length input and advances the elements' mean tension from the step's start state (MARE-03...
double m_inertiaB
The inertia of the end B.
Definition Cable.h:181
int m_IStates
The index to the internal states of the cable.
Definition Cable.h:170
std::mutex m_cableMutex
Definition Cable.h:174
~Cable()
The destructor deletes dynamically allocated memory.
ICommonComputation * m_commonCalc
Definition Cable.h:171
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:183
int m_numElements
The number of elements to divide the cable into.
Definition Cable.h:177
ISignalPort * m_inVelB
The velocity B input port.
Definition Cable.h:167
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:180
ISignalPort * m_inPosA
The position A input port.
Definition Cable.h:168
int m_numNodes
The number of nodes of the cable.
Definition Cable.h:178
SCableSpec m_CableSpec
The cable specification.
Definition Cable.h:188
double m_forceA[3]
The force on the end A.
Definition Cable.h:182
ISignalPort * m_inVelA
The velocity A input port.
Definition Cable.h:166
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:34