Skip to content

Commit

Permalink
Fix bug in reading legacy mesh. Should check that file exist before o…
Browse files Browse the repository at this point in the history
…pening it
  • Loading branch information
finsberg committed Apr 20, 2024
1 parent 934fffb commit fab43a9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/adios4dolfinx/legacy_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@ def read_mesh_from_legacy_h5(
group: Name of mesh in `h5`-file
cell_type: What type of cell type, by default tetrahedron.
"""
# Make sure we use the HDF5File and check that the file is present
filename = pathlib.Path(filename).with_suffix(".h5")
if not filename.is_file():
raise FileNotFoundError(f"File {filename} does not exist")

# Create ADIOS2 reader
adios = adios2.ADIOS(comm)
with ADIOSFile(
Expand All @@ -285,11 +290,6 @@ def read_mesh_from_legacy_h5(
io_name="Mesh reader",
engine="HDF5",
) as adios_file:
# Make sure we use the HDF5File and check that the file is present
filename = pathlib.Path(filename).with_suffix(".h5")
if not filename.is_file():
raise FileNotFoundError(f"File {filename} does not exist")

# Get mesh topology (distributed)
if f"{group}/topology" not in adios_file.io.AvailableVariables().keys():
raise KeyError(f"Mesh topology not found at '{group}/topology'")
Expand Down

0 comments on commit fab43a9

Please sign in to comment.