Add 0.8.1 coupling output restart APIs
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def run_command(args: list[str]) -> subprocess.CompletedProcess[str]:
|
||||
result = subprocess.run(args, text=True, capture_output=True)
|
||||
if result.returncode != 0:
|
||||
raise AssertionError(result.stderr or result.stdout)
|
||||
return result
|
||||
|
||||
|
||||
def read_fields(output: str) -> dict[str, str]:
|
||||
fields: dict[str, str] = {}
|
||||
for line in output.splitlines():
|
||||
if ":" in line:
|
||||
name, value = line.split(":", 1)
|
||||
fields[name.strip()] = value.strip()
|
||||
return fields
|
||||
|
||||
|
||||
def require_field(fields: dict[str, str], field: str) -> None:
|
||||
if field not in fields:
|
||||
raise AssertionError(f"missing coupling CLI 081 field {field}")
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--exe", required=True)
|
||||
parser.add_argument("--input", required=True)
|
||||
args = parser.parse_args()
|
||||
|
||||
fields = read_fields(run_command([str(Path(args.exe)), str(Path(args.input))]).stdout)
|
||||
for field in (
|
||||
"coupling_regions",
|
||||
"coupling_region_1_load_mode",
|
||||
"coupling_region_1_distribution_mode",
|
||||
"coupling_region_1_contact_state_mode",
|
||||
"coupling_region_2_load_mode",
|
||||
"coupling_region_2_distribution_mode",
|
||||
"coupling_region_2_contact_state_mode",
|
||||
"coupling_region_3_enabled",
|
||||
"coupling_force_balance_error",
|
||||
"coupling_moment_balance_error",
|
||||
"coupling_max_pressure",
|
||||
"coupling_max_traction",
|
||||
"coupling_max_penetration",
|
||||
"coupling_repeated_imports",
|
||||
"coupling_invalid_weights",
|
||||
"coupling_active_contacts",
|
||||
"coupling_skipped_contacts",
|
||||
"coupling_nonfinite_contact_imports",
|
||||
):
|
||||
require_field(fields, field)
|
||||
|
||||
if int(fields["coupling_regions"]) != 3:
|
||||
raise AssertionError("coupling CLI 081 region count mismatch")
|
||||
if int(fields["coupling_region_1_load_mode"]) != 3:
|
||||
raise AssertionError("coupling CLI 081 pressure load mode mismatch")
|
||||
if int(fields["coupling_region_1_distribution_mode"]) != 2:
|
||||
raise AssertionError("coupling CLI 081 pressure distribution mismatch")
|
||||
if int(fields["coupling_region_1_contact_state_mode"]) != 1:
|
||||
raise AssertionError("coupling CLI 081 pressure contact state mismatch")
|
||||
if int(fields["coupling_region_2_load_mode"]) != 4:
|
||||
raise AssertionError("coupling CLI 081 traction load mode mismatch")
|
||||
if int(fields["coupling_region_2_distribution_mode"]) != 3:
|
||||
raise AssertionError("coupling CLI 081 traction distribution mismatch")
|
||||
if int(fields["coupling_region_2_contact_state_mode"]) != 1:
|
||||
raise AssertionError("coupling CLI 081 traction contact state mismatch")
|
||||
if int(fields["coupling_region_3_enabled"]) != 0:
|
||||
raise AssertionError("coupling CLI 081 disabled region mismatch")
|
||||
if int(fields["coupling_active_contacts"]) != 0:
|
||||
raise AssertionError("coupling CLI 081 active contact default mismatch")
|
||||
if int(fields["coupling_skipped_contacts"]) != 0:
|
||||
raise AssertionError("coupling CLI 081 skipped contact default mismatch")
|
||||
|
||||
check_fields = read_fields(
|
||||
run_command([str(Path(args.exe)), str(Path(args.input)), "--check"]).stdout
|
||||
)
|
||||
if check_fields["mode"] != "check":
|
||||
raise AssertionError("coupling CLI 081 check mode mismatch")
|
||||
if int(check_fields["coupling_regions"]) != 3:
|
||||
raise AssertionError("coupling CLI 081 check region count mismatch")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user