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#include <set>
27#include <string>
28
29
31{
32public:
34 CTrawlNetAssembler(std::string outDir, std::string sNetName,bool usePlaceholders = false);
35
38
40 void ResetOutput(bool bResetError);
41
44
47
49 bool SetRefineFactor(double dRefineFactor);
50
52
54 bool SetRefineFactor(TrawlSpec::EPanel_t EPanel, int iSecNo, double dRefineFactor);
55
57 double GetScale();
58
60 void SetScale(double dScale);
61
63 void Scale(double dScaleMultiplier);
64
66 void SetMaxNumPanels(int iMaxNumPanels);
67
69 void SetMaxEdgeLengthFactor(double dEdgeLengthFactor);
70
72 void SetAdaptation(double dMaxStepLength, double dAdaptationPeriod = 0,
73 double dMeanCableTension = 0, double dStepSafetyFactor = 50);
74
77
96
105
108
111 {
112 std::string sMaterial;
113 double DrawScale;
114 };
115
117 virtual std::string ToFile(std::string filename = "");
118
120 std::string NetText();
121
123 std::string LibLine(const std::string& fileName);
124
126 std::vector<std::string> NodesInputForce();
127
129 std::vector<std::string> NodesOutputPosAndVel();
130
132 void SetWriteSideFiles(bool write) { m_writeSideFiles = write; }
133
134
137 const std::vector<TrawlSpec::SPanelNodes>& PanelNodes() const { return m_VSNodes; }
138
140 const std::vector<NetElementDef>& NetElements() const { return m_VSNetSections; }
141
143 const std::vector<SCableSectionData>& SimulationLines() const { return m_VSSimLines; }
144
146 const TrawlSpec::SNetExternalNodes& ExternalNodes() const { return m_SExternalNodes; }
147
149 void SectionSpecToFile(std::string sSectionSpecFileName);
150
151protected:
153 friend class CTrawlNetPrinter;
154
157
160
163
166
168 TrawlSpec::SPanelNodes CreateUnconnectedPanelNodes(TrawlSpec::EPanel_t EWhichPanel, int& iNextNode);
169
171 void ConnectNodes(std::vector<TrawlSpec::SNodeSpec> VSConn);
172
175
177 void ConnectNodes(TrawlSpec::EPanel_t Panel1, TrawlSpec::EPanelNodes NodePlacement1, int Section1,
178 TrawlSpec::EPanel_t Panel2, TrawlSpec::EPanelNodes NodePlacement2, int Section2);
179
181 bool IsSectionConnected(TrawlSpec::EPanel_t EWhichPanel, TrawlSpec::EPanelEdge_t EWhichEdge,
182 int iGlobalSection);
183
185 bool SetNodeNumber(TrawlSpec::SNodeSpec SNode, int iNodeNum);
186
189
191 std::vector<int> FindUnUsedNodes();
192
194 void CondenseNodes(std::vector<int> ViUnUsedNodes);
195
198
201
204
206 void CreateSimulationElements(TrawlSpec::EPanel_t EWhichPanel);
207
209 void CreateNodePosXY(TrawlSpec::EPanel_t EWhichPanel);
210
213
215 void AssignNodeNumbers(TrawlSpec::EPanel_t EWhichPanel, int iSecNo, int iElementNo,
216 NetElementDef* pNetElement);
217
219 std::vector<int> FindEdgeNodes(int iSecNo, TrawlSpec::EPanel_t EWhichPanel, TrawlSpec::ESectionSide_t EWhichSide, bool* pbDivide);
220
222 std::vector<int> FindEdgeNodesHP(int iSecNo, TrawlSpec::ESectionSide_t EWhichSide, TrawlSpec::EPanel_t EWhichPanel, bool* pbDivide);
223
225 std::vector<int> FindEdgeNodesSP(int iSecNo, TrawlSpec::ESectionSide_t EWhichSide, bool* pbDivide);
226
228 sfh::linalg::Vec2 GetNodePosUV(TrawlSpec::EPanel_t EWhichPanel, TrawlSpec::ESectionNode_t EWhichNode, int iSec);
229
231 TrawlSpec::SPosXY GetNodePosXY(TrawlSpec::EPanel_t EWhichPanel,
232 TrawlSpec::ESectionNode_t EWhichNode,
233 int iSec);
234
237
238 int ReplaceNodes(int iOldNode, int iNewNode);
239
241 std::vector<std::string> CreateNodeStringsFromIndices(std::set<TrawlSpec::ENetExternalNodes_t> ViExternalConnections);
242
243 std::vector<NetElementDef> m_VSNetSections;
244 std::vector<TrawlSpec::SPanelNodes> m_VSNodes;
245
248 double m_Scale;
251 std::vector<SCableSectionData> m_VSSimLines;
252 std::vector<std::vector<TrawlSpec::SNodeSpec>> m_VVSConnectedNodes;
253
254 TrawlSpec::SNetExternalNodes m_SExternalNodes;
255 bool m_writeSideFiles = true;
256};
257
258#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:31
SNetSimOptions m_SimOptions
The simulation options of the trawl net.
Definition CTrawlNetAssembler.h:247
double m_Scale
The scale of the trawl net in relation to the specifications.
Definition CTrawlNetAssembler.h:248
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:137
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:146
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:251
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:244
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:246
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:255
std::vector< NetElementDef > m_VSNetSections
A vector of the net sections ready for simulation.
Definition CTrawlNetAssembler.h:243
SNetIntegratorOptions m_IntegratorOptions
The integration options of the trawl net,.
Definition CTrawlNetAssembler.h:249
SLineVisualizationOptions m_SCableVisOptions
The visualization options of the cable elements.
Definition CTrawlNetAssembler.h:250
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:143
void SetExternalNodes()
Sets the external nodeNumbers.
const std::vector< NetElementDef > & NetElements() const
The net elements, as the net file lists them.
Definition CTrawlNetAssembler.h:140
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:132
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:56
Class used to collect and contain the specification of a trawl net.
Definition CTrawlNetSpec.h:30
Class containing the description of a net panel and methods necessary for taking this over to triangu...
Definition NetElementDef.h:24
A struct for defining how a cable element is to be visualized.
Definition CTrawlNetAssembler.h:111
Definition CTrawlNetAssembler.h:98
double MeanCableTension
The expected average tension of the cable elements.
Definition CTrawlNetAssembler.h:102
double AdaptationPeriod
The adaptation period for the mean tension in cables and net elements.
Definition CTrawlNetAssembler.h:100
double MaxStepLength
The maximum step the net simulation will encounter.
Definition CTrawlNetAssembler.h:99
double StepSafetyFactor
The safety factor when calculating the adapted stiffness of the elements.
Definition CTrawlNetAssembler.h:101
A struct for the simulation options concerning the trawl net.
Definition CTrawlNetAssembler.h:80
double MaxCableTension
The maximum tension of the cable elements.
Definition CTrawlNetAssembler.h:92
int NumPanels
The number of panels in the net before mesh refinement.
Definition CTrawlNetAssembler.h:82
int NumExternalNodes
The number of external nodes per side.
Definition CTrawlNetAssembler.h:90
int MaxNumPanels
The maximum number of panels in the net after mesh refinement.
Definition CTrawlNetAssembler.h:87
double MinElementLength
The minimum element length after mesh refinement.
Definition CTrawlNetAssembler.h:85
int MaxNumCables
The maximum number of cables in the net after mesh refinement.
Definition CTrawlNetAssembler.h:88
double MaxElementLength
The maximum element length after mesh refinement.
Definition CTrawlNetAssembler.h:84
double MaxElementLengthFactor
The maximum length factor of cables and net element edges after mesh refinement.
Definition CTrawlNetAssembler.h:89
int NumNodes
The number of nodes in the net before mesh refinement.
Definition CTrawlNetAssembler.h:81
int MaxNumNodes
The maximum number of nodes in the net after mesh refinement.
Definition CTrawlNetAssembler.h:86
double MinCableLength
The minimum length of the cable elements.
Definition CTrawlNetAssembler.h:91
int NumCables
The number of cables in the net before mesh refinement.
Definition CTrawlNetAssembler.h:83
Definition NTrawlSpec.h:43
Definition NTrawlSpec.h:252
Definition NTrawlSpec.h:271
Definition NTrawlSpec.h:264