FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
CTrawlNetAssembler.h
1
10#ifndef C_TRAWL_NET_ASSEMBLER_H
11#define C_TRAWL_NET_ASSEMBLER_H
12
13#include "CModelWriter.h"
14#include "CTrawlNetPrinter.h"
15#include "CTrawlNetSpec.h"
16#include "SCableSectionData.h"
17#include "SNetPanel.h"
18#include "net/NetElementDef.h"
19#include "net/NTrawlSpec.h"
20#include "net/SNetSectionData.h"
21
22#include <assert.h>
23#include <float.h>
24#include <limits.h>
25#include <vector>
26
27
29{
30public:
32 CTrawlNetAssembler(std::string outDir, std::string sNetName,bool usePlaceholders = false);
33
36
38 void ResetOutput(bool bResetError);
39
42
45
47 bool SetRefineFactor(double dRefineFactor);
48
50
52 bool SetRefineFactor(TrawlSpec::EPanel_t EPanel, int iSecNo, double dRefineFactor);
53
55 double GetScale();
56
58 void SetScale(double dScale);
59
61 void Scale(double dScaleMultiplier);
62
64 void SetMaxNumPanels(int iMaxNumPanels);
65
67 void SetMaxEdgeLengthFactor(double dEdgeLengthFactor);
68
70 void SetAdaptation(double dMaxStepLength, double dAdaptationPeriod = 0,
71 double dMeanCableTension = 0, double dStepSafetyFactor = 50);
72
75
94
103
106
109 {
110 std::string sMaterial;
111 double DrawScale;
112 };
113
115 virtual std::string ToFile(std::string filename = "");
116
118 std::string NetText();
119
121 std::string LibLine(const std::string& fileName);
122
124 std::vector<std::string> NodesInputForce();
125
127 std::vector<std::string> NodesOutputPosAndVel();
128
130 void SetWriteSideFiles(bool write) { m_writeSideFiles = write; }
131
132
135 const std::vector<TrawlSpec::SPanelNodes>& PanelNodes() const { return m_VSNodes; }
136
138 const std::vector<NetElementDef>& NetElements() const { return m_VSNetSections; }
139
141 const std::vector<SCableSectionData>& SimulationLines() const { return m_VSSimLines; }
142
144 const TrawlSpec::SNetExternalNodes& ExternalNodes() const { return m_SExternalNodes; }
145
147 void SectionSpecToFile(std::string sSectionSpecFileName);
148
149protected:
151 friend class CTrawlNetPrinter;
152
155
158
161
164
166 TrawlSpec::SPanelNodes CreateUnconnectedPanelNodes(TrawlSpec::EPanel_t EWhichPanel, int& iNextNode);
167
169 void ConnectNodes(std::vector<TrawlSpec::SNodeSpec> VSConn);
170
173
175 void ConnectNodes(TrawlSpec::EPanel_t Panel1, TrawlSpec::EPanelNodes NodePlacement1, int Section1,
176 TrawlSpec::EPanel_t Panel2, TrawlSpec::EPanelNodes NodePlacement2, int Section2);
177
179 bool IsSectionConnected(TrawlSpec::EPanel_t EWhichPanel, TrawlSpec::EPanelEdge_t EWhichEdge,
180 int iGlobalSection);
181
183 bool SetNodeNumber(TrawlSpec::SNodeSpec SNode, int iNodeNum);
184
187
189 std::vector<int> FindUnUsedNodes();
190
192 void CondenseNodes(std::vector<int> ViUnUsedNodes);
193
196
199
202
204 void CreateSimulationElements(TrawlSpec::EPanel_t EWhichPanel);
205
207 void CreateNodePosXY(TrawlSpec::EPanel_t EWhichPanel);
208
211
213 void AssignNodeNumbers(TrawlSpec::EPanel_t EWhichPanel, int iSecNo, int iElementNo,
214 NetElementDef* pNetElement);
215
217 std::vector<int> FindEdgeNodes(int iSecNo, TrawlSpec::EPanel_t EWhichPanel, TrawlSpec::ESectionSide_t EWhichSide, bool* pbDivide);
218
220 std::vector<int> FindEdgeNodesHP(int iSecNo, TrawlSpec::ESectionSide_t EWhichSide, TrawlSpec::EPanel_t EWhichPanel, bool* pbDivide);
221
223 std::vector<int> FindEdgeNodesSP(int iSecNo, TrawlSpec::ESectionSide_t EWhichSide, bool* pbDivide);
224
226 sfh::linalg::Vec2 GetNodePosUV(TrawlSpec::EPanel_t EWhichPanel, TrawlSpec::ESectionNode_t EWhichNode, int iSec);
227
229 TrawlSpec::SPosXY GetNodePosXY(TrawlSpec::EPanel_t EWhichPanel,
230 TrawlSpec::ESectionNode_t EWhichNode,
231 int iSec);
232
235
236 int ReplaceNodes(int iOldNode, int iNewNode);
237
239 std::vector<std::string> CreateNodeStringsFromIndices(std::set<TrawlSpec::ENetExternalNodes_t> ViExternalConnections);
240
241 std::vector<NetElementDef> m_VSNetSections;
242 std::vector<TrawlSpec::SPanelNodes> m_VSNodes;
243
246 double m_Scale;
249 std::vector<SCableSectionData> m_VSSimLines;
250 std::vector<std::vector<TrawlSpec::SNodeSpec>> m_VVSConnectedNodes;
251
252 TrawlSpec::SNetExternalNodes m_SExternalNodes;
253 bool m_writeSideFiles = true;
254};
255
256#endif
Contains static functions to write properties for fhSim from model to string and strings to model fil...
Definition CModelWriter.h:20
Class used to collect and contain the specification of a trawl net.
Definition CTrawlNetAssembler.h:29
SNetSimOptions m_SimOptions
The simulation options of the trawl net.
Definition CTrawlNetAssembler.h:245
double m_Scale
The scale of the trawl net in relation to the specifications.
Definition CTrawlNetAssembler.h:246
std::vector< std::string > CreateNodeStringsFromIndices(std::set< TrawlSpec::ENetExternalNodes_t > ViExternalConnections)
Creates node strings for external connections based on the given indexes (based on the TrawlSpec::ESe...
const std::vector< TrawlSpec::SPanelNodes > & PanelNodes() const
Definition CTrawlNetAssembler.h:135
void CreateUnconnectedPanelNodes()
Creates the unconnected structured panel node numbers.
void SetMaxEdgeLengthFactor(double dEdgeLengthFactor)
Sets the maximum edge length factor.
void ClearOutput()
Clears all output data.
const TrawlSpec::SNetExternalNodes & ExternalNodes() const
The node numbers of the external nodes, port and starboard; set by NetText.
Definition CTrawlNetAssembler.h:144
std::vector< std::string > NodesOutputPosAndVel()
The connected and the output external nodes (NodesOutputPosAndVel of LibLine).
void CreateNodeNumbers()
Creates structs containing the global node numbers for the various sections.
std::string LibLine(const std::string &fileName)
The <Lib> declaration ToFile returns, of a Net/NetStructure that reads the net file fileName.
std::vector< SCableSectionData > m_VSSimLines
A vector of the lines as they are to be included in the simulation.
Definition CTrawlNetAssembler.h:249
bool SetRefineFactor(double dRefineFactor)
Sets the refine factor of all sections of the net.
std::vector< TrawlSpec::SPanelNodes > m_VSNodes
A vector of the structured node numbers of the panels.
Definition CTrawlNetAssembler.h:242
std::vector< int > FindEdgeNodesSP(int iSecNo, TrawlSpec::ESectionSide_t EWhichSide, bool *pbDivide)
Finds the global nodes of the given edge of the given section in the sidepanels.
double GetScale()
Gets the scale of the trawl net.
void CreateCableElements()
Creates the cable elements associated with the net, including Headline and ground gear.
bool m_bAllNodesCW
Indicates if the nodes of all sections are set so that they are CW as seen from the outside of the tr...
Definition CTrawlNetAssembler.h:244
void CreatePanelNodes()
Creates the structured panel node numbers.
void ResetOutput(bool bResetError)
Resets both input and output data of the object.
bool SetNodeNumber(TrawlSpec::SNodeSpec SNode, int iNodeNum)
Sets the node number of the specified node.
bool m_writeSideFiles
Whether the panel drawings and the section table are written.
Definition CTrawlNetAssembler.h:253
std::vector< NetElementDef > m_VSNetSections
A vector of the net sections ready for simulation.
Definition CTrawlNetAssembler.h:241
SNetIntegratorOptions m_IntegratorOptions
The integration options of the trawl net,.
Definition CTrawlNetAssembler.h:247
SLineVisualizationOptions m_SCableVisOptions
The visualization options of the cable elements.
Definition CTrawlNetAssembler.h:248
int GetNumOriginalNodes()
Retrieves the number of nodes before mesh refinement.
void CreateNodePosXY(TrawlSpec::EPanel_t EWhichPanel)
Creates a xy-position for every node on a panel.
void Scale(double dScaleMultiplier)
Multiplies the scale of the trawl net by a factor.
void SetMaxNumPanels(int iMaxNumPanels)
Sets the maximum number of panels for the simulation.
TrawlSpec::SPanelNodes CreateUnconnectedPanelNodes(TrawlSpec::EPanel_t EWhichPanel, int &iNextNode)
Creates the unconnected structured panel node numbers of one panel.
void ConnectNodes(TrawlSpec::SNodeSpec SConn1, TrawlSpec::SNodeSpec SConn2)
Collects nodes to be connected.
std::vector< int > FindEdgeNodes(int iSecNo, TrawlSpec::EPanel_t EWhichPanel, TrawlSpec::ESectionSide_t EWhichSide, bool *pbDivide)
Finds the global nodes of the given edge of the given section.
virtual std::string ToFile(std::string filename="")
Writes the trawl net model to a model file.
bool IsSectionConnected(TrawlSpec::EPanel_t EWhichPanel, TrawlSpec::EPanelEdge_t EWhichEdge, int iGlobalSection)
Determines if a given panel is connected at the given side and the given global section number.
void SectionSpecToFile(std::string sSectionSpecFileName)
Sends the specification of the net sections to a csv file for debugging purposes.
void AssignNodeNumbers(TrawlSpec::EPanel_t EWhichPanel, int iSecNo, int iElementNo, NetElementDef *pNetElement)
Assigns node numbers to the given panel.
void ConnectNodes(std::vector< TrawlSpec::SNodeSpec > VSConn)
Collects nodes to be connected.
void CreateSimulationElements(TrawlSpec::EPanel_t EWhichPanel)
Creates a vector of all sections with the data necessary for simulation.
void ConnectNodes(TrawlSpec::EPanel_t Panel1, TrawlSpec::EPanelNodes NodePlacement1, int Section1, TrawlSpec::EPanel_t Panel2, TrawlSpec::EPanelNodes NodePlacement2, int Section2)
Collects nodes to be connected.
void SetAdaptation(double dMaxStepLength, double dAdaptationPeriod=0, double dMeanCableTension=0, double dStepSafetyFactor=50)
Sets some options for increasing the possible step length in the system.
SNetSimOptions GetSimoptions()
Gets the simulation options.
void MakeAllNodesCW()
Makes the nodes of all sections so that they are CW as seen from the outside of the trawl.
std::vector< std::string > NodesInputForce()
The external nodes the net is connected by (NodesInputForce of LibLine).
sfh::linalg::Vec2 GetNodePosUV(TrawlSpec::EPanel_t EWhichPanel, TrawlSpec::ESectionNode_t EWhichNode, int iSec)
Returns the mesh position of the specified node.
const std::vector< SCableSectionData > & SimulationLines() const
The lines as the net file lists them: each line of the specification per side, or in its two halves.
Definition CTrawlNetAssembler.h:141
void SetExternalNodes()
Sets the external nodeNumbers.
const std::vector< NetElementDef > & NetElements() const
The net elements, as the net file lists them.
Definition CTrawlNetAssembler.h:138
void CondenseNodes(std::vector< int > ViUnUsedNodes)
Sets the node numbers to fill in all node numbers not used.
~CTrawlNetAssembler(void)
Destructor.
void SetWriteSideFiles(bool write)
Writes the panel drawings (CreatePanelDefinitions) and the section table (SectionSpecToFile),...
Definition CTrawlNetAssembler.h:130
std::vector< int > FindEdgeNodesHP(int iSecNo, TrawlSpec::ESectionSide_t EWhichSide, TrawlSpec::EPanel_t EWhichPanel, bool *pbDivide)
Finds the global nodes of the given edge of the given section in the upper or lower panels.
bool SetRefineFactor(TrawlSpec::EPanel_t EPanel, int iSecNo, double dRefineFactor)
Sets a ratio to calculate the hydrodynamic forces on the net sections with.
std::vector< int > FindUnUsedNodes()
Finds all node numbers which are not in use.
void SetScale(double dScale)
Sets the scale of the trawl net.
TrawlSpec::SPosXY GetNodePosXY(TrawlSpec::EPanel_t EWhichPanel, TrawlSpec::ESectionNode_t EWhichNode, int iSec)
Returns the XY position of the specified node.
std::string NetText()
The text of the <Net> file ToFile writes.
bool VerifyCableNodes()
Checks if the cable nodes are all right.
void ConnectPanelNodes()
Creates the connected structured panel node numbers from the unconnected.
void CreatePanelDefinitions()
Uses the net specifications to construct the sections usable for simulation.
CTrawlNetAssembler(std::string outDir, std::string sNetName, bool usePlaceholders=false)
Constructor.
void SetSimOptions()
Sets the simulation options for the trawl net.
int GetNodeNumber(TrawlSpec::SNodeSpec SNode)
Gets the node number of the specified node.
Definition CTrawlNetPrinter.h:54
Class used to collect and contain the specification of a trawl net.
Definition CTrawlNetSpec.h:29
Class containing the description of a net panel and methods necessary for taking this over to triangu...
Definition NetElementDef.h:22
A struct for defining how a cable element is to be visualized.
Definition CTrawlNetAssembler.h:109
Definition CTrawlNetAssembler.h:96
double MeanCableTension
The expected average tension of the cable elements.
Definition CTrawlNetAssembler.h:100
double AdaptationPeriod
The adaptation period for the mean tension in cables and net elements.
Definition CTrawlNetAssembler.h:98
double MaxStepLength
The maximum step the net simulation will encounter.
Definition CTrawlNetAssembler.h:97
double StepSafetyFactor
The safety factor when calculating the adapted stiffness of the elements.
Definition CTrawlNetAssembler.h:99
A struct for the simulation options concerning the trawl net.
Definition CTrawlNetAssembler.h:78
double MaxCableTension
The maximum tension of the cable elements.
Definition CTrawlNetAssembler.h:90
int NumPanels
The number of panels in the net before mesh refinement.
Definition CTrawlNetAssembler.h:80
int NumExternalNodes
The number of external nodes per side.
Definition CTrawlNetAssembler.h:88
int MaxNumPanels
The maximum number of panels in the net after mesh refinement.
Definition CTrawlNetAssembler.h:85
double MinElementLength
The minimum element length after mesh refinement.
Definition CTrawlNetAssembler.h:83
int MaxNumCables
The maximum number of cables in the net after mesh refinement.
Definition CTrawlNetAssembler.h:86
double MaxElementLength
The maximum element length after mesh refinement.
Definition CTrawlNetAssembler.h:82
double MaxElementLengthFactor
The maximum length factor of cables and net element edges after mesh refinement.
Definition CTrawlNetAssembler.h:87
int NumNodes
The number of nodes in the net before mesh refinement.
Definition CTrawlNetAssembler.h:79
int MaxNumNodes
The maximum number of nodes in the net after mesh refinement.
Definition CTrawlNetAssembler.h:84
double MinCableLength
The minimum length of the cable elements.
Definition CTrawlNetAssembler.h:89
int NumCables
The number of cables in the net before mesh refinement.
Definition CTrawlNetAssembler.h:81
Definition NTrawlSpec.h:43
Definition NTrawlSpec.h:252
Definition NTrawlSpec.h:271
Definition NTrawlSpec.h:264