flow 1.3.0
Kokkos cut-cell IBM incompressible Navier-Stokes solver + pnm pore extraction
Loading...
Searching...
No Matches
flow_probe.py
Go to the documentation of this file.
1# Full-precision physics fingerprint of the flow solver, for a before/after comparison of the
2# set_solid refactor. Prints enough digits that a 1-ULP change is visible.
3import numpy as np, sys
4from peclet import flow as sdflow
5
6def packing_sdf(N, radius_frac=0.18):
7 R = radius_frac * N
8 c = [(0.25*N, 0.25*N, 0.25*N), (0.75*N, 0.75*N, 0.25*N),
9 (0.75*N, 0.25*N, 0.75*N), (0.25*N, 0.75*N, 0.75*N)]
10 g = np.arange(N) + 0.5
11 X, Y, Z = np.meshgrid(g, g, g, indexing="ij")
12 sdf = np.full((N, N, N), 1e30)
13 for (cx, cy, cz) in c:
14 dx = np.abs(X-cx); dx = np.minimum(dx, N-dx)
15 dy = np.abs(Y-cy); dy = np.minimum(dy, N-dy)
16 dz = np.abs(Z-cz); dz = np.minimum(dz, N-dz)
17 sdf = np.minimum(sdf, np.sqrt(dx*dx+dy*dy+dz*dz) - R)
18 return sdf
19
20N = 32
21s = sdflow.Solver(N, N, N)
22s.set_rho(1.0); s.set_mu(1.0); s.set_dt(50.0)
23s.set_solid(np.asfortranarray(packing_sdf(N)), cutcell_pressure=True)
24s.set_body_force(1.0, 0.0, 0.0)
25for _ in range(40): s.step()
26u = np.asarray(s.get_u()); p = np.asarray(s.get_p())
27print("u_sum %.17e" % float(u.sum()))
28print("u_absmax %.17e" % float(np.abs(u).max()))
29print("p_sum %.17e" % float(p.sum()))
30print("u_l2 %.17e" % float(np.sqrt((u*u).sum())))
packing_sdf(N, radius_frac=0.18)
Definition flow_probe.py:6