37 s.set_advection(
False)
38 s.set_pressure_geometry(np.full((N, N, N), 1.0, order=
"F"))
39 s.set_pressure_pcg(
True, 800, 1e-10)
41 x = (np.arange(N) + 0.5)[:,
None,
None]
42 y = (np.arange(N) + 0.5)[
None, :,
None]
43 z = (np.arange(N) + 0.5)[
None,
None, :]
44 r2 = (x - 0.5 * N) ** 2 + (y - 0.5 * N) ** 2 + (z - 0.5 * N) ** 2
45 s.set_vof(np.asfortranarray(np.clip(0.5 + 3.0 - np.sqrt(r2), 0.0, 1.0)))
46 s.set_property_model(
"rho",
"linear",
"C", [RHO_C0, RHO_C1 - RHO_C0])
47 if enable
is not None:
49 one = np.ones((N, N, N), order=
"F")
50 s.set_state(0.5 * one, 0.3 * one, 0.0 * one)
66 print(
"SKIP: peclet.flow not importable (set PYTHONPATH to the build tree)")
69 ref =
run(pf, CALLS[
"positional"])
70 assert float(np.max(np.abs(ref[
"u"] - 0.5))) > 0.0
or float(np.max(np.abs(ref[
"p"]))) > 0.0, \
71 "the fields did not evolve: the test is vacuous"
72 for name
in (
"canonical keywords",
"former keywords"):
73 got =
run(pf, CALLS[name])
75 assert np.array_equal(ref[k], got[k]), f
"{name}: field {k} differs from positional"
76 print(f
" {name}: bitwise identical to positional")
77 for bad
in (
lambda s: s.enable_vof_momentum(rho_c0=RHO_C0, rho_liquid=RHO_C1),
78 lambda s: s.enable_vof_momentum(rho_gas=RHO_C0, rho_c1=RHO_C1)):
84 raise AssertionError(
"mixed keywords did not raise TypeError")
85 print(
" mixed keywords: TypeError")
87 build(pf,
lambda s: s.enable_vof_momentum(RHO_C1, RHO_C0))
88 except RuntimeError
as e:
90 assert "rho_c0" in msg
and "rho_c1" in msg
and "SWAPPED" in msg, f
"message: {msg}"
91 assert "rho_gas" not in msg
and "rho_liquid" not in msg, f
"message: {msg}"
93 raise AssertionError(
"a swapped pair against the 'rho' closure did not raise")
94 print(
" swapped pair: error names rho_c0 / rho_c1")
95 except AssertionError
as e:
98 print(
"OK: enable_vof_momentum(rho_c0, rho_c1) == positional == former keywords")