43 #include "Waves/SpectrumKin.hpp"
57 using Vec2D = std::vector<std::vector<T>>;
61 using Vec3D = std::vector<std::vector<std::vector<T>>>;
65 using Vec4D = std::vector<std::vector<std::vector<std::vector<T>>>>;
72 init2DArray(
unsigned int nx,
unsigned int ny)
82 static inline Vec3D<real>
83 init3DArray(
unsigned int nx,
unsigned int ny,
unsigned int nz)
85 return Vec3D<real>(nx, init2DArray(ny, nz));
94 static inline Vec4D<vec3>
95 init4DArrayVec(
unsigned int nx,
102 Vec3D<vec3>(ny, Vec2D<vec3>(nz, std::vector<vec3>(nw, vec3::Zero()))));
110 static inline Vec4D<real>
111 init4DArray(
unsigned int nx,
unsigned int ny,
unsigned int nz,
unsigned int nw)
113 return Vec4D<real>(nx, init3DArray(ny, nz, nw));
122 real getAverageDepth()
const;
123 real getDepth(
const vec2& pos)
const;
188 waves::SpectrumKin spectrumKin;
200 : spectrumKin(spectrum)
218 real avgDepth = seafloor.getAverageDepth();
219 real actualDepth = seafloor.getDepth(pos.head<2>());
220 spectrumKin.getWaveKin(
221 pos, time, avgDepth, actualDepth, zeta, vel, acc);
236 const std::vector<real>&
py,
237 const std::vector<real>&
pz,
240 :
nx(
static_cast<unsigned int>(
px.size()))
241 ,
ny(
static_cast<unsigned int>(
py.size()))
242 ,
nz(
static_cast<unsigned int>(
pz.size()))
263 std::vector<real>
px;
265 std::vector<real>
py;
267 std::vector<real>
pz;
283 const std::vector<real>&
px,
284 const std::vector<real>&
py,
285 const std::vector<real>&
pz,
294 void allocateKinematicArrays();
302 real* pdyn)
override;
305 inline const Vec3D<real>& getZetas()
const {
return zetas; }
308 inline const Vec4D<real>& getPDyn()
const {
return pDyn; }
311 inline const Vec4D<vec3>& getWaveVel()
const {
return wave_vel; }
314 inline const Vec4D<vec3>& getWaveAcc()
const {
return wave_acc; }
316 inline const std::vector<real>& Px()
const {
return px; }
317 inline const std::vector<real>& Py()
const {
return py; }
318 inline const std::vector<real>& Pz()
const {
return pz; }
343 const std::vector<real>&
px,
344 const std::vector<real>&
py,
345 const std::vector<real>&
pz,
355 void allocateKinematicArrays();
363 inline Vec4D<vec3>& CurrentVel() {
return current_vel; }
364 inline const Vec4D<vec3>& getCurrentVel()
const {
return current_vel; }
366 inline Vec4D<vec3>& CurrentAcc() {
return current_acc; }
367 inline const Vec4D<vec3>& getCurrentAcc()
const {
return current_acc; }
369 inline const std::vector<real>& Px()
const {
return px; }
370 inline const std::vector<real>& Py()
const {
return py; }
371 inline const std::vector<real>& Pz()
const {
return pz; }
424 std::vector<vec>
const& Ud);
468 using NodeKinReturnType = std::tuple<const std::vector<real>&,
469 const std::vector<vec3>&,
470 const std::vector<vec3>&,
471 const std::vector<real>&>;
545 struct NodeKinematics
547 std::vector<const C*> structures;
548 std::vector<std::vector<real>> zetas;
549 std::vector<std::vector<vec3>> U;
550 std::vector<std::vector<vec3>> Ud;
551 std::vector<std::vector<real>> Pdyn;
553 NodeKinReturnType operator[](
size_t idx)
556 return { zetas[idx], U[idx], Ud[idx], Pdyn[idx] };
568 NodeKinematics<moordyn::Line> lines;
569 NodeKinematics<moordyn::Body> bodies;
570 NodeKinematics<moordyn::Rod> rods;
571 NodeKinematics<moordyn::Point> points;
588 void genericAdd(
const C*
const structure,
589 unsigned int num_nodes,
590 NodeKinematics<C>& nodeKinematics)
592 nodeKinematics.structures.push_back(structure);
593 nodeKinematics.zetas.emplace_back(num_nodes, 0.0);
594 nodeKinematics.U.emplace_back(num_nodes, vec3::Zero());
595 nodeKinematics.Ud.emplace_back(num_nodes, vec3::Zero());
596 nodeKinematics.Pdyn.emplace_back(num_nodes, 0.0);
609 void kinematicsForAllNodes(AllNodesKin& nodeKinematics, F f);
612 std::unique_ptr<AbstractWaveKin> waveKinematics{};
614 std::unique_ptr<AbstractCurrentKin> currentKinematics{};
623 std::unique_ptr<WaveGrid> waveGrid{};
676 void setup(EnvCondRef env,
679 const char* folder =
"Mooring/");
700 typedef std::shared_ptr<Waves>
WavesRef;
An abstract class representing the capability of providing water current data at some point and time.
Definition: Waves.hpp:131
virtual void getCurrentKin(const vec3 &pos, real time, const SeafloorProvider &seafloor, vec3 *vel, vec3 *acc)=0
Get the velocity and acceleration at a specific position and time.
An abstract class representing having the capability of providing wave kinematics data.
Definition: Waves.hpp:156
virtual void getWaveKin(const vec3 &pos, real time, const SeafloorProvider &seafloor, real *zeta, vec3 *vel, vec3 *acc, real *pdyn)=0
Get the velocity, acceleration, wave height and dynamic pressure at a specific position and time.
A rigid body.
Definition: Body.hpp:72
Contains grid based current data.
Definition: Waves.hpp:340
void getCurrentKin(const vec3 &pos, real time, const SeafloorProvider &seafloor, vec3 *vel, vec3 *acc) override
Get the velocity and acceleration at a specific position and time.
Definition: Waves.cpp:204
A rectilinear grid with x, y, z, and t axes.
Definition: Waves.hpp:233
std::vector< real > px
grid x coordinate arrays
Definition: Waves.hpp:263
unsigned int nx
number of grid points in x direction
Definition: Waves.hpp:251
std::vector< real > py
grid y coordinate arrays
Definition: Waves.hpp:265
std::vector< real > pz
grid z coordinate arrays
Definition: Waves.hpp:267
unsigned int nz
number of grid points in z direction
Definition: Waves.hpp:255
real dtWave
time step for wave kinematics time series
Definition: Waves.hpp:259
unsigned int nt
number of time steps used in wave kinematics time series
Definition: Waves.hpp:257
unsigned int ny
number of grid points in y direction
Definition: Waves.hpp:253
A mooring line.
Definition: Line.hpp:71
A Logging utility.
Definition: Log.hpp:149
A helper for the entities to use the logger.
Definition: Log.hpp:223
LogUser(Log *log=NULL)
Constructor.
Definition: Log.hpp:231
A point for a line endpoint.
Definition: Point.hpp:69
A cylindrical rod.
Definition: Rod.hpp:65
Bathymetry description for MoorDyn.
Definition: Seafloor.hpp:52
Wrapper around waves::SpectrumKin to make it adhere to the AbstractWaveKin interface.
Definition: Waves.hpp:187
SpectrumKinWrapper(waves::SpectrumKin &&spectrum)
Construct a new Spectrum Kin Wrapper object.
Definition: Waves.hpp:199
void getWaveKin(const vec3 &pos, real time, const SeafloorProvider &seafloor, real *zeta, vec3 *vel, vec3 *acc, real *pdyn) override
Get the velocity, acceleration, wave height and dynamic pressure at a specific position and time.
Definition: Waves.hpp:206
Contains the data and functionality for the Wave grid kinematics modes.
Definition: Waves.hpp:280
void getWaveKin(const vec3 &pos, real time, const SeafloorProvider &seafloor, real *zeta, vec3 *vel, vec3 *acc, real *pdyn) override
Get the velocity, acceleration, wave height and dynamic pressure at a specific position and time.
Definition: Waves.cpp:124
Class that handles wave and current kinematics.
Definition: Waves.hpp:398
std::vector< vec3 > getWaveKinematicsPoints()
Get the positions of all the nodes with wave kinematics.
Definition: Waves.cpp:666
NodeKinReturnType getWaveKinBody(size_t bodyId)
Get the water kinematics for the body with given Id.
Definition: Waves.cpp:579
NodeKinReturnType getWaveKinRod(size_t rodId)
Get the water kinematics for the rod with given Id.
Definition: Waves.cpp:573
NodeKinReturnType getWaveKinPoint(size_t pointId)
Get the water kinematics for the point with given Id.
Definition: Waves.cpp:585
void addBody(moordyn::Body *body)
Adds a body to the list of structures we calculate water kinematics for.
Definition: Waves.cpp:539
real getWaveHeightPoint(vec2 point)
Gets the surface height at a given (x, y) point.
Definition: Waves.cpp:591
void updateWaves()
Recalculates any wave and current kinematics for all the nodes.
Definition: Waves.cpp:755
void addPoint(moordyn::Point *point)
Adds a point to the list of structures we calculate water kinematics for.
Definition: Waves.cpp:552
~Waves()
Destructor.
Definition: Waves.cpp:254
Waves(moordyn::Log *log)
Constructor.
Definition: Waves.cpp:247
void setWaveKinematics(std::vector< vec > const &U, std::vector< vec > const &Ud)
Set the wave kinematics for all the structural nodes.
Definition: Waves.cpp:681
coordtypes
Types of coordinates input on the grid file.
Definition: Waves.hpp:654
@ GRID_LATTICE
EQUISPACED POINTS.
Definition: Waves.hpp:660
@ GRID_SINGLE
Single point (0, 0, 0)
Definition: Waves.hpp:656
@ GRID_LIST
List of points.
Definition: Waves.hpp:658
void getWaveKin(const vec3 &pos, real &zeta, vec3 &vel, vec3 &acc, real &pdyn, Seafloor *seafloor=nullptr)
Get the wave kinematics at a point at the current time.
Definition: Waves.cpp:608
void setup(EnvCondRef env, SeafloorRef seafloor, time::Scheme *t, const char *folder="Mooring/")
Setup the wave kinematics.
Definition: Waves.cpp:257
void addRod(moordyn::Rod *rod)
Adds a rod to the list of structures we calculate water kinematics for.
Definition: Waves.cpp:527
NodeKinReturnType getWaveKinLine(size_t lineId)
Get the water kinematics for the line with id.
Definition: Waves.cpp:567
void addLine(moordyn::Line *line)
Adds a line to the list of structures we calculate water kinematics for.
Definition: Waves.cpp:511
Time scheme abstraction.
Definition: Time.hpp:59
MoorDyn2 C++ API namespace.
Definition: Body.cpp:27
std::shared_ptr< Waves > WavesRef
Definition: Body.hpp:53
std::vector< std::vector< std::vector< T > >> Vec3D
STL std::vector of 3 dimensions.
Definition: Waves.hpp:61
Eigen::Vector2d vec2
2-D vector of real numbers
Definition: Misc.hpp:120
double real
Real numbers wrapper. It is either double or float.
Definition: Misc.hpp:118
std::vector< std::vector< T > > Vec2D
STL std::vector of 2 dimensions.
Definition: Waves.hpp:57
std::vector< real > gridAxisCoords(Waves::coordtypes coordtype, vector< string > &entries)
Compute the coordinates from a grid definition entry line.
Definition: Waves.cpp:69
std::vector< std::vector< std::vector< std::vector< T > >> > Vec4D
STL std::vector of 4 dimensions.
Definition: Waves.hpp:65
std::shared_ptr< Seafloor > SeafloorRef
Shared pointer.
Definition: Seafloor.hpp:109
Eigen::Vector3d vec3
3-D vector of real numbers
Definition: Misc.hpp:122
Helper for moordyn::AbstractCurrentKin.
Definition: Waves.hpp:119