#include <numeric>
#include <ddc/ddc.hpp>
-
-#include <Kokkos_Core.hpp>
-As you can see, DDC includes all follow the same convention: <ddc/SYMBOL>
where SYMBOL
is a the name of a DDC symbol. So for example, in order to use a class named Chunk
, you should include <ddc/Chunk>
and to use a free function template named for_each
, you should include <ddc/for_each>
.
+As you can see, to use DDC, we have to include <ddc/ddc.hpp>
Then, we define the value of some parameters that would typically be read from some form of configuration file in a more realistic code.
double const x_start = -1.;
diff --git a/heat_equation.html b/heat_equation.html
index d5806ec35..7fb55dee5 100644
--- a/heat_equation.html
+++ b/heat_equation.html
@@ -54,280 +54,278 @@
a discrete 7#include <numeric>
-
- 11#include <Kokkos_Core.hpp>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
- 45template <
class ChunkType>
- 46void display(
double time, ChunkType temp)
-
-
-
-
-
-
- 53 / temp.domain().size();
- 54 std::cout << std::fixed << std::setprecision(3);
- 55 std::cout <<
"At t = " << time <<
",\n";
- 56 std::cout <<
" * mean temperature = " << mean_temp <<
"\n";
-
-
- 59 = temp[ddc::get_domain<DDimY>(temp).front()
- 60 + ddc::get_domain<DDimY>(temp).size() / 2];
- 61 std::cout <<
" * temperature[y:"
- 62 << ddc::get_domain<DDimY>(temp).size() / 2 <<
"] = {";
-
-
- 65 ddc::get_domain<DDimX>(temp),
-
- 67 std::cout << std::setw(6) << temp_slice(ix);
-
- 69 std::cout <<
" }" << std::endl;
-
-
-
- 75int main(
int argc,
char** argv)
-
-
-
-
-
-
-
- 84 double const x_start = -1.;
-
- 86 double const x_end = 1.;
-
- 88 size_t const nb_x_points = 10;
-
- 90 double const kx = .01;
-
- 92 double const y_start = -1.;
-
- 94 double const y_end = 1.;
-
- 96 size_t const nb_y_points = 100;
-
- 98 double const ky = .002;
-
- 100 double const start_time = 0.;
-
- 102 double const end_time = 10.;
-
- 104 ptrdiff_t
const t_output_period = 10;
-
-
-
-
-
-
- 116 auto const [x_domain, ghosted_x_domain, x_pre_ghost, x_post_ghost]
-
-
-
-
-
-
-
-
-
- 128 x_domain_begin(x_domain.front(), x_post_ghost.extents());
-
-
-
- 132 x_domain.back() - x_pre_ghost.extents() + 1,
- 133 x_pre_ghost.extents());
-
-
-
-
-
-
- 142 auto const [y_domain, ghosted_y_domain, y_pre_ghost, y_post_ghost]
-
-
-
-
-
-
-
-
-
- 152 y_domain_begin(y_domain.front(), y_post_ghost.extents());
-
-
-
- 156 y_domain.back() - y_pre_ghost.extents() + 1,
- 157 y_pre_ghost.extents());
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 182 .5 / (kx * invdx2_max + ky * invdy2_max)};
-
-
-
- 186 std::ceil((end_time - start_time) / max_dt) + .2};
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 204 DDimY>(ghosted_x_domain, ghosted_y_domain),
-
-
-
-
-
-
- 211 DDimY>(ghosted_x_domain, ghosted_y_domain),
-
-
-
- 217 = ghosted_last_temp.span_view();
-
-
-
-
-
-
-
-
-
- 227 ghosted_initial_temp(ixy)
- 228 = 9.999 * ((x * x + y * y) < 0.25);
-
-
-
-
-
- 235 DDimY>(ghosted_x_domain, ghosted_y_domain),
-
-
-
-
-
-
- 243 ghosted_temp[x_domain][y_domain]);
-
-
-
- 249 for (
auto const iter :
-
-
-
-
- 256 ghosted_last_temp[x_pre_ghost][y_domain],
- 257 ghosted_last_temp[y_domain][x_domain_end]);
-
- 259 ghosted_last_temp[y_domain][x_post_ghost],
- 260 ghosted_last_temp[y_domain][x_domain_begin]);
-
- 262 ghosted_last_temp[x_domain][y_pre_ghost],
- 263 ghosted_last_temp[x_domain][y_domain_end]);
-
- 265 ghosted_last_temp[x_domain][y_post_ghost],
- 266 ghosted_last_temp[x_domain][y_domain_begin]);
-
-
-
-
- 273 ghosted_next_temp[x_domain][y_domain]};
-
-
-
-
-
-
-
-
-
-
- 286 = ddc::select<DDimX>(ixy);
-
- 288 = ddc::select<DDimY>(ixy);
-
-
- 291 double const dx_m = 0.5 * (dx_l + dx_r);
-
-
- 294 double const dy_m = 0.5 * (dy_l + dy_r);
- 295 next_temp(ix, iy) = last_temp(ix, iy);
-
- 297 += kx * ddc::step<DDimT>()
- 298 * (dx_l * last_temp(ix + 1, iy)
- 299 - 2.0 * dx_m * last_temp(ix, iy)
- 300 + dx_r * last_temp(ix - 1, iy))
- 301 / (dx_l * dx_m * dx_r);
-
- 303 += ky * ddc::step<DDimT>()
- 304 * (dy_l * last_temp(ix, iy + 1)
- 305 - 2.0 * dy_m * last_temp(ix, iy)
- 306 + dy_r * last_temp(ix, iy - 1))
- 307 / (dy_l * dy_m * dy_r);
-
-
- 312 if (iter - last_output >= t_output_period) {
-
-
-
- 316 ghosted_temp[x_domain][y_domain]);
-
-
-
- 322 std::swap(ghosted_last_temp, ghosted_next_temp);
-
-
- 327 if (last_output < time_domain.
back()) {
-
-
- 330 ghosted_temp[x_domain][y_domain]);
-
-
+ 43template <
class ChunkType>
+ 44void display(
double time, ChunkType temp)
+
+
+
+
+
+
+ 51 / temp.domain().size();
+ 52 std::cout << std::fixed << std::setprecision(3);
+ 53 std::cout <<
"At t = " << time <<
",\n";
+ 54 std::cout <<
" * mean temperature = " << mean_temp <<
"\n";
+
+
+ 57 = temp[ddc::get_domain<DDimY>(temp).front()
+ 58 + ddc::get_domain<DDimY>(temp).size() / 2];
+ 59 std::cout <<
" * temperature[y:"
+ 60 << ddc::get_domain<DDimY>(temp).size() / 2 <<
"] = {";
+
+
+ 63 ddc::get_domain<DDimX>(temp),
+
+ 65 std::cout << std::setw(6) << temp_slice(ix);
+
+ 67 std::cout <<
" }" << std::endl;
+
+
+
+ 73int main(
int argc,
char** argv)
+
+
+
+
+
+
+
+ 82 double const x_start = -1.;
+
+ 84 double const x_end = 1.;
+
+ 86 size_t const nb_x_points = 10;
+
+ 88 double const kx = .01;
+
+ 90 double const y_start = -1.;
+
+ 92 double const y_end = 1.;
+
+ 94 size_t const nb_y_points = 100;
+
+ 96 double const ky = .002;
+
+ 98 double const start_time = 0.;
+
+ 100 double const end_time = 10.;
+
+ 102 ptrdiff_t
const t_output_period = 10;
+
+
+
+
+
+
+ 114 auto const [x_domain, ghosted_x_domain, x_pre_ghost, x_post_ghost]
+
+
+
+
+
+
+
+
+
+ 126 x_domain_begin(x_domain.front(), x_post_ghost.extents());
+
+
+
+ 130 x_domain.back() - x_pre_ghost.extents() + 1,
+ 131 x_pre_ghost.extents());
+
+
+
+
+
+
+ 140 auto const [y_domain, ghosted_y_domain, y_pre_ghost, y_post_ghost]
+
+
+
+
+
+
+
+
+
+ 150 y_domain_begin(y_domain.front(), y_post_ghost.extents());
+
+
+
+ 154 y_domain.back() - y_pre_ghost.extents() + 1,
+ 155 y_pre_ghost.extents());
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 180 .5 / (kx * invdx2_max + ky * invdy2_max)};
+
+
+
+ 184 std::ceil((end_time - start_time) / max_dt) + .2};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 202 DDimY>(ghosted_x_domain, ghosted_y_domain),
+
+
+
+
+
+
+ 209 DDimY>(ghosted_x_domain, ghosted_y_domain),
+
+
+
+ 215 = ghosted_last_temp.span_view();
+
+
+
+
+
+
+
+
+
+ 225 ghosted_initial_temp(ixy)
+ 226 = 9.999 * ((x * x + y * y) < 0.25);
+
+
+
+
+
+ 233 DDimY>(ghosted_x_domain, ghosted_y_domain),
+
+
+
+
+
+
+ 241 ghosted_temp[x_domain][y_domain]);
+
+
+
+ 247 for (
auto const iter :
+
+
+
+
+ 254 ghosted_last_temp[x_pre_ghost][y_domain],
+ 255 ghosted_last_temp[y_domain][x_domain_end]);
+
+ 257 ghosted_last_temp[y_domain][x_post_ghost],
+ 258 ghosted_last_temp[y_domain][x_domain_begin]);
+
+ 260 ghosted_last_temp[x_domain][y_pre_ghost],
+ 261 ghosted_last_temp[x_domain][y_domain_end]);
+
+ 263 ghosted_last_temp[x_domain][y_post_ghost],
+ 264 ghosted_last_temp[x_domain][y_domain_begin]);
+
+
+
+
+ 271 ghosted_next_temp[x_domain][y_domain]};
+
+
+
+
+
+
+
+
+
+
+ 284 = ddc::select<DDimX>(ixy);
+
+ 286 = ddc::select<DDimY>(ixy);
+
+
+ 289 double const dx_m = 0.5 * (dx_l + dx_r);
+
+
+ 292 double const dy_m = 0.5 * (dy_l + dy_r);
+ 293 next_temp(ix, iy) = last_temp(ix, iy);
+
+ 295 += kx * ddc::step<DDimT>()
+ 296 * (dx_l * last_temp(ix + 1, iy)
+ 297 - 2.0 * dx_m * last_temp(ix, iy)
+ 298 + dx_r * last_temp(ix - 1, iy))
+ 299 / (dx_l * dx_m * dx_r);
+
+ 301 += ky * ddc::step<DDimT>()
+ 302 * (dy_l * last_temp(ix, iy + 1)
+ 303 - 2.0 * dy_m * last_temp(ix, iy)
+ 304 + dy_r * last_temp(ix, iy - 1))
+ 305 / (dy_l * dy_m * dy_r);
+
+
+ 310 if (iter - last_output >= t_output_period) {
+
+
+
+ 314 ghosted_temp[x_domain][y_domain]);
+
+
+
+ 320 std::swap(ghosted_last_temp, ghosted_next_temp);
+
+
+ 325 if (last_output < time_domain.
back()) {
+
+
+ 328 ghosted_temp[x_domain][y_domain]);
+
+
Definition: discrete_domain.hpp:24
KOKKOS_FUNCTION constexpr discrete_element_type front() const noexcept
Definition: discrete_domain.hpp:117
KOKKOS_FUNCTION constexpr DiscreteDomain remove_first(mlength_type n) const
Definition: discrete_domain.hpp:137