FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
NetStructureArray.h
1#pragma once
2#include "CommonTypes.h"
3
165// Includes
166#include <string>
167#include <utility>
168#include <vector>
169
171
172#include "NetBottomContactFilter.h"
173#include "NetCableElement.h"
174#include "NetElementDef.h"
175#include "NormalForceCalc.h"
176
177#include <fhsim/InputReader.h>
178#include <fhsim/simobject/SimObject.h>
179#include <fhsim_environment/EnvironmentProvider.h>
180
181#ifdef FH_VISUALIZATION
182# include <sfh/ogre/NMeshGenerators.h>
183#endif
184
185// Class definition
186class NetStructureArray : public SimObject
187{
188public:
190 NetStructureArray(std::string simObjectName, ISimObjectCreator* creator);
193 virtual void OdeFcn(const double dT, const double* const adX, double* const adXDot) const;
194 virtual void InitialConditionSetup(const double dT, const double* const adCurrentIC, double* const adUpdatedIC, ISimObjectCreator* const creator);
195 virtual void FinalSetup(const double dT, const double* const adX, ISimObjectCreator* const creator);
196#ifdef FH_VISUALIZATION
198 virtual void RenderInit(Ogre::Root* const ogreRoot, ISimObjectCreator* const creator);
200 virtual void RenderUpdate(const double dT, const double* const adX);
201#endif
202
203 void SetAddedDragPerMPS(double AddedDragPerMPS);
204 virtual const double* NumExternalPos(const double dT, const double* const adX);
205 virtual const double* NodePos(const double dT, const double* const adX, int extNode);
206 virtual const double* NodeVel(const double dT, const double* const adX, int extNode);
207 virtual const double* BottomContact(const double dT, const double* const adX);
208
209protected:
210 virtual void CalcStateDerivatives(const double* const adX, double* const adXDot) const;
211 virtual void AddExternalForces(const double dT, const double* const adX) const;
212 virtual void DeleteAllNodeForces() const;
213 virtual void ReadInputFile(ISimObjectCreator* creator);
214 virtual void AddNetForces(const double dT, const double* const adX) const;
215 virtual void AddCableForces(const double dT, const double* const adX) const;
216 void FindNodesToDivide(int nodesToDivide[2], double* length, double* lengthFactor);
217 void RefineMesh();
218 void CheckNodeNumber(int nodeNumber, ISimObjectCreator* const creator, std::string nodeDescription = "");
219 void CheckNodes(ISimObjectCreator* creator);
220 unsigned short AddCalcNode(int aiNodes[2]);
221 virtual double AddNodeBottomForce(const double* const adX, int node, double diam, double adForceInOut[3]) const;
222 virtual void AddBottomForces(const double* const adX) const;
223 virtual void AddInputPorts(ISimObjectCreator* creator);
224
225 mutable sfh::timers::StopWatch m_OdeTimer;
226
227 // Node indices
230
233
234 // Input ports
235 ISignalPort** m_inExternalForces;
236
237 // Output ports
239
240 // States
243
244 // Calculation variables
251 double m_fluidRho;
252 std::vector<NetElementDef> m_VSPanelData;
253 std::vector<NetCableElement*> m_VCableElements;
254 NetBottomContactFilter m_BottomContactFilter;
255 double m_bottomContact[6];
256 // Variables for controlling the calculation mesh refinement.
262 double m_scale;
264 double* m_inertia;
265 double* m_nodeForce;
266 std::string m_netName;
267 environment::EnvironmentProvider* m_environment;
268 // Net element properties.
269 int* m_netConn;
270 // Cable properties.
271 int** m_aaiCableConn;
272 // Variables controlling the simulation performance and adaptation.
283
284 int m_numNodeOutputs;
285 VSPairStrInt m_VsNodesOutput;
286 VSPairStrInt m_VsNodesInput;
287 VSPairStrInt m_VsNodesAvailable;
288
289 bool m_useTagForExternalNodes;
290 int CreateExternalNodeMap(VSPairStrInt& VsNodes, std::string tag, ISimObjectCreator* creator);
291 void CreateNetPanels(ISimObjectCreator* creator);
292 void CreateNetCables(ISimObjectCreator* creator);
293 void CreateDataStructures();
294 void CreateOutputPorts(ISimObjectCreator* creator);
295
296
297 // Net element data structures
298 // double* m_netElementNodeForces;
299 double* adNodesDistMesh;
300 double* adMesdDet;
301 double* adEATwine;
302 double* adMeshBarLength_unstretched;
303 double* adKnotDiameter;
304 double* adKnotMomStiff_contact;
305 double* adKKnot;
306 double* adTwineDragNormal;
307 double* adTwineDiameter;
308 double* adElementWaterVel;
309 double* adDampingCoeff;
310 double* adElementNodeWeight;
311
312 void PRINTALLNODEFORCES(std::string spec, double dT);
313};
Definition NetBottomContactFilter.h:7
Class containing a cable element object, allowing for disks and spheres to be connected.
Definition NetCableElement.h:34
Alias for std::vector<std::pair<std::string, int>> (was in fhsim v2 NFhSim.h).
Definition NetStructureArray.h:187
int m_maxNumNodes
The maximum number of nodes used for net calculations.
Definition NetStructureArray.h:259
VSPairStrInt m_VsNodesInput
The tag names and indices of the external nodes to be used as input.
Definition NetStructureArray.h:286
double m_numExternalPos
The index of the output port with position of the starboard wing external nodes.
Definition NetStructureArray.h:238
int m_numNodeOutputsUsed
The number of used external position outputs.
Definition NetStructureArray.h:229
double m_maxStepLength
The maximum step length for the simulation.
Definition NetStructureArray.h:273
double * m_nodeForce
The force on the global nodes.
Definition NetStructureArray.h:265
VSPairStrInt m_VsNodesAvailable
The tag names and indices of the available external nodes.
Definition NetStructureArray.h:287
double m_maxSideLengthFactor
The maximum element side length factor.
Definition NetStructureArray.h:257
double m_maxCableTension
The maximum tension of the cable elements.
Definition NetStructureArray.h:278
double m_minCableLength
The minimum length of the cable elements.
Definition NetStructureArray.h:276
VSPairStrInt m_VsNodesOutput
The tag names and indices of the external nodes to be used as output.
Definition NetStructureArray.h:285
int m_numNodesOriginal
The number of original nodes of the net.
Definition NetStructureArray.h:249
int * m_iStateVel
An array of indices to the node velocity states.
Definition NetStructureArray.h:242
std::vector< NetElementDef > m_VSPanelData
A vector of structs containing the section data read from the input file.
Definition NetStructureArray.h:252
int m_maxNumCables
The maximum number of cable elements used for the calculations.
Definition NetStructureArray.h:261
virtual ~NetStructureArray()
The destructor deletes dynamically allocated memory.
NetCableElement ** m_cableElements
An array holding the cable elements.
Definition NetStructureArray.h:263
int * m_iExternalConn
The index of the external nodes on the starboard wing.
Definition NetStructureArray.h:231
double m_maxAcceleration
The maximum acceleration component of each node.
Definition NetStructureArray.h:280
int m_numPanelsGlobal
The number of global sections of the net.
Definition NetStructureArray.h:246
double m_minSideLength
The side length limit for the elements to be further subdivided.
Definition NetStructureArray.h:258
std::string m_netName
The identification name of the net.
Definition NetStructureArray.h:266
int m_numNodeInputsUsed
The number of used external force inputs.
Definition NetStructureArray.h:228
double m_fluidRho
The density of the surrounding fluid.
Definition NetStructureArray.h:251
int m_maxNumPanels
The maximum number of net panels used for the calculations.
Definition NetStructureArray.h:260
double m_adaptationPeriod
The adaptation period for the mean tension in cables and net elements.
Definition NetStructureArray.h:274
int m_numCablesGlobal
The number of global cable elements.
Definition NetStructureArray.h:248
int m_numNodesCalc
The number of nodes of the net after refinement.
Definition NetStructureArray.h:250
long * m_externalNodes
The index of the starboard nodes corresponding to the elements of the enum TrawlSpec::ENetExternalNod...
Definition NetStructureArray.h:232
double m_stepSafetyFactor
The safety factor when calculating the adapted stiffness of the elements.
Definition NetStructureArray.h:275
int m_numPanelsCalc
The number of elements the net is divided into.
Definition NetStructureArray.h:245
double m_meanCableTension
The expected average tension of the cable elements.
Definition NetStructureArray.h:277
double * m_inertia
The inertia of the nodes.
Definition NetStructureArray.h:264
int m_numCablesCalc
The number of elements the cable is divided into.
Definition NetStructureArray.h:247
double m_scale
The scale of the trawl net in relation to the specifications.
Definition NetStructureArray.h:262
double m_maxVelocity
The maximum velocity component of each node.
Definition NetStructureArray.h:281
environment::EnvironmentProvider * m_environment
Environment provider.
Definition NetStructureArray.h:267
double m_addedDragPerMPS
The added linear drag per meter per second speed.
Definition NetStructureArray.h:282
ISignalPort ** m_inExternalForces
The external forces input port.
Definition NetStructureArray.h:235
double m_massFactor
A factor to multiply the mass of each node with, slowing down the eigenfrequencies of the system.
Definition NetStructureArray.h:279
int * m_iStatePos
An array of indices to the node position states.
Definition NetStructureArray.h:241
NetStructureArray(std::string simObjectName, ISimObjectCreator *creator)
The constructor sets the pointer to the output object and the parser object.
std::vector< NetCableElement * > m_VCableElements
A vector of structs containing the cable data read from the input file.
Definition NetStructureArray.h:253