13#include <ddc/kernels/fft.hpp>
15#include <Kokkos_Core.hpp>
51template <
class ChunkType>
52void display(
double time, ChunkType temp)
54 double const mean_temp
56 / temp.domain().size();
57 std::cout << std::fixed << std::setprecision(3);
58 std::cout <<
"At t = " << time <<
",\n";
59 std::cout <<
" * mean temperature = " << mean_temp <<
"\n";
65 std::cout << std::setw(6) << temp_slice(ix);
67 std::cout <<
" }\n" << std::flush;
70int main(
int argc,
char** argv)
72 Kokkos::ScopeGuard
const kokkos_scope(argc, argv);
79 double const x_start = -1.;
81 double const x_end = 1.;
83 std::size_t
const nb_x_points = 10;
85 double const kx = .01;
87 double const y_start = -1.;
89 double const y_end = 1.;
91 std::size_t
const nb_y_points = 100;
93 double const ky = .002;
95 double const start_time = 0.;
97 double const end_time = 10.;
99 std::ptrdiff_t
const t_output_period = 10;
148 initial_temp(ixy) = 9.999 * ((x * x + y * y) < 0.25);
169 time_domain.remove_first(
ddc::DiscreteVector<DDimT>(1))) {
178 Kokkos::DefaultExecutionSpace
const execution_space;
179 ddc::fft(execution_space, Ff, last_temp, kwargs);
188 Ff(ikxky) *= 1 - (kx * rkx * rkx + ky * rky * rky) * dt;
190 ddc::ifft(execution_space, next_temp, Ff, kwargs);
192 if (iter - last_output >= t_output_period) {
199 std::swap(_last_temp, _next_temp);
202 if (last_output < time_domain.
back()) {
KOKKOS_FUNCTION constexpr size_type size() const noexcept
KOKKOS_FUNCTION constexpr span_type span_view() const
KOKKOS_FUNCTION constexpr DiscreteDomain remove_last(discrete_vector_type n) const
KOKKOS_FUNCTION constexpr discrete_element_type front() const noexcept
KOKKOS_FUNCTION constexpr discrete_element_type back() const noexcept
A DiscreteElement identifies an element of the discrete dimension.
A DiscreteVector is a vector in the discrete dimension.
PeriodicSampling models a periodic discretization of the provided continuous dimension.
The top-level namespace of DDC.
void ifft(ExecSpace const &exec_space, ddc::ChunkSpan< Tout, ddc::DiscreteDomain< DDimX... >, LayoutOut, MemorySpace > out, ddc::ChunkSpan< Tin, ddc::DiscreteDomain< DDimFx... >, LayoutIn, MemorySpace > in, ddc::kwArgs_fft kwargs={ddc::FFT_Normalization::OFF})
Perform an inverse Fast Fourier Transform.
auto parallel_deepcopy(ChunkDst &&dst, ChunkSrc &&src)
Copy the content of a borrowed chunk into another.
void fft(ExecSpace const &exec_space, ddc::ChunkSpan< Tout, ddc::DiscreteDomain< DDimFx... >, LayoutOut, MemorySpace > out, ddc::ChunkSpan< Tin, ddc::DiscreteDomain< DDimX... >, LayoutIn, MemorySpace > in, ddc::kwArgs_fft kwargs={ddc::FFT_Normalization::OFF})
Perform a direct Fast Fourier Transform.
@ BACKWARD
No normalization for forward FFT, multiply by 1/N for backward FFT.
KOKKOS_FUNCTION Coordinate< typename DDim::continuous_dimension_type... > coordinate(DiscreteElement< DDim... > const &c)
void init_discrete_space(Args &&... args)
Initialize (emplace) a global singleton discrete space.
T transform_reduce(Support const &domain, T neutral, BinaryReductionOp &&reduce, UnaryTransformOp &&transform) noexcept
A reduction over a nD domain in serial.
detail::TaggedVector< CoordinateElement, CDims... > Coordinate
A Coordinate represents a coordinate in the continuous space.
void parallel_for_each(std::string const &label, ExecSpace const &execution_space, Support const &domain, Functor &&f) noexcept
iterates over a nD domain using a given Kokkos execution space
void for_each(Support const &domain, Functor &&f) noexcept
iterates over a nD domain in serial
auto create_mirror(Space const &space, ChunkSpan< ElementType, Support, Layout, MemorySpace > const &src)
A structure embedding the configuration of the exposed FFT function with the type of normalization.