flow 1.3.0
Kokkos cut-cell IBM incompressible Navier-Stokes solver + pnm pore extraction
Loading...
Searching...
No Matches
time_setsolid.py
Go to the documentation of this file.
1"""Time AmrFlow set_solid on the RCP graded bed — the Layer-2-for-core acceptance driver.
2Reuses the study script's own mesh builder so the mesh is exactly the campaign's."""
3import importlib.util, sys, time, os
4spec = importlib.util.spec_from_file_location(
5 "bed", "/home/frankp/Codes/suite/core/tests/study/amr_bed_graded.py")
6bed = importlib.util.module_from_spec(spec)
7sys.modules["bed"] = bed
8spec.loader.exec_module(bed)
9import numpy as np
10amr = bed.amr
11
12depth = int(sys.argv[1]) if len(sys.argv) > 1 else 6
13N = 2 ** depth
14t0 = time.time()
15gapfn, _ = bed.make_gap_lookup(N)
16tree = bed.build("g", N, gapfn)
17n = tree.num_leaves
18print(f"depth={depth} N={N} leaves={n} (mesh build {time.time()-t0:.1f}s)")
19fl = amr.Flow(tree, 1.0, bed.MU, 60.0)
20fl.set_body_force(bed.FX, 0.0, 0.0)
21fl.set_advection(False)
22fl.set_ghost_sampled(True)
23fl.set_cf_scheme(1)
24C, R = bed.load_pack(N)
25t0 = time.time()
26fl.set_solid_spheres(C, np.array([R]), True)
27dt = time.time() - t0
28print(f"set_solid: {dt:.2f} s = {1e6*dt/n:.1f} us/leaf")
29# classification fingerprint for the parity gate (before vs after must be bit-identical)
30m = np.asarray(fl.is_fluid())
31print(f"fluid mask: {int(m.sum())}/{n} fluid hash={hash(m.tobytes())}")
32np.save(sys.argv[2], m) if len(sys.argv) > 2 else None