33N, RTOL, STEPS = 16, 1e-8, 12
45 X, _, Z = np.meshgrid(*(np.arange(N) + 0.5,) * 3, indexing=
"ij")
46 sdf = np.sqrt((X - N / 2) ** 2 + (Z - N / 2) ** 2) - 0.25 * N
51 s.set_advection(
False)
52 s.set_body_force((1e-3, 0.0, 0.0))
53 s.set_pressure_multigrid(
True, levels=3)
54 s.set_solid(np.asfortranarray(sdf), cutcell_pressure=
True)
56 s.set_pressure_fcg(
True, 400, RTOL)
57 elif driver ==
"cheb":
58 s.set_pressure_chebyshev(
True, 400, RTOL)
60 s.set_pressure_pcg(
True, 400, RTOL)
61 s.diagnostics.set_pressure_initial_guess(guess, 2)
105 env = dict(os.environ, PECLET_FLOW_MG_DEBUG=
"2", PECLET_FLOW_MG_DEBUG_SOLVES=str(STEPS + 2))
106 out = subprocess.run([sys.executable, __file__,
"--child", driver], env=env,
107 capture_output=
True, text=
True, check=
False)
108 rows = re.findall(
r"\[mg\] guess solve \d+: hist (\d) .*? iters (\d+) .*?resid/rref (\S+) "
109 r"x0_nonfluid_nonzero (\d+)", out.stdout)
110 guessed = [r
for r
in rows
if int(r[0]) > 0]
111 worst = max((float(r[2])
for r
in guessed), default=float(
"nan"))
112 nz = sum(int(r[3])
for r
in guessed)
113 check(out.returncode == 0
and len(guessed) >= STEPS - 2
and worst <= 1.5 * RTOL
and nz == 0,
114 f
"{driver}: G-E2 {len(guessed)} guessed solves, max resid/rref {worst:.3e} <= 1.5 rtol, "
115 f
"x0 on solids {nz}")
116 zero =
solver(
"zero", driver)
117 proj =
solver(
"projected", driver)
119 for _
in range(STEPS):
122 iz += zero.diagnostics.last_pressure_iterations()
123 ip += proj.diagnostics.last_pressure_iterations()
124 check(ip < iz, f
"{driver}: iterations over {STEPS} steps 'zero' {iz} -> 'projected' {ip}")