11#ifndef PECLET_FLOW_MAC_STENCILS_HPP
12#define PECLET_FLOW_MAC_STENCILS_HPP
14#include <Kokkos_Core.hpp>
18using SExec = Kokkos::DefaultExecutionSpace;
19using SMem = SExec::memory_space;
20using SField = Kokkos::View<double*, SMem>;
21using SConst = Kokkos::View<const double*, SMem>;
27KOKKOS_INLINE_FUNCTION
long L3(
int x,
int y,
int z,
I3 e) {
28 return static_cast<long>(x) +
static_cast<long>(y) * e.x +
29 static_cast<long>(z) *
static_cast<long>(e.x) * e.y;
37 const bool hasD = (dcorr.extent(0) != 0);
38 using MD = Kokkos::MDRangePolicy<SExec, Kokkos::Rank<3>>;
40 "peclet::flow::diff", MD(space, {g, g, g}, {e.x - g, e.y - g, e.z - g}),
41 KOKKOS_LAMBDA(
int x,
int y,
int z) {
42 if ((((x + og.
x) + (y + og.
y) + (z + og.
z)) & 1) != color)
44 const long i =
L3(x, y, z, e), sx = 1, sy = e.x, sz =
static_cast<long>(e.x) * e.y;
45 const double s = c(i + sx) + c(i - sx) + c(i + sy) + c(i - sy) + c(i + sz) + c(i - sz);
46 c(i) = (b(i) + beta * s) / (Ac + (hasD ? dcorr(i) : 0.0));
53 using MD = Kokkos::MDRangePolicy<SExec, Kokkos::Rank<3>>;
55 "peclet::flow::pois", MD(space, {g, g, g}, {e.x - g, e.y - g, e.z - g}),
56 KOKKOS_LAMBDA(
int x,
int y,
int z) {
57 if ((((x + og.
x) + (y + og.
y) + (z + og.
z)) & 1) != color)
59 const long i =
L3(x, y, z, e), sx = 1, sy = e.x, sz =
static_cast<long>(e.x) * e.y;
61 phi(i + sx) + phi(i - sx) + phi(i + sy) + phi(i - sy) + phi(i + sz) + phi(i - sz);
62 phi(i) = (s - d(i)) / 6.0;
69 using MD = Kokkos::MDRangePolicy<SExec, Kokkos::Rank<3>>;
71 "peclet::flow::diverg", MD(space, {g, g, g}, {e.x - g, e.y - g, e.z - g}),
72 KOKKOS_LAMBDA(
int x,
int y,
int z) {
73 const long i =
L3(x, y, z, e), sx = 1, sy = e.x, sz =
static_cast<long>(e.x) * e.y;
74 d(i) = (u(i + sx) - u(i)) + (v(i + sy) - v(i)) + (w(i + sz) - w(i));
long L3(int x, int y, int z, I3 e)
void divergence(SConst u, SConst v, SConst w, SField d, I3 e, int g)
void diffSmoothColor(SField c, SConst b, I3 e, I3 og, int g, double beta, double Ac, int color, SConst dcorr)
Kokkos::View< const double *, SMem > SConst
void poisSmoothColor(SField phi, SConst d, I3 e, I3 og, int g, int color)
Kokkos::DefaultExecutionSpace SExec
Kokkos::View< double *, SMem > SField
void poisSweep(SField phi, SConst d, I3 e, I3 og, int g)