Virtual Testbed
Ship dynamics simulator for extreme conditions
velocity_potential.hh
1 #ifndef VTESTBED_CORE_VELOCITY_POTENTIAL_HH
2 #define VTESTBED_CORE_VELOCITY_POTENTIAL_HH
3 
4 #include <complex>
5 #include <limits>
6 #include <stdexcept>
7 
8 #include <vtestbed/core/assumptions.hh>
9 #include <vtestbed/core/fourier_transform.hh>
10 #include <vtestbed/core/grid.hh>
11 #include <vtestbed/core/policy.hh>
12 #include <vtestbed/core/types.hh>
13 
14 namespace vtb {
15 
16  namespace core {
17 
24  template <class T, int N>
26 
27  private:
29  Grid<T,2> _wngrid;
30  Assumptions _assumptions;
31 
32  public:
33 
34  Velocity_potential_solver() = default;
35 
36  virtual ~Velocity_potential_solver() = default;
37 
39  inline T
40  depth() const noexcept {
41  return this->_depth;
42  }
43 
45  inline void
46  depth(T rhs) {
47  if (rhs < T(0)) {
48  throw std::invalid_argument("negative depth");
49  }
50  this->_depth = rhs;
51  }
52 
53  inline void
54  wave_number_grid(const Grid<T,2>& rhs) {
55  this->_wngrid = rhs;
56  }
57 
58  inline const Grid<T,2>&
59  wave_number_grid() const {
60  return this->_wngrid;
61  }
62 
63  inline void
64  assumptions(Assumptions rhs) {
65  this->_assumptions = rhs;
66  }
67 
68  inline const Assumptions&
69  assumptions() const {
70  return this->_assumptions;
71  }
72 
83  virtual void
84  solve(
85  const Grid<T,N+1>& grid_tzxy,
86  const Array<T,N>& wavy_surface,
87  Array<T,N+1>& velocity_potential
88  ) = 0;
89 
90  inline void
91  operator()(
92  const Grid<T,4>& grid_tzxy,
93  const Array<T,3>& wavy_surface,
94  Array<T,4>& velocity_potential
95  ) {
96  this->solve(grid_tzxy, wavy_surface, velocity_potential);
97  }
98 
99  };
100 
106  template <class T>
108  public Velocity_potential_solver<T,3>
109  {
110 
111  private:
112  typedef std::complex<T> C;
113 
114  public:
115 
135  void
137  const Grid<T,4>& grid_tzxy,
138  const Array3<T>& wavy_surface,
139  Array3<C>& result
140  );
141 
142  };
143 
150  template <class T, Policy P>
153  {
154 
155  private:
156  typedef std::complex<T> C;
157  typedef blitz::TinyVector<int,2> int2;
159 
160  private:
161  fft_type _fft;
162  Array<T,3> _wf;
163  Grid<T,3> _wfgrid;
164 
165  public:
166 
168 
170 
191  void
192  solve(
193  const Grid<T,4>& grid_tzxy,
194  const Array<T,3>& wavy_surface,
195  Array<T,4>& velocity_potential
196  ) override;
197 
216  void
218  const Grid<T,2>& wngrid,
219  const T z,
220  Array2<T>& result
221  );
222 
223  };
224 
225  template <class T, int N, Policy P>
227  make_velocity_potential_solver();
228 
229  }
230 
231 }
232 
233 #endif // vim:filetype=cpp
virtual void solve(const Grid< T, N+1 > &grid_tzxy, const Array< T, N > &wavy_surface, Array< T, N+1 > &velocity_potential)=0
Calculate velocity potential for each grid point.
Uses formulae from linear wavy theory.
void depth(T rhs)
Set water depth.
void solve(const Grid< T, 4 > &grid_tzxy, const Array< T, 3 > &wavy_surface, Array< T, 4 > &velocity_potential) override
Computes velocity potential .
void window_function(const Grid< T, 2 > &wngrid, const T z, Array2< T > &result)
Computes window (first) function .
T infinity(T... args)
Main namespace.
Definition: convert.hh:9
Base class for all velocity potential solvers.
T depth() const noexcept
Get water depth.
Base class for linear velocity potential solver.
void second_function(const Grid< T, 4 > &grid_tzxy, const Array3< T > &wavy_surface, Array3< C > &result)
Computes second function.