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