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"
41 const std::string netName,
42 const unsigned long iID,
44 const double dRho_water,
45 const double knotDiameter,
46 const double knotMomStiff,
47 const double dKknotMomStiff_contact,
48 const net_solidity::PanelSolidity& solidity,
49 const double dampingRatio
82 void AddNodeForces(
const hydrodynamics::PanelLoadLaw& law,
const hydrodynamics::Fluid& fluid,
83 const T*
const posA_ned,
const T*
const posB_ned,
const T*
const posC_ned,
84 const T*
const velA_ned,
const T*
const velB_ned,
const T*
const velC_ned,
85 const T*
const waterVel_ned,
86 T*
const nodeAforce_ned, T*
const nodeBforce_ned, T*
const nodeCforce_ned,
87 double addedLinearDrag = 0.0,
const hydrodynamics::PanelClampLog* clampLog =
nullptr)
const
90 net_element_forces::ComputePanelFrame(m_panelForceParams, posA_ned, posB_ned, posC_ned);
91 const T solidity = net_solidity::Solidity(m_solidity, m_barD, m_barL0, frame.
meshOpeningAngle);
92 net_element_forces::AddNodeForces(m_panelForceParams, frame, law, fluid, solidity,
93 velA_ned, velB_ned, velC_ned, waterVel_ned,
94 nodeAforce_ned, nodeBforce_ned, nodeCforce_ned, addedLinearDrag, clampLog);
121 void NodeForceJacobian(
const hydrodynamics::PanelLoadLaw& law,
const hydrodynamics::Fluid& fluid,
122 const double posA_ned[3],
const double posB_ned[3],
const double posC_ned[3],
123 const double velA_ned[3],
const double velB_ned[3],
const double velC_ned[3],
124 const double waterVel_ned[3],
double addedLinearDrag,
double dF[3][6][9])
const
126 using Dual = sfh::ad::Dual<12>;
127 const int kVelocitySlot = 9;
129 Dual pos[3][3], vel[3][3], water[3];
130 const double* posIn[3] = {posA_ned, posB_ned, posC_ned};
131 const double* velIn[3] = {velA_ned, velB_ned, velC_ned};
132 for (
int node = 0; node < 3; ++node) {
133 for (
int k = 0; k < 3; ++k) {
134 pos[node][k] = Dual::Variable(posIn[node][k], 3 * node + k);
135 vel[node][k] = Dual::Variable(velIn[node][k], kVelocitySlot + k);
138 for (
int k = 0; k < 3; ++k)
139 water[k] = Dual(waterVel_ned[k]);
142 AddNodeForces<Dual>(law, fluid, pos[0], pos[1], pos[2], vel[0], vel[1], vel[2], water,
143 force[0], force[1], force[2], addedLinearDrag);
146 const double addedDragPerNode = addedLinearDrag > 0 ? addedLinearDrag / 3 : 0.0;
148 for (
int node = 0; node < 3; ++node) {
149 for (
int j = 0; j < 3; ++j) {
150 for (
int k = 0; k < 3; ++k) {
151 for (
int group = 0; group < 3; ++group)
152 dF[node][group][3 * j + k] = force[node][j].Grad(3 * group + k);
154 const double diagonal = (j == k) ? 1.0 : 0.0;
155 const double lawPart = (force[node][j].Grad(kVelocitySlot + k) + diagonal * addedDragPerNode) / 3;
156 for (
int other = 0; other < 3; ++other) {
157 const double self = (other == node) ? 1.0 : 0.0;
158 dF[node][3 + other][3 * j + k] = lawPart
159 + diagonal * (damping * (1.0 / 3.0 - self) - addedDragPerNode * self);
181 hydrodynamics::PanelLoad<double>
EvaluatePanelLoad(
const hydrodynamics::PanelLoadLaw& law,
const hydrodynamics::Fluid& fluid,
182 const double*
const posA_ned,
const double*
const posB_ned,
const double*
const posC_ned,
183 const double elementVel[3],
const double waterVel_ned[3],
double& area)
const
186 net_element_forces::ComputePanelFrame(m_panelForceParams, posA_ned, posB_ned, posC_ned);
188 return net_element_forces::EvaluatePanelLoad(m_panelForceParams, frame, law, fluid,
196 double Solidity(
double meshOpeningAngle)
const {
return net_solidity::Solidity(m_solidity, m_barD, m_barL0, meshOpeningAngle); }
199 double Solidity(
const double*
const posA_ned,
const double*
const posB_ned,
const double*
const posC_ned)
const
201 return Solidity(net_element_forces::ComputePanelFrame(m_panelForceParams, posA_ned, posB_ned, posC_ned).meshOpeningAngle);
205 double WakeSolidity(
const double*
const posA_ned,
const double*
const posB_ned,
const double*
const posC_ned)
const
207 return net_solidity::WakeSolidity(m_solidity, m_barD, m_barL0,
208 net_element_forces::ComputePanelFrame(m_panelForceParams, posA_ned, posB_ned, posC_ned).meshOpeningAngle);
214#ifdef FH_VISUALIZATION
216 void RenderInit(Ogre::Root* ogreRoot,
int NumMeshPerLine = 1);
219 void RenderUpdate(
const double*
const adPosA,
const double*
const adPosB,
220 const double*
const adPosC );
226 void FillPanelForceParams();
230 std::string m_netName;
231 double m_nodeInertia[3];
238 double m_nodeAPos_mesh[2];
239 double m_nodeBPos_mesh[2];
240 double m_nodeCPos_mesh[2];
244 double m_nodesDistAB_mesh[2];
245 double m_nodesDistAC_mesh[2];
246 double m_nodesDistBC_mesh[2];
256 double m_nodeAforce_ned[3];
257 double m_nodeBforce_ned[3];
258 double m_nodeCforce_ned[3];
259 double m_dampingCoeff;
264 net_solidity::PanelSolidity m_solidity;
266 double m_nodeAforce_ned_last[3];
267 double m_nodeBforce_ned_last[3];
268 double m_nodeCforce_ned_last[3];
271#ifdef FH_VISUALIZATION
273 Ogre::Root* m_ogreRoot;
274 Ogre::SceneManager* m_sceneMgr;
275 Ogre::Entity* m_renderElement[3];
276 Ogre::Entity* m_renderSphere[3];
277 Ogre::SceneNode* m_renderNodeMesh;
278 Ogre::SceneNode* m_renderNodeSphere[3];
279 Ogre::SceneNode* m_renderNodeOutline;
280 Ogre::SceneNode* m_renderNodeMaterial;
281#ifdef USE_DYNAMIC_LINES
282 C3DLine* m_lines =
nullptr;
284 C3DLine* m_lines =
nullptr;
285 Ogre::ColourValue m_twineColour;
287 C3DLine* m_lineOutline;
291 unsigned short* m_sortU =
nullptr;
292 unsigned short* m_sortV =
nullptr;
293 unsigned long m_numTwines;
294 unsigned long m_numUTwines;
295 unsigned long m_numVTwines;
296 double* m_interpCoeffAu =
nullptr;
297 double* m_interpCoeffAv =
nullptr;
298 double* m_interpCoeffBu =
nullptr;
299 double* m_interpCoeffBv =
nullptr;
300 int m_NumMeshPerLine;
Definition NetElement3N.h:37
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:82
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:199
bool HasBarDirections() const
True when the bar directions are defined, which needs a non-zero mesh determinant.
Definition NetElement3N.h:193
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:121
NetElement3N(const std::string netName, const unsigned long iID, const NetElementDef *netPanel, const double dRho_water, const double knotDiameter, const double knotMomStiff, const double dKknotMomStiff_contact, const net_solidity::PanelSolidity &solidity, const double dampingRatio)
The constructor.
double Solidity(double meshOpeningAngle) const
The solidity of the element at the given mesh half opening angle [rad].
Definition NetElement3N.h:196
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:181
~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:205
Class containing the description of a net panel and methods necessary for taking this over to triangu...
Definition NetElementDef.h:22
Definition NetElement3NForces.h:83
T meshOpeningAngle
The mesh half opening angle, rad; 0 when undefined.
Definition NetElement3NForces.h:87
T area
The element's area, m^2.
Definition NetElement3NForces.h:88
Definition NetElement3NForces.h:59
double dampingCoeff
Coefficient of the rotational and structural damping.
Definition NetElement3NForces.h:72