Virtual Testbed
Ship dynamics simulator for extreme conditions
gerstner.hh
1 #ifndef VTESTBED_CORE_GERSTNER_HH
2 #define VTESTBED_CORE_GERSTNER_HH
3 
4 #include <vector>
5 
6 #include <vtestbed/core/linear_wave.hh>
7 #include <vtestbed/core/policy.hh>
8 #include <vtestbed/core/ship.hh>
9 #include <vtestbed/core/ship_hull_panel.hh>
10 #include <vtestbed/core/types.hh>
11 #include <vtestbed/core/wave.hh>
12 #include <vtestbed/core/wavy_surface_generator.hh>
13 #include <vtestbed/geometry/types.hh>
14 
15 namespace vtb {
16 
17  namespace core {
18 
30  template <class T, int N>
32 
33  public:
34  using scalar_type = T;
35  using vertex_type = blitz::TinyVector<T,N>;
36  using vertex_field_3d = Array<vertex_type,3>;
37  using scalar_field_3d = Array<T,3>;
38  using grid3 = Grid<T,N>;
39  using grid4 = Grid<T,N+1>;
44  using ship_type = Ship<T>;
45  using C = std::complex<T>;
46 
47  protected:
49  wave_array _waves{{Amplitude<T>(1),Length<T>(40),Direction<T>(0)}};
50  vertex_field_3d _velocity;
51  scalar_field_3d _potential;
52  grid3 _velocity_grid_zxy;
53  panel_array _old_panels;
54  T _old_t{};
55  bool _diffraction = false;
56  bool _radiation = false;
57  bool _waterline_only = true;
58  bool _clip = true;
59 
60  public:
61 
63  inline T depth() const { return this->_depth; }
64  inline void depth(T rhs) { this->_depth = rhs; }
65 
66  inline const wave_array& waves() const { return this->_waves; }
67  inline void waves(wave_array&& rhs) { this->_waves = std::move(rhs); }
68  inline void waves(const wave_array& rhs) { this->_waves = rhs; }
69 
72  inline bool diffraction() const { return this->_diffraction; }
73  inline void diffraction(bool rhs) { this->_diffraction = rhs; }
74 
77  inline bool radiation() const { return this->_radiation; }
78  inline void radiation(bool rhs) { this->_radiation = rhs; }
79 
82  inline bool waterline_only() const { return this->_waterline_only; }
83  inline void waterline_only(bool rhs) { this->_waterline_only = rhs; }
84 
86  inline bool clip() const { return this->_clip; }
87  inline void clip(bool rhs) { this->_clip = rhs; }
88 
96  virtual void
98  const ship_type& ship,
99  const panel_array& panels,
100  const grid3& grid_txy,
101  vertex_field_3d& surface
102  ) = 0;
103 
111  virtual void
113  const ship_type& ship,
114  const grid4& grid_tzxy,
115  panel_array & wetted_panels
116  ) = 0;
117 
118  inline const vertex_field_3d& velocity() const { return this->_velocity; }
119  inline const scalar_field_3d& potential() const { return this->_potential; }
120  inline const grid3& velocity_grid() const { return this->_velocity_grid_zxy; }
121 
122  Gerstner_solver() = default;
123  virtual ~Gerstner_solver() = default;
124  Gerstner_solver(const Gerstner_solver&) = default;
125  Gerstner_solver& operator=(const Gerstner_solver&) = default;
126  Gerstner_solver(Gerstner_solver&&) = default;
127  Gerstner_solver& operator=(Gerstner_solver&&) = default;
128 
129  };
130 
131  template <class T, int N, Policy P>
133  make_gerstner_solver();
134 
135  template <class T, int N>
137  make_gerstner_solver(Policy policy);
138 
139  }
140 }
141 
142 #endif // vim:filetype=cpp
T depth() const
Water depth.
Definition: gerstner.hh:63
Trochoidal irrotational waves solves named after Gerstner.
Definition: gerstner.hh:31
Rigid ship with a mass and translational and angular velocity.
Definition: core/ship.hh:186
virtual void compute_positions(const ship_type &ship, const panel_array &panels, const grid3 &grid_txy, vertex_field_3d &surface)=0
Fluid motion without diffraction/radiation.
A region defined by start and end index and lower and upper bound for each dimension.
Definition: core/grid.hh:25
Triangular ship hull panel (face).
bool radiation() const
Calculate radiation forces?
Definition: gerstner.hh:77
T infinity(T... args)
Main namespace.
Definition: convert.hh:9
bool waterline_only() const
Calculate radiation/diffraction using waterline only?
Definition: gerstner.hh:82
bool diffraction() const
Calculate diffraction forces?
Definition: gerstner.hh:72
bool clip() const
Clamp grid to panels?
Definition: gerstner.hh:86
virtual void compute_forces(const ship_type &ship, const grid4 &grid_tzxy, panel_array &wetted_panels)=0
Compute Froude—Krylov force acting on each panel.