adios4dolfinx icon indicating copy to clipboard operation
adios4dolfinx copied to clipboard

Global cells in legacy files

Open finsberg opened this issue 2 years ago • 0 comments

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)

finsberg avatar Aug 09 '23 07:08 finsberg