FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
Sphere.h
1#ifndef CSphere_h__
2#define CSphere_h__
3
91#include "SphereBase.h"
92
93#include <fhsim/simobject/SimObject.h>
94#include <fhsim_environment/BodyFlowInteraction.h>
95#include <fhsim_environment/hydrodynamics/SphereHydro.h>
96
97#include <optional>
98#include <string>
99
100class Sphere : public SimObject
101{
102
103public:
104 Sphere(std::string SimObjectName, ISimObjectCreator* Creator);
105 ~Sphere() override;
106 void OdeFcn(const double T, const double* const X, double* const XDot) const;
107 void FinalSetup(const double T, const double* const X, ISimObjectCreator* const Creator);
109 void PreOdeFcn(double T, const double* X) override;
110 const double* Position(const double T, const double* const X);
111 const double* Velocity(const double T, const double* const X);
112
113 bool HasJacobians() const override;
114 void OdeJacobian(double T, const double* X, double* J, int nStates) override;
115 int GetJacobianSparsity(int nStates, int* rowPtr, int* colIdx) override;
116
118 const environment::wake::BodyWake* Wake() const { return m_flow.Wake(); }
119
120private:
121 ISignalPort* m_IForce;
122
123 int m_PosIdx;
124 int m_VelIdx;
125
126 double m_sphereD;
127 double m_sphereMass;
128 double m_Rho;
129 double m_lift;
130 double m_inertia;
131
133 const environment::sphere_hydro::Sphere& Shape() const { return m_caster->Shape(); }
134
135 std::optional<environment::sphere_hydro::SphereCaster> m_caster;
136 environment::wake::BodyFlowInteraction m_flow;
137
138#ifdef FH_VISUALIZATION
139public:
140 void RenderInit(Ogre::Root* const ogreRoot, ISimObjectCreator* const creator);
141 void RenderUpdate(const double dT, const double* const adX);
142
143private:
144 Ogre::SceneNode* m_Node;
145 Ogre::Entity* m_Entity;
146 Ogre::String m_Material;
147 std::string m_SphereMesh;
148#endif
149};
150#endif // CSphere_h__
Definition Sphere.h:101
const environment::wake::BodyWake * Wake() const
The wake: null without an Environment or before FinalSetup.
Definition Sphere.h:118
void PreOdeFcn(double T, const double *X) override
With CastWake: rebuilds the wake when due.