24#include <Kokkos_Core.hpp>
34 std::fprintf(stderr, "CHECK failed: %s\n at %s:%d\n", #cond, __FILE__, __LINE__); \
39constexpr int NX = 24,
NY = 24,
NZ = 16;
41constexpr int MAXIT = 200;
42constexpr double RTOL = 1e-8;
43constexpr double MU = 0.01,
DT = 1.0,
GRAV = 0.1;
44constexpr double DIV_TOL = 1e-8;
50 s.setAdvection(
false);
51 s.setDomainBc(4, 1, 0, 0, 0);
52 s.setDomainBc(5, 1, 0, 0, 0);
53 s.setPressureLevels(
LEVELS);
54 s.setPressureGeometry(std::vector<double>((std::size_t)
NX *
NY *
NZ, 10.0));
55 s.setBodyForce(0.0, 0.0, -
GRAV);
56 s.setPressureChebyshev(
true,
MAXIT,
RTOL);
62 const long it =
s.lastPressureIterations();
63 const double div =
s.maxOpenDivergence() / (
GRAV *
DT);
64 std::printf(
" %-34s its %3ld div/u %.2e estimates %ld\n", what, it, div,
65 s.numPressureEigenEstimates());
72 std::printf(
" 1. V-cycle setters invalidate the kept bounds\n");
75 stepChecked(s,
"step 1");
76 const long n1 =
s.numPressureEigenEstimates();
77 stepChecked(s,
"step 2 (kept bounds)");
78 stepChecked(s,
"step 3 (kept bounds)");
79 CHECK(
s.numPressureEigenEstimates() == n1);
86 const Toggle toggles[] = {{
"symmetric on (unchanged)",
false,
true, 0},
87 {
"symmetric off",
false,
false, 1},
88 {
"symmetric off (unchanged)",
false,
false, 0},
89 {
"symmetric on",
false,
true, 1},
90 {
"line relaxation on (unchanged)",
true,
true, 0},
91 {
"line relaxation off",
true,
false, 1},
92 {
"line relaxation on",
true,
true, 1}};
93 for (
const Toggle& t : toggles) {
94 const long n0 =
s.numPressureEigenEstimates();
96 s.setPressureLineRelaxation(
t.value);
98 s.setPressureVcycleSymmetric(
t.value);
99 stepChecked(s,
t.what);
100 CHECK(
s.numPressureEigenEstimates() - n0 ==
t.expect);
102 CHECK(
s.numPressureChebyshevGrowthTrips() == 0);
106void guardCase(
bool symmetric) {
107 std::printf(
" 2. growth guard, %s V-cycle, first estimate x 0.4\n",
108 symmetric ?
"symmetric" :
"trilinear");
111 s.setPressureVcycleSymmetric(symmetric);
112 s.debugSetPressureEigenScale(0.4);
113 stepChecked(s,
"step 1 (scaled bounds)");
114 CHECK(
s.numPressureChebyshevGrowthTrips() == 1);
115 CHECK(
s.numPressureEigenEstimates() == 2);
116 stepChecked(s,
"step 2");
117 stepChecked(s,
"step 3");
118 std::printf(
" growth trips %ld\n",
s.numPressureChebyshevGrowthTrips());
119 CHECK(
s.numPressureChebyshevGrowthTrips() == 1);
120 CHECK(
s.numPressureEigenEstimates() == 2);
125 std::printf(
" 3. bounds ratchet: trip, drop the bounds, warm re-estimate x 0.4\n");
128 s.debugSetPressureEigenScale(0.4);
129 stepChecked(s,
"step 1 (scaled bounds, trips)");
130 CHECK(
s.numPressureChebyshevGrowthTrips() == 1);
131 s.debugDropPressureBounds();
132 s.debugSetPressureEigenScale(0.4);
133 const long n0 =
s.numPressureEigenEstimates();
134 stepChecked(s,
"step 2 (warm x 0.4, ratcheted)");
135 std::printf(
" estimates +%ld restarts %ld growth trips %ld\n",
136 s.numPressureEigenEstimates() - n0,
s.numPressureChebyshevRestarts(),
137 s.numPressureChebyshevGrowthTrips());
138 CHECK(
s.numPressureEigenEstimates() - n0 == 1);
139 CHECK(
s.numPressureChebyshevRestarts() == 0);
140 CHECK(
s.numPressureChebyshevGrowthTrips() == 1);
144int main(
int argc,
char** argv) {
145 Kokkos::initialize(argc, argv);
147 std::printf(
"Chebyshev pressure bounds: %dx%dx%d, %d levels, cap %d, rtol %.0e\n",
NX,
NY,
NZ,
154 std::printf(
"PASS: pressure_chebyshev_bounds\n");
156 std::fprintf(stderr,
"FAIL: %d check(s)\n",
failures);
flow — host-facing Kokkos IBM Navier-Stokes solver (drop-in flow-style API).
Solver< Staggered > IbmSolver
void setUp(CutcellMG &mg, const Problem &P, int mode)
static constexpr double GRAV
static constexpr double DT
static constexpr double RTOL
static constexpr int MAXIT
static double value(int gx, int gy, int gz)
static constexpr double MU
static constexpr int LEVELS