| 798 | return meshes |
| 799 | |
| 800 | def create_mesh(self, model, parameters): |
| 801 | model_id = model.id() |
| 802 | if not self.folder_path.exists(): |
| 803 | self.folder_path.mkdir() |
| 804 | |
| 805 | template = self.env.get_template("salome/scriptSalome.py") |
| 806 | mesh_name = f'Model_{model_id}_v{parameters["mesh_size"]}' |
| 807 | |
| 808 | med_path = self.folder_path / f"{mesh_name}.med" |
| 809 | json_path = self.folder_path / f"Model_{model_id}.json" |
| 810 | with json_path.open("w") as f: |
| 811 | json.dump(self.parse_model(model), f, indent=4) |
| 812 | |
| 813 | rendered_script = template.render( |
| 814 | mesh_size=parameters["mesh_size"], |
| 815 | json_path=str(json_path.resolve()), |
| 816 | med_path=str(med_path.resolve()), |
| 817 | mesh_name=mesh_name, |
| 818 | ) |
| 819 | |
| 820 | # Write the rendered script to the new location |
| 821 | script_path = self.folder_path / f'ScriptSalome_Model_{model_id}_v{parameters["mesh_size"]}.py' |
| 822 | with open(script_path, "w") as f: |
| 823 | f.write(rendered_script) |
| 824 | |
| 825 | if self.salome_path is not None: |
| 826 | executable = Path(self.salome_path) |
| 827 | subprocess.run(["python", executable, "-t", script_path]) |
| 828 | |
| 829 | return { |
| 830 | "name": mesh_name, |
| 831 | "model_id": model.id(), |
| 832 | "med_path": med_path, |
| 833 | } |
| 834 | else: |
| 835 | print("Salome path not provided. Mesh operation aborted.") |
| 836 | print(f"The salome script file path can be found in the return statement.") |
| 837 | return { |
| 838 | "name": mesh_name, |
| 839 | "model_id": model.id(), |
| 840 | "script_path": script_path, |
| 841 | } |
| 842 | |
| 843 | def get_run_case_labels(self, data, target): |
| 844 | cases = [] |