FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
CenterWeight.h
1#pragma once
2
111#include <fhsim/simobject/SimObject.h>
112#include <fhsim_environment/BodyWake.h>
113#include <fhsim_environment/EnvironmentProvider.h>
114#include <fhsim_environment/SeafloorForcesInterface.h>
115#include <fhsim_environment/hydrodynamics/SphereHydro.h>
116#include <memory>
117#include <optional>
118
119class CenterWeight : public SimObject
120{
121public:
122 CenterWeight(std::string simObjectName, ISimObjectCreator* creator);
123
125 virtual void OdeFcn(const double dT, const double* const adX,
126 double* const adXDot) const;
127
135 bool HasJacobians() const override;
136 void OdeJacobian(double T, const double* X, double* J, int nStates) override;
137 int GetJacobianSparsity(int nStates, int* rowPtr, int* colIdx) override;
138 bool HasPortJacobians() const override;
139 void InputPortJacobian(const std::string& portName, double T, const double* X,
140 double* dF_dInput, int portSize, int nStates) override;
142#ifdef FH_VISUALIZATION
144 void RenderInit(Ogre::Root* const ogreRoot, ISimObjectCreator* const creator);
146 void RenderUpdate(const double T, const double* const X);
147#endif
148 void FinalSetup(const double dT, const double* const adX, ISimObjectCreator* const creator);
150 void PreOdeFcn(double T, const double* X, IStateUpdater* updater) override;
151 virtual const double* Position(const double dT, const double* const adX);
152 virtual const double* Velocity(const double dT, const double* const adX);
153
154protected:
156 void waterVelocity(double T, const double* X, double velocity[3]) const;
157
158 ISignalPort* m_inForce1;
159 ISignalPort* m_inForce2;
160 ISignalPort* m_inForce3;
163
164 double m_mass;
165 double m_density;
166 double m_visualizationScale;
167 double m_radius;
168 double m_weight;
169 double m_rhoWater;
170
171 environment::sphere_hydro::Sphere m_sphere;
172 std::optional<environment::sphere_hydro::SphereCaster> m_caster;
173 environment::wake::BodyWakeSettings m_wakeSettings;
174 std::unique_ptr<environment::wake::BodyWake> m_wake;
175
176 environment::EnvironmentProvider* m_environment;
177 environment::SeafloorForcesInterface* m_seafloor;
178 mutable bool m_inBottomContact = false;
179
180#ifdef FH_VISUALIZATION
181 std::string m_material;
182 std::string m_meshName;
183 double m_scale;
184 Ogre::Entity* m_renderEntity;
185 Ogre::SceneNode* m_renderNode;
186 Ogre::SceneManager* m_sceneMgr;
187#endif
188};
Definition CenterWeight.h:120
std::optional< environment::sphere_hydro::SphereCaster > m_caster
The sphere on its states, for the wake.
Definition CenterWeight.h:172
double m_rhoWater
The water density Rho [kg/m^3].
Definition CenterWeight.h:169
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:162
void waterVelocity(double T, const double *X, double velocity[3]) const
The water velocity at the weight: the BodyWake's, without the weight's own wake.
ISignalPort * m_inForce2
A pointer to the input force 2.
Definition CenterWeight.h:159
environment::wake::BodyWakeSettings m_wakeSettings
The wake parameters.
Definition CenterWeight.h:173
void PreOdeFcn(double T, const double *X, IStateUpdater *updater) override
Rebuilds the weight's wake when due and takes the other objects' wakes at the weight.
bool m_inBottomContact
Whether the seafloor force was non-zero at the last OdeFcn state.
Definition CenterWeight.h:178
int m_IStatePos
The index of the position state.
Definition CenterWeight.h:161
ISignalPort * m_inForce3
A pointer to the input force 3.
Definition CenterWeight.h:160
environment::sphere_hydro::Sphere m_sphere
ρ, D = 2 r and C_d of the drag.
Definition CenterWeight.h:171
ISignalPort * m_inForce1
A pointer to the input force 1.
Definition CenterWeight.h:158
std::unique_ptr< environment::wake::BodyWake > m_wake
The wake the weight casts and receives, from FinalSetup.
Definition CenterWeight.h:174