Skip to content
Snippets Groups Projects
Commit 18ac8a4b authored by joergbuchwald's avatar joergbuchwald Committed by Tobias Meisel
Browse files

Revert "[meshlib] remove filepath from Mesh"

This reverts commit d24f7029.
parent 573a9e0c
No related branches found
No related tags found
1 merge request!234add save_pvd method to mesh series
from pathlib import Path
from tempfile import mkdtemp
from typing import TypeVar
import numpy as np
......@@ -197,10 +196,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)
tempdir = mkdtemp(prefix="to_ip_point_cloud")
input_file = Path(tempdir) / "ipDataToPointCloud_input.vtu"
parentpath = Path() if mesh.filepath is None else mesh.filepath.parent
input_file = parentpath / "ipDataToPointCloud_input.vtu"
_mesh.save(input_file)
output_file = Path(tempdir) / "ip_mesh.vtu"
output_file = parentpath / "ip_mesh.vtu"
ogs.cli.ipDataToPointCloud(i=str(input_file), o=str(output_file))
return pv.XMLUnstructuredGridReader(output_file).read()
......
......@@ -27,6 +27,8 @@ 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:
......@@ -94,6 +96,7 @@ class Mesh(pv.UnstructuredGrid):
else:
mesh = cls(pv.read(filepath))
mesh.filepath = Path(filepath).with_suffix(".vtu")
return mesh
@classmethod
......
......@@ -245,6 +245,10 @@ class MeshSeries:
mesh = Mesh(self.mesh_func(pv_mesh))
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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment