Marine systems simulation
CSmallObject.h
1/*
2* Class SmallObject (SimObject)
3* Author: Biao Su
4* Last revision: 2022-09-27
5* This class enables simulation of a small-volume object in water.
6*/
7
12#ifndef C_SMALL_OBJECT_H
13#define C_SMALL_OBJECT_H
14#include <SimObject.h>
15#include "CEnvironment.h"
16#include "sfh/constants.h"
17#include <iostream>
18#include <iomanip>
19#include <fstream>
20#include <algorithm>
21#include <vector>
22#include <valarray>
23#include <Eigen/Eigen>
24
25
26namespace System
27{
28 typedef Eigen::Matrix<double, 6, 6> emat6;
29 typedef Eigen::Matrix<double, 6, 1> evec6;
30 typedef Eigen::Matrix<double, 3, 3> emat3;
31 typedef Eigen::Matrix<double, 2, 1> evec2;
32 typedef Eigen::Matrix<double, 3, 1> evec3;
33 typedef Eigen::Matrix<double, 4, 1> evec4;
34 typedef Eigen::Matrix<double, 13, 1> evec13;
35 typedef Eigen::Quaternion<double> equat;
36
37 class SmallObject : public SimObject
38 {
39 public:
40 SmallObject(const string& simObjectName, ISimObjectCreator* const creator);
41 virtual void FinalSetup(const double T, const double* const X, ISimObjectCreator* const creator);
42 virtual ~SmallObject();
43
44 void OdeFcn(const double T, const double* const X, double* const XDot, const bool IsMajorTimeStep);
45
46#ifdef FH_VISUALIZATION
47 void RenderInit(Ogre::Root* const ogreRoot, ISimObjectCreator* const creator) {};
48
49 void RenderUpdate(const double T, const double* const X) {};
50#endif
51
52 virtual void CalRotationMatrix(const double& Roll, const double& Pitch, const double& Yaw);
53 virtual void CalJMatrix(const double& Roll, const double& Pitch, const double& Yaw);
54 virtual evec6 CalCoriolisForce(const evec3& vl, const evec3& wl, const emat6& Inertia);
55 virtual evec6 CalConnectForce(const evec3& p, const evec3& v, const evec3& w, const double T, const double* const X);
56
57 virtual equat RoationToQuaternion(const evec3& EulerAngle);
58 virtual evec3 CalRollPitchYaw(const equat& ql2g);
59
60 protected:
61
62 // States
63 int m_IStatePos; //< Index of the global position in the state vector.
64 int m_IStateRot; //< Index of the global rotation in the state vector.
65 int m_IStateVel; //< Index of the global velocity in the state vector.
66 int m_IStateOmega; //< Index of the global angular velocity in the state vector.
67
68 // Rotation matrix
69 emat3 m_RotMatl2g; //< Rotation matrix local to global (translational)
70 emat3 m_RotMatg2l; //< Rotation matrix global to local (translational)
71 emat3 m_JMatl2g; //< Rotation matrix local to global (rotational)
72 emat3 m_JMatg2l; //< Rotation matrix global to local (rotational)
73
74 // Input parameters
75 double m_WaterDensity;
76 double m_SubmergedVolume;
77 double m_Mass;
78 emat6 m_Inertia;
79 evec6 m_AddedMass;
80 evec6 m_MorisonCM;
81 evec6 m_MorisonCD;
82 evec6 m_LinearDamping;
83 evec6 m_DragArea;
84 double m_RampTime;
85 evec6 m_Restoring;
86 evec3 m_InitialPos;
87 evec3 m_InitialRot;
88 bool m_ExtGravity;
89
90 // Output parameters
91 evec6 m_OutputPos;
92 virtual const double* OutputPos(const double dT, const double* const adX);
93 evec6 m_OutputVel;
94 virtual const double* OutputVel(const double dT, const double* const adX);
95 evec6 m_OutputVelLoc;
96 virtual const double* OutputVelLoc(const double dT, const double* const adX);
97 evec4 m_OutputQuat;
98 virtual const double* OutputQuat(const double dT, const double* const adX);
99 evec3 m_OutputQuatRot;
100 virtual const double* OutputQuatRot(const double dT, const double* const adX);
101 evec6 m_TotalConnectForce;
102 virtual const double* OutputConnectForce(const double dT, const double* const adX);
103
106
107 // Connections
110 double* m_ConnectLoc;
111 double* m_ConnectPos;
112 double* m_ConnectVel;
113 virtual const double* ConnectPos(const double dT, const double* const adX, int iConnect);
114 virtual const double* ConnectVel(const double dT, const double* const adX, int iConnect);
115 ISignalPort ** m_ConnectForce;
116
117 private:
118
119
120 };
121#endif
122} // namespace
Definition: CEnvironment.h:10
Definition: CSmallObject.h:38
CEnvironment * m_Environment
Sea environment variables.
Definition: CSmallObject.h:105
virtual const double * ConnectPos(const double dT, const double *const adX, int iConnect)
List of velocities (u,v,w) of the connections.
double * m_ConnectPos
List of local locations of the connections.
Definition: CSmallObject.h:111
double * m_ConnectVel
List of positions (x,y,z) of the connections.
Definition: CSmallObject.h:112
double * m_ConnectLoc
Index of the object to connect.
Definition: CSmallObject.h:110
int m_ConnectNum
Pointer to DeepSeaGravityWaves -> CEnvironment.
Definition: CSmallObject.h:108
int m_ConnectPA
Number of connections.
Definition: CSmallObject.h:109
Class modelling a flexible bottom ring, inheriting from CRing in RMCable lib.
Definition: CCable.h:142