flow 1.3.0
Kokkos cut-cell IBM incompressible Navier-Stokes solver + pnm pore extraction
Loading...
Searching...
No Matches
lattice_plane_gate.py
Go to the documentation of this file.
1"""The lattice-plane trap, gated: a MOVING box whose faces sit exactly on grid planes owns no cut
2cell, so its wall velocity never enters the momentum operator and the body is silently inert.
3set_solid_from_scene must (a) count > 0 DEGENERATE staggered points (sdf exactly zero) for that
4instance and warn, and (b) count 0 for the same box shifted 0.3 cells off the lattice -- and the
5fluid must actually move in (b).
6
7Usage: PYTHONPATH=<flow build> python lattice_plane_gate.py
8"""
9import numpy as np
10from peclet import flow as sdflow
11from peclet import geom
12
13N = 32
14U = 0.05
15KI_I, KI_R = 2, 17
16
17
18def run(half):
19 b = geom.SceneBuilder()
20 plate = b.add_leaf("box", [N * 0.6, half, N * 0.6]) # spans the box in x,z (a legitimate union)
21 ni, nr, _, _ = b.encode()
22 ii = np.zeros((1, KI_I), dtype=np.int32); ir = np.zeros((1, KI_R))
23 ii[0] = (plate, -1); ir[0, 0:3] = (0.5 * N, 8.0, 0.5 * N); ir[0, 6] = 1.0; ir[0, 7] = 1.0
24 s = sdflow.Solver(N, N, N)
25 s.set_rho(1.0); s.set_mu(0.1); s.set_dt(2.0)
26 s.set_velocity_solver_params(60); s.set_pressure_solver_params(20)
27 s.set_pressure_multigrid(True, levels=3)
28 s.set_scene(np.asarray(ni, np.int32), np.asarray(nr, float), ii.ravel(), ir.ravel(),
29 periodic=True)
30 s.set_instance_motion(0, lin_vel=[U, 0.0, 0.0]) # a plate sliding in x
31 s.set_solid_from_scene(True)
32 deg = np.asarray(s.moving_instance_degenerate_points())
33 for _ in range(40):
34 s.step()
35 umax = float(np.abs(np.asarray(s.get_u())).max())
36 return int(deg[0]) if deg.size else -1, umax
37
38
39ok = True
40for tag, half, want_deg in (("faces ON grid planes (y = 16.0)", 8.0, True),
41 ("faces off the lattice (y = 16.3)", 8.3, False)):
42 deg, umax = run(half)
43 good = (deg > 0) == want_deg and ((umax > 0.1 * U) != want_deg)
44 ok &= good
45 print(" %-34s degenerate points %6d max|u| after 40 steps %.3e (wall U=%.2f) %s"
46 % (tag, deg, umax, U, "ok" if good else "FAIL"))
47print("LATTICE-PLANE GATE %s" % ("PASS" if ok else "FAIL"))