<div dir="ltr"><div dir="ltr">On Mon, Jul 12, 2021 at 11:40 AM Matteo Semplice <<a href="mailto:matteo.semplice@uninsubria.it">matteo.semplice@uninsubria.it</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<p>Dear all,</p>
<p> I am experimenting with hdf5+xdmf output. At
<a href="https://www.xdmf.org/index.php/XDMF_Model_and_Format" target="_blank">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" href="https://www.hdfgroup.org/HDF5" target="_blank">[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></p></div></blockquote><div>The HDF5 stuff is only implemented for DMPlex since unstructured grids need to be explicitly stored. You can usually just define the structured grid in the XML</div><div>without putting anything in the HDF5. We could write metadata so that the XML could be autogenerated, but we have not done that.</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><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,
&<a href="http://ctx.is" target="_blank">ctx.is</a>, &ctx.daField); CHKERRQ(ierr);</p>
<p>//Initial data<br>
ierr = DMCreateGlobalVector(ctx.daAll,&ctx.U0); CHKERRQ(ierr);<br>
ierr = VecISSet(ctx.U0,<a href="http://ctx.is" target="_blank">ctx.is</a>[0],1.); CHKERRQ(ierr);<br>
ierr = VecISSet(ctx.U0,<a href="http://ctx.is" target="_blank">ctx.is</a>[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,<a href="http://ctx.is" target="_blank">ctx.is</a>[0],&uF); CHKERRQ(ierr);<br>
PetscObjectSetName((PetscObject) uF, "first");<br>
ierr = VecView(uF,viewer); CHKERRQ(ierr);<br>
ierr = VecRestoreSubVector(ctx.U,<a href="http://ctx.is" target="_blank">ctx.is</a>[0],&uF);
CHKERRQ(ierr);<br>
</p>
<p>ierr = VecGetSubVector(ctx.U,<a href="http://ctx.is" target="_blank">ctx.is</a>[1],&uF); CHKERRQ(ierr);<br>
PetscObjectSetName((PetscObject) uF, "second");<br>
ierr = VecView(uF,viewer); CHKERRQ(ierr);<br>
ierr = VecRestoreSubVector(ctx.U,<a href="http://ctx.is" target="_blank">ctx.is</a>[1],&uF);
CHKERRQ(ierr);<br>
</p>
<p>ierr = PetscViewerDestroy(&viewer); CHKERRQ(ierr);<br>
<br>
</p>
</div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>