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 <string>
9
10namespace environment::wake
11{
12class BodyFlowInteraction;
13}
14
33namespace hydro_body
34{
41{
42 const double* pos_n = nullptr;
43 const double* quater = nullptr;
44 const double* vel_d = nullptr;
45 const double* omega = nullptr;
46
47 double R[3][3] = {};
48 double vel_n[3] = {};
49 double waterVel_n[3] = {};
50 double waterVel_d[3] = {};
51 double relVel_d[3] = {};
52};
53
55struct Wrench
56{
57 double values[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
58
60 void Add(const double wrench[6]);
61
68 void AddForceAt(const FlowFrame& frame, const double pos_d[3], const double force_n[3]);
69};
70} // namespace hydro_body
71
78{
79 public:
88 HydroBody(ISimObjectCreator* creator, const std::string& angularRateName, double convergenceTime, rigid_body::MunkMoment munk);
89
95 void SetInertia(const double rigid[6], const double added[6]);
96
98 const BodyKinematics6Dof& Kinematics() const { return m_kinematics; }
99
101 const double* RigidInertia() const { return m_rigidInertia; }
102
104 const double* AddedMass() const { return m_addedMass; }
105
107 double InverseMass(int i) const { return m_massInverse[i][i]; }
108
114 hydro_body::FlowFrame Frame(const double* X, const double waterVel_n[3]) const;
115
117 hydro_body::FlowFrame Frame(const environment::wake::BodyFlowInteraction& flow, double t, const double* X) const;
118
121 hydro_body::FlowFrame LocalFrame(const double* localX, const double waterVel_n[3]) const;
122
124 hydro_body::FlowFrame LocalFrame(const environment::wake::BodyFlowInteraction& flow, double t, const double* localX) const;
125
133 void Derivatives(const hydro_body::FlowFrame& frame, const hydro_body::Wrench& wrench, const double* X, double* XDot) const;
134
146 void AddJacobian(const double* localX, const hydro_body::FlowFrame& frame, double dWrench[6][6], double* J, int nStates) const;
147
148 private:
150 hydro_body::FlowFrame FrameAtPos(const double* posState, const double waterVel_n[3]) const;
151
152 BodyKinematics6Dof m_kinematics;
153 rigid_body::MunkMoment m_munk;
154 double m_rigidInertia[6] = {};
155 double m_addedMass[6] = {};
156 double m_massInverse[6][6] = {};
157};
158
159#endif
Definition BodyKinematics6Dof.h:37
Definition HydroBody.h:78
const double * AddedMass() const
The diagonal of the added mass.
Definition HydroBody.h:104
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:98
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:101
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:107
Definition HydroBody.h:41
const double * omega
The angular-rate state, body frame [rad/s].
Definition HydroBody.h:45
double waterVel_n[3]
The water velocity at the body origin, NED [m/s].
Definition HydroBody.h:49
const double * vel_d
The velocity state, body frame [m/s].
Definition HydroBody.h:44
const double * quater
The attitude quaternion state [q0, q1, q2, q3].
Definition HydroBody.h:43
double waterVel_d[3]
The water velocity at the body origin, body frame [m/s].
Definition HydroBody.h:50
double R[3][3]
The body-to-NED rotation matrix.
Definition HydroBody.h:47
double relVel_d[3]
The velocity of the body relative to the water, vel_d - waterVel_d, body frame [m/s].
Definition HydroBody.h:51
double vel_n[3]
The velocity of the body origin, NED [m/s].
Definition HydroBody.h:48
const double * pos_n
The position state, NED [m].
Definition HydroBody.h:42
The sum of the loads on a body: the force [0..2] and the moment about the origin [3....
Definition HydroBody.h:56
void Add(const double wrench[6])
Adds the body-frame wrench wrench.
void AddForceAt(const FlowFrame &frame, const double pos_d[3], const double force_n[3])