[petsc-users] Example for hdf5 output and visualization

Praveen C cpraveen at gmail.com
Thu Sep 29 22:08:06 CDT 2016


Hello

I am creating my vector using DMDA, so the hdf file knows something about
the grid. But it uses (i,j) indices as (x,y) coordinates to plot. Here is
what I do

   ierr = DMCreateGlobalVector(da, &ug); CHKERRQ(ierr);

   // set values into ug

   ierr = PetscViewerHDF5Open(PETSC_COMM_WORLD,
"sol.h5",FILE_MODE_WRITE,&viewer);
CHKERRQ(ierr);

   ierr = PetscViewerHDF5SetTimestep(viewer, 0); CHKERRQ(ierr);

   ierr = VecView(ug, viewer); CHKERRQ(ierr);

   // update ug and save it again

   ierr = PetscViewerHDF5IncrementTimestep(viewer); CHKERRQ(ierr);

   ierr = VecView(ug, viewer); CHKERRQ(ierr);


I have not saved mesh coordinates, so I can understand that it uses (i,j)
coordinates. How can I save x,y coordinates and time information so that
VisIt will be able to know the mesh and time information ?

I can save solution at different times into different .h5 files but is that
really necessary ?

What I understood is that the h5 file only contains some data, and one has
to create a xdmf file that tells VisIt how to use the data in the h5 file.
The h5 file should contain "geometry" and "topology" sections. I could add
the "geometry" section by saving the mesh coordinates. But how to add the
"topology" section which contains cell information ? Is there an easy way
to add this o the hdf file when I use DMDA ?

Thanks
praveen

On Thu, Sep 29, 2016 at 11:03 PM, Santiago Ospina De Los Rios <
sospinar at unal.edu.co> wrote:

>
>
> 2016-09-29 18:57 GMT+02:00 Praveen C <cpraveen at gmail.com>:
>
>> Dear all
>>
>> Is there an example  to save hdf5 file on cartesian mesh with time
>> dependent solution, that I can visualize in VisIt ?
>>
>>
> If you save the file with a successive numbering at the final of the name,
> Visit will recognize it as a time-dependent.
>
> I am able to save in hdf5 and open in VisIt but I cannot get the actual
>> mesh coordinates or time dependent data.
>>
>>
> To get the mesh you have to save a vector associated to a DM object,
> otherwise, you will get a row of values at the visualization.
>
>
>> I have seen a script petsc_gen_xdmf.py but that needs lot of information
>> in the hdf5 file which I do not know how to create. An example for 2d
>> Cartesian mesh would be very useful to learn this.
>>
>>
> Anyway, it's a good question: how to visualize time-dependent hdf5 files
> in other viewers such as Paraview just using PETSc calls. Is there a way?
>
> Santiago O.
>
>
>> Thanks
>> praveen
>>
>
>
>
> --
>
> --
> Att:
>
> Santiago Ospina De Los Ríos
> National University of Colombia
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20160930/98ecc1f8/attachment.html>


More information about the petsc-users mailing list