FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
TrawlDoorBase.h
1#pragma once
2
3#include "PlateDoorLaw.h"
4
5#include "sfh/sim/kinematics.h"
6
7#include <fhsim/simobject/SimObject.h>
8#include <fhsim_base/body/HydroBody.h>
9#include <fhsim_environment/BodyFlowInteraction.h>
10#include <fhsim_environment/EnvironmentProvider.h>
11#include <fhsim_environment/WakeSourceSet.h>
12#include <fhsim_environment/hydrodynamics/PlateGeometry.h>
13#include <math.h>
14#include <string>
15
16
17#ifdef FH_VISUALIZATION
18# include "OgreParticleSystem.h"
19# ifdef USE_BILLBOARD_LABELS
20# include "sfh/ogre/CMovableText.h"
21# endif
22#endif
23
190class TrawlDoorBase : public SimObject
191{
192public:
194 TrawlDoorBase(std::string simObjectName, ISimObjectCreator* creator);
195
197 virtual void OdeFcn(const double dT, const double* const adX, double* const adXDot) const override;
198
212 bool HasJacobians() const override;
213 void OdeJacobian(double T, const double* X, double* J, int nStates) override;
214 int GetJacobianSparsity(int nStates, int* rowPtr, int* colIdx) override;
216
218 void PreOdeFcn(double T, const double* X) override;
219
220
221#ifdef FH_VISUALIZATION
223 virtual void RenderInit(Ogre::Root* const ogreRoot, ISimObjectCreator* const creator);
224
226 virtual void RenderUpdate(const double dT, const double* const adX);
227#endif
228
229protected:
231 void HydroForceAt(const double* X, const double relVel_n[3], double force_n[3]) const;
233 void OutOfBoundRotationalDamping(const hydro_body::FlowFrame& frame, double damping[3]) const;
234
241 hydro_body::Wrench SumLoads(double T, const double* X, const hydro_body::FlowFrame& frame, plate_door::Inflow& inflow) const;
243 virtual void AddExternalForces(double T, const double* X, const hydro_body::FlowFrame& frame, hydro_body::Wrench& wrench) const;
245 void AddInternalForces(double T, const hydro_body::FlowFrame& frame, hydro_body::Wrench& wrench) const;
249 hydro_body::Wrench WaterLoad(double T, const double* X, const hydro_body::FlowFrame& frame) const;
250
251 plate_door::Inflow AddHydroForces(const hydro_body::FlowFrame& frame, hydro_body::Wrench& wrench) const;
253 virtual void AddInflowDependentForces(double T, const double* X, const plate_door::Inflow& inflow, hydro_body::Wrench& wrench) const { }
257 virtual void AddBottomForces(const hydro_body::FlowFrame& frame, hydro_body::Wrench& wrench) const { }
259 virtual void AddOwnDerivatives(double T, const double* X, const plate_door::Inflow& inflow, double* XDot) const { }
260 virtual void CalcOutput(const double dT, const double* const adX);
261 void CalcOutputCommon(const double dT, const double* const adX) const;
262 void FinalSetup(const double dT, const double* const adX, ISimObjectCreator* const creator);
263 // Geometry and properties
264 bool m_isPort;
265 double m_cOG[3];
266 double m_area;
267 double m_height;
268 double m_length;
269 double m_aR;
270 double m_curvature;
271 double m_mass;
272 double m_mdCornerPos_body[4][3];
273 double m_rhoDoor;
274
275 // Hydrodynamic forces
277
278 // Fastening points
279 double m_warpPos_d[3];
280 double m_lBPos_d[3];
281 double m_uBPos_d[3];
282
283 // External
284 double m_rhoWater;
285 double m_force_warp[3];
286 double m_force_LB[3];
287 double m_force_UB[3];
288 ICommonComputation* m_commonCalc;
289
293 class DoorCaster final : public environment::wake::WakeCastingObject
294 {
295 public:
296 explicit DoorCaster(const TrawlDoorBase& door)
297 : m_door(door)
298 {
299 }
300
302 environment::wake::WakeCastState Reference(double T, const double* X) const override;
304 void CurrentLoad(double T, const double* X, const double freeStream[3], const double flowDir[3], double force[3], double& frontalArea,
305 double rearCentre[3]) const override;
307 double Radius() const override;
309 environment::wake::SourceLoad BodyLoad(double T, const double* X, const double bodyVel[3], const double waterVel[3]) const override;
310
311 private:
313 void PlateAxes(const double* X, double normal[3], double chordAxis[3]) const;
315 environment::plate_geometry::Plate Plate() const;
316
317 const TrawlDoorBase& m_door;
318 };
319
320 environment::EnvironmentProvider* m_environment = nullptr;
322 environment::wake::BodyFlowInteraction m_flow;
323
324 // Input ports
325 ISignalPort* m_inWarp_F;
326 ISignalPort* m_inLB_F;
327 ISignalPort* m_inUB_F;
328
329 // Output ports
330 const double* OutPos1(const double dT, const double* const adX);
331 const double* OutPos3(const double dT, const double* const adX);
332 const double* OutPos2(const double dT, const double* const adX);
333 const double* OutVel1(const double dT, const double* const adX);
334 const double* OutVel3(const double dT, const double* const adX);
335 const double* OutVel2(const double dT, const double* const adX);
336
337 double m_outPos1[3];
338 double m_outPos3[3];
339 double m_outPos2[3];
340 double m_outVel1[3];
341 double m_outVel3[3];
342 double m_outVel2[3];
343
345
346 unsigned long m_IStatePos;
347 unsigned long m_IStateQuater;
348 unsigned long m_IStateLocalVel;
349 unsigned long m_IStateOmega;
350 unsigned long m_IStateHydroForce;
351
355
358
359#ifdef FH_VISUALIZATION
360 void BottomContactRenderInit();
361 void RenderBottomContact(double depth, double m_cornerPos_ned[4][3], double m_submergence[4]);
362 Ogre::ParticleSystem* m_particleSystem;
363 Ogre::SceneNode* m_particleNode;
364 Ogre::ParticleEmitter* m_particleEmitter;
365 Ogre::Vector3 m_visualizationScale;
366
367 std::string m_meshName;
368 double m_visScale;
369 double m_lengthScale;
370 double m_heightScale;
371 double m_curvatureScale;
372 Ogre::Entity* m_renderEntity;
373 Ogre::SceneNode* m_renderNode;
374 Ogre::Quaternion m_InitOrientation;
375 Ogre::SceneManager* m_sceneMgr;
376
377# ifdef USE_BILLBOARD_LABELS
378 Ogre::SceneNode* m_BBRenderNode;
379 Ogre::CMovableText* m_BBTxt;
380 double m_bBTxtSize;
381# endif
382#endif
383};
Definition HydroBody.h:101
Definition TrawlDoorBase.h:294
environment::wake::SourceLoad BodyLoad(double T, const double *X, const double bodyVel[3], const double waterVel[3]) const override
plate_door::SteadyLoad at the inflow, M = F·ê/(½ρ|U|²), the plate's frontal area along ê (as CurrentL...
double Radius() const override
√(Area/π), the radius of the plate area (O9a).
void CurrentLoad(double T, const double *X, const double freeStream[3], const double flowDir[3], double force[3], double &frontalArea, double rearCentre[3]) const override
plate_door::SteadyLoad at the free stream; the plate chord × span of the door frame.
environment::wake::WakeCastState Reference(double T, const double *X) const override
The door's centre and its velocity in NED.
Definition TrawlDoorBase.h:191
hydro_body::Wrench WaterLoad(double T, const double *X, const hydro_body::FlowFrame &frame) const
double m_area
The trawldoor area.
Definition TrawlDoorBase.h:266
virtual void OdeFcn(const double dT, const double *const adX, double *const adXDot) const override
Calculates the state derivatives.
void OutOfBoundRotationalDamping(const hydro_body::FlowFrame &frame, double damping[3]) const
The derivative of the out-of-bound rotational damping moments against the angular rate,...
virtual void AddBottomForces(const hydro_body::FlowFrame &frame, hydro_body::Wrench &wrench) const
Adds the bottom contact. The base door has none.
Definition TrawlDoorBase.h:257
void HydroForceAt(const double *X, const double relVel_n[3], double force_n[3]) const
plate_door::SteadyLoad at the velocity relVel_n relative to the water (NED) and the attitude and rate...
double m_force_warp[3]
A pointer to the Warp force.
Definition TrawlDoorBase.h:285
virtual void AddOwnDerivatives(double T, const double *X, const plate_door::Inflow &inflow, double *XDot) const
Writes the derivatives of a subclass's own states, after the 13 of m_body. The base door has none.
Definition TrawlDoorBase.h:259
void AddDampingForces(const hydro_body::FlowFrame &frame, hydro_body::Wrench &wrench) const
Adds the linear damping, a numerical stabiliser on the door's own velocity and rates (R75,...
environment::wake::BodyFlowInteraction m_flow
The wake the door casts and receives.
Definition TrawlDoorBase.h:322
virtual void AddExternalForces(double T, const double *X, const hydro_body::FlowFrame &frame, hydro_body::Wrench &wrench) const
Adds the warp and bridle forces of the input ports at their fastening points.
environment::EnvironmentProvider * m_environment
m_flow's Environment, from FinalSetup.
Definition TrawlDoorBase.h:320
hydro_body::Wrench SumLoads(double T, const double *X, const hydro_body::FlowFrame &frame, plate_door::Inflow &inflow) const
plate_door::Inflow m_lastInflow
The inflow of the last OdeFcn, for the render only (the billboard label); never read by the dynamics.
Definition TrawlDoorBase.h:357
double m_rhoDoor
The density of the trawl door material.
Definition TrawlDoorBase.h:273
TrawlDoorBase(std::string simObjectName, ISimObjectCreator *creator)
The constructor sets the pointer to the output object and the parser object.
double m_cOG[3]
The trawl door center of gravity.
Definition TrawlDoorBase.h:265
double m_rhoWater
The density of the surrounding fluid.
Definition TrawlDoorBase.h:284
double m_force_LB[3]
A pointer to the force.
Definition TrawlDoorBase.h:286
double m_force_UB[3]
A pointer to the input force.
Definition TrawlDoorBase.h:287
ISignalPort * m_inLB_F
The cable length input port.
Definition TrawlDoorBase.h:326
DoorCaster m_caster
The door for its wake; declared before m_flow, which keeps a pointer to it.
Definition TrawlDoorBase.h:321
double m_mass
The mass of the object.
Definition TrawlDoorBase.h:271
ISignalPort * m_inUB_F
The cable length input port.
Definition TrawlDoorBase.h:327
void PreOdeFcn(double T, const double *X) override
Rebuilds the door's wake when due (CastWake) and takes the other objects' wakes at the door.
virtual void AddInflowDependentForces(double T, const double *X, const plate_door::Inflow &inflow, hydro_body::Wrench &wrench) const
Adds forces that depend on the plate-door inflow of this state. The base door has none.
Definition TrawlDoorBase.h:253
bool m_isPort
Is this a port trawl door?
Definition TrawlDoorBase.h:264
ISignalPort * m_inWarp_F
The cable length input port.
Definition TrawlDoorBase.h:325
void AddInternalForces(double T, const hydro_body::FlowFrame &frame, hydro_body::Wrench &wrench) const
Adds gravity at COG and the buoyancy of the wet part of the plate (R66, FISH-0092).
HydroBody m_body
The states Pos, Quater, LocalVel and Omega, the inertia (R70) and the derivatives.
Definition TrawlDoorBase.h:344
plate_door::Door m_law
The door's constants for the plate-door law (Area, AR, Rho, IsPort, MaxLiftCoeff, DragCoeffAtMaxLift)...
Definition TrawlDoorBase.h:276
ICommonComputation * m_commonCalc
Calculations necessary for more than one output port.
Definition TrawlDoorBase.h:288
double m_outAlpha
Definition TrawlDoorBase.h:354
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:57
A door's constants for the law; constant after construction.
Definition PlateDoorLaw.h:29
The door's inflow angles, in the starboard convention, and speed.
Definition PlateDoorLaw.h:60