flow 1.4.0
Kokkos cut-cell IBM incompressible Navier-Stokes solver + pnm pore extraction
Loading...
Searching...
No Matches
uf_outlet_staggered_leak.py
Go to the documentation of this file.
1#!/usr/bin/env python
2"""Follow-up A (branch uf-outlet-diag): does advanceScalars' wrap of the staggered outlet face
3(C[0].u at the outflow plane overwritten by the inlet plane) reach momentum?
4
5Staggered inflow/wall/outflow channel with a transported scalar, N steps; prints the SHA-256 of
6u/v/w/p/c and saves them to <out>.npz so two trees (with / without the fix) can be compared.
7Cases: 'passive' (one-way scalar), 'boussinesq' (scalar feeds force_y), 'colo-passive'.
8
9Run: OMP_NUM_THREADS=1 PYTHONPATH=<tree> python tests/study/uf_outlet_staggered_leak.py <out>
10"""
11import hashlib
12import sys
13
14import numpy as np
15
16import peclet.flow as pf
17
18NX, NY, NZ, STEPS = 48, 16, 4, 100
19
20
21def run(case):
22 cls = pf.SolverColocated if case.startswith("colo") else pf.Solver
23 s = cls(NX, NY, NZ)
24 s.set_rho(1.0); s.set_mu(0.1); s.set_dt(0.5)
25 s.set_advection(True); s.set_advection_scheme("koren")
26 if cls is pf.SolverColocated:
27 s.set_collocated_scheme("gauge-exact")
28 s.set_domain_bc("-x", "inflow", (1.0, 0.0, 0.0))
29 s.set_domain_bc("+x", "outflow")
30 s.set_domain_bc("-y", "wall"); s.set_domain_bc("+y", "wall")
31 s.set_pressure_geometry(np.asfortranarray(np.full((NX, NY, NZ), 10.0)))
32 s.set_pressure_pcg(True, 400, 1e-11)
33 s.add_scalar("c", diffusivity=0.01, scheme="koren", iters=50)
34 s.set_scalar_bc("c", "-x", "dirichlet", 1.0); s.set_scalar_bc("c", "+x", "neumann", 0.0)
35 s.set_scalar_bc("c", "-y", "neumann", 0.0); s.set_scalar_bc("c", "+y", "neumann", 0.0)
36 if case == "boussinesq":
37 s.set_property_model("force_y", "boussinesq", "c", [1.0, 1e-3, 1.0, 0.5])
38 for _ in range(STEPS):
39 s.step()
40 return {k: np.asarray(f).copy() for k, f in
41 (("u", s.get_u()), ("v", s.get_v()), ("w", s.get_w()), ("p", s.get_p()),
42 ("c", s.get_field("c")))}
43
44
45if __name__ == "__main__":
46 out = {}
47 for case in ("passive", "boussinesq", "colo-passive"):
48 d = run(case)
49 hs = " ".join(f"{k}={hashlib.sha256(np.ascontiguousarray(v, dtype=np.float64).tobytes()).hexdigest()[:12]}"
50 for k, v in d.items())
51 print(f"{case:14s} {hs}")
52 out.update({f"{case}_{k}": v for k, v in d.items()})
53 np.savez(sys.argv[1], **out)