<div dir="ltr"><div dir="ltr">On Thu, Mar 11, 2021 at 9:02 AM Smit Thijs <<a href="mailto:thijs.smit@hest.ethz.ch">thijs.smit@hest.ethz.ch</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 lang="EN-GB" style="overflow-wrap: break-word;">
<div class="gmail-m_3073969498773716927WordSection1">
<p class="MsoNormal"><span lang="DE-CH">Hi Matt,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="DE-CH"><u></u> <u></u></span></p>
<p class="MsoNormal">Oke, would a code change be difficult? I mean, feasible for me to do as a mechanical engineer? ;)</p></div></div></blockquote><div><br></div><div>Sure. The hard part is determining what to do with a given vector. Here</div><div><br></div><div> <a href="https://gitlab.com/petsc/petsc/-/blob/main/src/dm/impls/da/gr2.c#L677">https://gitlab.com/petsc/petsc/-/blob/main/src/dm/impls/da/gr2.c#L677</a></div><div><br></div><div>you can see that we just save vectors until they are written out. You would have to</div><div><br></div><div> 1) Enhance the DMCompatible() check to allow both cell and vertex meshes here, and mark</div><div> the cell vector somehow.</div><div><br></div><div> 2) Save that cell data mark when you save the vector</div><div><br></div><div> 3) Then when vectors are written here</div><div><br></div><div> <a href="https://gitlab.com/petsc/petsc/-/blob/main/src/dm/impls/da/grvtk.c#L106">https://gitlab.com/petsc/petsc/-/blob/main/src/dm/impls/da/grvtk.c#L106</a></div><div><br></div><div>you have to add a <Cell data> section. I do not understand the structured grid XML format, but I assume</div><div>you can look this up.</div><div><br></div><div>How does that sound?</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div lang="EN-GB" style="overflow-wrap: break-word;"><div class="gmail-m_3073969498773716927WordSection1">
<p class="MsoNormal">Or can I use an other version of PETSc where the output to ASCII VTK is still available?
<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Best, Thijs<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(225,225,225);padding:3pt 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US">From:</span></b><span lang="EN-US"> Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>>
<br>
<b>Sent:</b> 11 March 2021 14:54<br>
<b>To:</b> Smit Thijs <<a href="mailto:thijs.smit@hest.ethz.ch" target="_blank">thijs.smit@hest.ethz.ch</a>><br>
<b>Cc:</b> <a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a><br>
<b>Subject:</b> Re: [petsc-users] Outputting cell data in stead of point data while writing .vtr file<u></u><u></u></span></p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">On Thu, Mar 11, 2021 at 8:17 AM Smit Thijs <<a href="mailto:thijs.smit@hest.ethz.ch" target="_blank">thijs.smit@hest.ethz.ch</a>> wrote:<u></u><u></u></p>
</div>
<div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal"><span lang="DE-CH">Hi Matt,</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="DE-CH"> </span><u></u><u></u></p>
<p class="MsoNormal">Actually I have two 3D DMDA’s, one for the nodal data, where the FEM is solved on. The other DMDA is a cell centered one for the volume data, like the density of a particular voxel.
Ideally I would like to write both point data (displacement field) and cell data (density) to the vtr.<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">Code for DMDA.<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"> DMBoundaryType bx = DM_BOUNDARY_NONE;<u></u><u></u></p>
<p class="MsoNormal"> DMBoundaryType by = DM_BOUNDARY_NONE;<u></u><u></u></p>
<p class="MsoNormal"> DMBoundaryType bz = DM_BOUNDARY_NONE;<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"> DMDAStencilType stype = DMDA_STENCIL_BOX;<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal" style="text-indent:10pt">
PetscInt stencilwidth = 1;<u></u><u></u></p>
<p class="MsoNormal" style="text-indent:10pt">
<u></u><u></u></p>
<p class="MsoNormal"> // Create the nodal mesh<u></u><u></u></p>
<p class="MsoNormal">
<span lang="ES">ierr = DMDACreate3d(PETSC_COMM_WORLD, bx, by, bz, stype, nx, ny, nz, PETSC_DECIDE, PETSC_DECIDE, PETSC_DECIDE,</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="ES"> numnodaldof, stencilwidth, 0, 0, 0, &(da_nodes));</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="ES"> CHKERRQ(ierr);</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="DE-CH"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="DE-CH"> DMSetFromOptions(da_nodes);</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="DE-CH"> DMSetUp(da_nodes);</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="DE-CH"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="DE-CH"> ierr = DMDASetUniformCoordinates(da_nodes, xmin, xmax, ymin, ymax, zmin, zmax);</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="DE-CH"> CHKERRQ(ierr);</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="DE-CH"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="DE-CH"> ierr = DMDASetElementType(da_nodes, DMDA_ELEMENT_Q1);</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="DE-CH">
</span>CHKERRQ(ierr);<u></u><u></u></p>
</div>
</div>
</blockquote>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">When I wrote the original version which output to ASCII VTK, we allowed switching between point data and cell data. It is <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">fragile since you have to assure that the different grids match properly. When the viewer was rewritten to use the XML,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">all output was point data. It looks like it would take code changes to get this done.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"> Thanks,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"> Matt<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal">Best, Thijs<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(225,225,225);padding:3pt 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US">From:</span></b><span lang="EN-US"> Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>>
<br>
<b>Sent:</b> 11 March 2021 14:08<br>
<b>To:</b> Smit Thijs <<a href="mailto:thijs.smit@hest.ethz.ch" target="_blank">thijs.smit@hest.ethz.ch</a>><br>
<b>Cc:</b> <a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a><br>
<b>Subject:</b> Re: [petsc-users] Outputting cell data in stead of point data while writing .vtr file</span><u></u><u></u></p>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal">What kind of DM is it?<u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> Thanks,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> Matt<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<div>
<p class="MsoNormal">On Thu, Mar 11, 2021 at 3:36 AM Smit Thijs <<a href="mailto:thijs.smit@hest.ethz.ch" target="_blank">thijs.smit@hest.ethz.ch</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin:5pt 0cm 5pt 4.8pt">
<div>
<div>
<p class="MsoNormal">Hi All,<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">I am outputting several vectors to a .vtr file successfully for viewing in Paraview. At this moment the information is written to point data. How can I change this and make sure
the data is written to cell data?<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">The code I am currently using for outputting:<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">PetscViewer viewer;<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">ierr = PetscViewerVTKOpen(PETSC_COMM_WORLD, “test.vtr”, FILE_MODE_WRITE, &viewer);<u></u><u></u></p>
<p class="MsoNormal">CHKERRQ(ierr);<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">ierr = DMView(nd, viewer);<u></u><u></u></p>
<p class="MsoNormal">CHKERRQ(ierr);<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">PetscObjectSetName((PetscObject)xPhys,"xPhys");<u></u><u></u></p>
<p class="MsoNormal">ierr = VecView(xPhys, viewer);<u></u><u></u></p>
<p class="MsoNormal">CHKERRQ(ierr);<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">PetscObjectSetName((PetscObject)S,"SvonMises");<u></u><u></u></p>
<p class="MsoNormal">ierr = VecView(S, viewer);<u></u><u></u></p>
<p class="MsoNormal">CHKERRQ(ierr);<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">ierr = PetscViewerDestroy(&viewer);<u></u><u></u></p>
<p class="MsoNormal">CHKERRQ(ierr);<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"><span style="color:rgb(36,41,46)">Best regards,</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:rgb(36,41,46)"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:rgb(36,41,46)">Thijs Smit</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:rgb(36,41,46)"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:rgb(36,41,46)">PhD Candidate</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:rgb(36,41,46)">ETH Zurich</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:rgb(36,41,46)">Institute for Biomechanics</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="DE-CH"> </span><u></u><u></u></p>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><br clear="all">
<u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<p class="MsoNormal">--
<u></u><u></u></p>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal">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<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><br clear="all">
<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<p class="MsoNormal">-- <u></u><u></u></p>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal">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<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</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>