-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplot_all.py
More file actions
57 lines (46 loc) · 1.5 KB
/
Copy pathplot_all.py
File metadata and controls
57 lines (46 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python3
"""Run all case plotting scripts.
Usage:
python plot_all.py # all 13 cases
python plot_all.py --case tgv_2d # single case
python plot_all.py --case tgv_2d sod_1d # multiple cases
"""
import sys
import argparse
import importlib
from pathlib import Path
ROOT = Path(__file__).parent
sys.path.insert(0, str(ROOT))
# Model checkpoints live in PhysNN-Triton/output (local output dir)
MODEL_ROOT = ROOT / "output"
ALL_CASES = [
"burgers_1d_steady", "burgers_1d_unsteady",
"ldc_2d", "ldc_3d",
"tgv_2d", "tgv_3d", "tgv_3d_smooth",
"transport_2d", "sod_1d",
"diffusion_1d", "diffusion_2d",
"poisson_2d", "poisson_3d",
]
def run_case(case_name):
print(f"\n{'='*50}")
print(f" Plotting: {case_name}")
print(f"{'='*50}")
try:
physics = importlib.import_module(f"cases.{case_name}.physics")
plot_mod = importlib.import_module(f"plots.{case_name}")
model_dir = MODEL_ROOT / case_name
out_dir = ROOT / "output" / case_name / "figures"
plot_mod.plot_from_checkpoints(physics, out_dir, model_dir=model_dir)
except Exception as e:
print(f" ERROR: {e}")
def main():
p = argparse.ArgumentParser()
p.add_argument("--case", nargs="+", default=None,
help="Case name(s). Default: all")
args = p.parse_args()
cases = args.case if args.case else ALL_CASES
for case in cases:
run_case(case)
print("\nDone.")
if __name__ == "__main__":
main()