1 #ifndef VTESTBED_CORE_PLAIN_WAVE_GENERATOR_HH 2 #define VTESTBED_CORE_PLAIN_WAVE_GENERATOR_HH 10 #include <vtestbed/base/blitz.hh> 11 #include <vtestbed/base/for_loop.hh> 12 #include <vtestbed/core/grid.hh> 13 #include <vtestbed/core/policy.hh> 14 #include <vtestbed/core/types.hh> 15 #include <vtestbed/core/wavy_surface_generator.hh> 31 template <
class T,
int N,
class Wave>
34 #if defined(VTB_DEBUG) 35 if (!blitz::all(result.shape() == grid.
shape())) {
39 const auto delta{grid.
delta()};
43 [&result,&grid,&wave,&delta](
const blitz::TinyVector<int,N>& idx) {
44 blitz::TinyVector<T,N> v{grid(idx, delta)};
45 blitz::TinyVector<T,N-1> x;
46 for (
int i=1; i<N; ++i) { x(i-1) = v(i); }
47 result(idx) = wave(x, v(0));
52 template <
class T,
int N,
class Wave>
55 Array<T,N> result(grid.shape());
56 generate_wave<T,N,Wave>(grid, result, wave);
68 template <
class T,
int N,
class Wave, Policy P=Policy::OpenMP>
76 using typename base_type::array_type;
77 using wave_type = Wave;
91 generate(
const grid_type& grid, array_type& result) = 0;
93 inline const Wave& wave()
const {
return this->_wave; }
95 inline grid_type acf_grid()
const override {
return this->_wave.acf_grid(); }
99 template <
class T,
int N,
class Wave, Policy P>
101 make_plain_wave_generator(
const Wave& wave);
103 template <
class T,
int N,
class Wave, Policy P>
105 make_plain_wave_generator();
107 template <
class T,
int N>
109 make_plain_wave_generator(std::any wave, Policy policy);
121 template <
class T,
int N>
128 using typename base_type::array_type;
147 _generators(std::move(generators)) {}
150 generate(
const grid_type& grid, array_type& result)
override {
152 for (
auto& gen : this->_generators) {
153 result += gen->generate(grid);
163 #endif // vim:filetype=cpp Wavy surface generator that produces elevation grid for multiple waves.
const int_n & end() const noexcept
End indices (exclusive).
const int_n shape() const noexcept
The number of points for all dimensions.
const T delta(int i) const
The size of the patch (interval) for dimension i.
A region defined by start and end index and lower and upper bound for each dimension.
Wavy surface generator that produces elevation grid for individual wave.
const int_n & begin() const noexcept
Start indices (inclusive).
void generate_wave(const Grid< T, N > &grid, Array< T, N > &result, Wave wave)
Generate wavy surface for specified wave and spatio-temporal grid.
Base class for wavy surface generators.