Marine systems simulation
CBarge.h
1#ifndef CBarge_H
2#define CBarge_H
3
15#include <string>
16#include <Eigen/Eigen>
17
18#include "SimObject.h"
19#include "CEnvironment.h"
20#include <CIntegratorOptions.h>
21#include "Subroutines.h"
22
23
24namespace barge {
25#define sys_size 22
26
27class CBarge : public SimObject
28{
29public:
30 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
31
32 CBarge(std::string sSimObjectName, ISimObjectCreator* pCreator);
33 virtual void FinalSetup(const double dT, const double* const adX, ISimObjectCreator* const pCreator);
34 virtual void InitialConditionSetup(const double T, const double *const currentIC, double* updatedIC, ISimObjectCreator* creator);
35 virtual ~CBarge();
36
37#ifdef FH_VISUALIZATION
39 virtual void RenderInit(Ogre::Root* const ogreRoot, ISimObjectCreator* const creator);
40
42 virtual void RenderUpdate(const double dT, const double* const adX);
43
45 void DrawBody(Ogre::SceneNode* renderNode, Ogre::SceneManager* sceneMgr, const int& pi);
46#endif
47
49 virtual void OdeFcn(const double dT, const double* const adX, double* const adXDot, const bool bIsMajorTimeStep);
50
51 // r: global
52 // q: global
53 // dX: bodylocal
54 // return: forcelocal
55 virtual vec6 GetInternalForces(const int& pi, const vec6& dX, const vec3& r, const quat& ql2g, const quat& qg2l, double time, const double* const states);
56
57 // return: bodylocal
58 virtual mat6 GetInertiaMatrix(const int& pi, const vec3& r, const quat& q, const double dT, const double* const adX);
59
60 // all global coords
61 virtual vec13 GetSecondDerivative(const int& pi, const vec3& r, const quat& ql2g, const quat& qg2l, const vec3& v, const vec3& w, const vec6& externalForces, const double time, const double* const states);
62
63 // bodylocal coords
64 static vec6 GetCoriolisForce(const vec6& dX, const mat6& Inertia);
65
66
67 // Connections =============================================================================
68 virtual vec6 CalConnectForce(const vec3& r, const vec6& dX, const quat& ql2g, const quat& qg2l, const double dT, const double* const adX);
69 // Connections =============================================================================
70
71 // Wave overtopping ========================================================================
72 virtual vec6 CalcHydroforcesBarge(const int& pi, const vec6& dX, const vec3& r, const quat& ql2g, const quat& qg2l, double time, const double* const states);
73 virtual vec6 FroudeKriloffBarge(const int& pi, const vec6& dX, const vec3& r, const quat& ql2g, const quat& qg2l, double time, const double* const states);
74 virtual vec6 DiffractionBarge(const int& pi, const vec6& dX, const vec3& r, const quat& ql2g, const quat& qg2l, double time, const double* const states);
75
76 virtual vec6 CalWaveOverToppingBarge(const int& pi, const vec6& dX, const vec3& r, const quat& ql2g, const quat& qg2l, double time, const double* const states);
77 // Wave overtopping ========================================================================
78
79protected:
80
81 // Input ports.
82
83 // Output ports.
84 virtual const double* BargeState(const double dT, const double* const adX);
85 virtual const double* ConnectForce(const double dT, const double* const adX);
86 virtual const double* RadiationDamping(const double dT, const double* const adX);
87 virtual const double* FirstOrderWave(const double dT, const double* const adX);
88
89 // States
90 int m_IStatePos;
95
96 // Parameters
98 vec3** m_BargeV;
99 vec3** m_xyzBargeV;
100
103
106
108 double m_wDragCoeff[2];
109 double m_BargeSpeed[3];
111 double m_BargeState[22];
112 double m_StepSize;
113 double m_PrevTime;
114
115
116 // Connections =============================================================================
119 double* m_ConnectLoc;
120 double* m_ConnectPos;
121 double* m_ConnectVel;
122 virtual const double* ConnectPos(const double dT, const double* const adX, int iConnect);
123 virtual const double* ConnectVel(const double dT, const double* const adX, int iConnect);
124 ISignalPort ** m_ConnectForce;
125
126 double m_StructConnectForce[8];
127 // Connections =============================================================================
128
129 // State-space implementation ==============================================================
131 int m_IStateSSpace;
133 int m_StateNum;
134
135 Eigen::Matrix<double, sys_size, sys_size>* m_SSpaceA;
136 Eigen::Matrix<double, sys_size,1>* m_SSpaceB;
137 Eigen::Matrix<double,1, sys_size>* m_SSpaceC;
138 Eigen::Matrix<double,1,1>* m_SSpaceD;
139 double* m_SSpaceSDot;
140
141 virtual vec6 CalStateSpaceStructure(const int& pi, const double dT, const double* const adX, const vec6& VS);
142 // State-space implementation ==============================================================
143
144 // Wave components =========================================================================
145 int m_WNum;
146 std::vector<double> m_WaveF;
147 std::vector<double> m_WaveA;
148 std::vector<double> m_WaveP;
149 std::vector<double> m_WaveD;
150 std::vector<double> m_WaveN;
151
152 double* m_DiffA;
153 double* m_DiffP;
154 // Wave components =========================================================================
155
156 // Barge dimensions ========================================================================
157 double m_BargeL;
158 double m_BargeB;
159 double m_BargeD;
160 double m_BargeH;
161 double m_BargeCOG[3];
162 double m_BargeZG[2];
163 double m_BargeRST[6];
165 // Barge dimensions ========================================================================
166
167 // Wave overtopping ========================================================================
168 vec3 m_TAcc;
169 vec3 m_RAcc;
170 int m_wTop;
171 double m_wTopHmin;
172 double m_wTopCFL;
173 int m_wTopN;
174 double m_wTopL;
175 double m_dx;
176 int m_wodwriteoutput;
177 std::ofstream m_wodoutputfile1;
178 std::ofstream m_wodoutputfile2;
179 bool m_isMajorTimeStep;
180
181 // Shallow water grid and state variables:
182 std::valarray<double> m_x;
183 //std::valarray<double> m_h;
184 std::valarray<double> m_u;
185 std::valarray<double> m_q1;
186 std::valarray<double> m_q2;
187 //double* m_x;
188 //double* m_h;
189 //double* m_u;
190 //double* m_q1;
191 //double* m_q2;
192
193 // Wave overtopping ========================================================================
194
195 // Output buffer
196 double m_radiationForce[6];
197 double m_firstOrderWave[6];
198
199 // Test
200 int m_tNum;
201 int m_oNum;
202 double m_test[50];
203
204#ifdef FH_VISUALIZATION
205 string m_Material;
206 Ogre::SceneNode** m_RenderNodes;
207 Ogre::SceneManager* m_SceneMgr;
208 vector<Ogre::ManualObject*> m_Manual;
209#endif
210
211};
212
213};
214#endif
Definition: CEnvironment.h:10
Definition: CBarge.h:28
double m_BargeD
Beam.
Definition: CBarge.h:159
int m_ConnectNum
Previous time step.
Definition: CBarge.h:117
int m_IStateQuater
Index of the global rotation in the state vector.
Definition: CBarge.h:92
double m_BargeSpeed[3]
Water drag coefficient.
Definition: CBarge.h:109
int m_IStateLocalVel
Index of the quaternions in the state vector.
Definition: CBarge.h:93
virtual void OdeFcn(const double dT, const double *const adX, double *const adXDot, const bool bIsMajorTimeStep)
Calculates the state derivatives.
PolyplateSpec m_PolyPlate[1]
Particle class for contact detection.
Definition: CBarge.h:105
double m_PrevTime
Integration step size.
Definition: CBarge.h:113
double * m_ConnectLoc
Index of the object to connect.
Definition: CBarge.h:119
int m_numFloe
Index of the local angular velocity in the state vector.
Definition: CBarge.h:97
int m_IStateRot
Index of the global position in the state vector.
Definition: CBarge.h:91
double m_BargeH
Draft.
Definition: CBarge.h:160
mat6 m_BargeMass
Restoring coefficient.
Definition: CBarge.h:164
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: CBarge.h:120
int m_ModeNum
Index of the additional states for state-space implementation in the state vector.
Definition: CBarge.h:132
double m_BargeDensity
Polyplate structure.
Definition: CBarge.h:107
vec3 m_TAcc
Mass matrix.
Definition: CBarge.h:168
double m_StepSize
Barge states - Why 22?
Definition: CBarge.h:112
double m_BargeZG[2]
Centre of gravity.
Definition: CBarge.h:162
int m_ConnectPA
Number of connections.
Definition: CBarge.h:118
vec3 ** m_xyzBargeV
Local coordinates of the barge vertices.
Definition: CBarge.h:99
CEnvironment * m_Environment
Initial barge drift speed.
Definition: CBarge.h:110
Particle m_Particle[1]
Damping matrix.
Definition: CBarge.h:104
double m_BargeB
Length.
Definition: CBarge.h:158
double m_BargeCOG[3]
Depth - Height/thickness?
Definition: CBarge.h:161
int m_StateSpace
Output global connect force acting on the structure.
Definition: CBarge.h:130
double m_BargeRST[6]
Bottom and top relative to COG.
Definition: CBarge.h:163
vec3 ** m_BargeV
Number of barges -> Will always be 1, therefore remove?
Definition: CBarge.h:98
mat6 * m_AddedMass
Coordinates of the barge vertices.
Definition: CBarge.h:101
double m_wDragCoeff[2]
Density of barge.
Definition: CBarge.h:108
int m_IStateOmega
Index of the local velocity in the state vector.
Definition: CBarge.h:94
double m_BargeState[22]
Pointer to DeepSeaGravityWaves -> CEnvironment.
Definition: CBarge.h:111
double * m_ConnectVel
List of positions (x,y,z) of the connections.
Definition: CBarge.h:121
mat6 * m_DampMatrix
Added mass matrix.
Definition: CBarge.h:102
Definition: Subroutines.h:265
Definition: Subroutines.h:94