adios4dolfinx
adios4dolfinx copied to clipboard
Global cells in legacy files
In legacy dolfin, each function where stored with a cells group. I suspect this has something to do with the partition used when saving the file, but currently this information is not used in adios4dolfinx.
Here is a function for reading the global cells.
def read_global_cells(filename: pathlib.Path, group: str):
adios = adios2.ADIOS(MPI.COMM_WORLD)
io = adios.DeclareIO("Cells reader")
io.SetEngine("HDF5")
# Open ADIOS2 Reader
infile = io.Open(str(filename), adios2.Mode.Read)
cells = io.InquireVariable(f"/{group}/cells")
num_cells_global = cells.Shape()[0]
cells.SetSelection([[0], [num_cells_global]])
global_cells = np.empty(num_cells_global, dtype=cells.Type().strip("_t"))
infile.Get(cells, global_cells, adios2.Mode.Sync)
infile.Close()
assert adios.RemoveIO("Cells reader")
return global_cells.astype(np.int64)