53template <
class ChunkType>
54void display(
double time, ChunkType temp)
64 / temp.domain().size();
65 std::cout << std::fixed << std::setprecision(3);
66 std::cout <<
"At t = " << time <<
",\n";
67 std::cout <<
" * mean temperature = " << mean_temp <<
"\n";
72 std::cout <<
" * temperature[y:"
77 std::cout << std::setw(6) << temp_slice(ix);
79 std::cout <<
" }" << std::endl;
81#ifdef DDC_BUILD_PDI_WRAPPER
92int main(
int argc,
char** argv)
94#ifdef DDC_BUILD_PDI_WRAPPER
95 auto pdi_conf = PC_parse_string(
"");
98 Kokkos::ScopeGuard
const kokkos_scope(argc, argv);
106 double const x_start = -1.;
108 double const x_end = 1.;
110 size_t const nb_x_points = 10;
112 double const kx = .01;
114 double const y_start = -1.;
116 double const y_end = 1.;
118 size_t const nb_y_points = 100;
120 double const ky = .002;
122 double const start_time = 0.;
124 double const end_time = 10.;
126 ptrdiff_t
const t_output_period = 10;
138 auto const [x_domain, ghosted_x_domain, x_pre_ghost, x_post_ghost]
150 x_domain_begin(x_domain.front(), x_post_ghost.extents());
154 x_domain.back() - x_pre_ghost.extents() + 1,
155 x_pre_ghost.extents());
164 auto const [y_domain, ghosted_y_domain, y_pre_ghost, y_post_ghost]
174 y_domain_begin(y_domain.front(), y_post_ghost.extents());
178 y_domain.back() - y_pre_ghost.extents() + 1,
179 y_pre_ghost.extents());
204 .5 / (kx * invdx2_max + ky * invdy2_max)};
209 std::ceil((end_time - start_time) / max_dt) + .2};
228 DDimY>(ghosted_x_domain, ghosted_y_domain),
237 DDimY>(ghosted_x_domain, ghosted_y_domain),
245 = ghosted_last_temp.span_view();
254 ghosted_initial_temp(ixy)
255 = 9.999 * ((x * x + y * y) < 0.25);
263 DDimY>(ghosted_x_domain, ghosted_y_domain),
271 ghosted_temp[x_domain][y_domain]);
277 for (
auto const iter :
278 time_domain.remove_first(
ddc::DiscreteVector<DDimT>(1))) {
284 ghosted_last_temp[x_pre_ghost][y_domain],
285 ghosted_last_temp[y_domain][x_domain_end]);
287 ghosted_last_temp[y_domain][x_post_ghost],
288 ghosted_last_temp[y_domain][x_domain_begin]);
290 ghosted_last_temp[x_domain][y_pre_ghost],
291 ghosted_last_temp[x_domain][y_domain_end]);
293 ghosted_last_temp[x_domain][y_post_ghost],
294 ghosted_last_temp[x_domain][y_domain_begin]);
301 ghosted_next_temp[x_domain][y_domain]};
319 double const dx_m = 0.5 * (dx_l + dx_r);
322 double const dy_m = 0.5 * (dy_l + dy_r);
323 next_temp(ix, iy) = last_temp(ix, iy);
326 * (dx_l * last_temp(ix + 1, iy)
327 - 2.0 * dx_m * last_temp(ix, iy)
328 + dx_r * last_temp(ix - 1, iy))
329 / (dx_l * dx_m * dx_r);
332 * (dy_l * last_temp(ix, iy + 1)
333 - 2.0 * dy_m * last_temp(ix, iy)
334 + dy_r * last_temp(ix, iy - 1))
335 / (dy_l * dy_m * dy_r);
340 if (iter - last_output_iter >= t_output_period) {
341 last_output_iter = iter;
344 ghosted_temp[x_domain][y_domain]);
350 std::swap(ghosted_last_temp, ghosted_next_temp);
355 if (last_output_iter < time_domain.
back()) {
358 ghosted_temp[x_domain][y_domain]);
362#ifdef DDC_BUILD_PDI_WRAPPER
364 PC_tree_destroy(&pdi_conf);
Definition discrete_domain.hpp:51
KOKKOS_FUNCTION constexpr discrete_element_type front() const noexcept
Definition discrete_domain.hpp:154
KOKKOS_FUNCTION constexpr discrete_element_type back() const noexcept
Definition discrete_domain.hpp:159
A DiscreteElement identifies an element of the discrete dimension.
Definition discrete_element.hpp:146
A DiscreteVector is a vector in the discrete dimension.
Definition discrete_vector.hpp:254
Definition kokkos_allocator.hpp:17
PdiEvent & and_with(std::string const &name, T &&t)
Definition pdi.hpp:108
PdiEvent & with(std::string const &name, BorrowedChunk &&data)
Definition pdi.hpp:63
Definition scope_guard.hpp:17
The top-level namespace of DDC.
Definition aligned_allocator.hpp:11
constexpr bool enable_chunk
Definition chunk_traits.hpp:16
auto parallel_deepcopy(ChunkDst &&dst, ChunkSrc &&src)
Copy the content of a borrowed chunk into another.
Definition parallel_deepcopy.hpp:21
void for_each(DiscreteDomain< DDims... > const &domain, Functor &&f) noexcept
iterates over a nD domain in serial
Definition for_each.hpp:48
KOKKOS_FUNCTION Coordinate< typename DDim::continuous_dimension_type... > coordinate(DiscreteElement< DDim... > const &c)
Definition coordinate.hpp:29
T transform_reduce(DiscreteDomain< DDims... > const &domain, T neutral, BinaryReductionOp &&reduce, UnaryTransformOp &&transform) noexcept
A reduction over a nD domain in serial.
Definition transform_reduce.hpp:72
void parallel_for_each(std::string const &label, ExecSpace const &execution_space, DiscreteDomain< DDims... > const &domain, Functor &&f) noexcept
iterates over a nD domain using a given Kokkos execution space
Definition parallel_for_each.hpp:155
KOKKOS_FUNCTION Coordinate< typename DDim::continuous_dimension_type > distance_at_left(DiscreteElement< DDim > i)
Definition non_uniform_point_sampling.hpp:161
detail::TaggedVector< CoordinateElement, CDims... > Coordinate
A Coordinate represents a coordinate in the continuous space.
Definition coordinate.hpp:26
KOKKOS_FUNCTION Coordinate< typename DDim::continuous_dimension_type > distance_at_right(DiscreteElement< DDim > i)
Definition non_uniform_point_sampling.hpp:168
Definition chunk_span.hpp:30
Definition reducer.hpp:109
Definition reducer.hpp:15