6#include <Kokkos_Core.hpp>
17 std::fprintf(stderr, "CHECK failed: %s\n at %s:%d\n", #cond, __FILE__, __LINE__); \
24using FV = Kokkos::View<float*, peclet::flow::IMem>;
26float at(
const FV& v,
long i) {
27 auto h = Kokkos::create_mirror_view(v);
28 Kokkos::deep_copy(h, v);
33 const int ex = 8, ey = 6, ez = 6, g = 2;
34 const long n = (long)ex * ey * ez;
35 const long sx = 1, sy = ex, sz = (long)ex * ey;
36 FV AC(
"AC", n), AW(
"AW", n), AE(
"AE", n), AS(
"AS", n), AN(
"AN", n), AB(
"AB", n), AT(
"AT", n);
39 const double idiag = 0.1, beta = 0.5;
40 peclet::flow::ibmBuildDiffusionVar(
AC, AW, AE, AS, AN, AB, AT, ex, ey, ez, g,
42 const long i0 = (long)3 + (
long)3 * sy + (long)3 * sz;
43 CHECK(std::fabs(at(AW, i0) - (
float)(-beta)) < 1e-6);
44 CHECK(std::fabs(at(
AC, i0) - (
float)(idiag + beta + beta + beta + beta + beta + beta)) < 1e-6);
50 auto h = Kokkos::create_mirror_view(mu);
51 for (
int z = 0; z < ez; ++z)
52 for (
int y = 0; y < ey; ++y)
53 for (
int x = 0; x < ex; ++x)
54 h((
long)x + (
long)y * sy + (
long)z * sz) = (x <= 3) ? 1.0 : 0.1;
55 Kokkos::deep_copy(mu, h);
57 const long i4 = (long)4 + (
long)3 * sy + (long)3 * sz;
59 peclet::flow::ibmBuildDiffusionVar(
AC, AW, AE, AS, AN, AB, AT, ex, ey, ez, g,
61 CHECK(std::fabs(at(AW, i4) - (
float)(-0.55)) < 1e-6);
63 peclet::flow::ibmBuildDiffusionVar(
AC, AW, AE, AS, AN, AB, AT, ex, ey, ez, g,
65 const float harm = (float)(2.0 * 0.1 * 1.0 / 1.1);
66 CHECK(std::fabs(at(AW, i4) - (-harm)) < 1e-6);
68 CHECK(std::fabs(at(AE, i4) - (
float)(-0.1)) < 1e-6);
69 std::printf(
"variable-mu bands: uniform + arithmetic(-0.55) + harmonic(%.4f) vs oracle OK\n",
74int main(
int argc,
char** argv) {
75 Kokkos::initialize(argc, argv);
82 std::fprintf(stderr,
"%d failure(s)\n", failures);
flow — portable (Kokkos) Robust-Scaled cut-cell IBM primitives + per-cut-cell overlay build.
flow — face/cell material-property accessors for the variable-coefficient momentum operator.
void ibmBuildDiffusionVar(Kokkos::View< float *, IMem > AC, Kokkos::View< float *, IMem > AW, Kokkos::View< float *, IMem > AE, Kokkos::View< float *, IMem > AS, Kokkos::View< float *, IMem > AN, Kokkos::View< float *, IMem > AB, Kokkos::View< float *, IMem > AT, int ex, int ey, int ez, int g, FaceProps fp)
Kokkos::View< double *, CCMem > CCField
Kokkos::View< const double *, CCMem > CCConst
static constexpr double AC
Kokkos::View< float *, IMem > FV
int main(int argc, char **argv)