8#ifndef C_NET_ELEMENT_3N
9#define C_NET_ELEMENT_3N
14#include "NetElementDef.h"
15#include "NetElement3NForces.h"
16#include <fhsim_environment/hydrodynamics/NetSolidity.h>
17#include <fhsim/PrintDuringExec.h>
18#include <sfh/ad/Dual.h>
20#ifdef FH_VISUALIZATION
22 #ifdef USE_DYNAMIC_LINES
23 #include "sfh/ogre/CDynamicLines.h"
25 #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,
100 bool AddNodeForces(
const hydrodynamics::PanelLoadLaw& law,
const hydrodynamics::Fluid& fluid,
101 const T*
const posA_ned,
const T*
const posB_ned,
const T*
const posC_ned,
102 const T*
const velA_ned,
const T*
const velB_ned,
const T*
const velC_ned,
103 const T*
const waterVel_ned,
104 T*
const nodeAforce_ned, T*
const nodeBforce_ned, T*
const nodeCforce_ned,
105 const hydrodynamics::PanelClampLog* clampLog =
nullptr)
const
108 net_element_forces::ComputePanelFrame(m_panelForceParams, posA_ned, posB_ned, posC_ned);
109 const T solidity = net_solidity::Solidity(m_solidity, m_barD, m_barL0, frame.
meshOpeningAngle);
110 return net_element_forces::AddNodeForces(m_panelForceParams, frame, law, fluid, solidity,
111 velA_ned, velB_ned, velC_ned, waterVel_ned,
112 nodeAforce_ned, nodeBforce_ned, nodeCforce_ned, clampLog);
131 void NodeForceJacobian(
const hydrodynamics::PanelLoadLaw& law,
const hydrodynamics::Fluid& fluid,
132 const double posA_ned[3],
const double posB_ned[3],
const double posC_ned[3],
133 const double velA_ned[3],
const double velB_ned[3],
const double velC_ned[3],
134 const double waterVel_ned[3],
double dF[3][6][9])
const
136 using Dual = sfh::ad::Dual<18>;
137 const int kVelocitySlot = 9;
139 Dual pos[3][3], vel[3][3], water[3];
140 const double* posIn[3] = {posA_ned, posB_ned, posC_ned};
141 const double* velIn[3] = {velA_ned, velB_ned, velC_ned};
142 for (
int node = 0; node < 3; ++node) {
143 for (
int k = 0; k < 3; ++k) {
144 pos[node][k] = Dual::Variable(posIn[node][k], 3 * node + k);
145 vel[node][k] = Dual::Variable(velIn[node][k], kVelocitySlot + 3 * node + k);
148 for (
int k = 0; k < 3; ++k)
149 water[k] = Dual(waterVel_ned[k]);
152 AddNodeForces<Dual>(law, fluid, pos[0], pos[1], pos[2], vel[0], vel[1], vel[2], water,
153 force[0], force[1], force[2]);
155 for (
int node = 0; node < 3; ++node)
156 for (
int group = 0; group < 6; ++group)
157 for (
int j = 0; j < 3; ++j)
158 for (
int k = 0; k < 3; ++k)
159 dF[node][group][3 * j + k] = force[node][j].Grad(3 * group + k);
177 hydrodynamics::PanelLoad<double>
EvaluatePanelLoad(
const hydrodynamics::PanelLoadLaw& law,
const hydrodynamics::Fluid& fluid,
178 const double*
const posA_ned,
const double*
const posB_ned,
const double*
const posC_ned,
179 const double elementVel[3],
const double waterVel_ned[3],
double& area)
const
182 net_element_forces::ComputePanelFrame(m_panelForceParams, posA_ned, posB_ned, posC_ned);
184 return net_element_forces::EvaluatePanelLoad(m_panelForceParams, frame, law, fluid,
192 double Solidity(
double meshOpeningAngle)
const {
return net_solidity::Solidity(m_solidity, m_barD, m_barL0, meshOpeningAngle); }
195 double Solidity(
const double*
const posA_ned,
const double*
const posB_ned,
const double*
const posC_ned)
const
197 return Solidity(net_element_forces::ComputePanelFrame(m_panelForceParams, posA_ned, posB_ned, posC_ned).meshOpeningAngle);
201 double WakeSolidity(
const double*
const posA_ned,
const double*
const posB_ned,
const double*
const posC_ned)
const
203 return net_solidity::WakeSolidity(m_solidity, m_barD, m_barL0,
204 net_element_forces::ComputePanelFrame(m_panelForceParams, posA_ned, posB_ned, posC_ned).meshOpeningAngle);
217#ifdef FH_VISUALIZATION
219 void RenderInit(Ogre::Root* ogreRoot,
int NumMeshPerLine = 1);
222 void RenderUpdate(
const double*
const adPosA,
const double*
const adPosB,
223 const double*
const adPosC );
229 void FillPanelForceParams();
233 std::string m_netName;
234 double m_nodeInertia[3];
241 double m_nodeAPos_mesh[2];
242 double m_nodeBPos_mesh[2];
243 double m_nodeCPos_mesh[2];
247 double m_nodesDistAB_mesh[2];
248 double m_nodesDistAC_mesh[2];
249 double m_nodesDistBC_mesh[2];
259 double m_nodeAforce_ned[3];
260 double m_nodeBforce_ned[3];
261 double m_nodeCforce_ned[3];
262 double m_dampingCoeff;
263 double m_tensionDampingTime;
269 net_solidity::PanelSolidity m_solidity;
271 double m_nodeAforce_ned_last[3];
272 double m_nodeBforce_ned_last[3];
273 double m_nodeCforce_ned_last[3];
276#ifdef FH_VISUALIZATION
278 Ogre::Root* m_ogreRoot;
279 Ogre::SceneManager* m_sceneMgr;
280 Ogre::Entity* m_renderElement[3];
281 Ogre::Entity* m_renderSphere[3];
282 Ogre::SceneNode* m_renderNodeMesh;
283 Ogre::SceneNode* m_renderNodeSphere[3];
284 Ogre::SceneNode* m_renderNodeOutline;
285 Ogre::SceneNode* m_renderNodeMaterial;
286#ifdef USE_DYNAMIC_LINES
287 C3DLine* m_lines =
nullptr;
289 C3DLine* m_lines =
nullptr;
290 Ogre::ColourValue m_twineColour;
292 C3DLine* m_lineOutline;
296 unsigned short* m_sortU =
nullptr;
297 unsigned short* m_sortV =
nullptr;
298 unsigned long m_numTwines;
299 unsigned long m_numUTwines;
300 unsigned long m_numVTwines;
301 double* m_interpCoeffAu =
nullptr;
302 double* m_interpCoeffAv =
nullptr;
303 double* m_interpCoeffBu =
nullptr;
304 double* m_interpCoeffBv =
nullptr;
305 int m_NumMeshPerLine;
Definition NetElement3N.h:47
double TwineDiameter() const
The twine diameter [m].
Definition NetElement3N.h:215
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:195
bool HasBarDirections() const
True when the bar directions are defined, which needs a non-zero mesh determinant.
Definition NetElement3N.h:189
bool 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, const hydrodynamics::PanelClampLog *clampLog=nullptr) const
Definition NetElement3N.h:100
double Solidity(double meshOpeningAngle) const
The solidity of the element at the given mesh half opening angle [rad].
Definition NetElement3N.h:192
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:177
~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:201
double NumberOfTwineLengthsU() const
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 dF[3][6][9]) const
Definition NetElement3N.h:131
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:24
What a net panel adds beyond its load and weight in water. Net/NetStructure uses the defaults.
Definition NetElement3N.h:38
double dampingRatio
NetDampingRatio: the damping ratio of the panel's stiffest stretch mode, 1 = critical....
Definition NetElement3N.h:43
bool twineStructure
Definition NetElement3N.h:42
Definition NetElement3NForces.h:118
T meshOpeningAngle
The mesh half opening angle, rad; 0 when undefined.
Definition NetElement3NForces.h:122
T area
The element's area, m^2.
Definition NetElement3NForces.h:123
Definition NetElement3NForces.h:90