<div dir="ltr"><div dir="ltr">On Thu, Dec 22, 2022 at 12:41 AM Nicholas Arnold-Medabalimi <<a href="mailto:narnoldm@umich.edu">narnoldm@umich.edu</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 dir="ltr">Hi Petsc Users<br><br>I've been having trouble consistently getting a vector generated from a DM to output to VTK correctly. I've used ex1.c (which works properly)to try and figure it out, but I'm still having some issues. I must be missing something small that isn't correctly associating the section with the DM. <br><br><div style="color:rgb(255,255,255);background-color:rgb(0,36,81);font-family:Consolas,"Courier New",monospace;font-size:14px;line-height:19px;white-space:pre-wrap"><div>    <span style="color:rgb(187,218,255)">DMPlexGetChart</span>(<span style="color:rgb(255,157,164)">dm</span>, <span style="color:rgb(153,255,255)">&</span><span style="color:rgb(255,157,164)">p0</span>, <span style="color:rgb(153,255,255)">&</span><span style="color:rgb(255,157,164)">p1</span>);</div><div>    <span style="color:rgb(255,238,173)">PetscSection</span> <span style="color:rgb(255,157,164)">section_full</span>;</div><div>    <span style="color:rgb(187,218,255)">PetscSectionCreate</span>(<span style="color:rgb(255,157,164)">PETSC_COMM_WORLD</span>, <span style="color:rgb(153,255,255)">&</span><span style="color:rgb(255,157,164)">section_full</span>);</div><div>    <span style="color:rgb(187,218,255)">PetscSectionSetNumFields</span>(<span style="color:rgb(255,157,164)">section_full</span>, <span style="color:rgb(255,197,143)">1</span>);</div><div>    <span style="color:rgb(187,218,255)">PetscSectionSetChart</span>(<span style="color:rgb(255,157,164)">section_full</span>, <span style="color:rgb(255,157,164)">p0</span>, <span style="color:rgb(255,157,164)">p1</span>);</div><div>    <span style="color:rgb(187,218,255)">PetscSectionSetFieldName</span>(<span style="color:rgb(255,157,164)">section_full</span>, <span style="color:rgb(255,197,143)">0</span>, <span style="color:rgb(209,241,169)">"state"</span>);</div><br><div>    <span style="color:rgb(235,187,255)">for</span> (<span style="color:rgb(235,187,255)">int</span> <span style="color:rgb(255,157,164)">i</span> <span style="color:rgb(153,255,255)">=</span> <span style="color:rgb(255,157,164)">c0</span>; <span style="color:rgb(255,157,164)">i</span> <span style="color:rgb(153,255,255)"><</span> <span style="color:rgb(255,157,164)">c1</span>; <span style="color:rgb(255,157,164)">i</span><span style="color:rgb(153,255,255)">++</span>)</div><div>    {</div><div>        <span style="color:rgb(187,218,255)">PetscSectionSetDof</span>(<span style="color:rgb(255,157,164)">section_full</span>, <span style="color:rgb(255,157,164)">i</span>, <span style="color:rgb(255,197,143)">1</span>); </div><div>        <span style="color:rgb(187,218,255)">PetscSectionSetFieldDof</span>(<span style="color:rgb(255,157,164)">section_full</span>, <span style="color:rgb(255,157,164)">i</span>, <span style="color:rgb(255,197,143)">0</span>, <span style="color:rgb(255,197,143)">1</span>);</div><div>    }</div><div>    <span style="color:rgb(187,218,255)">PetscSectionSetUp</span>(<span style="color:rgb(255,157,164)">section_full</span>);</div><div>    <span style="color:rgb(187,218,255)">DMSetNumFields</span>(<span style="color:rgb(255,157,164)">dm</span>, <span style="color:rgb(255,197,143)">1</span>);</div><div>    <span style="color:rgb(187,218,255)">DMSetLocalSection</span>(<span style="color:rgb(255,157,164)">dm</span>, <span style="color:rgb(255,157,164)">section_full</span>);</div><div>    <span style="color:rgb(187,218,255)">DMCreateGlobalVector</span>(<span style="color:rgb(255,157,164)">dm</span>, <span style="color:rgb(153,255,255)">&</span><span style="color:rgb(255,157,164)">state_full</span>);</div><br><div>    <span style="color:rgb(235,187,255)">int</span> <span style="color:rgb(255,157,164)">o0</span>, <span style="color:rgb(255,157,164)">o1</span>;</div><div>    <span style="color:rgb(187,218,255)">VecGetOwnershipRange</span>(<span style="color:rgb(255,157,164)">state_full</span>, <span style="color:rgb(153,255,255)">&</span><span style="color:rgb(255,157,164)">o0</span>, <span style="color:rgb(153,255,255)">&</span><span style="color:rgb(255,157,164)">o1</span>);</div><div>    <span style="color:rgb(255,238,173)">PetscScalar</span> <span style="color:rgb(153,255,255)">*</span><span style="color:rgb(255,157,164)">state_full_array</span>;</div><div>    <span style="color:rgb(187,218,255)">VecGetArray</span>(<span style="color:rgb(255,157,164)">state_full</span>, <span style="color:rgb(153,255,255)">&</span><span style="color:rgb(255,157,164)">state_full_array</span>);</div><br><div>    <span style="color:rgb(235,187,255)">for</span> (<span style="color:rgb(235,187,255)">int</span> <span style="color:rgb(255,157,164)">i</span> <span style="color:rgb(153,255,255)">=</span> <span style="color:rgb(255,197,143)">0</span>; <span style="color:rgb(255,157,164)">i</span> <span style="color:rgb(153,255,255)"><</span> (<span style="color:rgb(255,157,164)">c1</span> <span style="color:rgb(153,255,255)">-</span> <span style="color:rgb(255,157,164)">c0</span>); <span style="color:rgb(255,157,164)">i</span><span style="color:rgb(153,255,255)">++</span>)</div><div>    {</div><div>        <span style="color:rgb(235,187,255)">int</span> <span style="color:rgb(255,157,164)">offset</span>;</div><div>        <span style="color:rgb(187,218,255)">PetscSectionGetOffset</span>(<span style="color:rgb(255,157,164)">section_full</span>, <span style="color:rgb(255,157,164)">i</span>, <span style="color:rgb(153,255,255)">&</span><span style="color:rgb(255,157,164)">offset</span>);</div><div>        <span style="color:rgb(255,157,164)">state_full_array</span>[<span style="color:rgb(255,157,164)">offset</span>] <span style="color:rgb(153,255,255)">=</span> <span style="color:rgb(255,197,143)">101325</span> <span style="color:rgb(153,255,255)">+</span> <span style="color:rgb(255,157,164)">i</span>;</div><div>    }</div><br><div>    <span style="color:rgb(187,218,255)">VecRestoreArray</span>(<span style="color:rgb(255,157,164)">state_full</span>, <span style="color:rgb(153,255,255)">&</span><span style="color:rgb(255,157,164)">state_full_array</span>);</div><br><div>    </div><div>    <span style="color:rgb(187,218,255)">PetscViewerCreate</span>(<span style="color:rgb(255,157,164)">PETSC_COMM_WORLD</span>, <span style="color:rgb(153,255,255)">&</span><span style="color:rgb(255,157,164)">viewer</span>);</div><div>    <span style="color:rgb(187,218,255)">PetscViewerSetType</span>(<span style="color:rgb(255,157,164)">viewer</span>, <span style="color:rgb(187,218,255)">PETSCVIEWERVTK</span>);</div><div>    <span style="color:rgb(187,218,255)">PetscViewerFileSetMode</span>(<span style="color:rgb(255,157,164)">viewer</span>, <span style="color:rgb(255,157,164)">FILE_MODE_WRITE</span>);</div><div>    <span style="color:rgb(187,218,255)">PetscViewerFileSetName</span>(<span style="color:rgb(255,157,164)">viewer</span>, <span style="color:rgb(209,241,169)">"mesh.vtu"</span>);</div><div>    <span style="color:rgb(187,218,255)">VecView</span>(<span style="color:rgb(255,157,164)">state_full</span>, <span style="color:rgb(255,157,164)">viewer</span>);</div></div><br>If I run this mesh.vtu isn't generated at all. If I instead do a DMView passing the DM it will just output the mesh correctly.<br><br>Any assistance would be greatly appreciated. <br></div></blockquote><div><br></div><div>DMCreateGlobalVector() dispatches to DMCreateGlobalVector_Plex(), which resets the view method to VecView_Plex(), which should dispatch to VecView_Plex_Local_VTK(). You can verify this in the debugger, or send us code we can run to verify it.</div><div><br></div><div>  Thanks,</div><div><br></div><div>    Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Sincerely<br>Nicholas<br><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div style="font-family:arial;font-size:small"><font color="#000000">Nicholas Arnold-Medabalimi<br><br></font><span style="font-family:sans-serif;font-size:14px">Ph.D. Candidate</span><font color="#000000"><br>Computational Aeroscience Lab<br>University of Michigan</font></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>