Marine systems simulation
CNetCageScreen.h
1
9#ifndef CNetCageScreen_H
10#define CNetCageScreen_H
11
12#include <stdio.h>
13#include <string>
14
15#include <ISimObjectCreator.h>
16#include <SimObject.h>
17#include <Eigen/Eigen>
18#include <CEnvironment.h>
19#include <ICurrentVel.h>
20#include <IBasicBottom.h>
21#include "sfh/timers/ProfilerWallclock.h"
22#include "net/CNetCableElementSpec.h"
23#include "net/CNetCableElement.h"
24#include "net/CScreenElementDef.h"
25#include <environment/DeepSeaGravityWaves.h>
26//#include <net/CNetStructureSpec.h>
27#include "net/CScreenStructureSpec.h"
28#include "net/CScreenElement3N.h"
29#include "net/CNetBottomContactFilter.h"
30
31
32#pragma once
33#ifdef FH_VISUALIZATION
34//#include "CFhVis.h"
35#include "sfh/ogre/NMeshGenerators.h"
36#include "sfh/ogre/C3DLine.h"
37#include <CTextRenderer.h>
38#endif
39
40namespace Netcage {
41
42class CNetCageScreen : public SimObject
43{
44public:
46 CNetCageScreen(const string& simobjectname, ISimObjectCreator* const creator);
48 virtual ~CNetCageScreen();
49 virtual void OdeFcn(const double dT, const double* const adX, double* const adXDot, const bool bIsMajorTimeStep);
50 virtual void InitialConditionSetup(const double dT, const double *const adCurrentIC, double *const adUpdatedIC, ISimObjectCreator *const pCreator);
51 virtual void FinalSetup(const double dT, const double *const adX, ISimObjectCreator *const pCreator); // NEW: overridden to test new approach where pos and vel for selected nodes are set by external objects
52 const double * outExternalNodeForce(const double dT, const double *const adX, int iExtNode);
54 //virtual void OdeFcn(const double T, const double *const X, double *const XDot, const bool bIsMajorTimeStep);
55
56#ifdef FH_VISUALIZATION
58 virtual void RenderInit(Ogre::Root* const pOgreRoot, ISimObjectCreator* const pCreator); // Overridden to be able to run two NetCageSim simobjects.
59 virtual void RenderUpdate(const double T, const double* const X); // NEW: overridden to test new approach where pos and vel for selected nodes are set by external objects
60 void CreateCapsule( Ogre::ManualObject *capsule_manual);
61 C3DLine *myline;
62
63#endif
64
66 virtual const double * NodePos(const double dT, const double *const adX, int iExtNode);
67 virtual const double * NodeVel(const double dT, const double *const adX, int iExtNode);
68 virtual const double * BottomContact(const double dT, const double *const adX);
69 void SetAddedDragPerMPS(double AddedDragPerMPS);
71
72
74 const double* outSumHydDynForce(const double T, const double* const X);
75 const double* outNodeSumForce(const double T, const double* const X);
76 const double* outNodeSumDragForceAbs(const double T, const double* const X);
77 const double* outNodeSumDragForceDirection(const double T, const double* const X);
78 const double* outNodeSumLiftForce(const double T, const double* const X);
79 const double* outBottomPosition(const double T, const double* const X);
80 const double* outSteadyStateEst_Tau(const double T, const double* const X);
81 const double* outSteadyStateEst_K(const double T, const double* const X);
82 const double* LowerMembranePosition(const double dT, const double* const adX);
83 const double* outMiddleCurrentVelocity(const double dT, const double* const adX);
84
85 const double * InternalNodeForce(const double dT, const double *const adX, int iExtNode); // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
86 const double * NodeForce(const double T, const double *const X, int iNode);
87 //const double *const outExternalNodeForce(const double dT, const double *const adX, int iExtNode);
88 //const double* const outCurrentVel(const double T, const double* const X);
89
90 // Overloads the function in CNetStructure
91 //void AddNetForces(const double dT, const double* const adX);
92
93
94 void GetNodePositionIndices( std::vector<int> &NodePositions);
95 void GetNodeVelocityIndices( std::vector<int> &NodeVelocities);
96 vector<CScreenElement3N*> getNetElements();
97 void getNetElementConnections(vector<int*> &ElementConnections);
98 void setTraversedElements(vector<bool> TraversedElements);
99
100
101
102protected:
103
104 void DecomposeDragForcesInCurrentDirection(double* const DragForcesProjected, const double T, const double* const X);
105 bool SteadyStateEstimator(const double T, const double* const X);
106 void AddDeadFishWeightForce(const double T, const double* const X);
107
108 void SetExternalPos(const double dT, const double *const adX); // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
109 void SetExternalVel(const double dT, const double *const adX); // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
110
111 virtual void CreateDataStructures(); // NEW: overridden to test new approach where pos and vel for selected nodes are set by external objects
112 virtual void AddInputPorts(ISimObjectCreator *pCreator); // NEW: overridden to test new approach where pos and vel for selected nodes are set by external objects
113 virtual void CreateOutputPorts(ISimObjectCreator *pCreator); // NEW: overridden to test new approach where pos and vel for selected nodes are set by external objects
114 virtual void CalcStateDerivatives(const double *const adX, double *const adXDot); // NEW: overridden to test new approach where pos and vel for selected nodes are set by external objects
115 virtual double AddNodeBottomForce(const double *const adX, int iNode, double dDiam, double adForceInOut[3]);// NEW: overridden to test new approach where pos and vel for selected nodes are set by external objects
116 virtual void AddNetForces(const double dT, const double *const adX); // NEW: overridden to test new approach where pos and vel for selected nodes are set by external objects
117 virtual void AddCableForces(const double dT, const double *const adX); // NEW: overridden to test new approach where pos and vel for selected nodes are set by external objects
118
119 //ISignalPort* m_CurrentVel; // Current velocity input
120 ISignalPort **m_InExternalPos; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
121 ISignalPort **m_InExternalVel; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
122 ISignalPort *m_MembraneDepth; // Depth of membrane (Perma skirt.)
123
124 double* m_NodeExternalPos; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
125 double* m_NodeExternalVel; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
126
127 double m_adNodeSumForce[3];
128 double m_adSumHydDynForce[3];
129 double m_dNodeSumDragForceAbs;
130 double m_dNodeSumDragDirection;
131 double m_dNodeSumLiftForce;
132 double m_MiddleCurrentVelocity[3];
133
134 double* m_adNodeHydDynForce;
135
136 double* m_NodeInternalForces; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
137
138 int(* m_hasPosAndVelStates)[2]; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
139
140 int m_NumNodesInputPosAndVel; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
141 int m_NumNodesOutputForce; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
142
143 VSPairStrInt m_VsNodesInputPosAndVel; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
144 VSPairStrInt m_VsNodesOutputForce; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
145
146 Eigen::MatrixXd m_SSPhi; // Regression matrix for steady state estimation
147 Eigen::MatrixXd m_SSY; // Output matrix for steady state estimation
148 double m_SS_Tau; // Estimated first order time constant
149 double m_SS_K; // Estimated gain
150 sfh::timers::StopWatch m_SSCalcIntervalWatch; // Stop watch for timing of steady state calculations
151
152 int m_IsMembrane; // True if simobject is (membrane)
153 int m_MembraneIsInSystem; // True if membrane is added
154 double m_LowerMembraneDepth;
155 std::string m_simobjectname; // for debug
156 bool m_TerminateAtSteadyState; // True if automatic termination at predefied steady state level
157
158 double m_PI;
159
160 // NEW VARIABLES ASSOCIATED WITH WAKE EFFECT
161 std::string m_CageShape;
162 /*double m_TopDiameter;
163 double m_BottomDiameter;
164 double m_WallDepth;
165 double m_ConeDepth;*/
166 double* m_CageCentre;
167
168 int m_BottomNodeIndex;
169 double m_DeadFishInertia[3]; // Inertia for dead fish
170 double m_DeadFishWeigthForce;
171 bool m_HasDeadFish;
172 sfh::timers::StopWatch m_RealTimeWatch; // For calculation of elapsedtime in simulation
173
174
176 virtual void CreateNetPanels(std::vector<const CScreenElementDef*> VNetElementDefs, ISimObjectCreator *pCreator);
177 virtual void CreateNetCables(std::vector<const CNetCableElementSpec*> VCableElements, ISimObjectCreator *pCreator);
178 void AddExternalForces(const double dT, const double *const adX);
179 void AddBottomForces(const double *const adX);
180 VSPairStrInt CreateExternalNodeMap( std::string sTag, int* piUsed, CScreenStructureSpec & ScreenSpec, ISimObjectCreator *pCreator);
181 void PRINTALLNODEFORCES(std::string spec, double dT);
182
183 int m_iNumNodeOutputs;
184 int** m_aaiCableConn;
187 bool m_useReynoldsDependentDragCoefficients;
188
189 float* m_afInertia;
190 double* m_adNodeForce;
191 double* m_NodeExternalForces;
192 double m_adBottomContact[6];
193 int* m_aIStateVel;
194 int m_iNumNodesCalc;
195 int m_iNumNodesOriginal;
196 int m_iNumNodesOutputPosAndVel;
197 int m_iNumPanelsCalc;
198 int m_iNumCablesCalc;
199 int m_iNumNodesInputForce;
200 int* m_aiNetConn;
201 int* m_aIStatePos;
202 bool m_bUseTagForExternalNodes;
203 bool m_InternalElementWakeEffectsActive;
204 bool m_bFoldingPointRefinementUsed;
205 bool m_ExternalElementWakeEffectsActive;
206
209
210 ISignalPort** m_apInExternalForces;
211
212 CNetBottomContactFilter m_BottomContactFilter;
213 SAdaptationSpec_t m_SAdaptations;
214 CEnvironment* m_pEnvironment;
215 ICurrentVel** m_ppCurrentVel;
216 VSPairStrInt m_VsNodesOutputPosAndVel;
217 VSPairStrInt m_VsNodesInputForce;
218 IBasicBottom** m_ppBottom;
219
220 std::vector<CNetCableElement*> m_VpCableElements;
221 sfh::timers::StopWatch m_OdeTimer;
222 //std::vector<CScreenElement3N*> m_VpNetElements;
223 std::vector<CScreenElement3N*> m_VpScreenElements;
225
226#ifdef FH_VISUALIZATION
227/*
228 double m_Scale; ///< Scale factor for the visualization.
229 const Ogre::Root* m_OgreRoot;
230 Ogre::SceneNode* m_renderNode;
231*/
232#endif
233
234#ifdef CNetStructureWakeEffect_DO_PROFILE
235 sfh::timers::ProfilerWallclock m_Profiler;
236#endif
237
238
239};
240
241} // namespace
242#endif
Definition: CEnvironment.h:10
Definition: CNetBottomContactFilter.h:7
Class containing the specification for a net object.
Definition: CScreenStructureSpec.h:42
Interface for calculating the bottom force on various objects.
Definition: IBasicBottom.h:23
Definition: ICurrentVel.h:12
Definition: CNetCageScreen.h:43
virtual void CreateNetPanels(std::vector< const CScreenElementDef * > VNetElementDefs, ISimObjectCreator *pCreator)
VARIABLES NEEDED AFTER REMOVING NETSTRUCTURE — START.
virtual ~CNetCageScreen()
The destructor cleans up.
ISignalPort ** m_apInExternalForces
Harmonic coeffisients in drag and lift force calculations (a3,a5,b4,b6) for CD/cd=a1*cos(Theta)+a3*co...
Definition: CNetCageScreen.h:210
double m_harmForceCoeff[4]
Spesific for screen model.
Definition: CNetCageScreen.h:208
const double * outSumHydDynForce(const double T, const double *const X)
VARIABLES NEEDED AFTER REMOVING NETSTRUCTURE — END.
bool m_UseActualElementSizeInWakeEffect
Set to true if actual size (number of u and v bars) of net element shall be used in wake effect calcu...
Definition: CNetCageScreen.h:185
int m_NElementBarsInWakeEffectCalc
Number of u and v bars in calculation of wake effect if m_UseActualElementSizeInWakeEffect is set to ...
Definition: CNetCageScreen.h:186
CNetCageScreen(const string &simobjectname, ISimObjectCreator *const creator)
The constructor sets the pointer to the output object and the parser object.
virtual const double * NodePos(const double dT, const double *const adX, int iExtNode)
Calculates the state derivatives.
Class modelling a Net cage.
Definition: CBottomRing.h:35
Class containing the specification for a net object.
Definition: CNetStructureSpec.h:22