FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
NetCore.h
1#pragma once
2
22#include "NetCableElement.h"
23#include "NetElement3N.h"
24#include "NetFlowInteraction.h"
25#include "NetNodeStates.h"
26#include "NetPanelSetup.h"
27#include "NetStructureSpec.h"
28
29#include <fhsim/ISimObjectLogger.h>
30#include <fhsim/PrintDuringExec.h>
31#include <fhsim/simobject/ISimObjectCreator.h>
32#include <fhsim_environment/EnvironmentProvider.h>
33#include <fhsim_environment/SeafloorForcesInterface.h>
34#include <fhsim_environment/hydrodynamics/PanelClampLog.h>
35#include <limits>
36#include <memory>
37#include <string>
38#include <vector>
39
48
50{
51public:
64 NetCore(const std::string& name, const NetStructureSpec& spec, const NetCoreOptions& options, ISimObjectCreator* creator);
65 ~NetCore();
66 NetCore(const NetCore&) = delete;
67 NetCore& operator=(const NetCore&) = delete;
68
77 void FinalSetup(const NetNodeStates& nodes, const double* X, ISimObjectCreator* creator);
78
81 void PreOdeFcn(double T, const double* X);
82
87 void Evaluate(double T, const double* X, double* XDot) const;
88
90 void AcceptedStep(double T);
91
93 void SetAddedDragPerMPS(double addedDragPerMPS) { m_adaptations.addedDragPerMPS = addedDragPerMPS; }
94
96 NetNodeView View(const double* X, int stateBase = 0) const { return NetNodeView {X, &m_layout, stateBase}; }
97
98 int NumNodes() const { return m_numNodesCalc; }
99 int NumOriginalNodes() const { return m_numNodesOriginal; }
100 int NumPanels() const { return static_cast<int>(m_panels.size()); }
101 int NumCables() const { return static_cast<int>(m_cables.size()); }
102
104 const int* PanelNodes(int panel) const { return m_panelNodes.data() + 3 * panel; }
105 const NetElement3N& Panel(int panel) const { return *m_panels[panel]; }
106 NetElement3N& Panel(int panel) { return *m_panels[panel]; }
107 const NetCableElement& Cable(int cable) const { return *m_cables[cable]; }
108 NetCableElement& Cable(int cable) { return *m_cables[cable]; }
109
111 float Inertia(int node) const { return m_inertia[node]; }
113 const double* NodeForce(int node) const { return m_nodeForce.data() + 3 * node; }
114
115 const SAdaptationSpec_t& Adaptations() const { return m_adaptations; }
116 bool FoldingPointRefinementUsed() const { return m_foldingPointRefinementUsed; }
117 const net_panel_setup::PanelHydrodynamics& PanelHydrodynamics() const { return m_panelHydrodynamics; }
118 environment::EnvironmentProvider* Environment() const { return m_environment; }
119
121 bool InBottomContact() const { return m_inBottomContact; }
123 const double* BottomContact() const { return m_bottomContactFiltered; }
124
126 void PrepareFlow(double T, const double* X, int stateBase) const { UpdateNodeWaveVelocities(T, View(X, stateBase), 0, m_numNodesCalc); }
128 void FlowAt(double T, int point, const double pos[3], double vel[3]) const;
131 void CableHydrodynamicForce(double T, const double* X, double force[3]) const;
133 const environment::wake::BodyWake* Wake() const { return m_flow->Wake(); }
134
135private:
136 void CreatePanels(std::vector<const NetElementDef*> definitions, ISimObjectCreator* creator);
137 void CreateCables(std::vector<const NetCableElementSpec*> specs, ISimObjectCreator* creator);
139 void UpdateNodeWaveVelocities(double T, const NetNodeView& nodes, int begin, int end) const;
141 void AddPanelForceRange(double T, const NetNodeView& nodes, int begin, int end, double* nodeForce) const;
144 void AddCableForceRange(double T, const NetNodeView& nodes, int begin, int end, double* nodeForce, bool waterFollowsElement = false) const;
146 void AddBottomForces(const NetNodeView& nodes) const;
147
148 std::string m_name;
149 NetCoreOptions m_options;
150
152
153 int m_numNodesCalc = 0;
154 int m_numNodesOriginal = 0;
155 std::vector<std::unique_ptr<NetElement3N>> m_panels;
156 std::vector<int> m_panelNodes;
157 std::vector<std::unique_ptr<NetCableElement>> m_cables;
158 std::vector<float> m_inertia;
159 mutable std::vector<double> m_nodeForce;
160 SAdaptationSpec_t m_adaptations;
161 bool m_foldingPointRefinementUsed = false;
163
165
166 const NetNodeStates* m_nodes = nullptr;
167 NetNodeLayout m_layout;
169
171
172 net_panel_setup::PanelHydrodynamics m_panelHydrodynamics;
173 net_solidity::SolidityModel m_solidityModel = net_solidity::kDefaultSolidityModel;
175
177
178 environment::EnvironmentProvider* m_environment = nullptr;
179 std::unique_ptr<NetFlowInteraction> m_flow;
180 mutable std::vector<double> m_nodeWaveVelocity;
181 ISimObjectLogger* m_logger = nullptr;
182 PrintDuringExec* m_print = nullptr;
183 hydrodynamics::PanelClampLog m_clampLog;
185
186 int m_numThreads = 1;
187 mutable std::vector<double> m_threadNodeForces;
189 double m_meanTensionTime = std::numeric_limits<double>::quiet_NaN();
190
192
193 environment::SeafloorForcesInterface* m_seafloor = nullptr;
194 double m_bottomContactTimeConstant = 0.01;
195 double m_bottomContactDiameter = 0.5;
196 mutable double m_bottomContact[6] = {};
197 double m_bottomContactFiltered[6] = {};
198 double m_lastAcceptedTime = 0.0;
199 bool m_hasAcceptedStep = false;
200 mutable bool m_inBottomContact = false;
202};
Definition Cable.h:128
Definition NetCableElement.h:49
Definition NetCore.h:50
NetNodeView View(const double *X, int stateBase=0) const
The nodes of X; stateBase as NetNodeView. Valid after FinalSetup.
Definition NetCore.h:96
const environment::wake::BodyWake * Wake() const
The net's BodyWake; null without an environment or before FinalSetup.
Definition NetCore.h:133
bool InBottomContact() const
Whether the seabed gave an original node a force at the last evaluation (false without bottom contact...
Definition NetCore.h:121
const double * NodeForce(int node) const
The force on node of the last evaluation, 3 values [N].
Definition NetCore.h:113
void AcceptedStep(double T)
Filters the seabed contact of the last evaluation once per accepted step (MARE-0355).
int NumNodes() const
The calculation nodes.
Definition NetCore.h:98
void CableHydrodynamicForce(double T, const double *X, double force[3]) const
const double * BottomContact() const
The filtered seabed force and its moment about the NED origin, 6 values (MARE-0064,...
Definition NetCore.h:123
const int * PanelNodes(int panel) const
The three nodes of panel.
Definition NetCore.h:104
int NumOriginalNodes() const
The nodes of the net file, before refinement.
Definition NetCore.h:99
void PrepareFlow(double T, const double *X, int stateBase) const
For a Jacobian: the node wave velocities at X, whose positions are offset by stateBase (R62).
Definition NetCore.h:126
void PreOdeFcn(double T, const double *X)
const SAdaptationSpec_t & Adaptations() const
MassFactor, MaxVelocity, AddedDragPerMPS.
Definition NetCore.h:115
void FinalSetup(const NetNodeStates &nodes, const double *X, ISimObjectCreator *creator)
void Evaluate(double T, const double *X, double *XDot) const
NetCore(const std::string &name, const NetStructureSpec &spec, const NetCoreOptions &options, ISimObjectCreator *creator)
void SetAddedDragPerMPS(double addedDragPerMPS)
Sets the added drag per unit speed, spread over the panels [N s/m].
Definition NetCore.h:93
float Inertia(int node) const
The node mass from the panels and cable elements [kg].
Definition NetCore.h:111
void FlowAt(double T, int point, const double pos[3], double vel[3]) const
The water velocity at a panel centroid (point = panel) or a cable midpoint (point = number of panels ...
Definition NetElement3N.h:49
Definition NetNodeStates.h:39
Definition NetStructureSpec.h:40
Class containing a cable element object, allowing for disks and spheres to be connected.
Definition NetCableElement.h:36
What the two nets choose differently in the core (owner ruling Q3, 2026-10-14: adapter choices).
Definition NetCore.h:42
NetCableOptions cable
How the cable elements are built (NetCableElement.h).
Definition NetCore.h:45
bool bottomContact
Seabed contact of the original nodes, its sum and its filtered port value.
Definition NetCore.h:46
NetPanelOptions panel
How the panels are built (NetElement3N.h); dampingRatio is read from NetDampingRatio when twineStruct...
Definition NetCore.h:44
std::string structureName
"NetStructure" or "NetStructureWithConstraints", for messages.
Definition NetCore.h:43
Definition NetNodeStates.h:19
The nodes of one state vector, as the net core reads them: plain index arithmetic,...
Definition NetNodeStates.h:26
What a net panel adds beyond its load and weight in water. Net/NetStructure uses the defaults.
Definition NetElement3N.h:40
Class containing the specification for a net object.
Definition NetStructureSpec.h:25
The panel load law and the fluid shared by all panels of a structure.
Definition NetPanelSetup.h:38