6#include <Kokkos_Core.hpp>
14static void hostVel(std::vector<double>& f,
B3 ext,
int g,
int a,
int s,
int comp,
double wall,
16 int dims[3] = {ext.
x, ext.
y, ext.
z};
17 long st[3] = {1, ext.
x, (
long)ext.
x * ext.
y};
18 int b = (a + 1) % 3, c = (a + 2) % 3;
19 long sa = st[a],
sb = st[b], sc = st[c];
20 int na =
dims[a],
bf = (s == 0) ? g : (
na - g);
21 for (
int p0 = 0; p0 <
dims[b]; ++p0)
23 long base = (
long)p0 *
sb + (
long)
p1 * sc;
24 auto at = [&](
int ia) ->
double& {
return f[base + (
long)
ia *
sa]; };
28 for (
int ia = 0;
ia < g; ++
ia)
35 for (
int ia = 0;
ia < g; ++
ia)
42 for (
int ia = 0;
ia < g; ++
ia)
51 int dims[3] = {ext.
x, ext.
y, ext.
z};
52 long st[3] = {1, ext.
x, (
long)ext.
x * ext.
y};
53 int b = (a + 1) % 3, c = (a + 2) % 3,
bf = (s == 0) ? g : (
dims[a] - g);
54 for (
int p0 = 0; p0 <
dims[b]; ++p0)
56 oa[(
long)p0 * st[b] + (
long)
p1 * st[c] + (
long)
bf * st[a]] = 0.0;
65 const std::size_t n = (std::size_t)ext.x * ext.y * ext.z;
67 std::uniform_real_distribution<double>
uf(-1.0, 1.0);
68 std::vector<double> base(n);
72 auto up = [&](std::vector<double>&
h) {
74 auto m = Kokkos::create_mirror_view(v);
75 for (std::size_t
i = 0;
i < n; ++
i)
77 Kokkos::deep_copy(v, m);
81 std::vector<double> o(n);
82 auto m = Kokkos::create_mirror_view(v);
83 Kokkos::deep_copy(m, v);
84 for (std::size_t
i = 0;
i < n; ++
i)
88 auto close = [](
double x,
double y) {
89 return std::fabs(x - y) <= 1e-12 * (1.0 + std::fabs(y));
92 int bad = 0, cases = 0;
94 for (
int a = 0; a < 3; ++a)
95 for (
int s = 0; s < 2; ++s)
98 std::vector<double>
h = base;
100 const double wall = 0.37;
104 for (std::size_t
i = 0;
i < n; ++
i)
110 for (
int a = 0; a < 3; ++a)
111 for (
int s = 0; s < 2; ++s) {
112 std::vector<double>
h = base;
117 for (std::size_t
i = 0;
i < n; ++
i)
124 std::fprintf(
stderr,
"FAIL: %d mismatches across %d BC cases\n",
bad, cases);
128 "[mac_bc] PASS: %d BC cases (velocity normal/tangential/fold + wall openness) match host "
130 cases, BExec::name());
flow — portable (Kokkos) native per-face domain boundary conditions for the MAC grid.
void bcZeroOpenness(BField oa, B3 ext, int g, int a, int s)
void bcVelocityComp(BField f, B3 ext, int g, int a, int s, int comp, double wall, int fold, BField prof=BField(), int prof_nc=0)
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< double *, BMem > BField
int main(int argc, char **argv)
static void hostZeroOpen(std::vector< double > &oa, B3 ext, int g, int a, int s)
static void hostVel(std::vector< double > &f, B3 ext, int g, int a, int s, int comp, double wall, int fold)