16 Kokkos::initialize(
argc, argv);
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);
95 int x0 = (int)
fx, y0 = (
int)
fy,
z0 = (int)
fz;
97 double c00 =
F(x0, y0,
z0) * (1 -
wx) +
F(x0 + 1, y0,
z0) *
wx,
98 c10 =
F(x0, y0 + 1,
z0) * (1 -
wx) +
F(x0 + 1, y0 + 1,
z0) *
wx;
99 double c01 =
F(x0, y0,
z0 + 1) * (1 -
wx) +
F(x0 + 1, y0,
z0 + 1) *
wx,
100 c11 =
F(x0, y0 + 1,
z0 + 1) * (1 -
wx) +
F(x0 + 1, y0 + 1,
z0 + 1) *
wx;
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);
156 if (
bad && !status) {
157 std::fprintf(
stderr,
"FAIL: constant-field property\n");
163 "[mac_transfer] PASS: restrict/prolong/correct match host + constant properties (exec: "