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