FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
WaveHull.h
1#ifndef WaveHull_H
2#define WaveHull_H
3
236#include <array>
237#include "HeaveRollPitch.h"
238#include <fhsim/simobject/SimObject.h>
239#include <fhsim_environment/EnvironmentProvider.h>
240#include <optional>
241#include <string>
242#include <vector>
243
244class WaveHull : public SimObject
245{
246public:
248 using Dof = std::array<double, 3>;
250 using Loads = std::array<double, 6>;
251
252 WaveHull(std::string simObjectName, ISimObjectCreator* creator);
253
254 void FinalSetup(double T, const double* X, ISimObjectCreator* creator) override;
255
256 void OdeFcn(double T, const double* X, double* XDot) const override;
257
258 bool HasJacobians() const override { return true; }
259 void OdeJacobian(double T, const double* X, double* J, int nStates) override;
260 int GetJacobianSparsity(int /*nStates*/, int* /*rowPtr*/, int* /*colIdx*/) override { return -1; }
261
262#ifdef FH_VISUALIZATION
264 void RenderInit(Ogre::Root* ogreRoot, ISimObjectCreator* creator) override;
265 void RenderUpdate(double T, const double* X) override;
266#endif
267
269 Dof RawWaveLoads(double T, const double* pose) const;
270
271 const double* MotionPort(double T, const double* X);
272 const double* MotionRatePort(double T, const double* X);
273 const double* ExcitationPort(double T, const double* X);
274 const double* VelocityPort(double T, const double* X);
275 const double* PositionPort(double T, const double* X);
276 const double* RotationPort(double T, const double* X);
277
278protected:
282 virtual Loads ExtraLoads(double /*T*/, const double* /*X*/, const Dof& /*velocity*/) const { return {}; }
283
287 virtual std::array<Dof, 6> ExtraLoadsVelocityJacobian(const Dof& /*velocity*/) const { return {}; }
288
293 virtual std::array<double, 3> WaterVelocity(double /*T*/, const double* /*X*/) const { return {0.0, 0.0, 0.0}; }
294
296 virtual std::array<double, 3> HeldWaterVelocity() const { return {0.0, 0.0, 0.0}; }
297
299 static Dof InBodyFrame(const std::array<double, 3>& water, double psi);
300
302 Dof VelocityThroughWater(double T, const double* X) const;
303
305 Dof HullDamping(const Dof& velocity) const;
306
307 double Length() const { return m_length; }
308 double Breadth() const { return m_breadth; }
309 double Lcf() const { return m_lcf; }
310 double Draught() const { return m_draught; }
311 double Rho() const { return m_rho; }
312 int MotionIndex() const { return m_vertical->MotionIndex(); }
313 int RateIndex() const { return m_vertical->RateIndex(); }
314 int PoseIndex() const { return m_indexPose; }
315 int VelocityIndex() const { return m_indexVelocity; }
316
317private:
319 Dof HorizontalAccelerations(const double* velocity, const Dof& load) const;
320
321
322 std::optional<HeaveRollPitch> m_vertical;
323
324 int m_indexPose = 0;
325 int m_indexVelocity = 0;
326
327 double m_rho = 0.0;
328 double m_mass = 0.0;
329 double m_a11 = 0.0;
330 double m_a22 = 0.0;
331 Dof m_horizontalInertia {};
332 Dof m_horizontalLinearDamping {};
333 Dof m_horizontalQuadraticDamping {};
334
335 std::array<double, 3> m_positionOut {};
336 std::array<double, 3> m_rotationOut {};
337
338 double m_length = 0.0;
339 double m_breadth = 0.0;
340 double m_lcf = 0.0;
341 double m_draught = 0.0;
342
343#ifdef FH_VISUALIZATION
344 Ogre::SceneNode* m_renderNode = nullptr;
345#endif
346};
347
348#endif
Definition WaveHull.h:245
virtual Loads ExtraLoads(double, const double *, const Dof &) const
Definition WaveHull.h:282
virtual std::array< double, 3 > HeldWaterVelocity() const
The water velocity of the step [m/s], NED, which OdeJacobian holds fixed. The base: still water.
Definition WaveHull.h:296
Dof VelocityThroughWater(double T, const double *X) const
(u, v, r) through the water at time T for the model-global state X.
std::array< double, 3 > Dof
Three generalized loads or coordinates: (heave, roll, pitch) or (surge, sway, yaw).
Definition WaveHull.h:248
static Dof InBodyFrame(const std::array< double, 3 > &water, double psi)
The water velocity water (NED) in the body frame of heading psi: (u_c, v_c, 0).
std::array< double, 6 > Loads
Generalized loads on the six modes, ordered surge, sway, heave, roll, pitch, yaw [N,...
Definition WaveHull.h:250
virtual std::array< double, 3 > WaterVelocity(double, const double *) const
Definition WaveHull.h:293
Dof RawWaveLoads(double T, const double *pose) const
Unfiltered wave loads (Fz, Mphi, Mtheta) at time T for the hull at pose (N, E, psi).
virtual std::array< Dof, 6 > ExtraLoadsVelocityJacobian(const Dof &) const
Definition WaveHull.h:287
Dof HullDamping(const Dof &velocity) const
The hull's damping X(u), Y(v), N(r) at the velocity through the water velocity (u,...