Virtual Testbed
Ship dynamics simulator for extreme conditions
shallow_water_wave.hh
1 #ifndef VTESTBED_CORE_SHALLOW_WATER_WAVE_HH
2 #define VTESTBED_CORE_SHALLOW_WATER_WAVE_HH
3 
4 #include <vtestbed/base/constants.hh>
5 #include <vtestbed/core/wave.hh>
6 
7 namespace vtb {
8 
9  namespace core {
10 
11  template <class T, int N>
12  inline Frequency<T>
13  shallow_water_wave_angular_frequency(const blitz::TinyVector<T,N>& k, T depth) {
14  using std::sqrt;
15  using std::tanh;
16  using base::constants;
17  constexpr auto g = constants<T>::g();
18  const auto k_len = length(k);
19  return Frequency<T>{sqrt(g*k_len*tanh(k_len*depth))};
20  }
21 
22  template <class T, int N>
23  inline Frequency<T>
24  shallow_water_wave_angular_frequency(
25  Length<T> length,
26  Direction<T> angle,
27  T depth
28  ) {
29  return shallow_water_wave_angular_frequency<T,N>(
30  wave_number<T,N>(length, angle), depth
31  );
32  }
33 
34  template <class T, int N>
35  class Shallow_water_wave: public Wave_base<T,N> {
36 
37  public:
38  using typename Wave_base<T,N>::vec;
39 
40  Shallow_water_wave() = default;
41  ~Shallow_water_wave() = default;
42  Shallow_water_wave(const Shallow_water_wave&) = default;
43  Shallow_water_wave& operator=(const Shallow_water_wave&) = default;
44 
45  inline
48  amplitude,
50  linear_wave_angular_frequency(wave_number, depth)
51  ) {}
52 
53  inline
58  T depth
59  ):
60  Shallow_water_wave(amplitude, wave_number<T,N-1>(length, direction), depth)
61  {}
62 
63  };
64 
65  }
66 
67 }
68 
69 #endif // vim:filetype=cpp
const vec & wave_number() const noexcept
Get wave numbers for each dimension.
Definition: core/wave.hh:96
T tanh(T... args)
vec length() const noexcept
Get wave length.
Definition: core/wave.hh:108
T direction() const noexcept
Get wave direction in radians.
Definition: core/wave.hh:120
T length(const blitz::TinyVector< T, N > &x)
Computes vector length without overflow.
Definition: blitz.hh:471
T amplitude() const noexcept
Get wave amplitude.
Definition: core/wave.hh:90
Main namespace.
Definition: convert.hh:9
T sqrt(T... args)
Base class for water waves.
Definition: core/types.hh:49