FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
CenterWeight.h
1#pragma once
2
119#include <fhsim/simobject/SimObject.h>
120#include <fhsim_environment/BodyFlowInteraction.h>
121#include <fhsim_environment/EnvironmentProvider.h>
122#include <fhsim_environment/SeafloorForcesInterface.h>
123#include <fhsim_environment/hydrodynamics/SphereHydro.h>
124#include <optional>
125#include <string>
126
127class CenterWeight : public SimObject
128{
129public:
130 CenterWeight(std::string simObjectName, ISimObjectCreator* creator);
131
133 virtual void OdeFcn(const double dT, const double* const adX,
134 double* const adXDot) const;
135
143 bool HasJacobians() const override;
144 void OdeJacobian(double T, const double* X, double* J, int nStates) override;
145 int GetJacobianSparsity(int nStates, int* rowPtr, int* colIdx) override;
146 bool HasPortJacobians() const override;
147 void InputPortJacobian(const std::string& portName, double T, const double* X,
148 double* dF_dInput, int portSize, int nStates) override;
150#ifdef FH_VISUALIZATION
152 void RenderInit(Ogre::Root* const ogreRoot, ISimObjectCreator* const creator);
154 void RenderUpdate(const double T, const double* const X);
155#endif
156 void FinalSetup(const double dT, const double* const adX, ISimObjectCreator* const creator);
158 void PreOdeFcn(double T, const double* X) override;
159 virtual const double* Position(const double dT, const double* const adX);
160 virtual const double* Velocity(const double dT, const double* const adX);
161
162protected:
164 void waterVelocity(double T, const double* X, double velocity[3]) const;
165
166 ISignalPort* m_inForce1;
167 ISignalPort* m_inForce2;
168 ISignalPort* m_inForce3;
171
172 double m_mass;
173 double m_inertia;
174 double m_density;
175 double m_visualizationScale;
176 double m_radius;
177 double m_weight;
178 double m_rhoWater;
179
180 environment::sphere_hydro::Sphere m_sphere;
181 std::optional<environment::sphere_hydro::SphereCaster> m_caster;
182 environment::wake::BodyFlowInteraction m_flow;
183
184 environment::SeafloorForcesInterface* m_seafloor = nullptr;
185 mutable bool m_inBottomContact = false;
186
187#ifdef FH_VISUALIZATION
188 std::string m_material;
189 std::string m_meshName;
190 double m_scale;
191 Ogre::Entity* m_renderEntity;
192 Ogre::SceneNode* m_renderNode;
193 Ogre::SceneManager* m_sceneMgr;
194#endif
195};
Definition CenterWeight.h:128
std::optional< environment::sphere_hydro::SphereCaster > m_caster
The sphere on its states, for the wake.
Definition CenterWeight.h:181
double m_rhoWater
The water density Rho [kg/m^3].
Definition CenterWeight.h:178
virtual void OdeFcn(const double dT, const double *const adX, double *const adXDot) const
Calculates the state derivatives.
int m_IStateVel
The index of the velocity state.
Definition CenterWeight.h:170
void waterVelocity(double T, const double *X, double velocity[3]) const
The water velocity at the weight: the BodyFlowInteraction's, without the weight's own wake.
ISignalPort * m_inForce2
A pointer to the input force 2.
Definition CenterWeight.h:167
void PreOdeFcn(double T, const double *X) override
Rebuilds the weight's wake when due and takes the other objects' wakes at the weight.
environment::wake::BodyFlowInteraction m_flow
The wake the weight casts and receives.
Definition CenterWeight.h:182
double m_inertia
Mass plus the added mass of the sphere [kg].
Definition CenterWeight.h:173
bool m_inBottomContact
Whether the seafloor force was non-zero at the last OdeFcn state.
Definition CenterWeight.h:185
int m_IStatePos
The index of the position state.
Definition CenterWeight.h:169
ISignalPort * m_inForce3
A pointer to the input force 3.
Definition CenterWeight.h:168
environment::sphere_hydro::Sphere m_sphere
ρ, D = 2 r and C_d of the drag.
Definition CenterWeight.h:180
ISignalPort * m_inForce1
A pointer to the input force 1.
Definition CenterWeight.h:166