13#include <ddc/kernels/fft.hpp>
15#include <Kokkos_Core.hpp>
57template <
class ChunkType>
58void display(
double time, ChunkType temp)
60 double const mean_temp
62 / temp.domain().size();
64 std::cout << std::fixed << std::setprecision(3);
65 std::cout <<
"At t = " << time <<
",\n";
66 std::cout <<
" * mean temperature = " << mean_temp <<
'\n';
67 std::cout <<
" * temperature[y:" << yslice.value() <<
"] = ";
69 std::cout <<
'\n' << std::flush;
72int main(
int argc,
char** argv)
74 Kokkos::ScopeGuard
const kokkos_scope(argc, argv);
81 double const x_start = -1.;
83 double const x_end = 1.;
85 std::size_t
const nb_x_points = 10;
87 double const kx = .01;
89 double const y_start = -1.;
91 double const y_end = 1.;
93 std::size_t
const nb_y_points = 100;
95 double const ky = .002;
97 double const start_time = 0.;
99 double const end_time = 10.;
101 std::ptrdiff_t
const t_output_period = 10;
150 initial_temp(ixy) = 9.999 * ((x * x + y * y) < 0.25);
171 time_domain.remove_first(
ddc::DiscreteVector<DDimT>(1))) {
180 Kokkos::DefaultExecutionSpace
const execution_space;
181 ddc::fft(execution_space, Ff, last_temp, kwargs);
190 Ff(ikxky) *= 1 - (kx * rkx * rkx + ky * rky * rky) * dt;
192 ddc::ifft(execution_space, next_temp, Ff, kwargs);
194 if (iter - last_output >= t_output_period) {
201 std::swap(_last_temp, _next_temp);
204 if (last_output < time_domain.
back()) {
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.
std::ostream & print_content(std::ostream &os, ChunkSpan< ElementType, SupportType, LayoutStridedPolicy, MemorySpace > const &chunk_span)
Print the content of a ChunkSpan.
T host_transform_reduce(Support const &domain, T neutral, BinaryReductionOp &&reduce, UnaryTransformOp &&transform) noexcept
A reduction over a nD domain in serial.
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 DDims::continuous_dimension_type... > coordinate(DiscreteElement< DDims... > const &c)
void init_discrete_space(Args &&... args)
Initialize (emplace) a global singleton discrete space.
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
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.