FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
LocalWaveVessel.h
1#ifndef LocalWaveVessel_H
2#define LocalWaveVessel_H
3
198#include <array>
199#include <fhsim/simobject/SimObject.h>
200#include <fhsim_environment/EnvironmentProvider.h>
201#include <string>
202#include <vector>
203
204class LocalWaveVessel : public SimObject
205{
206public:
208 using Dof = std::array<double, 3>;
209
210 LocalWaveVessel(std::string simObjectName, ISimObjectCreator* creator);
211
212 void FinalSetup(double T, const double* X, ISimObjectCreator* creator) override;
213
214 void OdeFcn(double T, const double* X, double* XDot) const override;
215
216 bool HasJacobians() const override { return true; }
217 void OdeJacobian(double T, const double* X, double* J, int nStates) override;
218 int GetJacobianSparsity(int nStates, int* rowPtr, int* colIdx) override { return -1; }
219
220#ifdef FH_VISUALIZATION
222 void RenderInit(Ogre::Root* ogreRoot, ISimObjectCreator* creator) override;
223 void RenderUpdate(double T, const double* X) override;
224#endif
225
227 Dof RawWaveLoads(double T, const double* X) const;
228
229 const double* MotionPort(double T, const double* X);
230 const double* MotionRatePort(double T, const double* X);
231 const double* ExcitationPort(double T, const double* X);
232 const double* PositionPort(double T, const double* X);
233 const double* RotationPort(double T, const double* X);
234
235private:
237 struct SamplePoint
238 {
239 double x;
240 double y;
241 };
242
243 void BuildFootprint(double length, double breadth, double lcf, int sampleLevel);
244 double RotationalStiffness(ISimObjectCreator* creator, const std::string& gmName, const std::string& periodName,
245 double mass, double inertia) const;
246
248 Dof Accelerations(const double* motion, const double* rate, const double* load) const;
249
250 ISignalPort* m_inPosition = nullptr;
251 ISignalPort* m_inRotation = nullptr;
252 environment::EnvironmentProvider* m_environment = nullptr;
253
254 int m_indexMotion = 0;
255 int m_indexRate = 0;
256 int m_indexExcitation = 0;
257
258 double m_rho = 0.0;
259 double m_waterplaneArea = 0.0;
260 double m_filterTime = 0.0;
261 double m_rollQuadraticDamping = 0.0;
262
263 Dof m_inertia {};
264 Dof m_stiffness {};
265 Dof m_damping {};
266 double m_a35 = 0.0;
267 double m_b35 = 0.0;
268 double m_c35 = 0.0;
269
270 std::vector<SamplePoint> m_samples;
271 double m_sampleWeight = 0.0;
272
273 std::array<double, 3> m_positionOut {};
274 std::array<double, 3> m_rotationOut {};
275
276 double m_length = 0.0;
277 double m_breadth = 0.0;
278 double m_lcf = 0.0;
279 double m_draught = 0.0;
280
281#ifdef FH_VISUALIZATION
282 Ogre::SceneNode* m_renderNode = nullptr;
283#endif
284};
285
286#endif
Definition LocalWaveVessel.h:205
std::array< double, 3 > Dof
Generalized loads or coordinates, ordered heave, roll, pitch.
Definition LocalWaveVessel.h:208
Dof RawWaveLoads(double T, const double *X) const
Unfiltered wave loads (Fz, Mphi, Mtheta) at time T for the position and heading inputs.