(self, mesh, target: str)
| 853 | return cases |
| 854 | |
| 855 | def run_code_aster(self, mesh, target: str): |
| 856 | model = self.file.by_id(mesh["model_id"]) |
| 857 | json_path = self.folder_path / f"Model_{model.id()}.json" |
| 858 | |
| 859 | # Read data from data file |
| 860 | with open(json_path, "r") as f: |
| 861 | data = json.load(f) |
| 862 | cases = self.get_run_case_labels(data, target) |
| 863 | run_label = "_".join(cases) |
| 864 | |
| 865 | comm_path = self.folder_path / f'{mesh["name"]}_{run_label}.comm' |
| 866 | |
| 867 | constructor = CommandFileConstructor(data) |
| 868 | constructor.create_comm(comm_path, cases=cases) |
| 869 | |
| 870 | export_template = self.env.get_template("codeaster/export") |
| 871 | export_content = export_template.render( |
| 872 | model_name=mesh["name"], |
| 873 | allocated_memory=7000.0, # in MBs |
| 874 | time_limit=900000.0, # in seconds |
| 875 | cases=cases, |
| 876 | run_label=run_label, |
| 877 | ) |
| 878 | export_path = self.folder_path / f"export" |
| 879 | with open(export_path, "w") as f: |
| 880 | f.write(export_content) |
| 881 | |
| 882 | subprocess.run( |
| 883 | [ |
| 884 | "docker", |
| 885 | "run", |
| 886 | "-ti", |
| 887 | "--rm", |
| 888 | "-v", |
| 889 | f"{self.folder_path.resolve()}:/home/aster/shared", |
| 890 | "-w", |
| 891 | "/home/aster/shared", |
| 892 | "aethereng/ifc2ca", |
| 893 | "as_run", |
| 894 | "export", |
| 895 | ] |
| 896 | ) |
| 897 | return {"comm_path": comm_path, "export_path": export_path} |
| 898 | |
| 899 | # except Exception as e: |
| 900 | # # print(f"Exception `{e}` raised. Run operation aborted.") |
| 901 | # # print(f"The command and export file paths can be found in the return statement.") |
| 902 | # return {"Exception": e, "comm_path": comm_path, "export_path": export_path} |
| 903 | |
| 904 | def write_results_to_ifc(self, mesh, target, fields): |
| 905 | model = self.file.by_id(mesh["model_id"]) |
nothing calls this directly
no test coverage detected