[petsc-users] Loading PETSC Grid
Alfredo J Duarte Gomez
aduarteg at utexas.edu
Wed Jul 14 14:47:04 CDT 2021
Good morning,
We are currently developing a PETSC application on a structured grid,
however, we are applying a curvilinear transformation so that the physical
domain is not a rectangle (the computational domain is).
As a result we are trying to load in a mesh into the PETSC dmda object to
create easy visualizations. I have successfully done this through the
following code:
ierr=VecCreateMPI(PETSC_COMM_WORLD,PETSC_DECIDE,6400,&co);CHKERRQ(ierr);
ierr=PetscObjectSetName((PetscObject) co, "coordinates");CHKERRQ(ierr);
ierr=PetscViewerHDF5Open(PETSC_COMM_WORLD,"coord2d.h5",FILE_MODE_READ,&viewer);CHKERRQ(ierr);
ierr=VecLoad(co,viewer);CHKERRQ(ierr);
ierr=PetscViewerDestroy(&viewer);CHKERRQ(ierr);
ierr=DMSetCoordinates(da,co);CHKERRQ(ierr);
Where my coordinate vector in HDF5 format is a single column vector in the
order x1,y1,x2,y2,...xN,yN,etc. where 1 is the lower left corner and N.
However this seems like a rather crude way of doing it, it seems like using
the DMGetCoordinateDM() and DMCreateGlobalVector() is a more sophisticated
way of leveraging the dmda object, however when I use:
DMGetCoordinateDM(da, &cda);
DMCreateGlobalVector(cda, &co);
ierr=PetscObjectSetName((PetscObject) co, "coordinates");CHKERRQ(ierr);
ierr=PetscViewerHDF5Open(PETSC_COMM_WORLD,"coord2d.h5",FILE_MODE_READ,&viewer);CHKERRQ(ierr);
ierr=VecLoad(co,viewer);CHKERRQ(ierr);
ierr=PetscViewerDestroy(&viewer);CHKERRQ(ierr);
ierr=DMSetCoordinates(da,co);CHKERRQ(ierr);
The loading function complains about the structure/format of my data. I
haven't been able to find the format that this coordinate dmda expects from
an HDF5 file in any of the documentation. Is there anywhere I could find
this information?
Thank you,
-Alfredo
--
Alfredo Duarte
Graduate Research Assistant
The University of Texas at Austin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20210714/4b7debfb/attachment.html>
More information about the petsc-users
mailing list