FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
TwineFriction.h
1#pragma once
2
31#include "PanelLoadTypes.h"
32#include "TwineCrossFlow.h"
33
34#include <sfh/constants.h>
35#include <sfh/math/math.h>
36
37#include <cmath>
38
39namespace hydrodynamics
40{
41namespace twine_friction
42{
43
45template<class T>
47{
48 T force[3];
49 T drag;
50 T lift;
51};
52
53
63template<class T>
64void AddBarFamilyFriction(double dragFactor, double frictionCoefficient, const T barDirection[3],
65 const T effVel[3], const T& effSpeed, T force[3])
66{
67 const T alongBar = twine_cross_flow_detail::Dot(effVel, barDirection);
68 const T factor = dragFactor * frictionCoefficient * effSpeed * alongBar;
69 for (int i = 0; i < 3; i++) {
70 force[i] = force[i] + factor * barDirection[i];
71 }
72}
73
74
88template<class T>
89InPlaneFriction<T> EvaluateTwineFriction(const Netting<T>& netting, const Fluid& fluid, const T& solidity,
90 const T velocity[3], const T normal[3])
91{
92 using namespace twine_cross_flow_detail;
93 using std::sqrt;
94
95 InPlaneFriction<T> friction;
96 for (int i = 0; i < 3; i++) {
97 friction.force[i] = T(0);
98 }
99 friction.drag = T(0);
100 friction.lift = T(0);
101 if (!netting.hasBarDirections) {
102 return friction;
103 }
104
105 // The speed-up of TwineCrossFlow, on the normal component only (R10).
106 const T speedUp = sqrt(2 - solidity) / (sqrt(2.0) * (1 - solidity));
107 const T normalSpeed = Dot(velocity, normal);
108 T effVel[3];
109 for (int i = 0; i < 3; i++) {
110 effVel[i] = velocity[i] + (speedUp - 1) * normalSpeed * normal[i];
111 }
112 const T effSpeed = sfh::math::Bound(sfh::math::Norm(effVel, 3), T(kMinSpeed), T(kMaxSpeed));
113
114 const double twineLength = sfh::math::Max(netting.barLength - netting.knotDiameter, 0.0);
115 const double barDragFactor = 0.5 * fluid.rho * netting.twineThickness * twineLength;
116 const double frictionCoefficient = TwineCrossFlow {}.ct * sfh::pi;
117 AddBarFamilyFriction(barDragFactor * netting.numBarsU, frictionCoefficient, netting.barU, effVel, effSpeed, friction.force);
118 AddBarFamilyFriction(barDragFactor * netting.numBarsV, frictionCoefficient, netting.barV, effVel, effSpeed, friction.force);
119
120 const T boundedSpeed = sfh::math::Max(sfh::math::Norm(velocity, 3), T(kMinSpeed));
121 T flowDirection[3];
122 for (int i = 0; i < 3; i++) {
123 flowDirection[i] = velocity[i] / boundedSpeed;
124 }
125 T cosTheta = Dot(flowDirection, normal);
126 T normalDownstream[3];
127 for (int i = 0; i < 3; i++) {
128 normalDownstream[i] = (cosTheta < 0) ? -normal[i] : normal[i];
129 }
130 if (cosTheta < 0) {
131 cosTheta = -cosTheta;
132 }
133 T liftDirection[3];
134 for (int i = 0; i < 3; i++) {
135 liftDirection[i] = normalDownstream[i] - cosTheta * flowDirection[i];
136 }
137 const T liftDirectionNorm =
138 sfh::math::Max(sfh::math::Norm(liftDirection, 3), T(kMinLiftDirectionNorm));
139
140 friction.drag = Dot(friction.force, flowDirection);
141 friction.lift = Dot(friction.force, liftDirection) / liftDirectionNorm;
142 return friction;
143}
144
145} // namespace twine_friction
146} // namespace hydrodynamics
The in-plane friction force and its projections on the drag and lift directions.
Definition TwineFriction.h:47
T force[3]
N, global frame, in the panel plane.
Definition TwineFriction.h:48
T drag
N, the projection of force on U-hat.
Definition TwineFriction.h:49
T lift
N, the projection of force on L-hat.
Definition TwineFriction.h:50