On Wed, Jul 14, 2021 at 3:47 PM Alfredo J Duarte Gomez <aduarteg@utexas.edu> wrote:
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?

Yes, I agree that it should work that way. You have to show me the complaint, or a small example that I can run. Perhaps
it is the fact that the coordinate vector will have a block size (the spatial dimension), which your HDF5 data may be missing.

  Thanks,

     Matt
 
Thank you,

-Alfredo





--
Alfredo Duarte
Graduate Research Assistant
The University of Texas at Austin


--
What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.
-- Norbert Wiener