7#include <Kokkos_Core.hpp>
19 const int N = 64, g = 1;
20 I3 e{
N + 2 * g,
N + 2 * g,
N + 2 * g};
21 const std::size_t n = (std::size_t)e.x * e.y * e.z;
25 std::uniform_real_distribution<double>
uf(-1.0, 1.0);
26 std::vector<double>
hd(n, 0.0);
29 for (
int z = g; z < e.z - g; ++z)
30 for (
int y = g; y < e.y - g; ++y)
31 for (
int x = g; x < e.x - g; ++x) {
32 long i = (
long)x + (
long)y * e.x + (
long)z * (
long)e.x * e.y;
38 for (
int z = g; z < e.z - g; ++z)
39 for (
int y = g; y < e.y - g; ++y)
40 for (
int x = g; x < e.x - g; ++x) {
41 long i = (
long)x + (
long)y * e.x + (
long)z * (
long)e.x * e.y;
47 auto m = Kokkos::create_mirror_view(d);
48 for (std::size_t
i = 0;
i < n; ++
i)
50 Kokkos::deep_copy(d, m);
54 std::printf(
"[mg] N=%d levels=%d\n",
N,
mg.numLevels());
57 for (
int nv = 1;
nv <= 6; ++
nv) {
60 double res =
mg.finestResidualMax();
61 double factor = (
nv > 1) ? res / prev : 0.0;
62 std::printf(
"[mg] %d V-cycle(s): max|resid|=%.3e (factor vs prev %.3f)\n",
nv, res,
factor);
69 double res8 =
mg.finestResidualMax();
71 std::fprintf(
stderr,
"FAIL: 8 V-cycles did not converge (resid %.3e)\n",
res8);
74 std::printf(
"[mg] PASS: 8 V-cycles -> max|resid|=%.3e (exec %s)\n",
res8, SExec::name());
flow — portable (Kokkos) geometric multigrid V-cycle for the periodic pressure Poisson.
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::View< double *, SMem > SField
int main(int argc, char **argv)