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