<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"><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><br>Sincerely<br>Nicholas<br><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><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>