[petsc-users] VecLoad from HDF5 file
Thibault Bridel-Bertomeu
thibault.bridelbertomeu at gmail.com
Wed Apr 7 01:18:12 CDT 2021
Dear all,
I have been facing a problem with VecLoad recently, even though it seems to
me I did exactly like in the examples/tutorials.
Basically, a program writes a vector with the HDF5 writer like this :
call DMCreateGlobalVector(dm, sol, ierr);
CHKERRA(ierr) call VecZeroEntries(X, ierr);
CHKERRA(ierr) call PetscObjectSetName(X,
"Solution", ierr); CHKERRA(ierr)
< do something with X to fill it up with relevant data >
call PetscViewerCreate(PETSC_COMM_WORLD, hdf5Viewer,
ierr); CHKERRA(ierr) call
PetscViewerSetType(hdf5Viewer, PETSCVIEWERHDF5, ierr); CHKERRA(ierr)
call PetscViewerFileSetMode(hdf5Viewer, FILE_MODE_WRITE,
ierr); CHKERRA(ierr); write(filename,'(A,I5.5,A)')
"restart_", stepnum, ".h5" call
PetscViewerFileSetName(hdf5Viewer, trim(filename), ierr);
CHKERRA(ierr) call VecView(X, hdf5Viewer, ierr);
CHKERRA(ierr) call PetscViewerDestroy(hdf5Viewer,
ierr); CHKERRA(ierr)
and the same program (but with different start-up options, say) re-reads
such a file like this :
call DMCreateGlobalVector(dm, sol, ierr);
CHKERRA(ierr) call VecZeroEntries(sol, ierr);
CHKERRA(ierr) call PetscObjectSetName(sol,
"Solution", ierr); CHKERRA(ierr)
call PetscViewerCreate(PETSC_COMM_WORLD, hdf5Viewer,
ierr); CHKERRA(ierr) call
PetscViewerSetType(hdf5Viewer, PETSCVIEWERHDF5, ierr); CHKERRA(ierr)
call PetscViewerFileSetMode(hdf5Viewer, FILE_MODE_READ,
ierr); CHKERRA(ierr) call
PetscViewerFileSetName(hdf5Viewer, trim(restartname), ierr);
CHKERRA(ierr) call VecLoad(sol, hdf5Viewer, ierr);
CHKERRA(ierr) call PetscViewerDestroy(hdf5Viewer,
ierr); CHKERRA(ierr)
Such a dataset can be found under this link :
https://drive.google.com/file/d/1owLAx5vknNhj61_5ieAwnWOR9cmkTseL/view?usp=sharing
I would like the reader to read the /fields/Solution group basically, but I
am not even sure it tries to do that.
Anyhow, I got an error, saying that the size found in the file (105) does
not match the expected size (25300). If I look at the shape of
/fields/Solution it is given as (21, 5030, 5). First, it is weird, cause
the 21 seems to be 1 + current iteration number ... but anyways we find the
5 variables and the 5030 cells. Only the reader seems to do 21 * 5 when it
should be doing 5030 * 5 ...
I tried adding 'PetscViewerHDF5PushGroup(hdf5Viewer, "/fields/Solution",
ierr)' to force it to read that group, but it does not change anything.
I would appreciate it if anyone could give me pointers on this issue ...
Thank you very much in advance !!
Thibault
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20210407/5ff21596/attachment.html>
More information about the petsc-users
mailing list