FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
HeaveRollPitch.h
1#ifndef HeaveRollPitch_H
2#define HeaveRollPitch_H
3
23#include <array>
24#include <fhsim/simobject/SimObject.h>
25#include <fhsim_environment/EnvironmentProvider.h>
26#include <optional>
27#include <string>
28#include <vector>
29
31{
32public:
34 using Dof = std::array<double, 3>;
35
40 struct Defaults
41 {
42 std::optional<double> mass;
43 std::optional<double> waterplaneArea;
44 std::optional<double> rollInertia;
45 std::optional<double> pitchInertia;
46 std::optional<double> rollPeriod;
47 std::optional<double> gml;
48 std::optional<double> rollQuadraticDamping;
49 int sampleLevel = 2;
50 double rollDampingRatio = 0.45;
51 };
52
56 HeaveRollPitch(ISimObjectCreator* creator, double length, double breadth, const Defaults& defaults);
57
59 int AddStates(ISimObjectCreator* creator);
60
62 void SetEnvironment(environment::EnvironmentProvider* environment) { m_environment = environment; }
63
68 void OdeFcn(double T, const double* X, double* XDot, const double* pose, const Dof& extraLoad) const;
69
74 void OdeJacobian(double T, const double* X, double* J, int nStates, int first, int poseIndex) const;
75
79 Dof AccelerationPerLoad(const Dof& dLoad) const;
80
82 Dof RawWaveLoads(double T, const double* pose) const;
83
85 Dof VerticalAccelerations(const double* motion, const double* rate, const Dof& load) const;
86
87 int MotionIndex() const { return m_indexMotion; }
88 int RateIndex() const { return m_indexRate; }
89 int ExcitationIndex() const { return m_indexExcitation; }
90
91 double Rho() const { return m_rho; }
92 double Lcf() const { return m_lcf; }
93 double Mass() const { return m_mass; }
94 double WaterplaneArea() const { return m_waterplaneArea; }
96 double Draught() const { return m_draught; }
97
98 const Dof& Inertia() const { return m_inertia; }
99 const Dof& Stiffness() const { return m_stiffness; }
100 const Dof& Damping() const { return m_damping; }
101
102private:
104 struct SamplePoint
105 {
106 double x;
107 double y;
108 };
109
110 void BuildFootprint(double length, double breadth, double lcf, int sampleLevel);
111 double RotationalStiffness(ISimObjectCreator* creator, const std::string& gmName, const std::string& periodName,
112 double mass, double inertia, std::optional<double> defaultGm, std::optional<double> defaultPeriod) const;
113
114 environment::EnvironmentProvider* m_environment = nullptr;
115
116 int m_indexMotion = 0;
117 int m_indexRate = 0;
118 int m_indexExcitation = 0;
119
120 double m_rho = 0.0;
121 double m_waterplaneArea = 0.0;
122 double m_filterTime = 0.0;
123 double m_rollQuadraticDamping = 0.0;
124
125 Dof m_inertia {};
126 Dof m_stiffness {};
127 Dof m_damping {};
128 double m_a35 = 0.0;
129 double m_b35 = 0.0;
130 double m_c35 = 0.0;
131
132 double m_mass = 0.0;
133 double m_length = 0.0;
134 double m_lcf = 0.0;
135 double m_draught = 0.0;
136
137 std::vector<SamplePoint> m_samples;
138 double m_sampleWeight = 0.0;
139};
140
141#endif
Definition HeaveRollPitch.h:31
void OdeJacobian(double T, const double *X, double *J, int nStates, int first, int poseIndex) const
const Dof & Damping() const
Diagonal of B.
Definition HeaveRollPitch.h:100
const Dof & Inertia() const
Diagonal of M + A.
Definition HeaveRollPitch.h:98
std::array< double, 3 > Dof
Three generalized loads or coordinates: (heave, roll, pitch).
Definition HeaveRollPitch.h:34
void SetEnvironment(environment::EnvironmentProvider *environment)
The provider of the waves, or nullptr for calm water. Not owned.
Definition HeaveRollPitch.h:62
double Draught() const
Mass / (Rho WaterplaneArea) [m].
Definition HeaveRollPitch.h:96
HeaveRollPitch(ISimObjectCreator *creator, double length, double breadth, const Defaults &defaults)
Dof RawWaveLoads(double T, const double *pose) const
Unfiltered wave loads (Fz, Mphi, Mtheta) at time T for the body at pose (N, E, psi).
int AddStates(ISimObjectCreator *creator)
Adds the states Motion, MotionRate and Excitation (3 each, in that order, contiguous) and returns the...
void OdeFcn(double T, const double *X, double *XDot, const double *pose, const Dof &extraLoad) const
Dof VerticalAccelerations(const double *motion, const double *rate, const Dof &load) const
Accelerations of heave, roll and pitch for the given motion, rates and loads.
Dof AccelerationPerLoad(const Dof &dLoad) const
const Dof & Stiffness() const
Diagonal of C.
Definition HeaveRollPitch.h:99
Definition FlukeAnchor.h:124
Definition HeaveRollPitch.h:41
std::optional< double > rollQuadraticDamping
Default of RollQuadraticDamping [N m s^2].
Definition HeaveRollPitch.h:48
std::optional< double > rollPeriod
Used when neither GMT nor RollPeriod is given [s].
Definition HeaveRollPitch.h:46
std::optional< double > gml
Used when neither GML nor PitchPeriod is given [m].
Definition HeaveRollPitch.h:47