FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
HydroBody.h
1#ifndef HYDRO_BODY_H
2#define HYDRO_BODY_H
3
4#include "BodyKinematics6Dof.h"
5#include "RigidBodyTerms.h"
6
7#include <fhsim/simobject/ISimObjectCreator.h>
8#include <fhsim_environment/WakeSourceSet.h>
9#include <string>
10
11namespace environment::wake
12{
13class BodyFlowInteraction;
14}
15
34namespace hydro_body
35{
42{
43 const double* pos_n = nullptr;
44 const double* quater = nullptr;
45 const double* vel_d = nullptr;
46 const double* omega = nullptr;
47
48 double R[3][3] = {};
49 double vel_n[3] = {};
50 double waterVel_n[3] = {};
51 double waterVel_d[3] = {};
52 double relVel_d[3] = {};
53};
54
56struct Wrench
57{
58 double values[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
59
61 void Add(const double wrench[6]);
62
69 void AddForceAt(const FlowFrame& frame, const double pos_d[3], const double force_n[3]);
70
84 void AddWeightAndBuoyancy(const FlowFrame& frame, double mass, const double cog_d[3], const double buoyancy_n[3]);
85};
86
92environment::wake::WakeCastState CastStateOf(const FlowFrame& frame);
93} // namespace hydro_body
94
101{
102 public:
111 HydroBody(ISimObjectCreator* creator, const std::string& angularRateName, double convergenceTime, rigid_body::MunkMoment munk);
112
118 void SetInertia(const double rigid[6], const double added[6]);
119
121 const BodyKinematics6Dof& Kinematics() const { return m_kinematics; }
122
124 const double* RigidInertia() const { return m_rigidInertia; }
125
127 const double* AddedMass() const { return m_addedMass; }
128
130 double InverseMass(int i) const { return m_massInverse[i][i]; }
131
137 hydro_body::FlowFrame Frame(const double* X, const double waterVel_n[3]) const;
138
140 hydro_body::FlowFrame Frame(const environment::wake::BodyFlowInteraction& flow, double t, const double* X) const;
141
144 hydro_body::FlowFrame LocalFrame(const double* localX, const double waterVel_n[3]) const;
145
147 hydro_body::FlowFrame LocalFrame(const environment::wake::BodyFlowInteraction& flow, double t, const double* localX) const;
148
156 void Derivatives(const hydro_body::FlowFrame& frame, const hydro_body::Wrench& wrench, const double* X, double* XDot) const;
157
169 void AddJacobian(const double* localX, const hydro_body::FlowFrame& frame, double dWrench[6][6], double* J, int nStates) const;
170
171 private:
173 hydro_body::FlowFrame FrameAtPos(const double* posState, const double waterVel_n[3]) const;
174
175 BodyKinematics6Dof m_kinematics;
176 rigid_body::MunkMoment m_munk;
177 double m_rigidInertia[6] = {};
178 double m_addedMass[6] = {};
179 double m_massInverse[6][6] = {};
180};
181
182#endif
Definition BodyKinematics6Dof.h:37
Definition HydroBody.h:101
const double * AddedMass() const
The diagonal of the added mass.
Definition HydroBody.h:127
hydro_body::FlowFrame LocalFrame(const environment::wake::BodyFlowInteraction &flow, double t, const double *localX) const
LocalFrame(localX, waterVel_n) with the water velocity of flow at the body origin at time t.
void AddJacobian(const double *localX, const hydro_body::FlowFrame &frame, double dWrench[6][6], double *J, int nStates) const
HydroBody(ISimObjectCreator *creator, const std::string &angularRateName, double convergenceTime, rigid_body::MunkMoment munk)
hydro_body::FlowFrame LocalFrame(const double *localX, const double waterVel_n[3]) const
void Derivatives(const hydro_body::FlowFrame &frame, const hydro_body::Wrench &wrench, const double *X, double *XDot) const
const BodyKinematics6Dof & Kinematics() const
The kinematic states and their indices.
Definition HydroBody.h:121
hydro_body::FlowFrame Frame(const environment::wake::BodyFlowInteraction &flow, double t, const double *X) const
Frame(X, waterVel_n) with the water velocity of flow at the body origin at time t (BodyFlowInteractio...
hydro_body::FlowFrame Frame(const double *X, const double waterVel_n[3]) const
const double * RigidInertia() const
The diagonal of the rigid-body inertia.
Definition HydroBody.h:124
void SetInertia(const double rigid[6], const double added[6])
double InverseMass(int i) const
The entry i of the diagonal of M^-1.
Definition HydroBody.h:130
Definition HydroBody.h:42
const double * omega
The angular-rate state, body frame [rad/s].
Definition HydroBody.h:46
double waterVel_n[3]
The water velocity at the body origin, NED [m/s].
Definition HydroBody.h:50
const double * vel_d
The velocity state, body frame [m/s].
Definition HydroBody.h:45
const double * quater
The attitude quaternion state [q0, q1, q2, q3].
Definition HydroBody.h:44
double waterVel_d[3]
The water velocity at the body origin, body frame [m/s].
Definition HydroBody.h:51
double R[3][3]
The body-to-NED rotation matrix.
Definition HydroBody.h:48
double relVel_d[3]
The velocity of the body relative to the water, vel_d - waterVel_d, body frame [m/s].
Definition HydroBody.h:52
double vel_n[3]
The velocity of the body origin, NED [m/s].
Definition HydroBody.h:49
const double * pos_n
The position state, NED [m].
Definition HydroBody.h:43
The sum of the loads on a body: the force [0..2] and the moment about the origin [3....
Definition HydroBody.h:57
void Add(const double wrench[6])
Adds the body-frame wrench wrench.
void AddWeightAndBuoyancy(const FlowFrame &frame, double mass, const double cog_d[3], const double buoyancy_n[3])
void AddForceAt(const FlowFrame &frame, const double pos_d[3], const double force_n[3])