flow 0.4.0
Kokkos cut-cell IBM incompressible Navier-Stokes solver + pnm pore extraction
Loading...
Searching...
No Matches
ghost_collocated_apriori Namespace Reference

Functions

 phi_man_grad (x, y, z)
 
 cell_fields (geo, ufun)
 
 face_avg (U3)
 
 face_openness (geo, ns=6)
 
 cell_grad (geo, P, mode, o_real=None)
 
 order (prev, cur, Nprev, N)
 
 test_constraint (Ns)
 
 test_grad_ladder (Ns)
 
 pinned_solve (A, b, activef)
 
 run_chain (geo, cc_mode)
 
 test_chain (Ns, modes=("ghost", "open", "pcc"))
 

Variables

float TP = 2.0 * np.pi
 
 ap = argparse.ArgumentParser()
 
 action
 
 args = ap.parse_args()
 
list Ns_eval = [16, 32, 64] if args.quick else [16, 32, 64, 128]
 
list Ns_solve = [16, 24, 32] if args.quick else [16, 24, 32, 48]
 
 c1 = test_constraint(Ns_eval)
 
 c2
 
 gauge_ok
 
 c3 = test_chain(Ns_solve)
 
 g = c3["ghost"]
 
list gates
 
int npass = 0
 

Detailed Description

A-priori validation of the directional ghost-cell projection on the COLLOCATED grid.

Extends ghost_projection_apriori.py (staggered, 9/9 gates) to Solver<Colocated> — the open
problem of doc/collocated_second_order_open_problem.md. Structure of the collocated scheme under
test (the steady fixed point feels ONLY the momentum grad(P) operator and the constraint, since
the incremental phi -> 0 there):

  constraint C   = ghost-closed point divergence of the 1/2-1/2 face-AVERAGED cell field
                   (the closures/matrix are IDENTICAL to the staggered ghost scheme: the face
                   correction uf -= grad(phi) is the same substitution, so assemble() is reused
                   verbatim and every staggered matrix gate carries over);
  grad(P) / cell correction = directional cell gradient: central difference where both axis
                   neighbours are fluid-centered, 2nd-order ONE-SIDED (-3P_i+4P_{i+1}-P_{i+2})/2
                   toward the fluid where the neighbour center is solid (falls back to the
                   2-point one-sided when i+2 is solid too; 0 when sandwiched). NEVER reads a
                   solid-centered cell's P/phi — those rows are decoupled (0), and reading them
                   is a GAUGE-DEPENDENT O(1) gradient error (the shipping mode-0 central
                   difference and the o-weighted kernels all make it; measured here in [C2]).

Tests (gates in main):
  [C1] constraint truncation (open-problem doc T1): ghost-closed divergence of the face-averaged
       exact solenoidal Stokes field. Near-IB rows O(h) localized truncation (same structure the
       staggered scheme damps to global 2nd order), bulk O(h^2). Contrast column: the mode-0
       openness divergence o_f * faceavg on the same field.
  [C2] cell-gradient operator ladder on a smooth pressure at cut cells (fluid center, solid
       axis-neighbour): central-reading-solid-0 and the o-weighted kernels are O(1) (and gauge-
       dependent where they read solid P); the directional one-sided gradient is O(h^2) and
       exactly gauge-independent.
  [C3] the full projection chain, manufactured (open-problem doc T2 analog): perturb the CELL
       field with Gc(phi_man), face-average, ghost-divergence, pinned singular solve, face
       correction (plain grad) + CELL correction (Gc). Gates: phi ~O(h^2), corrected CELL
       velocity ~O(h^2), diagnostic == residual identity. Ladder comparison of the cell
       correction shows the one-sided directional variant is required.

Run:  python tests/study/ghost_collocated_apriori.py  [--quick]

Function Documentation

◆ phi_man_grad()

ghost_collocated_apriori.phi_man_grad (   x,
  y,
  z 
)
Analytic gradient of phi_man (sin/cos triple).

Definition at line 52 of file ghost_collocated_apriori.py.

Referenced by test_grad_ladder().

◆ cell_fields()

ghost_collocated_apriori.cell_fields (   geo,
  ufun 
)
Cell-centered samples, masked to 0 at solid centers (maskVelocity model).

Definition at line 60 of file ghost_collocated_apriori.py.

Referenced by run_chain(), and test_constraint().

◆ face_avg()

ghost_collocated_apriori.face_avg (   U3)
Minus-face field of the cell field: uf_a(i) = 1/2 (U_a(i) + U_a(i-1)), periodic.

Definition at line 66 of file ghost_collocated_apriori.py.

Referenced by run_chain(), and test_constraint().

◆ face_openness()

ghost_collocated_apriori.face_openness (   geo,
  ns = 6 
)
Sampled area fraction of the minus face per axis (mode-0 contrast only).

Definition at line 71 of file ghost_collocated_apriori.py.

Referenced by test_constraint(), and test_grad_ladder().

◆ cell_grad()

ghost_collocated_apriori.cell_grad (   geo,
  P,
  mode,
  o_real = None 
)
Per-axis discrete cell-center gradient (grid units) of a cell field P that is only
defined on fluid cells (solid cells read as 0 — what the solver's decoupled rows hold).
  central  : plain central difference (mode-0 predictor; reads the solid 0)
  pcc      : projectCorrectCenter — 1/2 (g- + g+), closed-face gradient zeroed (binary)
  open     : centerGradOpen with binary openness — full-weight open-face gradient
  open_real: centerGradOpen with the REAL sampled openness (reads the solid 0 through
             partially-open faces — the shipping mode-6 kernel)
  ghost    : central where both neighbours fluid; 2nd-order one-sided else; 2-point
             one-sided fallback; 0 when sandwiched. Never reads solid cells.

Definition at line 89 of file ghost_collocated_apriori.py.

Referenced by run_chain(), and test_grad_ladder().

◆ order()

ghost_collocated_apriori.order (   prev,
  cur,
  Nprev,
  N 
)

Definition at line 137 of file ghost_collocated_apriori.py.

Referenced by test_chain(), test_constraint(), and test_grad_ladder().

◆ test_constraint()

ghost_collocated_apriori.test_constraint (   Ns)

Definition at line 142 of file ghost_collocated_apriori.py.

References cell_fields(), face_avg(), face_openness(), and order().

◆ test_grad_ladder()

ghost_collocated_apriori.test_grad_ladder (   Ns)

Definition at line 189 of file ghost_collocated_apriori.py.

References cell_grad(), face_openness(), order(), and phi_man_grad().

◆ pinned_solve()

ghost_collocated_apriori.pinned_solve (   A,
  b,
  activef 
)
Direct solve of the singular Neumann-like system with the incompatibility dumped
UNIFORMLY (residual = lambda*e), the sparse-friendly equivalent of mean removal.
See ghost_projection_apriori.test_solve for the derivation + measured failure modes.

Definition at line 232 of file ghost_collocated_apriori.py.

Referenced by run_chain().

◆ run_chain()

ghost_collocated_apriori.run_chain (   geo,
  cc_mode 
)
One manufactured projection chain; returns error metrics.

Definition at line 252 of file ghost_collocated_apriori.py.

References cell_fields(), cell_grad(), face_avg(), and pinned_solve().

Referenced by test_chain().

◆ test_chain()

ghost_collocated_apriori.test_chain (   Ns,
  modes = ("ghost", "open", "pcc") 
)

Definition at line 307 of file ghost_collocated_apriori.py.

References order(), and run_chain().

Variable Documentation

◆ TP

float ghost_collocated_apriori.TP = 2.0 * np.pi

Definition at line 49 of file ghost_collocated_apriori.py.

◆ ap

ghost_collocated_apriori.ap = argparse.ArgumentParser()

Definition at line 334 of file ghost_collocated_apriori.py.

◆ action

ghost_collocated_apriori.action

Definition at line 335 of file ghost_collocated_apriori.py.

◆ args

ghost_collocated_apriori.args = ap.parse_args()

Definition at line 336 of file ghost_collocated_apriori.py.

◆ Ns_eval

list ghost_collocated_apriori.Ns_eval = [16, 32, 64] if args.quick else [16, 32, 64, 128]

Definition at line 338 of file ghost_collocated_apriori.py.

◆ Ns_solve

list ghost_collocated_apriori.Ns_solve = [16, 24, 32] if args.quick else [16, 24, 32, 48]

Definition at line 339 of file ghost_collocated_apriori.py.

◆ c1

ghost_collocated_apriori.c1 = test_constraint(Ns_eval)

Definition at line 341 of file ghost_collocated_apriori.py.

◆ c2

ghost_collocated_apriori.c2

Definition at line 342 of file ghost_collocated_apriori.py.

◆ gauge_ok

ghost_collocated_apriori.gauge_ok

Definition at line 342 of file ghost_collocated_apriori.py.

◆ c3

ghost_collocated_apriori.c3 = test_chain(Ns_solve)

Definition at line 343 of file ghost_collocated_apriori.py.

◆ g

ghost_collocated_apriori.g = c3["ghost"]

Definition at line 345 of file ghost_collocated_apriori.py.

◆ gates

list ghost_collocated_apriori.gates
Initial value:
1= [
2 ("C1 constraint near-IB truncation order >= 0.8", c1["ib"] >= 0.8),
3 ("C1 constraint bulk order >= 1.7", c1["bulk"] >= 1.7),
4 ("C2 ghost gradient cut-cell order >= 1.7", c2["ghost"] >= 1.7),
5 ("C2 ghost gradient gauge-independent", gauge_ok),
6 # phi max is dominated by a near-IB layer that converges at ~O(h^1.4) (the averaging/
7 # cell-gradient perturbation mismatch is an O(h) surface source); the quantities the
8 # physics feels — corrected cell velocity, COUPLED faces — are ~O(h^2) (gates below).
9 ("C3 ghost chain: phi order >= 1.3", g["o_phi"] >= 1.3),
10 ("C3 ghost chain: cell-velocity order >= 1.7", g["o_c"] >= 1.7),
11 ("C3 ghost chain: COUPLED-face order >= 1.7", g["o_f"] >= 1.7),
12 ("C3 diagnostic == residual identity", g["ident"]),
13 ]

Definition at line 347 of file ghost_collocated_apriori.py.

◆ npass

int ghost_collocated_apriori.npass = 0

Definition at line 360 of file ghost_collocated_apriori.py.