8#ifndef C_NET_ELEMENT_3N
9#define C_NET_ELEMENT_3N
12#include "NetElementDef.h"
13#include "NetElement3NForces.h"
14#include <fhsim_environment/hydrodynamics/NetSolidity.h>
15#include <fhsim/PrintDuringExec.h>
16#include <sfh/ad/Dual.h>
18#ifdef FH_VISUALIZATION
20 #ifdef USE_DYNAMIC_LINES
21 #include "sfh/ogre/CDynamicLines.h"
23 #include "sfh/ogre/C3DLine.h"
60 const std::string netName,
61 const unsigned long iID,
63 const double dRho_water,
64 const double knotDiameter,
65 const net_solidity::PanelSolidity& solidity,
99 void AddNodeForces(
const hydrodynamics::PanelLoadLaw& law,
const hydrodynamics::Fluid& fluid,
100 const T*
const posA_ned,
const T*
const posB_ned,
const T*
const posC_ned,
101 const T*
const velA_ned,
const T*
const velB_ned,
const T*
const velC_ned,
102 const T*
const waterVel_ned,
103 T*
const nodeAforce_ned, T*
const nodeBforce_ned, T*
const nodeCforce_ned,
104 double addedLinearDrag = 0.0,
const hydrodynamics::PanelClampLog* clampLog =
nullptr)
const
107 net_element_forces::ComputePanelFrame(m_panelForceParams, posA_ned, posB_ned, posC_ned);
108 const T solidity = net_solidity::Solidity(m_solidity, m_barD, m_barL0, frame.
meshOpeningAngle);
109 net_element_forces::AddNodeForces(m_panelForceParams, frame, law, fluid, solidity,
110 velA_ned, velB_ned, velC_ned, waterVel_ned,
111 nodeAforce_ned, nodeBforce_ned, nodeCforce_ned, addedLinearDrag, clampLog);
138 void NodeForceJacobian(
const hydrodynamics::PanelLoadLaw& law,
const hydrodynamics::Fluid& fluid,
139 const double posA_ned[3],
const double posB_ned[3],
const double posC_ned[3],
140 const double velA_ned[3],
const double velB_ned[3],
const double velC_ned[3],
141 const double waterVel_ned[3],
double addedLinearDrag,
double dF[3][6][9])
const
143 using Dual = sfh::ad::Dual<12>;
144 const int kVelocitySlot = 9;
146 Dual pos[3][3], vel[3][3], water[3];
147 const double* posIn[3] = {posA_ned, posB_ned, posC_ned};
148 const double* velIn[3] = {velA_ned, velB_ned, velC_ned};
149 for (
int node = 0; node < 3; ++node) {
150 for (
int k = 0; k < 3; ++k) {
151 pos[node][k] = Dual::Variable(posIn[node][k], 3 * node + k);
152 vel[node][k] = Dual::Variable(velIn[node][k], kVelocitySlot + k);
155 for (
int k = 0; k < 3; ++k)
156 water[k] = Dual(waterVel_ned[k]);
159 AddNodeForces<Dual>(law, fluid, pos[0], pos[1], pos[2], vel[0], vel[1], vel[2], water,
160 force[0], force[1], force[2], addedLinearDrag);
163 const double addedDragPerNode = addedLinearDrag > 0 ? addedLinearDrag / 3 : 0.0;
165 for (
int node = 0; node < 3; ++node) {
166 for (
int j = 0; j < 3; ++j) {
167 for (
int k = 0; k < 3; ++k) {
168 for (
int group = 0; group < 3; ++group)
169 dF[node][group][3 * j + k] = force[node][j].Grad(3 * group + k);
171 const double diagonal = (j == k) ? 1.0 : 0.0;
172 const double lawPart = (force[node][j].Grad(kVelocitySlot + k) + diagonal * addedDragPerNode) / 3;
173 for (
int other = 0; other < 3; ++other) {
174 const double self = (other == node) ? 1.0 : 0.0;
175 dF[node][3 + other][3 * j + k] = lawPart
176 + diagonal * (damping * (1.0 / 3.0 - self) - addedDragPerNode * self);
198 hydrodynamics::PanelLoad<double>
EvaluatePanelLoad(
const hydrodynamics::PanelLoadLaw& law,
const hydrodynamics::Fluid& fluid,
199 const double*
const posA_ned,
const double*
const posB_ned,
const double*
const posC_ned,
200 const double elementVel[3],
const double waterVel_ned[3],
double& area)
const
203 net_element_forces::ComputePanelFrame(m_panelForceParams, posA_ned, posB_ned, posC_ned);
205 return net_element_forces::EvaluatePanelLoad(m_panelForceParams, frame, law, fluid,
213 double Solidity(
double meshOpeningAngle)
const {
return net_solidity::Solidity(m_solidity, m_barD, m_barL0, meshOpeningAngle); }
216 double Solidity(
const double*
const posA_ned,
const double*
const posB_ned,
const double*
const posC_ned)
const
218 return Solidity(net_element_forces::ComputePanelFrame(m_panelForceParams, posA_ned, posB_ned, posC_ned).meshOpeningAngle);
222 double WakeSolidity(
const double*
const posA_ned,
const double*
const posB_ned,
const double*
const posC_ned)
const
224 return net_solidity::WakeSolidity(m_solidity, m_barD, m_barL0,
225 net_element_forces::ComputePanelFrame(m_panelForceParams, posA_ned, posB_ned, posC_ned).meshOpeningAngle);
238#ifdef FH_VISUALIZATION
240 void RenderInit(Ogre::Root* ogreRoot,
int NumMeshPerLine = 1);
243 void RenderUpdate(
const double*
const adPosA,
const double*
const adPosB,
244 const double*
const adPosC );
250 void FillPanelForceParams();
254 std::string m_netName;
255 double m_nodeInertia[3];
262 double m_nodeAPos_mesh[2];
263 double m_nodeBPos_mesh[2];
264 double m_nodeCPos_mesh[2];
268 double m_nodesDistAB_mesh[2];
269 double m_nodesDistAC_mesh[2];
270 double m_nodesDistBC_mesh[2];
280 double m_nodeAforce_ned[3];
281 double m_nodeBforce_ned[3];
282 double m_nodeCforce_ned[3];
283 double m_dampingCoeff;
289 net_solidity::PanelSolidity m_solidity;
291 double m_nodeAforce_ned_last[3];
292 double m_nodeBforce_ned_last[3];
293 double m_nodeCforce_ned_last[3];
296#ifdef FH_VISUALIZATION
298 Ogre::Root* m_ogreRoot;
299 Ogre::SceneManager* m_sceneMgr;
300 Ogre::Entity* m_renderElement[3];
301 Ogre::Entity* m_renderSphere[3];
302 Ogre::SceneNode* m_renderNodeMesh;
303 Ogre::SceneNode* m_renderNodeSphere[3];
304 Ogre::SceneNode* m_renderNodeOutline;
305 Ogre::SceneNode* m_renderNodeMaterial;
306#ifdef USE_DYNAMIC_LINES
307 C3DLine* m_lines =
nullptr;
309 C3DLine* m_lines =
nullptr;
310 Ogre::ColourValue m_twineColour;
312 C3DLine* m_lineOutline;
316 unsigned short* m_sortU =
nullptr;
317 unsigned short* m_sortV =
nullptr;
318 unsigned long m_numTwines;
319 unsigned long m_numUTwines;
320 unsigned long m_numVTwines;
321 double* m_interpCoeffAu =
nullptr;
322 double* m_interpCoeffAv =
nullptr;
323 double* m_interpCoeffBu =
nullptr;
324 double* m_interpCoeffBv =
nullptr;
325 int m_NumMeshPerLine;
Definition NetElement3N.h:47
void AddNodeForces(const hydrodynamics::PanelLoadLaw &law, const hydrodynamics::Fluid &fluid, const T *const posA_ned, const T *const posB_ned, const T *const posC_ned, const T *const velA_ned, const T *const velB_ned, const T *const velC_ned, const T *const waterVel_ned, T *const nodeAforce_ned, T *const nodeBforce_ned, T *const nodeCforce_ned, double addedLinearDrag=0.0, const hydrodynamics::PanelClampLog *clampLog=nullptr) const
Definition NetElement3N.h:99
double TwineDiameter() const
The twine diameter [m].
Definition NetElement3N.h:236
double CalcNodeInertia(int node)
Calculates the inertia of a node.
double Solidity(const double *const posA_ned, const double *const posB_ned, const double *const posC_ned) const
The solidity of the element at the given node positions, global frame.
Definition NetElement3N.h:216
bool HasBarDirections() const
True when the bar directions are defined, which needs a non-zero mesh determinant.
Definition NetElement3N.h:210
void NodeForceJacobian(const hydrodynamics::PanelLoadLaw &law, const hydrodynamics::Fluid &fluid, const double posA_ned[3], const double posB_ned[3], const double posC_ned[3], const double velA_ned[3], const double velB_ned[3], const double velC_ned[3], const double waterVel_ned[3], double addedLinearDrag, double dF[3][6][9]) const
Definition NetElement3N.h:138
double Solidity(double meshOpeningAngle) const
The solidity of the element at the given mesh half opening angle [rad].
Definition NetElement3N.h:213
hydrodynamics::PanelLoad< double > EvaluatePanelLoad(const hydrodynamics::PanelLoadLaw &law, const hydrodynamics::Fluid &fluid, const double *const posA_ned, const double *const posB_ned, const double *const posC_ned, const double elementVel[3], const double waterVel_ned[3], double &area) const
Definition NetElement3N.h:198
~NetElement3N(void)
The destructor.
double WakeSolidity(const double *const posA_ned, const double *const posB_ned, const double *const posC_ned) const
The solidity the element hands to its wake source at the given node positions, global frame (NetSolid...
Definition NetElement3N.h:222
double NumberOfTwineLengthsU() const
NetElement3N(const std::string netName, const unsigned long iID, const NetElementDef *netPanel, const double dRho_water, const double knotDiameter, const net_solidity::PanelSolidity &solidity, const NetPanelOptions &options)
Class containing the description of a net panel and methods necessary for taking this over to triangu...
Definition NetElementDef.h:22
What a net panel adds beyond its load and weight in water. Net/NetStructure uses the defaults.
Definition NetElement3N.h:38
double dampingRatio
NetDampingRatio: scales the structural damping; unused without twineStructure.
Definition NetElement3N.h:43
bool twineStructure
Definition NetElement3N.h:42
Definition NetElement3NForces.h:86
T meshOpeningAngle
The mesh half opening angle, rad; 0 when undefined.
Definition NetElement3NForces.h:90
T area
The element's area, m^2.
Definition NetElement3NForces.h:91
Definition NetElement3NForces.h:59
double dampingCoeff
Definition NetElement3NForces.h:72