[petsc-users] A question about loading data form .h5 file
Barry Smith
bsmith at petsc.dev
Fri Aug 9 09:37:05 CDT 2024
Vectors created from a DMDA have multi-dimensional information attached to them. When the vector is saved with an HDF5 viewer, this multi-dimensional information is saved in the HDF5 file. When a vector created with a DMDA loads the HDF5 file, the multi-dimensional information is used for a successful load.
When a plain vector (obtained with VecCreate) loads from the HDF5 file, it does not have the concept of multidimensional information and thus, for some reason, works incorrectly. I would consider the current error output to be a bug; it should provide a more useful error message.
Note that for DMDA in parallel, the DMDA vector data is transformed to be stored in the natural multidimensional ordering on the disk. When it is read back in with a DMDA vector, the transformation is reversed to get the data back into PETSc's parallel ordering. So, in parallel, it would never make sense to store a DMDA vector with hdf5 and then read it back in with a "plain" vector since the plain vector does not know how to transform the data.
Barry
> On Aug 9, 2024, at 1:11 AM, 王惊梦 <pentaerythrotol at gmail.com> wrote:
>
> Dear Barry,
>
> Thank you for your quick reply, the problem has been solved.
>
> I'm just still curious why when I use PETSC_COMM_SELF in PETSCVIEWER to load a 50*50*50 vector, and the error happens that "Global size of array in file is 2500(50*50), not 125000(50*50*50) as expected".
>
> Best regards,
> Yingjie ZHOU
>
> Barry Smith <bsmith at petsc.dev <mailto:bsmith at petsc.dev>> 于2024年8月9日周五 02:28写道:
>>
>> Try reading the vector back in with a vector created from the DM.
>>
>>
>>
>>> On Aug 8, 2024, at 10:46 AM, 王惊梦 <pentaerythrotol at gmail.com <mailto:pentaerythrotol at gmail.com>> wrote:
>>>
>>> This Message Is From an External Sender
>>> This message came from outside your organization.
>>> Dear Sir or Madam,
>>>
>>> I met a problem about loading data from hdf5 file. Attached is a simple test program.
>>>
>>> A introduction of the program is as follows:
>>> I create a 3d DMDA object(50*50*50), and create 2 global vectors x and y by DMDA, then I write the vector x into file test.h5.
>>> When I try to load the vector y from test.h5, the error occurs that "Global size of array in file is 2500, not 125000 as expected", but the size of the array should be 125000 which I've checked in python.
>>>
>>> Thank you for your help!
>>>
>>> Best regards
>>> ZHOU Yingjie
>>> <test.c>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20240809/15cae67d/attachment.html>
More information about the petsc-users
mailing list