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