flow 1.4.0
Kokkos cut-cell IBM incompressible Navier-Stokes solver + pnm pore extraction
Loading...
Searching...
No Matches
uf_outlet_census.py
Go to the documentation of this file.
1#!/usr/bin/env python
2"""Diagnosis probe 2 (branch uf-outlet-diag): read the RAW outlet plane of the face field with no
3scalar in the step (advanceScalars re-wraps the plane itself, on both grids).
4
5outflow_backflow() reads the collocated uf_ (staggered C[0].u) at the outlet face index directly.
6It only sees REVERSED flow, so the channel is driven backwards: the -x Dirichlet face has
7u = -U and fluid enters through the +x open face. The census max_reverse is then max(-u_out); the
8discrete-divergence answer is max(-U_out_required) from the inner faces (get_uf/vf/wf).
9
10Run: OMP_NUM_THREADS=4 OMP_PROC_BIND=false PYTHONPATH=build_host python tests/study/uf_outlet_census.py
11"""
12import numpy as np
13
14import peclet.flow as pf
15
16NX, NY, NZ = 48, 16, 4
17
18
20 uf, vf, wf = (np.asarray(s.get_uf()), np.asarray(s.get_vf()), np.asarray(s.get_wf()))
21 i = NX - 1
22 vtop = np.zeros((NY, NZ)); vtop[:-1] = vf[i, 1:, :]
23 wtop = np.roll(wf[i], -1, axis=1)
24 return uf[i] - (vtop - vf[i]) - (wtop - wf[i]), uf[0]
25
26
27for name, cls, scheme in (("colo-gauge-exact", pf.SolverColocated, "gauge-exact"),
28 ("colo-embed", pf.SolverColocated, "embed"),
29 ("staggered", pf.Solver, None)):
30 s = cls(NX, NY, NZ)
31 s.set_rho(1.0); s.set_mu(0.1); s.set_dt(0.5)
32 s.set_advection(True); s.set_advection_scheme("koren")
33 if scheme:
34 s.set_collocated_scheme(scheme)
35 s.set_domain_bc("-x", "inflow", (-1.0, 0.0, 0.0))
36 s.set_domain_bc("+x", "outflow")
37 s.set_domain_bc("-y", "wall"); s.set_domain_bc("+y", "wall")
38 s.set_pressure_geometry(np.asfortranarray(np.full((NX, NY, NZ), 10.0)))
39 s.set_pressure_pcg(True, 400, 1e-11)
40 print(f"--- {name}")
41 for n in range(1, 201):
42 s.step()
43 if n in (1, 2, 10, 200):
44 req, uin = required_outlet(s)
45 ob = s.diagnostics.outflow_backflow()
46 print(f" step {n:3d}: census max_reverse = {ob['max_reverse']:.6f} "
47 f"reversed {ob['reversed_faces']}/{ob['outlet_faces']} | required: "
48 f"max(-u_out) = {(-req).max():.6f} min(-u_out) = {(-req).min():.6f} "
49 f"sum = {req.sum():.4f} | inlet face sum = {uin.sum():.4f} | "
50 f"max_open_div_proj = {s.max_open_divergence_projected():.2e}")