8#ifndef PECLET_FLOW_MAC_TRANSFER_HPP
9#define PECLET_FLOW_MAC_TRANSFER_HPP
11#include <Kokkos_Core.hpp>
12#include <Kokkos_MathematicalFunctions.hpp>
18using TExec = Kokkos::DefaultExecutionSpace;
19using TMem = TExec::memory_space;
20using TField = Kokkos::View<double*, TMem>;
21using TConst = Kokkos::View<const double*, TMem>;
36 for (
int dz = 0; dz < ratio.z; ++dz)
37 for (
int dy = 0; dy < ratio.y; ++dy)
38 for (
int dx = 0; dx < ratio.x; ++dx) {
39 const int fx = ratio.x *
icx + dx + g,
fy = ratio.y *
icy + dy + g,
40 fz = ratio.z *
icz + dz + g;
41 sum +=
fine(
static_cast<long>(
fx) +
static_cast<long>(
fy) *
fsy +
42 static_cast<long>(
fz) *
fsz);
44 const long ci =
static_cast<long>(
icx + g) +
static_cast<long>(
icy + g) *
cext.x +
45 static_cast<long>(
icz + g) *
static_cast<long>(
cext.x) *
cext.y;
46 coarse(
ci) = sum /
static_cast<double>(ratio.x * ratio.y * ratio.z);
51 const double fx = Kokkos::floor(x),
fy = Kokkos::floor(y),
fz = Kokkos::floor(z);
53 const int x0 = (int)
fx, y0 = (
int)
fy,
z0 = (int)
fz;
54 const long sy =
cext.x, sz =
static_cast<long>(
cext.x) *
cext.y;
55 auto F = [&](
int xx,
int yy,
int zz) {
56 return c(
static_cast<long>(
xx) +
static_cast<long>(
yy) * sy +
static_cast<long>(
zz) * sz);
58 const double c00 =
F(x0, y0,
z0) * (1 -
wx) +
F(x0 + 1, y0,
z0) *
wx;
59 const double c10 =
F(x0, y0 + 1,
z0) * (1 -
wx) +
F(x0 + 1, y0 + 1,
z0) *
wx;
60 const double c01 =
F(x0, y0,
z0 + 1) * (1 -
wx) +
F(x0 + 1, y0,
z0 + 1) *
wx;
61 const double c11 =
F(x0, y0 + 1,
z0 + 1) * (1 -
wx) +
F(x0 + 1, y0 + 1,
z0 + 1) *
wx;
64 return c0 * (1 -
wz) + c1 *
wz;
75 const double cx = ratio.x == 2 ? 0.5 *
ifx - 0.25 + g : (
double)(
ifx + g);
76 const double cy = ratio.y == 2 ? 0.5 *
ify - 0.25 + g : (
double)(
ify + g);
77 const double cz = ratio.z == 2 ? 0.5 *
ifz - 0.25 + g : (
double)(
ifz + g);
78 const long fi =
static_cast<long>(
ifx + g) +
static_cast<long>(
ify + g) *
fext.x +
79 static_cast<long>(
ifz + g) *
static_cast<long>(
fext.x) *
fext.y;
89 "peclet::flow::correct",
MD(
space, {g, g, g}, {e.x - g, e.y - g, e.z - g}),
91 const long i =
static_cast<long>(x) +
static_cast<long>(y) * e.x +
92 static_cast<long>(z) *
static_cast<long>(e.x) * e.y;
93 const long sx = 1, sy = e.x, sz =
static_cast<long>(e.x) * e.y;
94 u(i) -= phi(i) - phi(i -
sx);
95 v(i) -= phi(i) - phi(i - sy);
96 w(i) -= phi(i) - phi(i - sz);
void correct(TField u, TField v, TField w, TConst phi, T3 e, int g)
Kokkos::DefaultExecutionSpace TExec
Kokkos::View< const double *, TMem > TConst
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)
double trilerp(TConst c, double x, double y, double z, T3 cext)
flow — the multidimensional iteration policies: iteration order follows storage.
static constexpr double F