diff --git a/ogstools/meshlib/ip_mesh.py b/ogstools/meshlib/ip_mesh.py index c05c1eeb8f5ab1dfe710cc17ce79a9cde102063e..2b4111d2bb256a88fd08ff9cc27ec2b89652650b 100644 --- a/ogstools/meshlib/ip_mesh.py +++ b/ogstools/meshlib/ip_mesh.py @@ -1,4 +1,5 @@ from pathlib import Path +from tempfile import mkdtemp from typing import TypeVar import numpy as np @@ -199,10 +200,10 @@ def to_ip_point_cloud(mesh: Mesh) -> pv.UnstructuredGrid: for key in bad_keys: if key in _mesh.field_data: _mesh.field_data.remove(key) - parentpath = Path() if mesh.filepath is None else mesh.filepath.parent - input_file = parentpath / "ipDataToPointCloud_input.vtu" + tempdir = mkdtemp(prefix="to_ip_point_cloud") + input_file = Path(tempdir) / "ipDataToPointCloud_input.vtu" _mesh.save(input_file) - output_file = parentpath / "ip_mesh.vtu" + output_file = Path(tempdir) / "ip_mesh.vtu" ogs.cli.ipDataToPointCloud(i=str(input_file), o=str(output_file)) return pv.XMLUnstructuredGridReader(output_file).read() diff --git a/ogstools/meshlib/mesh.py b/ogstools/meshlib/mesh.py index f30cd51e63f703d5946af56d03924f081bd003ae..a2b044a6bf437614a836c0967395fe8c0c1c67b7 100644 --- a/ogstools/meshlib/mesh.py +++ b/ogstools/meshlib/mesh.py @@ -28,8 +28,6 @@ class Mesh(pv.UnstructuredGrid): Contains additional data and functions mainly for postprocessing. """ - filepath: Path | None = None - # pylint: disable=C0116 @copy_method_signature(data_processing.difference) def difference(self, *args: Any, **kwargs: Any) -> Any: @@ -119,7 +117,6 @@ class Mesh(pv.UnstructuredGrid): else: mesh = cls(pv.read(filepath)) - mesh.filepath = Path(filepath).with_suffix(".vtu") mesh.field_data[SPATIAL_UNITS_KEY] = np.asarray( [ord(char) for char in f"{spatial_unit},{spatial_output_unit}"] ) diff --git a/ogstools/meshlib/mesh_series.py b/ogstools/meshlib/mesh_series.py index 4e0fb83a720fece6b6879b1ca4ba37a003519738..06a4c5503d0550e030bb544c0befcbf34bd9ea24 100644 --- a/ogstools/meshlib/mesh_series.py +++ b/ogstools/meshlib/mesh_series.py @@ -267,10 +267,6 @@ class MeshSeries: ) if lazy_eval: self._mesh_cache[timevalue] = mesh - if self._data_type == "pvd": - mesh.filepath = Path(self.timestep_files[data_timestep]) - else: - mesh.filepath = Path(self.filepath) return mesh def rawdata_file(self) -> Path | None: