10#include <Kokkos_Core.hpp>
21 const int N = 24, g = 1;
22 const double nu = 1.0,
fx = 1.0;
23 I3 e{
N + 2 * g,
N + 2 * g,
N + 2 * g}, og{0, 0, 0};
24 const std::size_t n = (std::size_t)e.x * e.y * e.z;
26 const double Ac = 6.0 *
nu;
29 Kokkos::deep_copy(u, 0.0);
34 auto hb = Kokkos::create_mirror_view(b);
35 auto hd = Kokkos::create_mirror_view(
dcorr);
36 Kokkos::deep_copy(
hb, b);
38 for (std::size_t
i = 0;
i < n; ++
i) {
42 for (
int z = g; z < e.z - g; ++z)
43 for (
int y = g; y < e.y - g; ++y)
44 for (
int x = g; x < e.x - g; ++x) {
45 long i = (
long)x + (
long)y * e.x + (
long)z * (
long)e.x * e.y;
47 if (y == g || y == e.y - g - 1)
50 Kokkos::deep_copy(b,
hb);
61 "fx", Kokkos::MDRangePolicy<
SExec, Kokkos::Rank<2>>(
space, {0, 0}, {e.y, e.z}),
63 long base = (
long)y * e.x + (
long)z * (
long)e.x * e.y;
64 for (
int gl = 0;
gl < g; ++
gl) {
66 uu(base + g +
N +
gl) =
uu(base + g +
gl);
71 "fz", Kokkos::MDRangePolicy<
SExec, Kokkos::Rank<2>>(
space, {0, 0}, {e.x, e.y}),
73 long base = (
long)x + (
long)y * e.x;
75 for (
int gl = 0;
gl < g; ++
gl) {
77 uu(base + (
long)(g +
N +
gl) *
sz) =
uu(base + (
long)(g +
gl) *
sz);
82 "fy", Kokkos::MDRangePolicy<
SExec, Kokkos::Rank<2>>(
space, {0, 0}, {e.x, e.z}),
84 long base = (
long)x + (
long)z * (
long)e.x * e.y;
85 for (
int gl = 0;
gl < g; ++
gl) {
86 uu(base + (
long)
gl *
sy) = 0.0;
87 uu(base + (
long)(g +
N +
gl) *
sy) = 0.0;
94 for (
int it = 0;
it < 6000; ++
it) {
102 auto hu = Kokkos::create_mirror_view(u);
103 Kokkos::deep_copy(
hu, u);
106 for (
int yc = 0;
yc <
N; ++
yc) {
117 for (
int yc = 0;
yc <
N; ++
yc) {
124 "[poiseuille] u_max/U_mean=%.4f (target 1.5); profile L2 err vs parabola=%.3e "
127 if (std::fabs(ratio - 1.5) > 0.03) {
128 std::fprintf(
stderr,
"FAIL: u_max/U_mean off 1.5\n");
132 std::fprintf(
stderr,
"FAIL: profile not parabolic\n");
137 "[poiseuille] PASS: no-slip-wall diffusion gives the Poiseuille parabola (exec %s)\n",
138 Kokkos::DefaultExecutionSpace::name());
flow — portable (Kokkos) MAC stencil operators: Red-Black Gauss-Seidel smoothers + divergence.
void diffSmoothColor(SField c, SConst b, I3 e, I3 og, int g, double beta, double Ac, int color, SConst dcorr)
void ibmFillEntry(const OV &o, int list_idx, int c_idx, float sdf_c, const float sdf_n[6], int bc_type, const float *thEx)
Kokkos::View< const double *, SMem > SConst
Kokkos::DefaultExecutionSpace SExec
Kokkos::View< double *, SMem > SField
int main(int argc, char **argv)