21#include "WetCylinderWater.h"
23#include <fhsim_environment/ElementFlowInteraction.h>
24#include <fhsim_environment/hydrodynamics/WetCylinderLaw.h>
33namespace wet_cylinder_water
35using environment::wet_cylinder::EndWater;
40 Eigen::Vector3d
force = Eigen::Vector3d::Zero();
41 Eigen::Vector3d
moment = Eigen::Vector3d::Zero();
74 void Add(
const Eigen::Vector3d& centre,
const Eigen::Vector3d& axis)
76 m_centres.push_back(centre);
77 m_axes.push_back(axis);
83 const double offset = m_length / (2.0 * std::sqrt(3.0));
84 m_positions.resize(2 * m_centres.size());
85 for (
size_t i = 0; i < m_centres.size(); i++) {
86 m_positions[2 * i] = m_centres[i] - offset * m_axes[i];
87 m_positions[2 * i + 1] = m_centres[i] + offset * m_axes[i];
92 int NumElements()
const {
return static_cast<int>(m_centres.size()); }
95 int NumPoints()
const {
return static_cast<int>(m_positions.size()); }
98 const Eigen::Vector3d&
Position(
int point)
const {
return m_positions[point]; }
106 points.reserve(points.size() + 3 * m_positions.size());
107 for (
const Eigen::Vector3d& position : m_positions)
108 points.insert(points.end(), position.data(), position.data() + 3);
117 void QueryWater(
const environment::wake::ElementFlowInteraction& flow,
double T,
int firstPoint)
119 m_water.resize(m_positions.size());
120 for (
int point = 0; point <
NumPoints(); point++) {
121 m_water[point].setZero();
122 flow.WaterVelocity(T, firstPoint + point, m_positions[point].data(), m_water[point].data());
134 const Eigen::Vector3d& atMinus = m_water[2 * element];
135 const Eigen::Vector3d& atPlus = m_water[2 * element + 1];
136 const double ratio = std::sqrt(3.0);
137 const Eigen::Vector3d mean = 0.5 * (atMinus + atPlus);
138 const Eigen::Vector3d halfRise = 0.5 * ratio * (atPlus - atMinus);
139 const Eigen::Vector3d minus = mean - halfRise;
140 const Eigen::Vector3d plus = mean + halfRise;
141 return {{minus(0), minus(1), minus(2)}, {plus(0), plus(1), plus(2)}};
145 double m_length = 0.0;
146 std::vector<Eigen::Vector3d> m_centres;
147 std::vector<Eigen::Vector3d> m_axes;
148 std::vector<Eigen::Vector3d> m_positions;
149 std::vector<Eigen::Vector3d> m_water;
163template<
class DragModel = environment::wet_cylinder::ReynoldsDrag>
164inline GaussDragLoad GaussPointDragLoad(
const environment::wet_cylinder::WetCylinder& cylinder,
double f,
const Eigen::Vector3d& V,
const Eigen::Vector3d& W,
165 const Eigen::Vector3d& axis,
const EndWater& water,
const DragModel& model = DragModel {})
167 const auto parts = environment::wet_cylinder::GaussPointDragLoad(cylinder, model, f, {V(0), V(1), V(2)}, {W(0), W(1), W(2)}, {axis(0), axis(1), axis(2)}, water);
168 return {Eigen::Vector3d(parts.force.data()), Eigen::Vector3d(parts.moment.data())};
Definition GaussPointDrag.h:56
int NumPoints() const
The number of points: two per element.
Definition GaussPointDrag.h:95
void AppendPositions(std::vector< double > &points) const
Definition GaussPointDrag.h:104
int NumElements() const
The number of elements in the chain.
Definition GaussPointDrag.h:92
void Build()
Finds the Gauss points from the elements added.
Definition GaussPointDrag.h:81
EndWater WaterOf(int element) const
Definition GaussPointDrag.h:132
void QueryWater(const environment::wake::ElementFlowInteraction &flow, double T, int firstPoint)
Definition GaussPointDrag.h:117
void Add(const Eigen::Vector3d ¢re, const Eigen::Vector3d &axis)
Definition GaussPointDrag.h:74
const Eigen::Vector3d & Position(int point) const
The position of point point [m], NED.
Definition GaussPointDrag.h:98
void Begin(double length)
Definition GaussPointDrag.h:62
< The water velocity at the two ends of an element, from fhsim_environment.
Definition GaussPointDrag.h:39
Eigen::Vector3d moment
The sum of (s N) × F over the two points.
Definition GaussPointDrag.h:41
Eigen::Vector3d force
The sum of the drag at the two points.
Definition GaussPointDrag.h:40