FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
WetCylinderWater.h
1#pragma once
2
15#include <fhsim_environment/ElementFlowInteraction.h>
16#include <fhsim_environment/EnvironmentProvider.h>
17#include <fhsim_environment/hydrodynamics/BodySubmergence.h>
18#include <fhsim_environment/hydrodynamics/WetCylinderLaw.h>
19
20#include <sfh/constants.h>
21
22#include <marenv/marenv.h>
23
24#include <Eigen/Eigen>
25
26#include <optional>
27
28namespace wet_cylinder_water
29{
32{
33 double wetFraction;
34 environment::wet_cylinder::Vector waterVelocity;
35 std::optional<environment::wet_cylinder::Vector> waveAcceleration;
36};
37
49inline WaterAtElement SampleWaterGivenVelocity(const environment::wake::ElementFlowInteraction& flow, double T, const double centre[3], const double axis[3], double length, double radius,
50 const environment::wet_cylinder::Vector& waterVelocity)
51{
52 environment::EnvironmentProvider& environment = *flow.Environment();
53 WaterAtElement water;
54 water.waterVelocity = waterVelocity;
55
56 const double half = 0.5 * length;
57 const double endA[3] = {centre[0] - half * axis[0], centre[1] - half * axis[1], centre[2] - half * axis[2]};
58 const double endB[3] = {centre[0] + half * axis[0], centre[1] + half * axis[1], centre[2] + half * axis[2]};
59 water.wetFraction = environment::body_submergence::CylinderWetFraction(environment, environment.MaxWaveElevation(), T, endA, endB, radius);
60 const auto waves = environment.GetWaves();
61 if (waves && water.wetFraction > 0.0) {
62 environment::wet_cylinder::Vector mean;
63 environment::body_submergence::MeanWaveAcceleration(waves.get(), T, endA, endB, mean.data());
64 water.waveAcceleration = mean;
65 }
66 return water;
67}
68
81inline WaterAtElement SampleWater(const environment::wake::ElementFlowInteraction& flow, double T, const double centre[3], const double axis[3], double length, double radius, int point)
82{
83 environment::wet_cylinder::Vector waterVelocity = {0.0, 0.0, 0.0};
84 flow.WaterVelocity(T, point, centre, waterVelocity.data());
85 return SampleWaterGivenVelocity(flow, T, centre, axis, length, radius, waterVelocity);
86}
87
90{
91 double length;
92 double radius;
93 double tangential;
94 double normal;
96 double addedMassCoefficient = 0.0;
97};
98
101{
102 Eigen::Vector3d force = Eigen::Vector3d::Zero();
103 Eigen::Vector3d moment = Eigen::Vector3d::Zero();
104 double displacedMass = 0.0;
105 double addedMass = 0.0;
106};
107
130inline FixedDragLoad FixedDragLoadOnElement(const environment::wake::ElementFlowInteraction& flow, double T, const Eigen::Vector3d& P, const Eigen::Vector3d& V,
131 const Eigen::Vector3d& axis, const FixedDragElement& element, int point, const Eigen::Vector3d& angularVelocity = Eigen::Vector3d::Zero(),
132 const environment::wet_cylinder::EndWater* gaussWater = nullptr)
133{
134 using environment::wet_cylinder::Vector;
135 FixedDragLoad load;
136 const auto water = gaussWater ? SampleWaterGivenVelocity(flow, T, P.data(), axis.data(), element.length, element.radius, gaussWater->Mean())
137 : SampleWater(flow, T, P.data(), axis.data(), element.length, element.radius, point);
138 const double f = water.wetFraction;
139 if (!(f > 0.0))
140 return load;
141
142 environment::wet_cylinder::WetCylinder cylinder {};
143 cylinder.length = element.length;
144 cylinder.radius = element.radius;
145 cylinder.volume = sfh::pi * element.radius * element.radius * element.length;
146 cylinder.waterDensity = element.waterDensity;
147 cylinder.addedMassCoefficient = element.addedMassCoefficient;
148 load.displacedMass = element.waterDensity * cylinder.volume * f;
149 load.addedMass = environment::wet_cylinder::AddedMass(cylinder, f);
150
151 const Vector unitAxis {axis(0), axis(1), axis(2)};
152 const Vector relative {V(0) - water.waterVelocity[0], V(1) - water.waterVelocity[1], V(2) - water.waterVelocity[2]};
153 if (element.addedMassCoefficient != 0.0) {
154 const environment::wet_cylinder::WetCylinderState state {f, {V(0), V(1), V(2)}, water.waterVelocity, {angularVelocity(0), angularVelocity(1), angularVelocity(2)}, unitAxis, water.waveAcceleration};
155 load.force += Eigen::Vector3d(environment::wet_cylinder::CoriolisForce(cylinder, state).data());
156 }
157 const environment::wet_cylinder::DragCoefficients model {element.normal, element.tangential};
158 if (gaussWater) {
159 const auto gauss = environment::wet_cylinder::GaussPointDragLoad(cylinder, model, f, {V(0), V(1), V(2)}, {angularVelocity(0), angularVelocity(1), angularVelocity(2)}, unitAxis, *gaussWater);
160 load.force += Eigen::Vector3d(gauss.force.data());
161 load.moment += Eigen::Vector3d(gauss.moment.data());
162 } else {
163 const Vector drag = environment::wet_cylinder::Drag(cylinder, model, f, relative, unitAxis);
164 load.force += Eigen::Vector3d(drag.data());
165 }
166 if (water.waveAcceleration)
167 load.force += Eigen::Vector3d(environment::wet_cylinder::MorisonForce(cylinder, f, *water.waveAcceleration, unitAxis).data());
168 return load;
169}
170} // namespace wet_cylinder_water
constexpr double seawaterDensity
Ocean water density.
Definition marenv.h:20
A cylinder element with fixed drag coefficients (RbCable/6DofCable, RbCable/Ring).
Definition WetCylinderWater.h:90
double addedMassCoefficient
Ca: 0 for an element whose inertia has no added mass (the default), kCylinderAddedMassCoefficient for...
Definition WetCylinderWater.h:96
double radius
The element radius [m].
Definition WetCylinderWater.h:92
double normal
Cn, on the flow normal to the axis.
Definition WetCylinderWater.h:94
double waterDensity
The water density [kg/m³].
Definition WetCylinderWater.h:95
double tangential
Ct, on the skin area π D L, on the flow along the axis.
Definition WetCylinderWater.h:93
double length
The element length [m].
Definition WetCylinderWater.h:91
The water load on an element with fixed drag coefficients.
Definition WetCylinderWater.h:101
double addedMass
m_a = Ca ρ f V [kg], normal to the axis, for the element's inertia; 0 at Ca = 0.
Definition WetCylinderWater.h:105
double displacedMass
ρ f V, the mass of the water the wet part displaces [kg]; its buoyancy is g times it,...
Definition WetCylinderWater.h:104
Eigen::Vector3d force
The drag, the Morison inertia force and the Coriolis force of the added mass [N], NED.
Definition WetCylinderWater.h:102
Eigen::Vector3d moment
The drag moment about the centre [N m]; only with the Gauss-point drag (MARE-0396),...
Definition WetCylinderWater.h:103
The wet fraction, the water velocity and the wave acceleration at one element.
Definition WetCylinderWater.h:32
double wetFraction
f in [0, 1].
Definition WetCylinderWater.h:33
std::optional< environment::wet_cylinder::Vector > waveAcceleration
The mean of the ends [m/s²]; none without waves or when dry.
Definition WetCylinderWater.h:35
environment::wet_cylinder::Vector waterVelocity
u at the centre [m/s].
Definition WetCylinderWater.h:34