flow 1.4.0
Kokkos cut-cell IBM incompressible Navier-Stokes solver + pnm pore extraction
Loading...
Searching...
No Matches
mgd_case Namespace Reference

Functions

 arg (name, default, cast=str)
 depth (s)
 build_swarm ()
 build_bc ()
 _ibm_sdf (name, N)
 build_ibm ()
 build_channel ()
 build_anchored ()
 build_porous ()
 one (timed)
 fmt (v)

Variables

 A = list(sys.argv)
 CASE = arg("--case", None)
 LEVELS = arg("--levels", 0, int)
 STEPS = arg("--steps", 30, int)
 WARM = arg("--warm", 5, int)
 DUMP = arg("--dump", None)
 JSON = arg("--json", None)
 RTOL = arg("--rtol", None, float)
 TAG = arg("--tag", "")
 LINE = arg("--line-relaxation", None)
 SYM = arg("--vcycle-symmetric", None)
 load0 = os.getloadavg()
 NP_ENV = int(os.environ.get("OMPI_COMM_WORLD_SIZE", os.environ.get("PMI_SIZE", "1")))
 comm = MPI.COMM_WORLD
 rank
 size
dict info = {}
 FLUID_MASK = None
bool fields_C = False
dict BUILD
 t_setup0 = time.perf_counter()
 s
 GRID
 dt_of
 IBM
 t_setup = time.perf_counter() - t_setup0
 step_ms
 iters
 divs
 prec
 failed
 pres
str POROUS = "porous"
 w0 = time.perf_counter()
 wall = time.perf_counter() - w0
float prev = 0.0
 m = float(s.get_u().mean())
 u = s.get_u()
 umean = float(u.mean())
dict sdf = info.pop("_sdf")
dict deep = sdf < -2.0
list ratios = [tuple(int(v) for v in r) for r in s.diagnostics.pressure_mg_level_ratios()]
 g = list(GRID)
list dims = [tuple(g)]
list bottom = dims[-1]
 h = hashlib.sha256()
dict fx = {"u": s.get_u, "v": s.get_v, "w": s.get_w, "p": lambda: s.get_field("p")}
dict arrs = {k: np.ascontiguousarray(f()) for k, f in fx.items()}
 allv = comm.gather((list(info.get("origin", [0, 0, 0])), arrs), root=0)
dict out = {}
 digest = h.hexdigest()
 ds = comm.gather(digest, root=0)
 gg = hashlib.sha256()
 load1 = os.getloadavg()
 sm = np.asarray(step_ms)
 prec_flips = sum(1 for a, b in zip(prec, prec[1:]) if a == "fp32" and b == "fp64")
dict res
 porous_res_max
 porous_res_last
tuple keep
 flush
 step_ms_list
 iters_list
 div_list
 prec_list
 failed_list
 porous_res_list
 fo
 indent
 default

Detailed Description

MG-depth measurement driver (doc/mg_depth_policy.md ยง6 WO-0; reused by the WO-2 gates).

One process = one case at one pressure-multigrid depth. Every case takes

    --levels L   L >= 1: set_pressure_multigrid(True, L) BEFORE the geometry (an exact depth);
                 L = 0 (the default): do NOT call set_pressure_multigrid -- the solver default
                 (depth 4 on the pre-WO-2 module, AUTO after WO-2).
    --steps N    timed steps (default 30); --warm W untimed warm-up steps (default 5)
    --dump F.npz u, v, w, p (and C where present) at the end; per rank under MPI (keys u_r<k>, ...,
                 origin_r<k>)
    --json F     the per-row metrics below plus the per-step lists
    --rtol R     the case's Krylov tolerance, where the case has a Krylov driver (see each case)
    --line-relaxation on|off
                 diagnostics.set_pressure_line_relaxation (doc/mg_depth_policy.md A2.4) before the
                 geometry; absent: no call (the solver default, on since WO-7)
    --vcycle-symmetric on|off
                 diagnostics.set_pressure_vcycle_symmetric (doc/mg_depth_policy.md A3) before the
                 geometry; absent: no call (the solver default)

Cases (--case):
    swarm      periodic bubble swarm, case A groups, single rank: the --single path of
               tests/study/vof_perf/weak_swarm.py, code for code (--cells n, default 192;
               --d-over-h 20, --bubbles-per-axis 2). --driver pcg (default; MG-PCG cap 800 at
               --rtol, default 1e-8, as weak_swarm) or --driver default (no driver call: the
               variable-density default, Chebyshev).
               --dims NX NY NZ: an anisotropic box instead of --cells^3 (row M10: an axis that
               stops coarsening early, doc/mg_depth_policy_log.md); the bubble lattice then has
               max(1, N_axis // 64) bubbles along each axis (measurement choice) unless
               --bubbles-per-axis is given, which stays one count for every axis.
    bc         the peclet-examples bubble column (run_peclet.build(), MG-PCG rtol 1e-8 as built)
               at --cells-per-d S (default 32: 256 x 192 x 128), FRESH START from the seeded
               spheres at rest (the 128 x 96 x 64 checkpoint does not exist at other
               resolutions). --rtol re-selects MG-PCG cap 800 at R.
    zh_sphere / random_spheres
               the cut-cell Stokes geometries of tests/regression/sdflow_regression.py at --n N
               with its CFG (MG-PCG cap 300 rtol 1e-8; --rtol overrides), marched to steady with
               its stop test (--max-steps, default 400; --steps is ignored, --warm 0). Records K / k*.
               --solver colocated: SolverColocated with NO scheme call, i.e. the AUTO default
               ('ghost': BiCGStab preconditioned by the V-cycle, at the MG-PCG cap / rtol above);
               --dump then also writes the fluid-cell mask `fluid` (sdf > 0 at the cell centres,
               where every colocated field lives). Row M9 (doc/mg_depth_policy_log.md); its exit
               trace is the solver's PECLET_FLOW_MG_DEBUG=2 line (debug output only).
    channel    single-phase all-fluid channel --nx x --ny x --nz (default 2048 x 64 x 64):
               periodic x, walls on +-y and +-z, body force along x, from rest plus a fixed-seed
               non-solenoidal low-mode perturbation (--perturb, default 1e-2). Single rank:
               the default driver (MG-PCG, auto-enabled); --rtol selects MG-PCG cap 800 at R.
               Under mpirun (np > 1): mpi_block + init_mpi, the multi-rank default (the
               standalone V-cycle, no Krylov driver selected; --rtol is refused).
    anchored   inflow/outflow channel --nx x --ny x --nz (default 128 x 32 x 32): uniform inflow
               U at -x, outflow at +x, walls on +-y, +-z, all fluid; MG-PCG cap --maxit
               (default 300) at --rtol (default 1e-12) -- the divergence floor at an identical
               budget at every depth.
    porous     CFD-DEM-style fixed porous bed --n^3 (default 128): add 'eps' via
               set_porous_continuity(True) with implicit drag (enable_drag), drag_beta from the
               viscous Ergun term, advection + implicit advection ON (as peclet_coupling's
               CfdDem), periodic, body force along x; the driver is the solver default for that
               configuration (no driver call). --no-drag drops enable_drag.

Per step: wall ms of step() alone, last_pressure_iterations(), max_open_divergence_projected()
(read after the step, outside the timer), pressure_vcycle_precision(), pressure_solve_failed(),
and for the porous case max_porous_residual() (the continuity the porous projection solves).
At the end: the level ratios, the bottom's global dims, the load average before/after. The bottom
ENGINE is not visible through the API; run_matrix.sh reads it from a short probe run with
PECLET_FLOW_MG_DEBUG=1 PECLET_FLOW_AGMG_DEBUG=1 (debug output only).
Rank 0 prints one `RESULT key=value ...` line.

Function Documentation

◆ arg()

mgd_case.arg ( name,
default,
cast = str )

◆ depth()

mgd_case.depth ( s)
--levels L >= 1: an exact depth, before the geometry; 0: leave the solver default.
--line-relaxation on|off: the A2.4 line smoother switch (absent: the default).
--vcycle-symmetric on|off: the A3 symmetric V-cycle switch (absent: the default).

Definition at line 115 of file mgd_case.py.

Referenced by build_anchored(), build_channel(), build_ibm(), build_porous(), and build_swarm().

◆ build_swarm()

mgd_case.build_swarm ( )
weak_swarm.py --single, code for code (case A groups, cell units).

Definition at line 128 of file mgd_case.py.

References arg(), and depth().

◆ build_bc()

mgd_case.build_bc ( )

Definition at line 197 of file mgd_case.py.

References arg().

◆ _ibm_sdf()

mgd_case._ibm_sdf ( name,
N )
protected

Definition at line 231 of file mgd_case.py.

Referenced by build_ibm().

◆ build_ibm()

mgd_case.build_ibm ( )

Definition at line 254 of file mgd_case.py.

References _ibm_sdf(), arg(), and depth().

◆ build_channel()

mgd_case.build_channel ( )

Definition at line 276 of file mgd_case.py.

References arg(), and depth().

◆ build_anchored()

mgd_case.build_anchored ( )

Definition at line 318 of file mgd_case.py.

References arg(), and depth().

◆ build_porous()

mgd_case.build_porous ( )

Definition at line 337 of file mgd_case.py.

References arg(), and depth().

◆ one()

mgd_case.one ( timed)

Definition at line 393 of file mgd_case.py.

References dt_of, and one().

Referenced by one().

◆ fmt()

mgd_case.fmt ( v)

Definition at line 514 of file mgd_case.py.

Variable Documentation

◆ A

mgd_case.A = list(sys.argv)

Definition at line 76 of file mgd_case.py.

◆ CASE

mgd_case.CASE = arg("--case", None)

Definition at line 83 of file mgd_case.py.

◆ LEVELS

mgd_case.LEVELS = arg("--levels", 0, int)

Definition at line 86 of file mgd_case.py.

◆ STEPS

mgd_case.STEPS = arg("--steps", 30, int)

Definition at line 87 of file mgd_case.py.

◆ WARM

mgd_case.WARM = arg("--warm", 5, int)

Definition at line 88 of file mgd_case.py.

◆ DUMP

mgd_case.DUMP = arg("--dump", None)

Definition at line 89 of file mgd_case.py.

◆ JSON

mgd_case.JSON = arg("--json", None)

Definition at line 90 of file mgd_case.py.

◆ RTOL

mgd_case.RTOL = arg("--rtol", None, float)

Definition at line 91 of file mgd_case.py.

◆ TAG

mgd_case.TAG = arg("--tag", "")

Definition at line 92 of file mgd_case.py.

◆ LINE

mgd_case.LINE = arg("--line-relaxation", None)

Definition at line 93 of file mgd_case.py.

◆ SYM

mgd_case.SYM = arg("--vcycle-symmetric", None)

Definition at line 96 of file mgd_case.py.

◆ load0

mgd_case.load0 = os.getloadavg()

Definition at line 99 of file mgd_case.py.

◆ NP_ENV

mgd_case.NP_ENV = int(os.environ.get("OMPI_COMM_WORLD_SIZE", os.environ.get("PMI_SIZE", "1")))

Definition at line 102 of file mgd_case.py.

◆ comm

mgd_case.comm = MPI.COMM_WORLD

Definition at line 105 of file mgd_case.py.

◆ rank

mgd_case.rank

Definition at line 106 of file mgd_case.py.

◆ size

mgd_case.size

Definition at line 106 of file mgd_case.py.

◆ info

dict mgd_case.info = {}

Definition at line 110 of file mgd_case.py.

◆ FLUID_MASK

dict mgd_case.FLUID_MASK = None

Definition at line 111 of file mgd_case.py.

◆ fields_C

bool mgd_case.fields_C = False

Definition at line 112 of file mgd_case.py.

◆ BUILD

dict mgd_case.BUILD
Initial value:
1= {"swarm": build_swarm, "bc": build_bc, "zh_sphere": build_ibm, "random_spheres": build_ibm,
2 "channel": build_channel, "anchored": build_anchored, "porous": build_porous}

Definition at line 378 of file mgd_case.py.

◆ t_setup0

mgd_case.t_setup0 = time.perf_counter()

Definition at line 382 of file mgd_case.py.

◆ s

mgd_case.s

Definition at line 383 of file mgd_case.py.

◆ GRID

mgd_case.GRID

Definition at line 383 of file mgd_case.py.

◆ dt_of

mgd_case.dt_of

Definition at line 383 of file mgd_case.py.

Referenced by one().

◆ IBM

mgd_case.IBM

Definition at line 383 of file mgd_case.py.

◆ t_setup

mgd_case.t_setup = time.perf_counter() - t_setup0

Definition at line 386 of file mgd_case.py.

◆ step_ms

mgd_case.step_ms

Definition at line 389 of file mgd_case.py.

◆ iters

mgd_case.iters

Definition at line 389 of file mgd_case.py.

◆ divs

mgd_case.divs

Definition at line 389 of file mgd_case.py.

◆ prec

mgd_case.prec

Definition at line 389 of file mgd_case.py.

◆ failed

mgd_case.failed

Definition at line 389 of file mgd_case.py.

◆ pres

mgd_case.pres

Definition at line 389 of file mgd_case.py.

◆ POROUS

str mgd_case.POROUS = "porous"

Definition at line 390 of file mgd_case.py.

◆ w0

mgd_case.w0 = time.perf_counter()

Definition at line 414 of file mgd_case.py.

◆ wall

mgd_case.wall = time.perf_counter() - w0

Definition at line 419 of file mgd_case.py.

◆ prev

mgd_case.prev = 0.0

Definition at line 421 of file mgd_case.py.

◆ m

mgd_case.m = float(s.get_u().mean())

Definition at line 426 of file mgd_case.py.

◆ u

mgd_case.u = s.get_u()

Definition at line 432 of file mgd_case.py.

◆ umean

mgd_case.umean = float(u.mean())

Definition at line 433 of file mgd_case.py.

◆ sdf

dict mgd_case.sdf = info.pop("_sdf")

Definition at line 434 of file mgd_case.py.

◆ deep

dict mgd_case.deep = sdf < -2.0

Definition at line 437 of file mgd_case.py.

◆ ratios

list mgd_case.ratios = [tuple(int(v) for v in r) for r in s.diagnostics.pressure_mg_level_ratios()]

Definition at line 448 of file mgd_case.py.

◆ g

list mgd_case.g = list(GRID)

Definition at line 449 of file mgd_case.py.

◆ dims

list mgd_case.dims = [tuple(g)]

Definition at line 450 of file mgd_case.py.

◆ bottom

list mgd_case.bottom = dims[-1]

Definition at line 454 of file mgd_case.py.

◆ h

mgd_case.h = hashlib.sha256()

Definition at line 456 of file mgd_case.py.

◆ fx

dict mgd_case.fx = {"u": s.get_u, "v": s.get_v, "w": s.get_w, "p": lambda: s.get_field("p")}

Definition at line 457 of file mgd_case.py.

◆ arrs

dict mgd_case.arrs = {k: np.ascontiguousarray(f()) for k, f in fx.items()}

Definition at line 460 of file mgd_case.py.

◆ allv

mgd_case.allv = comm.gather((list(info.get("origin", [0, 0, 0])), arrs), root=0)

Definition at line 467 of file mgd_case.py.

◆ out

dict mgd_case.out = {}

Definition at line 469 of file mgd_case.py.

◆ digest

mgd_case.digest = h.hexdigest()

Definition at line 475 of file mgd_case.py.

◆ ds

mgd_case.ds = comm.gather(digest, root=0)

Definition at line 477 of file mgd_case.py.

◆ gg

mgd_case.gg = hashlib.sha256()

Definition at line 479 of file mgd_case.py.

◆ load1

mgd_case.load1 = os.getloadavg()

Definition at line 483 of file mgd_case.py.

◆ sm

mgd_case.sm = np.asarray(step_ms)

Definition at line 486 of file mgd_case.py.

◆ prec_flips

mgd_case.prec_flips = sum(1 for a, b in zip(prec, prec[1:]) if a == "fp32" and b == "fp64")

Definition at line 487 of file mgd_case.py.

◆ res

mgd_case.res
Initial value:
1= {
2 "case": CASE, "tag": TAG, "np": size, "grid": list(GRID), "levels_req": LEVELS,
3 "line_relaxation": LINE or "default", "vcycle_symmetric": SYM or "default",
4 "levels": len(ratios), "ratios": [list(r) for r in ratios], "bottom": list(bottom),
5 "bottom_cells": int(np.prod(bottom)), "dims": [list(d) for d in dims],
6 "space": str(getattr(pf, "execution_space", "?")),
7 "flow_module": os.path.dirname(pf.__file__),
8 "omp_threads": os.environ.get("OMP_NUM_THREADS", "unset"),
9 "warm": WARM, "steps": STEPS, "setup_s": t_setup, "wall_ms": 1000.0 * wall / max(STEPS, 1),
10 "step_ms_mean": float(sm.mean()), "step_ms_median": float(np.median(sm)),
11 "iters_mean": float(np.mean(iters)), "iters_min": int(min(iters)),
12 "iters_max": int(max(iters)), "div_max": float(max(divs)), "div_last": divs[-1],
13 "prec_first": prec[0], "prec_last": prec[-1], "fp32_restart_flips": prec_flips,
14 "solve_failed": int(sum(failed)),
15 "cheb_restarts": int(getattr(s.diagnostics, "num_pressure_chebyshev_restarts", -1)),
16 "cheb_growth_trips": int(getattr(s.diagnostics, "num_pressure_chebyshev_growth_trips", -1)),
17 "load_before": list(load0), "load_after": list(load1), "hash": digest,
18 }

Definition at line 488 of file mgd_case.py.

◆ porous_res_max

mgd_case.porous_res_max

Definition at line 508 of file mgd_case.py.

◆ porous_res_last

mgd_case.porous_res_last

Definition at line 508 of file mgd_case.py.

◆ keep

tuple mgd_case.keep
Initial value:
1= ("case", "tag", "np", "levels_req", "levels", "bottom", "steps", "wall_ms",
2 "step_ms_median", "iters_mean", "iters_min", "iters_max", "div_max", "prec_last",
3 "fp32_restart_flips", "solve_failed", "cheb_restarts", "cheb_growth_trips",
4 "porous_res_max", "K", "k_star")

Definition at line 509 of file mgd_case.py.

◆ flush

mgd_case.flush

Definition at line 519 of file mgd_case.py.

◆ step_ms_list

mgd_case.step_ms_list

Definition at line 521 of file mgd_case.py.

◆ iters_list

mgd_case.iters_list

Definition at line 521 of file mgd_case.py.

◆ div_list

mgd_case.div_list

Definition at line 521 of file mgd_case.py.

◆ prec_list

mgd_case.prec_list

Definition at line 521 of file mgd_case.py.

◆ failed_list

mgd_case.failed_list

Definition at line 522 of file mgd_case.py.

◆ porous_res_list

mgd_case.porous_res_list

Definition at line 522 of file mgd_case.py.

◆ fo

mgd_case.fo

Definition at line 524 of file mgd_case.py.

◆ indent

mgd_case.indent

Definition at line 524 of file mgd_case.py.

◆ default

mgd_case.default

Definition at line 524 of file mgd_case.py.