26ZH_PHI = [0.000125, 0.001, 0.008, 0.027, 0.064, 0.125, 0.216, 0.343, 0.45, 0.5236]
27ZH_K = [1.096, 1.212, 1.525, 2.008, 2.810, 4.292, 7.442, 15.4, 28.1, 42.1]
58def run_sdflow(N, phi, mu=0.1, f=1e-3, dt=None, max_steps=600, tol=1e-6, coarse="rediscretized",
60 """Multilevel MG-PCG pressure solve; `coarse` selects the coarse-operator mode
61 ('rediscretized' = the geometric per-level cut-cell operator, the recommended default;
62 'galerkin' = the inconsistent aggregation path; 'const' = geometry-blind coarse).
63 `seed` = (u,v,w) from the next-coarser N, upsampled here, to start the march near steady."""
64 from peclet
import flow
as sdflow
66 dt = 60.0
if N <= 64
else 120.0
67 lv = max(2, int(np.log2(N)) - 1)
69 s = sdflow.Solver(N, N, N)
70 s.set_rho(1.0); s.set_mu(mu); s.set_dt(dt); s.set_body_force(f, 0, 0); s.set_advection(
False)
71 s.set_velocity_solver_params(200)
73 s.set_pressure_multigrid(
True, levels=lv)
74 s.set_pressure_pcg(
True, max_iter=200, rtol=1e-8)
75 s.set_solid(sdf, cutcell_pressure=
True, pressure_coarse=coarse)
77 u, v, w = (np.asfortranarray(
_upsample2(c))
for c
in seed)
79 prev = 0.0; t0 = time.time()
80 for it
in range(max_steps):
83 m = float(s.get_u().mean())
84 if it > 10
and abs(m - prev) < tol * (abs(m) + 1e-30):
87 m = float(s.get_u().mean())
88 return drag_K(m, R, N, f, mu), (s.get_u(), s.get_v(), s.get_w()), time.time() - t0