This commit is contained in:
@@ -19,6 +19,10 @@ def parse_args() -> argparse.Namespace:
|
||||
parser.add_argument("--output-interval", type=int, default=0)
|
||||
parser.add_argument("--require-contact", action="store_true")
|
||||
parser.add_argument("--require-friction", action="store_true")
|
||||
parser.add_argument("--probe-node", type=int)
|
||||
parser.add_argument("--probe-field", choices=("ux", "uy", "uz"))
|
||||
parser.add_argument("--min-abs-displacement", type=float, default=0.0)
|
||||
parser.add_argument("--sign", choices=("negative", "positive", "either"), default="either")
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
@@ -122,6 +126,41 @@ def check_friction_output(build_dir: Path, case_name: str, step: int) -> None:
|
||||
raise RuntimeError(f"{contact_file} did not record positive friction work")
|
||||
|
||||
|
||||
def check_node_probe(args: argparse.Namespace, step: int) -> None:
|
||||
if args.probe_node is None:
|
||||
return
|
||||
if args.probe_field is None:
|
||||
raise RuntimeError("--probe-field is required when --probe-node is set")
|
||||
|
||||
build_dir = Path(args.build_dir).resolve()
|
||||
node_file = build_dir / "example_smoke" / args.case_name / f"nodes_{step:08d}.csv"
|
||||
if not node_file.exists():
|
||||
raise RuntimeError(f"missing node output: {node_file}")
|
||||
|
||||
with node_file.open(newline="", encoding="utf-8") as handle:
|
||||
rows = list(csv.DictReader(handle))
|
||||
row = next(
|
||||
(item for item in rows if int(item["node_id"]) == args.probe_node),
|
||||
None,
|
||||
)
|
||||
if row is None:
|
||||
raise RuntimeError(f"{node_file} does not contain node {args.probe_node}")
|
||||
|
||||
value = float(row[args.probe_field])
|
||||
if abs(value) < args.min_abs_displacement:
|
||||
raise RuntimeError(
|
||||
f"{args.probe_field} at node {args.probe_node} is too small: {value}"
|
||||
)
|
||||
if args.sign == "negative" and value >= 0.0:
|
||||
raise RuntimeError(
|
||||
f"{args.probe_field} at node {args.probe_node} is not negative: {value}"
|
||||
)
|
||||
if args.sign == "positive" and value <= 0.0:
|
||||
raise RuntimeError(
|
||||
f"{args.probe_field} at node {args.probe_node} is not positive: {value}"
|
||||
)
|
||||
|
||||
|
||||
def main() -> int:
|
||||
args = parse_args()
|
||||
_, steps = run_case(args)
|
||||
@@ -129,6 +168,7 @@ def main() -> int:
|
||||
check_contact_output(Path(args.build_dir).resolve(), args.case_name, steps)
|
||||
if args.require_friction:
|
||||
check_friction_output(Path(args.build_dir).resolve(), args.case_name, steps)
|
||||
check_node_probe(args, steps)
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user