flow 1.3.0
Kokkos cut-cell IBM incompressible Navier-Stokes solver + pnm pore extraction
Loading...
Searching...
No Matches
mg_trace_parse.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2"""Summarise a PECLET_FLOW_MG_DEBUG=2 residual trace: per solve, the iteration count, the minimum
3r/r0 reached (the ATTAINABLE FLOOR when the run is driven with an unreachable rtol), the final
4r/r0, and the rebound factor final/min.
5
6The distinction this exists for: an iteration count cannot tell a FLOOR (min == final, both far
7above rtol — round-off has taken over) from a REBOUND (final > min — the CG recurrence has lost
8conjugacy and is walking back up) from honest slow convergence. WO-M's whole float-vs-double
9comparison turns on it, and so does reading the classical attainable-accuracy bound
10||r||/||r0|| ~ O(eps * kappa(A)) off a measured plateau.
11
12Usage: <run emitting [mg] lines> | python mg_trace_parse.py [label]
13"""
14import re
15import sys
16
17
18def main():
19 label = sys.argv[1] if len(sys.argv) > 1 else ""
20 solves, cur = [], None
21 for line in sys.stdin:
22 if line.startswith("[mg] solve"):
23 cur = []
24 solves.append(cur)
25 elif "r/r0" in line and cur is not None:
26 cur.append(float(re.search(r"r/r0=([0-9.eE+-]+)", line).group(1)))
27 print(f"--- {label}")
28 for i, v in enumerate(solves):
29 if not v:
30 continue
31 mn = min(v)
32 k = v.index(mn)
33 print(f" solve {i}: {len(v):4d} its floor(min r/r0) {mn:.3e} at it {k + 1:4d} "
34 f"final {v[-1]:.3e} rebound x{v[-1] / mn:.3g}")
35 return 0
36
37
38if __name__ == "__main__":
39 sys.exit(main())