7#include <Kokkos_Core.hpp>
29 std::uniform_real_distribution<double>
uf(-1.0, 1.0);
37 auto upN = [&](
const char*
nm, std::vector<double>&
h, std::size_t n) {
39 auto m = Kokkos::create_mirror_view(v);
40 for (std::size_t
i = 0;
i < n; ++
i)
42 Kokkos::deep_copy(v, m);
46 std::vector<double> o(n);
47 auto m = Kokkos::create_mirror_view(v);
48 Kokkos::deep_copy(m, v);
49 for (std::size_t
i = 0;
i < n; ++
i)
53 auto close = [](
double a,
double b) {
54 return std::fabs(a - b) <= 1e-10 * (1.0 + std::fabs(b));
56 long lc = [&](
int x,
int y,
int z) {
60 auto CI = [&](
int x,
int y,
int z) {
61 return (std::size_t)x + (std::size_t)y *
cext.x +
62 (std::size_t)z * (std::size_t)
cext.x *
cext.y;
64 auto FI = [&](
int x,
int y,
int z) {
65 return (std::size_t)x + (std::size_t)y *
fext.x +
66 (std::size_t)z * (std::size_t)
fext.x *
fext.y;
78 for (
int dz = 0;
dz < ratio.z; ++
dz)
79 for (
int dy = 0;
dy < ratio.y; ++
dy)
80 for (
int dx = 0;
dx < ratio.x; ++
dx)
82 ratio.z *
icz +
dz + g)];
83 double r = s / (ratio.x * ratio.y * ratio.z);
92 auto trilerp_h = [&](
double x,
double y,
double z) {
93 double fx = std::floor(x),
fy = std::floor(y),
fz = std::floor(z);
102 return c0 * (1 -
wz) + c1 *
wz;
107 double cx = ratio.x == 2 ? 0.5 *
ifx - 0.25 + g : (
double)(
ifx + g);
108 double cy = ratio.y == 2 ? 0.5 *
ify - 0.25 + g : (
double)(
ify + g);
109 double cz = ratio.z == 2 ? 0.5 *
ifz - 0.25 + g : (
double)(
ifz + g);
120 for (
int z = g; z <
fext.z - g; ++z)
121 for (
int y = g; y <
fext.y - g; ++y)
122 for (
int x = g; x <
fext.x - g; ++x) {
123 std::size_t
i =
FI(x, y, z);
133 std::fprintf(
stderr,
"FAIL: %d transfer/correct cells differ\n",
bad);
138 std::vector<double>
ones(
fn, 3.5);
157 std::fprintf(
stderr,
"FAIL: constant-field property\n");
163 "[mac_transfer] PASS: restrict/prolong/correct match host + constant properties (exec: "
flow — portable (Kokkos) multigrid transfer operators + projection velocity correction.
void correct(TField u, TField v, TField w, TConst phi, T3 e, int g)
void restrict_(TField coarse, TConst fine, T3 cext, T3 fext, int g, T3 cinner, T3 ratio)
Kokkos::View< double *, TMem > TField
void prolong(TField fine, TConst coarse, T3 fext, T3 cext, int g, T3 finner, T3 ratio)
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)
static constexpr double F
int main(int argc, char **argv)