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"
59 const std::string netName,
60 const unsigned long iID,
62 const double dRho_water,
63 const double knotDiameter,
64 const net_solidity::PanelSolidity& solidity,
98 template<
class T,
class Law>
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 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 return 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, clampLog);
130 void NodeForceJacobian(
const hydrodynamics::PanelLoadLaw& law,
const hydrodynamics::Fluid& fluid,
131 const double posA_ned[3],
const double posB_ned[3],
const double posC_ned[3],
132 const double velA_ned[3],
const double velB_ned[3],
const double velC_ned[3],
133 const double waterVel_ned[3],
double dF[3][6][9])
const
135 using Dual = sfh::ad::Dual<18>;
136 const int kVelocitySlot = 9;
138 Dual pos[3][3], vel[3][3], water[3];
139 const double* posIn[3] = {posA_ned, posB_ned, posC_ned};
140 const double* velIn[3] = {velA_ned, velB_ned, velC_ned};
141 for (
int node = 0; node < 3; ++node) {
142 for (
int k = 0; k < 3; ++k) {
143 pos[node][k] = Dual::Variable(posIn[node][k], 3 * node + k);
144 vel[node][k] = Dual::Variable(velIn[node][k], kVelocitySlot + 3 * node + k);
147 for (
int k = 0; k < 3; ++k)
148 water[k] = Dual(waterVel_ned[k]);
151 AddNodeForces<Dual>(law, fluid, pos[0], pos[1], pos[2], vel[0], vel[1], vel[2], water,
152 force[0], force[1], force[2]);
154 for (
int node = 0; node < 3; ++node)
155 for (
int group = 0; group < 6; ++group)
156 for (
int j = 0; j < 3; ++j)
157 for (
int k = 0; k < 3; ++k)
158 dF[node][group][3 * j + k] = force[node][j].Grad(3 * group + k);
176 hydrodynamics::PanelLoad<double>
EvaluatePanelLoad(
const hydrodynamics::PanelLoadLaw& law,
const hydrodynamics::Fluid& fluid,
177 const double*
const posA_ned,
const double*
const posB_ned,
const double*
const posC_ned,
178 const double elementVel[3],
const double waterVel_ned[3],
double& area)
const
181 net_element_forces::ComputePanelFrame(m_panelForceParams, posA_ned, posB_ned, posC_ned);
183 return net_element_forces::EvaluatePanelLoad(m_panelForceParams, frame, law, fluid,
191 double Solidity(
double meshOpeningAngle)
const {
return net_solidity::Solidity(m_solidity, m_barD, m_barL0, meshOpeningAngle); }
194 double Solidity(
const double*
const posA_ned,
const double*
const posB_ned,
const double*
const posC_ned)
const
196 return Solidity(net_element_forces::ComputePanelFrame(m_panelForceParams, posA_ned, posB_ned, posC_ned).meshOpeningAngle);
200 double WakeSolidity(
const double*
const posA_ned,
const double*
const posB_ned,
const double*
const posC_ned)
const
202 return net_solidity::WakeSolidity(m_solidity, m_barD, m_barL0,
203 net_element_forces::ComputePanelFrame(m_panelForceParams, posA_ned, posB_ned, posC_ned).meshOpeningAngle);
216#ifdef FH_VISUALIZATION
218 void RenderInit(Ogre::Root* ogreRoot,
int NumMeshPerLine = 1);
221 void RenderUpdate(
const double*
const adPosA,
const double*
const adPosB,
222 const double*
const adPosC );
228 void FillPanelForceParams();
232 std::string m_netName;
233 double m_nodeInertia[3];
240 double m_nodeAPos_mesh[2];
241 double m_nodeBPos_mesh[2];
242 double m_nodeCPos_mesh[2];
246 double m_nodesDistAB_mesh[2];
247 double m_nodesDistAC_mesh[2];
248 double m_nodesDistBC_mesh[2];
258 double m_nodeAforce_ned[3];
259 double m_nodeBforce_ned[3];
260 double m_nodeCforce_ned[3];
261 double m_dampingCoeff;
262 double m_tensionDampingTime;
268 net_solidity::PanelSolidity m_solidity;
270 double m_nodeAforce_ned_last[3];
271 double m_nodeBforce_ned_last[3];
272 double m_nodeCforce_ned_last[3];
275#ifdef FH_VISUALIZATION
277 Ogre::Root* m_ogreRoot;
278 Ogre::SceneManager* m_sceneMgr;
279 Ogre::Entity* m_renderElement[3];
280 Ogre::SceneNode* m_renderNodeMesh;
281 Ogre::SceneNode* m_renderNodeOutline;
282 Ogre::SceneNode* m_renderNodeMaterial;
283#ifdef USE_DYNAMIC_LINES
284 C3DLine* m_lines =
nullptr;
286 C3DLine* m_lines =
nullptr;
287 Ogre::ColourValue m_twineColour;
289 C3DLine* m_lineOutline;
293 unsigned short* m_sortU =
nullptr;
294 unsigned short* m_sortV =
nullptr;
295 unsigned long m_numTwines;
296 unsigned long m_numUTwines;
297 unsigned long m_numVTwines;
298 double* m_interpCoeffAu =
nullptr;
299 double* m_interpCoeffAv =
nullptr;
300 double* m_interpCoeffBu =
nullptr;
301 double* m_interpCoeffBv =
nullptr;
302 int m_NumMeshPerLine;
Definition NetElement3N.h:46
double TwineDiameter() const
The twine diameter [m].
Definition NetElement3N.h:214
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:194
bool HasBarDirections() const
True when the bar directions are defined, which needs a non-zero mesh determinant.
Definition NetElement3N.h:188
double Solidity(double meshOpeningAngle) const
The solidity of the element at the given mesh half opening angle [rad].
Definition NetElement3N.h:191
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:176
~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:200
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:130
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)
bool AddNodeForces(const Law &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:99
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:37
double dampingRatio
NetDampingRatio: the damping ratio of the panel's stiffest stretch mode, 1 = critical....
Definition NetElement3N.h:42
bool twineStructure
Definition NetElement3N.h:41
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