<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <p>Dear all,</p>
    <p>    I am experimenting with hdf5+xdmf output. At
      <a class="moz-txt-link-freetext" href="https://www.xdmf.org/index.php/XDMF_Model_and_Format">https://www.xdmf.org/index.php/XDMF_Model_and_Format</a> I read that
      "XDMF uses XML to store Light data and to describe the data Model.
      Either HDF5<a rel="nofollow" class="external autonumber" href="https://www.hdfgroup.org/HDF5">[3]</a> or binary files can
      be used to store Heavy data.
      The data Format is stored redundantly in both XML and HDF5."</p>
    <p>However, if I call DMView(dmda,hdf5viewer) and then I run h5ls or
      h5stat on the resulting h5 file, I see no "geometry" section in
      the file. How should I write the geometry to the HDF5 file?<br>
    </p>
    <p>Here below is what I have tried.</p>
    <p>Best</p>
    <p>    Matteo<br>
    </p>
    <p>//Setup<br>
    </p>
    <p>ierr = DMDACreate2d(PETSC_COMM_WORLD,<br>
                                    DM_BOUNDARY_NONE,DM_BOUNDARY_NONE,<br>
                                    DMDA_STENCIL_STAR,<br>
                                    ctx.Nx,ctx.Ny, //global dim<br>
                                    PETSC_DECIDE,PETSC_DECIDE, //n proc
      on each dim<br>
                                    2,stWidth, //dof, stencil width<br>
                                    NULL, NULL, //n nodes per direction
      on each cpu<br>
                                    &(ctx.daAll));</p>
    <p>ierr = DMDASetUniformCoordinates(ctx.daAll, 0.0, 1.0, 0.0, 1.0,
      0.0, 1.0); CHKERRQ(ierr);<br>
      ierr = DMDASetFieldName(ctx.daAll,0,"first"); CHKERRQ(ierr);<br>
      ierr = DMDASetFieldName(ctx.daAll,1,"second"); CHKERRQ(ierr);<br>
      ierr = DMDAGetLocalInfo(ctx.daAll,&ctx.daInfo); CHKERRQ(ierr);<br>
      ierr = DMCreateFieldDecomposition(ctx.daAll,NULL, NULL,
      &ctx.is, &ctx.daField); CHKERRQ(ierr);</p>
    <p>//Initial data<br>
      ierr = DMCreateGlobalVector(ctx.daAll,&ctx.U0); CHKERRQ(ierr);<br>
      ierr = VecISSet(ctx.U0,ctx.is[0],1.); CHKERRQ(ierr);<br>
      ierr = VecISSet(ctx.U0,ctx.is[1],100.0); CHKERRQ(ierr);<br>
    </p>
    <p><br>
    </p>
    <p>Write mesh and Vec to hdf5:<br>
    </p>
    <p>PetscViewer viewer;<br>
        ierr =
PetscViewerHDF5Open(PETSC_COMM_WORLD,"solution.h5",FILE_MODE_WRITE,&viewer);
      CHKERRQ(ierr);<br>
        ierr = DMView(ctx.daAll , viewer); CHKERRQ(ierr);  //does not
      output anything to solution.h5??<br>
        ierr = VecView(ctx.U0,viewer); CHKERRQ(ierr);</p>
    <p>ierr = PetscViewerDestroy(&viewer); CHKERRQ(ierr);<br>
      <br>
    </p>
    <p>Attempt to save the two fields separately::</p>
    <p>PetscViewer viewer;<br>
      ierr =
PetscViewerHDF5Open(PETSC_COMM_WORLD,"solution.h5",FILE_MODE_WRITE,&viewer);
      CHKERRQ(ierr);<br>
      ierr = DMView(ctx.daField[0] , viewer); CHKERRQ(ierr); //does not
      output anything to solution.h5??<br>
      <br>
      Vec uF;<br>
      ierr = VecGetSubVector(ctx.U,ctx.is[0],&uF); CHKERRQ(ierr);<br>
      PetscObjectSetName((PetscObject) uF, "first");<br>
      ierr = VecView(uF,viewer); CHKERRQ(ierr);<br>
      ierr = VecRestoreSubVector(ctx.U,ctx.is[0],&uF);
      CHKERRQ(ierr);<br>
    </p>
    <p>ierr = VecGetSubVector(ctx.U,ctx.is[1],&uF); CHKERRQ(ierr);<br>
      PetscObjectSetName((PetscObject) uF, "second");<br>
      ierr = VecView(uF,viewer); CHKERRQ(ierr);<br>
      ierr = VecRestoreSubVector(ctx.U,ctx.is[1],&uF);
      CHKERRQ(ierr);<br>
    </p>
    <p>ierr = PetscViewerDestroy(&viewer); CHKERRQ(ierr);<br>
      <br>
    </p>
  </body>
</html>