31 s =
pf.Solver((n, n, n), extent=(1.0, 1.0, 1.0))
36 s.set_advection(
False)
37 R = (0.3 * 3.0 / (4.0 * math.pi)) ** (1.0 / 3.0)
39 s.set_solid(np.asfortranarray(np.sqrt((X - 0.513) ** 2 + (Y - 0.479) ** 2 + (Z - 0.507) ** 2) - R),
40 cutcell_pressure=
True)
41 s.set_body_force((30.0, 9.0, 0.0))
45 s.add_scalar(
"c", diffusivity=h * h / dt, scheme=
"koren", cutcell=
True)
46 s.set_scalar_wall(
"c",
"dirichlet", 0.0)
47 geo = s.diagnostics.scalar_geometry(
"c")
48 s.set_field(
"c", np.asfortranarray(np.where(geo[
"unknown"] > 0.5, 1.0, 0.0)))
50 for _
in range(steps):
52 tm = s.diagnostics.last_step_timers()
53 t0 = time.perf_counter()
55 s.diagnostics.scalar_budget(
"c")
56 ta = time.perf_counter() - t0
57 it = s.diagnostics.scalar_census(
"c")[
"krylov_iterations"]
58 rows.append((tm[
"step"], tm[
"projection"], ta, it))
59 print(f
"advance {n}^3 bed, dt D/h^2 = 1 (koren, Dirichlet spheres), per step:")
60 for st, pr, ta, it
in rows:
61 print(f
" step {st * 1e3:8.1f} ms projection {pr * 1e3:8.1f} ms advance_scalars "
62 f
"{ta * 1e3:8.1f} ms ({it} it) advance/projection {ta / pr:5.2f}")
63 med = np.median([r[2] / r[1]
for r
in rows])
64 print(f
" median advance/projection {med:.2f} (red flag > 1)")
71 def __init__(self, *a, **k):
72 super().__init__(*a, **k)
75 def solve_scalar_steady(self, *a, **k):
76 t0 = time.perf_counter()
77 r = super().solve_scalar_steady(*a, **k)
78 self.diagnostics.scalar_budget(
"c")
79 times.append(time.perf_counter() - t0)
83 for pe
in (1.0, 10.0):
85 g.gadv_b_case(n, pe,
"neumann")
86 it = made[-1].diagnostics.scalar_census(
"c")[
"krylov_iterations"]
87 print(f
"gadvb {n}^3 Pe_h {pe:g}: gated solve {times[-1]:.3f} s ({it} it); the probe solve "
88 f
"before the rescale (assembly + MG build) {times[0]:.3f} s")