Marine systems simulation
CScreenElement3N.h
1
7
8#pragma once
9#ifndef C_SCREEN_ELEMENT_3N
10#define C_SCREEN_ELEMENT_3N
11
12#include <math.h>
13#include "CScreenElementDef.h"
14#include "CPrintDuringExec.h"
15#include <complex>
16#include "Eigen/Eigen"
17#include "Eigen/StdVector"
18using namespace std;
19using std::vector;
20#define vec3 Eigen::Matrix<double,3,1>
21
22//#include "math\sfhMath.h"
23//
24//#include <sfh/text.h>
25//#include <Eigen/Core>
26
27#ifdef FH_VISUALIZATION
28//#define USE_DYNAMIC_LINES
29#ifdef USE_DYNAMIC_LINES
30#include "sfh/ogre/CDynamicLines.h"
31#else
32#include "sfh/ogre/C3DLine.h"
33#endif
34#endif
35
36//#define RENDER_OUTLINE
37#define RENDER_MESH
38//#define ATTACH_SPHERE
39//#define RENDER_MATERIAL
40//#define FILTER_FORCES
41//#define CScreenElement3N_TRANSPARENT
42
43class CDynamicLines; // forward declaration
44
46{
47public:
50 const std::string sNetName,
51 const unsigned long iID,
52 const CScreenElementDef* pNetPanel,
53 const int NBarsInWakeEffectCalc,
54 const double dNy_water,
55 const double dRho_water,
56 const double dKnotDiameterRatio,
57 const double dKnotMomStiff,
58 const double dKknotMomStiff_contact,
59 const double dCnLinearLimitAngle,
60 const double dCnLinear,
61 const double dCnTurb,
62 const double dCnLam,
63 const double dTurbLimit,
64 const double dLamLimit,
65 const double dCt_nominal,
66 const double dCnKnots_nominal,
67 const double dDampingRatio,
68 const bool internalWakeEffectsActive,
69 const bool useActualSizeInWakeEffect,
70 const bool useReynoldsDependentDrag);
71
74
75 void AddNodeForces(const double* const adNodePosA_ned,
76 const double* const adNodePosB_ned,
77 const double* const adNodePosC_ned,
78 const double* const adNodeVelA_ned,
79 const double* const adNodeVelB_ned,
80 const double* const adNodeVelC_ned,
81 const double* const adWaterVel_ned,
82 double * const adNodeForceA_ned,
83 double * const adNodeForceB_ned,
84 double * const adNodeForceC_ned,
85 //double dBarD,
86 //double dBarL,
87 const double* const harmonicForceCoeffs,
88 double dHydroForcesRatio = 1.0,
89 double dAddedLinearDrag = 0.0);
90
92 double CalcNodeInertia(int iNode);
93
94 //****NEW STUFF FOR WAKE EFFECT INCLUSION****//
95 void GenerateInternalWakeEffectPolynomial(double* currentVel);
96 void GenerateExternalWakeEffectPolynomial(double* currentVel);
97 bool IsInShadowedRegionOfCage();
98 void SetInShadowedRegionOfCage(bool value);
99 void SetDistanceToWallInFront(double distance);
100 double GetExternalWakeEffect(double* currentVel, double* posA, double* posB, double* posC);
101 double GetInternalWakeEffect(double* currentVel, double* posA, double* posB, double* posC);
102
103 //****END NEW STUFF FOR WAKE EFFECT INCLUSION****//
104
105#ifdef FH_VISUALIZATION
107 void RenderInit(Ogre::Root* pOgreRoot);
108
110 void RenderUpdate( const double* const adPosA, const double* const adPosB,
111 const double* const adPosC );
112#endif
113
114 void setElementIsCoveredByROV(bool _covered);
115
116private:
117 void CalcTensionForces( double meshBarComp_panel[6], double meshBarLength[2],
118 double twineTension[2], double nodeATension_panel[3], double nodeBTension_panel[3],
119 double nodeCTension_panel[3]);
120
121 void CalcLocalUVComponents( double nodesABdist_panel[3], double nodesACdist_panel[3],
122 double nodesBCdist_panel[3], double meshBarComp_panel[6], double meshBarLength[2]);
123
124 void CalcMeshContactForces( double meshBarComp_panel[6],
125 double meshBarLength[2],
126 double nodeAMeshOpeningRes_panel[3],
127 double nodeBMeshOpeningRes_panel[3],
128 double nodeCMeshOpeningRes_panel[3],
129 double nodeATwineContactRes_panel[3],
130 double nodeBTwineContactRes_panel[3],
131 double nodeCTwineContactRes_panel[3]);
132
133 double CalcVelocities(double R_ned2panel[3][3],
134 const double* const adNodeVelA_ned,
135 const double* const adNodeVelB_ned,
136 const double* const adNodeVelC_ned,
137 const double* const adWaterVel_ned,
138 double elementVel_ned[3],
139 double hydDynVel_ned[3],
140 double hydDynVel_panel[3]);
141
142 void CalcHydroDynamicForces(double meshBarComp_panel[6],
143 double meshBarLength[2],
144 double R_ned2panel[3][3],
145 const double* const adNodeVelA_ned,
146 const double* const adNodeVelB_ned,
147 const double* const adNodeVelC_ned,
148 const double* const adWaterVel_ned,
149 double elementVel_ned[3],
150 double totalDragPerNode_panel[3]);
151
152 void CalcDampingForces( double elementVel_ned[3],
153 const double* const adNodeVelA_ned,
154 const double* const adNodeVelB_ned,
155 const double* const adNodeVelC_ned,
156 const double* const adWaterVel_ned,
157 double adDampingForcesNodeA[3],
158 double adDampingForcesNodeB[3],
159 double adDampingForcesNodeC[3],
160 double dAddedLinearDrag);
161
162 //****NEW STUFF FOR WAKE EFFECT INCLUSION****//
163
164 void SortPanelNodes(int index, const double * aadNodes[3], double adNodePosA_mesh[2], double adNodePosB_mesh[2], double adNodePosC_mesh[2], unsigned short* aiSort);
165 void FindTwineCrossings(unsigned short index, unsigned short kiNumMeshPerLine, double* CoeffA, double* CoeffB, const double* aadNodes[3]);
166
167 double GetDragCoefficientFromPolynomial(double nominalReynoldsNumber);
168 double Blevins(double DX, double DY, double Cd);
169 double SquaredSumColumnIn2DDoubleArray(Eigen::MatrixXd input,int colIndex,int length);
170 Eigen::VectorXd PolynomialFit(Eigen::VectorXd alpha, int nAlpha, Eigen::VectorXd targetArray, int order);
171 double ComputePolynomialValue(std::string polynomialType, double inputValue);
172 int m_maxUBarDimension;
173 int m_maxVBarDimension;
174 double *m_InternalWakeEffectPolynomial;
175 double *m_ExternalWakeEffectPolynomial;
176 int m_orderOfInternalPolynomial;
177 int m_orderOfExternalPolynomial;
178 bool m_InternalWakeEffectsActive;
179 bool m_isInShadowedRegionOfCage;
180 double m_distanceToWallInFront;
181 bool m_useReynoldsDependentDrag;
182 bool m_UseActualSizeInWakeEff;
183 int m_NBarsInWakeEffectCalc;
184
185 //****END NEW STUFF FOR WAKE EFFECT INCLUSION****//
186
187 double m_Sn;
188 double m_knotFactor;
189
190 // Input
191 unsigned long m_iID;
192
194 bool m_isWake;
195 double m_rWake;
197
198 std::string m_sNetName;
199 double m_ny_water;
200 double m_adNodeInertia[3];
201 //double m_rho_water; ///< Density of water.
202 //double m_rho_twines; ///< Material density of twines.
203 //double m_EModulus; ///< E-modulus of twine material.
204 double m_dBarD;
205 double m_dKnotD;
206 double m_dBarL0;
207 double m_dKnotMomStiff;
208 double m_dKnotMomStiffContact;
209 double m_adNodeAPos_mesh[2];
210 double m_adNodeBPos_mesh[2];
211 double m_adNodeCPos_mesh[2];
212 double m_CnLinearLimitAngle;
213 double m_CnLinear;
214 double m_CnTurb;
215 double m_CnLam;
216 double m_TurbLimit;
217 double m_LamLimit;
218 double m_Ct_nominal;
219 double m_CnKnots_nominal;
220
221 // Calculated element properties
222 //double m_twineCrossSecArea; ///< The cross sectional area of each twine.
223 double m_adNodesDistAB_mesh[2];
224 double m_adNodesDistAC_mesh[2];
225 double m_adNodesDistBC_mesh[2];
226 double m_dMeshDet;
227 double m_dNumMeshes;
228 double m_dNumUBars;
229 double m_dNumVBars;
230 double m_dNumKnots;
231 double m_dWeight;
232 double m_dEATwine;
233
234 double m_dMeshOpeningAngle;
235 double m_ShadowEffect[3];
236 double m_ShadowEffectBias;
237 // Calculated constants for increased computational performance.
238 double m_Ct;
239 double m_kKnot;
240 double m_NodeWeight;
241 double m_kTwineDragNormal[2];
242 double m_nodeAforce_ned[3];
243 double m_nodeBforce_ned[3];
244 double m_nodeCforce_ned[3];
245 double m_dDampingCoeff;
246
247
249 // typedef Eigen::Matrix<double,3,1> vec3;
251
252#ifdef FILTER_FORCES
253 double m_nodeAforce_ned_last[3];
254 double m_nodeBforce_ned_last[3];
255 double m_nodeCforce_ned_last[3];
256#endif
257
258 bool m_isCoveredByROV;
259
260#ifdef FH_VISUALIZATION
261 // Visualization specifics
262 Ogre::Root* m_pOgreRoot;
263 Ogre::SceneManager* m_pSceneMgr;
264 Ogre::Entity* m_apRenderElement[3];
265 Ogre::Entity* m_apRenderSphere[3];
266 Ogre::SceneNode* m_pRenderNodeMesh;
267 Ogre::SceneNode* m_apRenderNodeSphere[3];
268 Ogre::SceneNode* m_pRenderNodeOutline;
269 Ogre::SceneNode* m_pRenderNodeMaterial;
270#ifdef USE_DYNAMIC_LINES
271 CDynamicLines* m_pLines;
272#else
273 C3DLine* m_pLines;
274#endif
275 CDynamicLines* m_pLineOutline;
276 Ogre::ManualObject * m_pNetRenderObj;
277
278 // Visualization variables
279 unsigned short* m_aiSortU;
280 unsigned short* m_aiSortV;
281 unsigned long m_iNumTwines;
282 unsigned long m_iNumUTwines;
283 unsigned long m_iNumVTwines;
284 double* m_adInterpCoeffAu;
285 double* m_adInterpCoeffAv;
286 double* m_adInterpCoeffBu;
287 double* m_adInterpCoeffBv;
288#endif
289
290};
291
292
293#endif
Definition: CScreenElement3N.h:46
double CalcNodeInertia(int iNode)
Calculates the inertia of a node.
CScreenElement3N(const std::string sNetName, const unsigned long iID, const CScreenElementDef *pNetPanel, const int NBarsInWakeEffectCalc, const double dNy_water, const double dRho_water, const double dKnotDiameterRatio, const double dKnotMomStiff, const double dKknotMomStiff_contact, const double dCnLinearLimitAngle, const double dCnLinear, const double dCnTurb, const double dCnLam, const double dTurbLimit, const double dLamLimit, const double dCt_nominal, const double dCnKnots_nominal, const double dDampingRatio, const bool internalWakeEffectsActive, const bool useActualSizeInWakeEffect, const bool useReynoldsDependentDrag)
The constructor.
~CScreenElement3N(void)
The destructor.
Definition: CScreenElementDef.h:23