Files
FemLite/examples/contact_two_blocks_compression/check_contact_results.py
T
shenw 255c7caf4f
FemLite CI / build-test (push) Has been cancelled
Advance V4 contact search and parallelism
2026-06-25 08:59:14 +08:00

45 lines
1.4 KiB
Python

from __future__ import annotations
import csv
import glob
import os
import sys
def main() -> int:
result_dir = sys.argv[1] if len(sys.argv) > 1 else "results"
pair_rows: list[dict[str, str]] = []
for path in sorted(glob.glob(os.path.join(result_dir, "contact_*.csv"))):
with open(path, newline="") as stream:
pair_rows.extend(row for row in csv.DictReader(stream) if row["kind"] == "PAIR")
if not pair_rows:
print("no contact pair rows found")
return 1
max_active = max(int(float(row["active_count"])) for row in pair_rows)
max_force = max(float(row["force_norm"]) for row in pair_rows)
max_gap = max(float(row["gap_residual"]) for row in pair_rows)
max_lambda = max(float(row["aug_lambda"]) for row in pair_rows)
if max_active <= 0 or max_force <= 0.0 or max_gap <= 0.0:
print("face-to-face contact did not activate")
return 1
if max_lambda <= 0.0:
print("augmented contact multiplier did not grow")
return 1
if not glob.glob(os.path.join(result_dir, "result_*.vtk")):
print("no VTK output found")
return 1
print(
"ok: max_active={}, max_force={:.6e}, max_gap={:.6e}, max_aug_lambda={:.6e}".format(
max_active, max_force, max_gap, max_lambda
)
)
return 0
if __name__ == "__main__":
raise SystemExit(main())