FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
WaveHull.h
1#ifndef WaveHull_H
2#define WaveHull_H
3
237#include <array>
238#include <fhsim/simobject/SimObject.h>
239#include <fhsim_environment/EnvironmentProvider.h>
240#include <string>
241#include <vector>
242
243class WaveHull : public SimObject
244{
245public:
247 using Dof = std::array<double, 3>;
249 using Loads = std::array<double, 6>;
250
251 WaveHull(std::string simObjectName, ISimObjectCreator* creator);
252
253 void FinalSetup(double T, const double* X, ISimObjectCreator* creator) override;
254
255 void OdeFcn(double T, const double* X, double* XDot) const override;
256
257 bool HasJacobians() const override { return true; }
258 void OdeJacobian(double T, const double* X, double* J, int nStates) override;
259 int GetJacobianSparsity(int /*nStates*/, int* /*rowPtr*/, int* /*colIdx*/) override { return -1; }
260
261#ifdef FH_VISUALIZATION
263 void RenderInit(Ogre::Root* ogreRoot, ISimObjectCreator* creator) override;
264 void RenderUpdate(double T, const double* X) override;
265#endif
266
268 Dof RawWaveLoads(double T, const double* pose) const;
269
270 const double* MotionPort(double T, const double* X);
271 const double* MotionRatePort(double T, const double* X);
272 const double* ExcitationPort(double T, const double* X);
273 const double* VelocityPort(double T, const double* X);
274 const double* PositionPort(double T, const double* X);
275 const double* RotationPort(double T, const double* X);
276
277protected:
281 virtual Loads ExtraLoads(double /*T*/, const double* /*X*/, const Dof& /*velocity*/) const { return {}; }
282
286 virtual std::array<Dof, 6> ExtraLoadsVelocityJacobian(const Dof& /*velocity*/) const { return {}; }
287
288 double Length() const { return m_length; }
289 double Lcf() const { return m_lcf; }
290 double Draught() const { return m_draught; }
291 double Rho() const { return m_rho; }
292
293private:
295 struct SamplePoint
296 {
297 double x;
298 double y;
299 };
300
301 void BuildFootprint(double length, double breadth, double lcf, int sampleLevel);
302 double RotationalStiffness(ISimObjectCreator* creator, const std::string& gmName, const std::string& periodName,
303 double mass, double inertia) const;
304
306 Dof VerticalAccelerations(const double* motion, const double* rate, const Dof& load) const;
308 Dof HorizontalAccelerations(const double* velocity, const Dof& load) const;
309
310 environment::EnvironmentProvider* m_environment = nullptr;
311
312 int m_indexMotion = 0;
313 int m_indexRate = 0;
314 int m_indexExcitation = 0;
315 int m_indexPose = 0;
316 int m_indexVelocity = 0;
317
318 double m_rho = 0.0;
319 double m_waterplaneArea = 0.0;
320 double m_filterTime = 0.0;
321 double m_rollQuadraticDamping = 0.0;
322
323 Dof m_inertia {};
324 Dof m_stiffness {};
325 Dof m_damping {};
326 double m_a35 = 0.0;
327 double m_b35 = 0.0;
328 double m_c35 = 0.0;
329
330 double m_mass = 0.0;
331 double m_a11 = 0.0;
332 double m_a22 = 0.0;
333 Dof m_horizontalInertia {};
334 Dof m_horizontalLinearDamping {};
335 Dof m_horizontalQuadraticDamping {};
336
337 std::vector<SamplePoint> m_samples;
338 double m_sampleWeight = 0.0;
339
340 std::array<double, 3> m_positionOut {};
341 std::array<double, 3> m_rotationOut {};
342
343 double m_length = 0.0;
344 double m_breadth = 0.0;
345 double m_lcf = 0.0;
346 double m_draught = 0.0;
347
348#ifdef FH_VISUALIZATION
349 Ogre::SceneNode* m_renderNode = nullptr;
350#endif
351};
352
353#endif
Definition WaveHull.h:244
virtual Loads ExtraLoads(double, const double *, const Dof &) const
Definition WaveHull.h:281
std::array< double, 3 > Dof
Three generalized loads or coordinates: (heave, roll, pitch) or (surge, sway, yaw).
Definition WaveHull.h:247
std::array< double, 6 > Loads
Generalized loads on the six modes, ordered surge, sway, heave, roll, pitch, yaw [N,...
Definition WaveHull.h:249
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:286