flow 1.4.0
Kokkos cut-cell IBM incompressible Navier-Stokes solver + pnm pore extraction
Loading...
Searching...
No Matches
test_vof_blocks_debris_mpi.cpp
Go to the documentation of this file.
1// flow — doc/vof_overlap_design.md gate G5: the block container's DEBRIS removal, distributed.
2//
3// The G1 scene (two R = 5 markers 16 cells apart along x, plus a speck of B's colour painted into
4// A's interface band -- three cells with no cell of B above 1/2 within two cells) under a linear
5// shear u = gamma (y - y_c), advected 20 steps by the block container with the block CSF on (so
6// the debris pass runs). The speck is removed at the first step and its volume returned to B's
7// attached interface; the removal's sums are sequential in index order on the master, so the
8// result must be BITWISE independent of the decomposition.
9//
10// Compared bitwise against a single-rank run of the same scene (rank 0): the union colour, every
11// marker's volume, and the seven ledger fields (with residueReturned). At np >= 2 the ORB cuts x
12// and the masters are round-robin, so A and B live on different ranks.
13//
14// Second scene (review finding 3c): an OVERLAPPING pair with variable density, split between ranks
15// -- the phantom capillary bound activates, cuts the capillary dt by exactly
16// sqrt(2 rho_min / (rho_min + rho_max)) against the set_vof_phantom_capillary_bound(False) run, and
17// max S, the overlap cell count, the flag and the capillary dt are identical to np = 1.
18//
19// Third scene (vof_overlap_design §15): a marker CUT BY THE LOW WALL y = 0 (walls +-y), colour in
20// the wall-adjacent layer, in a solenoidal field with v = 0 exactly on the wall face and v != 0 one
21// face in. The block's wall-face velocity lives at global index -1, outside the domain, and is
22// gathered from the wall rank's patch ghosts. np 2 cuts x through the marker and its master is
23// rank 1 (round robin, marker id 1), so the out-of-domain pieces travel by MPI; np 4 also cuts y
24// through its box, so ranks that own NO wall face take part. Per-marker volume <= 1e-12 and union
25// colour + volumes bitwise np = 1. (With the pre-§15 zero-gradient clamp: volume drift ~1e-3.)
26#include <mpi.h>
27
28#include <algorithm>
29#include <array>
30#include <cmath>
31#include <cstdio>
32#include <cstring>
33#include <Kokkos_Core.hpp>
34#include <vector>
35
36#include "flow_ibm.hpp"
37#include "peclet/core/common/types.hpp"
38#include "peclet/core/decomp/block_decomposer.hpp"
39
41
42static constexpr int NX = 48, NY = 32, NZ = 32;
43static constexpr std::size_t GCELLS = (std::size_t)NX * NY * NZ;
44static constexpr double R = 5.0, SIGMA = 320.0, AX = 16.3, BX = 32.3, CY = 16.2, CZ = 16.1;
45static constexpr int SX = 21, SY0 = 15, SZ = 16;
46static constexpr double SPECK[3] = {1e-5, 1e-2, 3e-3};
47static constexpr double GAMMA = 0.25, DT = 0.05;
48static const std::array<int, 6> BOX[2] = {{7, 7, 7, 26, 26, 26}, {18, 7, 7, 41, 26, 26}};
49
50static double sphereFrac(double cx, int x, int y, int z) {
51 const int NS = 8;
52 int in = 0;
53 for (int k = 0; k < NS; ++k)
54 for (int j = 0; j < NS; ++j)
55 for (int i = 0; i < NS; ++i) {
56 const double px = x + (i + 0.5) / NS - cx, py = y + (j + 0.5) / NS - CY,
57 pz = z + (k + 0.5) / NS - CZ;
58 in += (px * px + py * py + pz * pz < R * R) ? 1 : 0;
59 }
60 return static_cast<double>(in) / (NS * NS * NS);
61}
62
63static std::vector<double> colour(int m) {
64 const auto& b = BOX[m];
65 std::vector<double> c;
66 for (int z = b[2]; z < b[5]; ++z)
67 for (int y = b[1]; y < b[4]; ++y)
68 for (int x = b[0]; x < b[3]; ++x) {
69 double v = sphereFrac(m == 0 ? AX : BX, x, y, z);
70 if (m == 1 && x == SX && z == SZ && y >= SY0 && y < SY0 + 3)
71 v = SPECK[y - SY0];
72 c.push_back(v);
73 }
74 return c;
75}
76
77static void configure(IbmSolver& s, int ox, int oy, int oz, int lnx, int lny, int lnz) {
78 s.setAdvection(false);
79 const std::size_t loc = (std::size_t)lnx * lny * lnz;
80 s.setRho(1.0);
81 s.setMu(0.5);
82 s.setPressureGeometry(std::vector<double>(loc, 10.0));
83 s.enableVof();
84 s.setVof(std::vector<double>(loc, 0.0));
85 s.setSurfaceTension(SIGMA);
86 s.enableVofBlocksFromColours({BOX[0], BOX[1]}, {colour(0), colour(1)});
87 s.enableVofBlockCsf(); // the debris pass runs under the block CSF (removal default ON)
88 // u = gamma (y - y_c) at the u faces (x + 1/2, y, z): divergence-free, periodic in x.
89 std::vector<double> u(loc, 0.0), zero(loc, 0.0);
90 for (int z = 0; z < lnz; ++z)
91 for (int y = 0; y < lny; ++y)
92 for (int x = 0; x < lnx; ++x)
93 u[(std::size_t)x + (std::size_t)y * lnx + (std::size_t)z * lnx * lny] =
94 GAMMA * ((y + oy) + 0.5 - CY);
95 (void)ox;
96 (void)oz;
97 s.setVelocity(0, u);
98 s.setVelocity(1, zero);
99 s.setVelocity(2, zero);
100}
101
102// ---- the PHANTOM capillary bound (vof_overlap_design §5.6/§11.3; review finding 3c): two
103// markers 8 cells apart (R = 5: 2 cells of overlap), each carrying only its own sphere, with a
104// variable density so the bound has a density range to act on. The x cut of np 2 / 4 falls
105// between the two centres, so the S = sum_k C_k census is assembled from both masters.
106static constexpr double PAX = 18.3, PBX = 26.3, RHO_L = 1.0, RHO_G = 0.1;
107static const std::array<int, 6> PBOX[2] = {{9, 7, 7, 28, 26, 26}, {17, 7, 7, 36, 26, 26}};
108static std::vector<double> pairColour(int m) {
109 const auto& b = PBOX[m];
110 std::vector<double> c;
111 for (int z = b[2]; z < b[5]; ++z)
112 for (int y = b[1]; y < b[4]; ++y)
113 for (int x = b[0]; x < b[3]; ++x)
114 c.push_back(sphereFrac(m == 0 ? PAX : PBX, x, y, z));
115 return c;
116}
117static void configurePair(IbmSolver& s, int lnx, int lny, int lnz, bool bound) {
118 s.setAdvection(false);
119 const std::size_t loc = (std::size_t)lnx * lny * lnz;
120 s.setRho(RHO_L);
121 s.setMu(0.5);
122 s.setPressureGeometry(std::vector<double>(loc, 10.0));
123 s.enableVof();
124 s.setVof(std::vector<double>(loc, 0.0));
125 s.setPropertyModel("rho", peclet::flow::ClosureKind::LinearMix, "C", "", {RHO_L, RHO_G - RHO_L});
126 s.setSurfaceTension(SIGMA);
127 if (!bound)
128 s.setVofPhantomCapillaryBound(false);
129 s.enableVofBlocksFromColours({PBOX[0], PBOX[1]}, {pairColour(0), pairColour(1)});
130 s.enableVofBlockCsf(); // forms S and the census for the first step
131}
132
133// ---- a marker at the LOW wall y = 0 (§15)
134static constexpr double WR[2] = {5.0, 9.0}, WC[2][3] = {{40.3, 22.2, 16.1}, {20.3, 3.2, 16.1}};
135static constexpr double WA = 0.5, WDT = 0.5;
136static constexpr int WSTEPS = 40;
137static double sphereFrac3(const double* c, double r, int x, int y, int z) {
138 const int NS = 8;
139 int in = 0;
140 for (int k = 0; k < NS; ++k)
141 for (int j = 0; j < NS; ++j)
142 for (int i = 0; i < NS; ++i) {
143 const double px = x + (i + 0.5) / NS - c[0], py = y + (j + 0.5) / NS - c[1],
144 pz = z + (k + 0.5) / NS - c[2];
145 in += (px * px + py * py + pz * pz < r * r) ? 1 : 0;
146 }
147 return static_cast<double>(in) / (NS * NS * NS);
148}
149static std::array<int, 6> wallBox(int m) { // bubble box + the margin 3, inside the y walls
150 std::array<int, 6> q;
151 for (int d = 0; d < 3; ++d) {
152 q[d] = (int)std::floor(WC[m][d] - WR[m]) - 3;
153 q[3 + d] = (int)std::ceil(WC[m][d] + WR[m]) + 3;
154 }
155 q[1] = std::max(q[1], 0);
156 q[4] = std::min(q[4], NY);
157 return q;
158}
159static std::vector<double> wallColour(int m) {
160 const auto b = wallBox(m);
161 std::vector<double> c;
162 for (int z = b[2]; z < b[5]; ++z)
163 for (int y = b[1]; y < b[4]; ++y)
164 for (int x = b[0]; x < b[3]; ++x)
165 c.push_back(sphereFrac3(WC[m], WR[m], x, y, z));
166 return c;
167}
168
169static double wallPsi(int x, int y) {
170 const double PI = 3.14159265358979323846;
171 const int xm = ((x % NX) + NX) % NX;
172 return WA * (NX / (2.0 * PI)) * std::sin(2.0 * PI * xm / NX) * 4.0 * y * (NY - y) /
173 (double)(NY * NY);
174}
175static void configureWall(IbmSolver& s, int ox, int oy, int lnx, int lny, int lnz) {
176 s.setAdvection(false);
177 const std::size_t loc = (std::size_t)lnx * lny * lnz;
178 s.setRho(1.0);
179 s.setMu(0.5);
180 s.setDomainBc(2, 1, 0, 0, 0);
181 s.setDomainBc(3, 1, 0, 0, 0); // walls +-y
182 s.setPressureGeometry(std::vector<double>(loc, 10.0));
183 s.enableVof();
184 s.setVof(std::vector<double>(loc, 0.0));
185 s.setSurfaceTension(SIGMA);
186 s.enableVofBlocksFromColours({wallBox(0), wallBox(1)}, {wallColour(0), wallColour(1)});
187 s.enableVofBlockCsf(); // the production configuration: debris + residue pass on
188 // flow's LOW-face convention: u(i, j) on the x face i between z-edges (i, j) and (i, j + 1),
189 // v(i, j) on the y face j between (i, j) and (i + 1, j) -- the discrete curl, so the discrete
190 // divergence telescopes; v(., 0) = 0 exactly (psi(., 0) = 0).
191 std::vector<double> u(loc, 0.0), v(loc, 0.0), w(loc, 0.0);
192 for (int z = 0; z < lnz; ++z)
193 for (int y = 0; y < lny; ++y)
194 for (int x = 0; x < lnx; ++x) {
195 const int gx = x + ox, gy = y + oy;
196 const std::size_t i = (std::size_t)x + (std::size_t)y * lnx + (std::size_t)z * lnx * lny;
197 u[i] = wallPsi(gx, gy + 1) - wallPsi(gx, gy);
198 v[i] = -(wallPsi(gx + 1, gy) - wallPsi(gx, gy));
199 }
200 s.setVelocity(0, u);
201 s.setVelocity(1, v);
202 s.setVelocity(2, w);
203}
204
205static std::vector<double> gatherGlobal(const std::vector<double>& local, int ox, int oy, int oz,
206 int lnx, int lny, int lnz, int rank, int size) {
207 std::vector<double> global;
208 if (rank == 0)
209 global.assign(GCELLS, 0.0);
210 for (int r = 0; r < size; ++r) {
211 int meta[6] = {ox, oy, oz, lnx, lny, lnz};
212 if (r == 0) {
213 if (rank == 0)
214 for (int z = 0; z < lnz; ++z)
215 for (int y = 0; y < lny; ++y)
216 std::memcpy(&global[(std::size_t)ox + (std::size_t)(y + oy) * NX +
217 (std::size_t)(z + oz) * NX * NY],
218 &local[(std::size_t)y * lnx + (std::size_t)z * lnx * lny],
219 (std::size_t)lnx * sizeof(double));
220 continue;
221 }
222 if (rank == r) {
223 MPI_Send(meta, 6, MPI_INT, 0, 100 + r, MPI_COMM_WORLD);
224 MPI_Send(local.data(), (int)local.size(), MPI_DOUBLE, 0, 200 + r, MPI_COMM_WORLD);
225 } else if (rank == 0) {
226 MPI_Recv(meta, 6, MPI_INT, r, 100 + r, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
227 std::vector<double> buf((std::size_t)meta[3] * meta[4] * meta[5]);
228 MPI_Recv(buf.data(), (int)buf.size(), MPI_DOUBLE, r, 200 + r, MPI_COMM_WORLD,
229 MPI_STATUS_IGNORE);
230 for (int z = 0; z < meta[5]; ++z)
231 for (int y = 0; y < meta[4]; ++y)
232 std::memcpy(&global[(std::size_t)meta[0] + (std::size_t)(y + meta[1]) * NX +
233 (std::size_t)(z + meta[2]) * NX * NY],
234 &buf[(std::size_t)y * meta[3] + (std::size_t)z * meta[3] * meta[4]],
235 (std::size_t)meta[3] * sizeof(double));
236 }
237 }
238 return global;
239}
240
241// per marker: volume, debrisCells, debrisVolume, debrisReturned, debrisLost, debrisUnresolved,
242// residueReturned (§13)
243static constexpr int NF = 7;
244static std::vector<double> ledger(IbmSolver& s) {
245 std::vector<double> v;
246 for (const auto& q : s.vofBlockStats()) {
247 v.push_back(q.volume);
248 v.push_back(static_cast<double>(q.debrisCells));
249 v.push_back(q.debrisVolume);
250 v.push_back(q.debrisReturned);
251 v.push_back(q.debrisLost);
252 v.push_back(static_cast<double>(q.debrisUnresolved));
253 v.push_back(q.residueReturned);
254 }
255 return v;
256}
257
258int main(int argc, char** argv) {
259 MPI_Init(&argc, &argv);
260 Kokkos::initialize(argc, argv);
261 int fail = 0;
262 {
263 int rank = 0, size = 1;
264 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
265 MPI_Comm_size(MPI_COMM_WORLD, &size);
266 auto dec = peclet::flow::CutcellMG::decomposition(static_cast<std::size_t>(size), NX, NY, NZ);
267 auto blk = dec.block(rank);
268 const int ox = (int)blk.origin[0], oy = (int)blk.origin[1], oz = (int)blk.origin[2];
269 const int lnx = (int)blk.size[0], lny = (int)blk.size[1], lnz = (int)blk.size[2];
270 bool cutX = false;
271 for (const auto& sz : dec.sizes())
272 if ((int)sz[0] != NX)
273 cutX = true;
274 if (rank == 0)
275 std::printf(
276 "VOF BLOCK DEBRIS MPI (vof_overlap_design G5) np=%d grid %dx%dx%d block "
277 "%dx%dx%d x cut: %s\n",
278 size, NX, NY, NZ, lnx, lny, lnz, cutX ? "yes" : "no");
279 if (size > 1 && !cutX) {
280 if (rank == 0)
281 std::printf(" FAIL - the decomposition does not cut x, so the markers share a rank\n");
282 fail = 1;
283 }
284 const int STEPS = (argc > 1) ? std::atoi(argv[1]) : 20;
285 IbmSolver sd(lnx, lny, lnz);
286 sd.initMpi(dec, MPI_COMM_WORLD);
287 configure(sd, ox, oy, oz, lnx, lny, lnz);
288 for (int k = 0; k < STEPS; ++k)
289 sd.advectVofBlocks(DT, /*requireSolenoidal=*/false);
290 // the measured entries live on each block's master (zero elsewhere): a SUM is the census,
291 // and x + 0 is exact, so the sum carries the master's double bit for bit
292 std::vector<double> lLoc = ledger(sd), lAll(lLoc.size(), 0.0);
293 MPI_Allreduce(lLoc.data(), lAll.data(), (int)lLoc.size(), MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
294 const std::vector<double> gC = gatherGlobal(sd.getVof(), ox, oy, oz, lnx, lny, lnz, rank, size);
295 if (rank == 0) {
296 IbmSolver ref(NX, NY, NZ);
297 configure(ref, 0, 0, 0, NX, NY, NZ);
298 const std::vector<double> r0 = ledger(ref);
299 for (int k = 0; k < STEPS; ++k)
300 ref.advectVofBlocks(DT, false);
301 const std::vector<double> rl = ledger(ref), rC = ref.getVof();
302 long nC = 0;
303 for (std::size_t i = 0; i < GCELLS; ++i)
304 nC += (gC[i] == rC[i]) ? 0 : 1;
305 long nL = 0;
306 for (std::size_t i = 0; i < rl.size(); ++i)
307 nL += (lAll[i] == rl[i]) ? 0 : 1;
308 const char* fn[NF] = {"volume", "cells", "vol", "returned", "lost", "unresolved", "residue"};
309 for (std::size_t m = 0; m < rl.size() / NF; ++m) {
310 std::printf(" marker %zu:", m);
311 for (int f = 0; f < NF; ++f)
312 std::printf(" %s %.17g%s", fn[f], lAll[m * NF + f],
313 lAll[m * NF + f] == rl[m * NF + f] ? "" : " (!= np1)");
314 std::printf("\n");
315 }
316 const double painted = SPECK[0] + SPECK[1] + SPECK[2];
317 std::printf(
318 " after %d steps: union colour cells differing from np=1: %ld; ledger fields "
319 "differing: %ld; B returned %.17g (painted %.17g)\n",
320 STEPS, nC, nL, rl[NF + 3], painted);
321 double dv = 0.0;
322 for (std::size_t m = 0; m < rl.size() / NF; ++m)
323 dv = std::fmax(dv, std::fabs(rl[m * NF] - r0[m * NF]) / r0[m * NF]);
324 std::printf(" max marker volume rel change over the run (np=1): %.3e\n", dv);
325 if (!(dv <= 1e-12)) {
326 std::printf(" FAIL: marker volume not conserved\n");
327 fail = 1;
328 }
329 if (nC != 0 || nL != 0) {
330 std::printf(" FAIL: not bitwise decomposition-independent\n");
331 fail = 1;
332 }
333 if (!(rl[NF + 3] > 0.9 * painted)) { // the gate must not be vacuous: the speck was removed
334 std::printf(" FAIL: the debris removal did not fire (returned %.3e)\n", rl[NF + 3]);
335 fail = 1;
336 }
337 if (!(rl[3] == 0.0 && rl[NF + 4] == 0.0)) {
338 std::printf(" FAIL: marker A removed debris, or the return lost volume\n");
339 fail = 1;
340 }
341 }
342 MPI_Bcast(&fail, 1, MPI_INT, 0, MPI_COMM_WORLD);
343
344 // ---- the phantom capillary bound on an OVERLAPPING pair split between ranks
345 {
346 IbmSolver pb(lnx, lny, lnz), pn(lnx, lny, lnz);
347 pb.initMpi(dec, MPI_COMM_WORLD);
348 pn.initMpi(dec, MPI_COMM_WORLD);
349 configurePair(pb, lnx, lny, lnz, true);
350 configurePair(pn, lnx, lny, lnz, false);
351 const auto cb = pb.vofBlockOverlapCensus(), cn = pn.vofBlockOverlapCensus();
352 const double dtB = pb.capillaryDt(), dtN = pn.capillaryDt(); // collective
353 const double want = std::sqrt(2.0 * RHO_G / (RHO_G + RHO_L));
354 if (rank == 0) {
355 IbmSolver ref(NX, NY, NZ);
356 configurePair(ref, NX, NY, NZ, true);
357 const auto cr = ref.vofBlockOverlapCensus();
358 const double dtR = ref.capillaryDt();
359 std::printf(
360 " phantom bound, overlapping pair: max S %.17g, excess %.17g, cells %ld, "
361 "active %d (off-switch run: active %d); capillary dt ratio %.17g (want "
362 "%.17g); np=1: max S %.17g cells %ld active %d dt %.17g\n",
363 cb.maxSum, cb.excess, cb.cells, (int)cb.active, (int)cn.active, dtB / dtN, want,
364 cr.maxSum, cr.cells, (int)cr.active, dtR);
365 if (!(cb.active && !cn.active)) {
366 std::printf(" FAIL: the phantom bound did not activate (or the off switch failed)\n");
367 fail = 1;
368 }
369 if (!(std::fabs(dtB / dtN / want - 1.0) <= 1e-14)) {
370 std::printf(" FAIL: capillary dt ratio is not sqrt(2 rho_min / (rho_min + rho_max))\n");
371 fail = 1;
372 }
373 // max S and the cell count are exact across np (a two-term sum is order-independent and
374 // the reductions are MAX / integer SUM); the excess is a floating SUM over ranks
375 if (!(cb.maxSum == cr.maxSum && cb.cells == cr.cells && cb.active == cr.active &&
376 dtB == dtR && std::fabs(cb.excess - cr.excess) <= 1e-12 * cr.excess)) {
377 std::printf(" FAIL: the overlap census / bound differs from np = 1\n");
378 fail = 1;
379 }
380 }
381 MPI_Bcast(&fail, 1, MPI_INT, 0, MPI_COMM_WORLD);
382 }
383 // ---- a marker at the LOW wall (§15), split between ranks
384 {
385 bool cutY = false;
386 for (const auto& sz : dec.sizes())
387 if ((int)sz[1] != NY)
388 cutY = true;
389 IbmSolver sw(lnx, lny, lnz);
390 sw.initMpi(dec, MPI_COMM_WORLD);
391 configureWall(sw, ox, oy, lnx, lny, lnz);
392 std::vector<double> v0Loc, v0All;
393 for (const auto& q : sw.vofBlockStats())
394 v0Loc.push_back(q.volume);
395 v0All.assign(v0Loc.size(), 0.0);
396 MPI_Allreduce(v0Loc.data(), v0All.data(), (int)v0Loc.size(), MPI_DOUBLE, MPI_SUM,
397 MPI_COMM_WORLD);
398 const int wMaster = sw.vofBlockStats()[1].master;
399 double worst = 0.0;
400 std::vector<double> vLoc(v0Loc.size()), vAll(v0Loc.size());
401 for (int k = 0; k < WSTEPS; ++k) {
402 sw.advectVofBlocks(WDT, /*requireSolenoidal=*/false);
403 const auto st = sw.vofBlockStats();
404 for (std::size_t m = 0; m < st.size(); ++m)
405 vLoc[m] = st[m].volume;
406 MPI_Allreduce(vLoc.data(), vAll.data(), (int)vLoc.size(), MPI_DOUBLE, MPI_SUM,
407 MPI_COMM_WORLD);
408 for (std::size_t m = 0; m < vAll.size(); ++m)
409 worst = std::fmax(worst, std::fabs(vAll[m] / v0All[m] - 1.0));
410 }
411 const std::vector<double> gC =
412 gatherGlobal(sw.getVof(), ox, oy, oz, lnx, lny, lnz, rank, size);
413 if (rank == 0) {
414 IbmSolver ref(NX, NY, NZ);
415 configureWall(ref, 0, 0, NX, NY, NZ);
416 for (int k = 0; k < WSTEPS; ++k)
417 ref.advectVofBlocks(WDT, false);
418 const std::vector<double> rC = ref.getVof();
419 const auto rs = ref.vofBlockStats();
420 long nC = 0, nV = 0;
421 for (std::size_t i = 0; i < GCELLS; ++i)
422 nC += (gC[i] == rC[i]) ? 0 : 1;
423 for (std::size_t m = 0; m < rs.size(); ++m)
424 nV += (vAll[m] == rs[m].volume) ? 0 : 1;
425 // the triggering condition, so the gate cannot go vacuous
426 const auto wb = wallBox(1);
427 const std::vector<double> wc = wallColour(1);
428 double layer = 0.0;
429 for (int z = 0; z < wb[5] - wb[2]; ++z)
430 for (int x = 0; x < wb[3] - wb[0]; ++x)
431 layer += wc[(std::size_t)x + (std::size_t)z * (wb[3] - wb[0]) * (wb[4] - wb[1])];
432 const double vIn = std::fabs(wallPsi(20, 1) - wallPsi(21, 1));
433 std::printf(
434 " low-wall marker: box y [%d, %d), wall-layer colour %.3f cells, |v| one face in "
435 "%.3e; master rank %d; y cut %s\n",
436 wb[1], wb[4], layer, vIn, wMaster, cutY ? "yes" : "no");
437 std::printf(
438 " after %d steps: max marker |V/V0-1| %.3e (volumes %.17g, %.17g); union cells "
439 "differing from np=1: %ld; volumes differing: %ld\n",
440 WSTEPS, worst, vAll[0], vAll[1], nC, nV);
441 if (!(layer > 1.0 && wb[1] == 0 && vIn > 1e-3)) {
442 std::printf(" FAIL: the low-wall scene does not put colour on the wall layer\n");
443 fail = 1;
444 }
445 if (size > 1 && wMaster == 0) {
446 std::printf(" FAIL: the wall marker's master is rank 0 (no MPI gather exercised)\n");
447 fail = 1;
448 }
449 if (!(worst <= 1e-12)) {
450 std::printf(" FAIL: a marker at the low wall does not conserve its volume\n");
451 fail = 1;
452 }
453 if (nC != 0 || nV != 0) {
454 std::printf(" FAIL: the low-wall scene is not bitwise decomposition-independent\n");
455 fail = 1;
456 }
457 }
458 MPI_Bcast(&fail, 1, MPI_INT, 0, MPI_COMM_WORLD);
459 }
460 if (rank == 0)
461 std::printf("%s\n", fail ? "FAILED" : "PASSED");
462 }
463 Kokkos::finalize();
464 MPI_Finalize();
465 return fail;
466}
std::vector< double > getVof()
double capillaryDt()
The Brackbill capillary limit in the CALLER's time unit.
VofOverlapCensus vofBlockOverlapCensus() const
std::vector< vof::VofBlockStats > vofBlockStats() const
void advectVofBlocks(double dtPhysArg, bool requireSolenoidal=true)
dt is in the caller's time unit.
flow — host-facing Kokkos IBM Navier-Stokes solver (drop-in flow-style API).
Solver< Staggered > IbmSolver
static constexpr int NY
static constexpr int NX
static constexpr std::size_t GCELLS
static constexpr int NZ
static constexpr int STEPS
static constexpr double DT
static constexpr double R
static const std::array< int, 6 > BOX[2]
static constexpr double SIGMA
static constexpr double WA
static std::vector< double > gatherGlobal(const std::vector< double > &local, int ox, int oy, int oz, int lnx, int lny, int lnz, int rank, int size)
static void configure(IbmSolver &s, int ox, int oy, int oz, int lnx, int lny, int lnz)
static constexpr double PAX
static constexpr int NF
static constexpr double CY
static constexpr int SZ
static constexpr double GAMMA
static std::array< int, 6 > wallBox(int m)
static constexpr double RHO_G
static constexpr int SX
static std::vector< double > colour(int m)
static constexpr double WR[2]
static std::vector< double > pairColour(int m)
static void configureWall(IbmSolver &s, int ox, int oy, int lnx, int lny, int lnz)
static constexpr int SY0
static constexpr double SPECK[3]
static void configurePair(IbmSolver &s, int lnx, int lny, int lnz, bool bound)
static constexpr double BX
static constexpr double WC[2][3]
static constexpr double PBX
static constexpr int WSTEPS
static constexpr double AX
static constexpr double WDT
static constexpr double RHO_L
static double sphereFrac3(const double *c, double r, int x, int y, int z)
static constexpr double CZ
static std::vector< double > wallColour(int m)
static double sphereFrac(double cx, int x, int y, int z)
static double wallPsi(int x, int y)
psi on the z-edge (x, y): zero on both walls, periodic in x with an EXACT wrap (x mod NX).
static std::vector< double > ledger(IbmSolver &s)
static const std::array< int, 6 > PBOX[2]