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/simobject/ISimObjectCreator.h>
31#include <fhsim_environment/EnvironmentProvider.h>
32#include <fhsim_environment/SeafloorForcesInterface.h>
33#include <fhsim_environment/hydrodynamics/PanelClampLog.h>
34#include <limits>
35#include <memory>
36#include <string>
37#include <vector>
38
47
49{
50public:
63 NetCore(const std::string& name, NetStructureSpec& spec, const NetCoreOptions& options, ISimObjectCreator* creator);
64 ~NetCore();
65 NetCore(const NetCore&) = delete;
66 NetCore& operator=(const NetCore&) = delete;
67
76 void FinalSetup(const NetNodeStates& nodes, const double* X, ISimObjectCreator* creator);
77
80 void PreOdeFcn(double T, const double* X);
81
86 void Evaluate(double T, const double* X, double* XDot) const;
87
89 void AcceptedStep(double T);
90
92 void SetAddedDragPerMPS(double addedDragPerMPS) { m_adaptations.addedDragPerMPS = addedDragPerMPS; }
93
95 NetNodeView View(const double* X, int stateBase = 0) const { return NetNodeView {X, &m_layout, stateBase}; }
96
97 int NumNodes() const { return m_numNodesCalc; }
98 int NumOriginalNodes() const { return m_numNodesOriginal; }
99 int NumPanels() const { return static_cast<int>(m_panels.size()); }
100 int NumCables() const { return static_cast<int>(m_cables.size()); }
101
103 const int* PanelNodes(int panel) const { return m_panelNodes.data() + 3 * panel; }
104 const NetElement3N& Panel(int panel) const { return *m_panels[panel]; }
105 NetElement3N& Panel(int panel) { return *m_panels[panel]; }
106 const NetCableElement& Cable(int cable) const { return *m_cables[cable]; }
107 NetCableElement& Cable(int cable) { return *m_cables[cable]; }
108
110 float Inertia(int node) const { return m_inertia[node]; }
112 const double* NodeForce(int node) const { return m_nodeForce.data() + 3 * node; }
113
114 const SAdaptationSpec_t& Adaptations() const { return m_adaptations; }
115 bool FoldingPointRefinementUsed() const { return m_foldingPointRefinementUsed; }
116 const net_panel_setup::PanelHydrodynamics& PanelHydrodynamics() const { return m_panelHydrodynamics; }
117 environment::EnvironmentProvider* Environment() const { return m_environment; }
118
120 bool InBottomContact() const { return m_inBottomContact; }
122 const double* BottomContact() const { return m_bottomContactFiltered; }
123
125 void PrepareFlow(double T, const double* X, int stateBase) const { UpdateNodeWaveVelocities(T, View(X, stateBase), 0, m_numNodesCalc); }
127 void FlowAt(double T, int point, const double pos[3], double vel[3]) const;
129 void CableHydrodynamicForce(double T, const double* X, double force[3]) const;
131 const environment::wake::BodyWake* Wake() const { return m_flow->Wake(); }
132
133private:
134 void CreatePanels(std::vector<const NetElementDef*> definitions, ISimObjectCreator* creator);
135 void CreateCables(std::vector<const NetCableElementSpec*> specs, ISimObjectCreator* creator);
137 void UpdateNodeWaveVelocities(double T, const NetNodeView& nodes, int begin, int end) const;
139 void AddPanelForceRange(double T, const NetNodeView& nodes, int begin, int end, double* nodeForce) const;
142 void AddCableForceRange(double T, const NetNodeView& nodes, int begin, int end, double* nodeForce, bool waterFollowsElement = false) const;
144 void AddBottomForces(const NetNodeView& nodes) const;
145
146 std::string m_name;
147 NetCoreOptions m_options;
148
150
151 int m_numNodesCalc = 0;
152 int m_numNodesOriginal = 0;
153 std::vector<std::unique_ptr<NetElement3N>> m_panels;
154 std::vector<int> m_panelNodes;
155 std::vector<std::unique_ptr<NetCableElement>> m_cables;
156 std::vector<float> m_inertia;
157 mutable std::vector<double> m_nodeForce;
158 SAdaptationSpec_t m_adaptations;
159 bool m_foldingPointRefinementUsed = false;
161
163
164 const NetNodeStates* m_nodes = nullptr;
165 NetNodeLayout m_layout;
167
169
170 net_panel_setup::PanelHydrodynamics m_panelHydrodynamics;
171 net_solidity::SolidityModel m_solidityModel = net_solidity::kDefaultSolidityModel;
173
175
176 environment::EnvironmentProvider* m_environment = nullptr;
177 std::unique_ptr<NetFlowInteraction> m_flow;
178 mutable std::vector<double> m_nodeWaveVelocity;
179 ISimObjectLogger* m_logger = nullptr;
180 hydrodynamics::PanelClampLog m_clampLog;
182
183 int m_numThreads = 1;
184 mutable std::vector<double> m_threadNodeForces;
186 double m_meanTensionTime = std::numeric_limits<double>::quiet_NaN();
187
189
190 environment::SeafloorForcesInterface* m_seafloor = nullptr;
191 double m_bottomContactTimeConstant = 0.01;
192 mutable double m_bottomContact[6] = {};
193 double m_bottomContactFiltered[6] = {};
194 double m_lastAcceptedTime = 0.0;
195 bool m_hasAcceptedStep = false;
196 mutable bool m_inBottomContact = false;
198};
Definition Cable.h:122
Definition NetCableElement.h:48
Definition NetCore.h:49
NetNodeView View(const double *X, int stateBase=0) const
The nodes of X; stateBase as NetNodeView. Valid after FinalSetup.
Definition NetCore.h:95
const environment::wake::BodyWake * Wake() const
The net's BodyWake; null without an environment or before FinalSetup.
Definition NetCore.h:131
bool InBottomContact() const
Whether the seabed gave an original node a force at the last evaluation (false without bottom contact...
Definition NetCore.h:120
const double * NodeForce(int node) const
The force on node of the last evaluation, 3 values [N].
Definition NetCore.h:112
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:97
void CableHydrodynamicForce(double T, const double *X, double force[3]) const
The sum of the cables' hydrodynamic forces on the nodes [N] (MARE-0141); for the wake caster's log.
const double * BottomContact() const
The filtered seabed force and its moment about the NED origin, 6 values (MARE-0064,...
Definition NetCore.h:122
const int * PanelNodes(int panel) const
The three nodes of panel.
Definition NetCore.h:103
int NumOriginalNodes() const
The nodes of the net file, before refinement.
Definition NetCore.h:98
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:125
void PreOdeFcn(double T, const double *X)
const SAdaptationSpec_t & Adaptations() const
MassFactor, MaxVelocity, AddedDragPerMPS.
Definition NetCore.h:114
void FinalSetup(const NetNodeStates &nodes, const double *X, ISimObjectCreator *creator)
void Evaluate(double T, const double *X, double *XDot) const
void SetAddedDragPerMPS(double addedDragPerMPS)
Sets the added drag per unit speed, spread over the panels [N s/m].
Definition NetCore.h:92
float Inertia(int node) const
The node mass from the panels and cable elements [kg].
Definition NetCore.h:110
NetCore(const std::string &name, NetStructureSpec &spec, const NetCoreOptions &options, ISimObjectCreator *creator)
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:47
Definition NetNodeStates.h:39
Definition NetStructureSpec.h:39
Class containing a cable element object, allowing for disks and spheres to be connected.
Definition NetCableElement.h:35
What the two nets choose differently in the core (owner ruling Q3, 2026-10-14: adapter choices).
Definition NetCore.h:41
NetCableOptions cable
How the cable elements are built (NetCableElement.h).
Definition NetCore.h:44
bool bottomContact
Seabed contact of the original nodes, its sum and its filtered port value.
Definition NetCore.h:45
NetPanelOptions panel
How the panels are built (NetElement3N.h); dampingRatio is read from NetDampingRatio when twineStruct...
Definition NetCore.h:43
std::string structureName
"NetStructure" or "NetStructureWithConstraints", for messages.
Definition NetCore.h:42
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:38
Class containing the specification for a net object.
Definition NetStructureSpec.h:24
The panel load law and the fluid shared by all panels of a structure.
Definition NetPanelSetup.h:38