10#include <Kokkos_Core.hpp>
30 std::vector<int> wantLine = {};
33void check(
const Row& r) {
36 const int bc[6] = {2, 3, 1, 1, 1, 1};
40 mg.
init(
r.grid.x,
r.grid.y,
r.grid.z,
r.levels);
43 for (std::size_t L = 0;
L + 1 <
ratio.size(); ++
L)
49 const bool lineOk =
line ==
r.wantLine;
50 const bool ok =
D ==
r.wantD &&
b.x ==
r.wantBottom.x &&
b.y ==
r.wantBottom.y &&
51 b.z ==
r.wantBottom.z &&
D == (
int)
ratio.size() && lineOk;
55 "%s %4dx%4dx%4d levels=%d mode=%2d%s: D %d bottom %dx%dx%d (want %d, %dx%dx%d)%s %s\n",
56 ok ?
"PASS" :
"FAIL",
r.grid.x,
r.grid.y,
r.grid.z,
r.levels,
r.mode,
57 r.outflow ?
" outflow" :
"", D,
b.x,
b.y,
b.z,
r.wantD,
r.wantBottom.x,
r.wantBottom.y,
58 r.wantBottom.z,
line.empty() ?
"" :
" LINE-TRIGGERED",
r.what);
69 std::vector<int> want;
73void checkLine(
const LineRow& r) {
76 const int bc[6] = {2, 3, 1, 1, 1, 1};
80 mg.
init(
r.grid.x,
r.grid.y,
r.grid.z,
r.levels);
86 axisOk = axisOk &&
ax[
L] == 2;
87 const bool ok =
D ==
r.wantD && got ==
r.want && axisOk;
90 std::string
gs =
"{", ws =
"{", as;
91 for (std::size_t i = 0;
i < got.size(); ++
i)
92 gs += (i ?
"," :
"") + std::to_string(got[i]);
93 for (std::size_t i = 0;
i <
r.want.size(); ++
i)
94 ws += (i ?
"," :
"") + std::to_string(
r.want[i]);
95 for (std::size_t L = 0;
L <
ax.size(); ++
L)
96 as += (L ?
" " :
"") + std::to_string(ax[L]);
98 "%s line %4dx%4dx%4d levels=%d%s: D %d triggered smoothed %s} (want %d, %s}) "
100 ok ?
"PASS" :
"FAIL",
r.grid.x,
r.grid.y,
r.grid.z,
r.levels,
r.outflow ?
" outflow" :
"", D,
101 gs.c_str(),
r.wantD, ws.c_str(), as.c_str(),
r.what);
107int main(
int argc,
char** argv) {
108 Kokkos::initialize(argc, argv);
111 const int per[6] = {0, 0, 0, 0, 0, 0};
119 {{16, 16, 16},
false, -1,
false},
120 {{12, 12, 12},
false, -1,
true},
121 {{24, 24, 24},
false, -1,
false},
122 {{128, 4, 4},
false, -1,
true},
123 {{16, 12, 8},
false, -1,
true},
124 {{4, 4, 4},
false, 0,
true},
125 {{12, 12, 12},
false, 0,
false},
126 {{16, 4, 4},
true, -1,
true},
128 for (
const P& p : ps) {
132 std::printf(
"%s admissible(%dx%dx%d, anchored %d, mode %d) = %d\n",
133 got == p.want ?
"PASS" :
"FAIL", p.g.x, p.g.y, p.g.z, (
int)p.anchored, p.mode,
138 {{16, 16, 16}, 0, -1,
false, 4, {2, 2, 2},
"state_hash N=16"},
139 {{16, 16, 8}, 0, -1,
false, 4, {2, 2, 2},
"state_hash"},
140 {{16, 16, 4}, 0, -1,
false, 4, {2, 2, 2},
"state_hash", {3}},
141 {{24, 12, 8}, 0, -1,
false, 4, {3, 3, 2},
"state_hash channel"},
142 {{48, 48, 48}, 0, -1,
false, 4, {6, 6, 6},
"direct at 4"},
143 {{64, 64, 64}, 0, -1,
false, 4, {8, 8, 8},
"direct at 4"},
144 {{96, 96, 96}, 0, -1,
false, 4, {12, 12, 12},
"direct at 4"},
145 {{128, 96, 64}, 0, -1,
false, 4, {16, 12, 8},
"bubble column: unchanged"},
146 {{64, 48, 32}, 0, -1,
false, 4, {8, 6, 4},
"bottom_direct_mpi grid"},
147 {{128, 128, 128}, 0, -1,
false, 5, {8, 8, 8},
"16^3 plane 256 -> 5"},
148 {{192, 192, 192}, 0, -1,
false, 5, {12, 12, 12},
"swarm 192^3"},
149 {{256, 256, 256}, 0, -1,
false, 6, {8, 8, 8},
"swarm 256^3"},
150 {{256, 192, 128}, 0, -1,
false, 5, {16, 12, 8},
"bubble column x2"},
151 {{2048, 64, 64}, 0, -1,
false, 5, {128, 4, 4},
"long channel"},
152 {{400, 400, 400}, 0, -1,
false, 5, {25, 25, 25},
"natural end, inadmissible"},
153 {{128, 32, 32}, 0, -1,
true, 4, {16, 4, 4},
"anchored: 4 until WO-5"},
154 {{192, 192, 192}, 0, 0,
false, 7, {3, 3, 3},
"'smoother' forced: <= 4 per axis"},
155 {{192, 192, 192}, 0, 1,
false, 5, {12, 12, 12},
"'agglomerated' forced"},
157 {{192, 192, 192}, 4, -1,
false, 4, {24, 24, 24},
"explicit 4"},
158 {{192, 192, 192}, 7, -1,
false, 7, {3, 3, 3},
"explicit 7"},
159 {{16, 16, 16}, 3, -1,
false, 3, {4, 4, 4},
"explicit 3"},
160 {{16, 16, 16}, 1, -1,
false, 1, {16, 16, 16},
"explicit 1 (pure RB-GS)"},
162 for (
const Row& r : rows)
165 const LineRow lines[] = {
166 {{128, 128, 25}, 0,
false, 5, {2, 3},
"M10: bottom 8x8x25 direct (A' 16, not smoothed)"},
167 {{128, 128, 25}, 4,
false, 4, {2},
"M10 explicit 4: bottom 16x16x25 GraphAMG"},
168 {{512, 512, 100}, 0,
false, 7, {4, 5},
"M10b: z stops at 25"},
169 {{512, 64, 25}, 0,
false, 5, {2, 3},
"M10v grid: bottom 32x4x25"},
170 {{34, 34, 116}, 0,
false, 3, {},
"fluidized bed: no unique strong axis"},
171 {{34, 34, 116}, 0,
true, 3, {},
"fluidized bed, anchored"},
172 {{8, 8, 18}, 0,
false, 3, {},
"small bed: A' 2 = theta"},
173 {{8, 8, 18}, 0,
true, 3, {},
"small bed, anchored"},
175 for (
const LineRow& r : lines)
179 std::printf(
"mg_depth_policy: %s (%d failures)\n", g_fail ?
"FAIL" :
"PASS", g_fail);
180 return g_fail ? 1 : 0;
static bool bottomAdmissible(C3 g, int extent, bool anchored, int agglomMode, const int bc[6])
std::vector< C3 > levelRatios() const
The per-level coarsening ratio actually chosen (the level table of §5, gate §8.5).
void setBoundaryConditions(const int bc[6])
std::vector< int > lineAxes() const
std::vector< int > lineSmoothedLevels() const
void setAgglomerationMode(int mode)
void init(int nx, int ny, int nz, int nLevels)
flow — portable (Kokkos) geometric multigrid for the cut-cell (variable-openness) pressure Poisson.
static void check(bool ok, const std::string &what)