<div dir="ltr"><div dir="ltr">On Tue, May 23, 2023 at 8:44 PM Ferrand, Jesus A. <<a href="mailto:FERRANJ2@my.erau.edu">FERRANJ2@my.erau.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 class="msg-2506333726718493817">




<div dir="ltr">
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
Dear PETSc team:</div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
I am trying to use DMPlex and DMLabel to develop an API to write plexes to .cgns format in parallel.</div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
To that end, I need a way to extract the height-0 points and sort them by topological type (i.e., chunk of tetrahedra, followed by chunk of pyramids, etc.).</div></div></div></blockquote><div><br></div><div>I thought I already sorted them this way. Are you adding them in a different order?</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 class="msg-2506333726718493817"><div dir="ltr">
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
I figured I could use the DMLabel produced by <span style="font-family:"Courier New",monospace">
DMPlexComputeCellTypes()</span> as follows:</div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
** I get the "celltype" DMLabel **<br>
</div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-family:"Courier New",monospace">PetscBool has_tetrahedra, has_hexahedra, has_pyramids, has_tri_prisms;</span><br>
</div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-family:"Courier New",monospace">PetscCall(DMLabelHasStratum(ctype_label, DM_POLYTOPE_TETRAHEDRON, &has_tetrahedra));
</span>
<div><span style="font-family:"Courier New",monospace">PetscCall(DMLabelHasStratum(ctype_label, DM_POLYTOPE_HEXAHEDRON, &has_hexahedra));</span></div>
<div><span style="font-family:"Courier New",monospace">PetscCall(DMLabelHasStratum(ctype_label, DM_POLYTOPE_PYRAMID, &has_pyramids));</span></div>
<div><span style="font-family:"Courier New",monospace">PetscCall(DMLabelHasStratum(ctype_label, DM_POLYTOPE_TRI_PRISM, &has_tri_prisms));</span></div>
<br>
</div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-family:"Courier New",monospace">PetscInt nTopology = (PetscInt)has_tetrahedra + (PetscInt)has_hexahedra + (PetscInt)has_pyramids + (PetscInt)has_tri_prisms;</span></div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-family:"Courier New",monospace">PetscInt *pType, *vType, *nType;</span><br>
</div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-family:"Courier New",monospace">PetscMalloc3(nTopology, &pType, nTopology, &vType, nTopology, &nType);</span></div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-family:"Courier New",monospace">PetscInt counter = -1;</span><br>
</div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-family:"Courier New",monospace">if(has_tetrahedra){</span></div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-family:"Courier New",monospace"><span>      </span>counter++;</span></div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-family:"Courier New",monospace">     <span> </span>pType[counter] = DM_POLYTOPE_TETRAHEDRON;</span></div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-family:"Courier New",monospace">   </span><span style="font-family:"Courier New",monospace"><span>   </span>vType[counter] = 4;</span></div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-family:"Courier New",monospace">     <span> </span>PetscCall(DMLabelGetStratumSize(ctype_label, DM_POLYTOPE_TETRAHEDRON, &nType[counter]));</span><br>
</div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-family:"Courier New",monospace">}</span></div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
** Repeat this pattern of if-statement for the rest. **</div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-size:12pt;font-family:"Courier New",monospace;color:rgb(0,0,0)">if(has_tri_prisms) {</span></div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
<div style="font-size:12pt;color:rgb(0,0,0)">
<span style="font-family:"Courier New",monospace"><span>      </span>counter++;</span></div>
<div style="font-size:12pt;color:rgb(0,0,0)">
<span style="font-family:"Courier New",monospace">     <span> </span>pType[counter] = DM_POLYTOPE_TRI_PRISM;</span></div>
<div style="font-size:12pt;color:rgb(0,0,0)">
<span style="font-family:"Courier New",monospace">   </span>
<span style="font-family:"Courier New",monospace"><span>   </span>vType[counter] = 6;</span></div>
<div style="font-size:12pt;color:rgb(0,0,0)">
<span style="font-family:"Courier New",monospace">     <span> </span>PetscCall(DMLabelGetStratumSize(ctype_label, DM_POLYTOPE_TRI_PRISM, &nType[counter]));</span><br>
</div>
<span style="font-size:12pt;font-family:"Courier New",monospace;color:rgb(0,0,0)">}</span><br>
</div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-family:"Courier New",monospace">IS pIS;</span></div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-family:"Courier New",monospace">PetscInt StratumIdx;</span><br>
</div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-family:"Courier New",monospace">const PetscInt* pPoints;</span><br>
</div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-family:"Courier New",monospace">for(PetscInt ii = 0; ii < nTopology; ii++){</span></div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-family:"Courier New",monospace"> <span>     </span></span><span style="font-family:"Courier New",monospace">PetscCall(DMLabelGetValueIndex(ctype_label, pType[ii], &StratumIdx));</span></div></div></div></div></blockquote><div><br></div><div>I do not understand why you need the index of this value.</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 class="msg-2506333726718493817"><div dir="ltr"><div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-family:"Courier New",monospace">    <span>  </span>PetscCall(DMLabelGetStratumIS(ctype_label, StratumIdx, &pIS));</span></div></div></div></div></blockquote><div><br></div><div>This does not look right. You lookup by value, not by value index.</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 class="msg-2506333726718493817"><div dir="ltr"><div><div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)"><br>
</div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-family:"Courier New",monospace">    <span>  </span>PetscCall(ISGetIndices(pIS, &pPoints));</span><br>
</div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-family:"Courier New",monospace">  <span>    </span>for(PetscInt jj = 0; jj < nType[ii]; jj++){</span></div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-family:"Courier New",monospace">    </span><span style="font-family:"Courier New",monospace">  </span><span style="font-family:"Courier New",monospace"><span>      </span>PetscCall(DMPlexGetTransitiveClosure(dm, pPoints[ii], PETSC_TRUE,
 &ClosureSize, &pClosure));</span><br>
<br>
</div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
<span>      </span>**  Assemble connectivity array for each chunk of height-0 topology **</div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
    <span>  </span><span style="font-family:"Courier New",monospace"><span>      </span>PetscCall(DMPlexRestoreTransitiveClosure(dm, pPoints[ii], PETSC_TRUE, &ClosureSize, &pClosure));</span><br>
</div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-family:"Courier New",monospace">  <span>    </span>}</span><br>
</div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-family:"Courier New",monospace">    <span>  </span>PetscCall(ISRestoreIndices(pS, &pPoints));</span><br>
</div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-family:"Courier New",monospace">    <span>  </span>PetscCall(ISDestroy(&pIS));</span><br>
</div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-family:"Courier New",monospace">}</span><br>
</div>
<div id="m_-2506333726718493817Signature">
<div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-size:12pt;font-family:"Courier New",monospace;color:rgb(0,0,0)">PetscFree3(pType, vType, nType);</span><br>
</div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<br>
</div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
I think, that in principle, this is the correct approach for my immediate objective.
<br>
</div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
However, my problem is that the DAG points returned by <span style="font-family:"Courier New",monospace">
pIS</span> through <span style="font-family:"Courier New",monospace">pPoints</span> are outside the height-0 stratum.
<br>
</div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
I can tell because I'm printing the contents of <span style="font-family:"Courier New",monospace">
pPoints</span> and comparing againts my DAG's height/depth strata.<br>
</div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<br>
</div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
It is as if the DMLabel has a different numbering from the DAG.</div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
Also, for DMLabel's APIs, is the "stratum value" the same thing as the "label value"?</div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
My gutt feeling is that the former is 0 <= StratumValue < nStrata, and the latter could be potentially disjoint (e.g., LabelValue in [-1, 0, 3 , 6, 7, 8]).<br>
</div>
<div style="font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
Is that what <span style="font-family:"Courier New",monospace">DMLabelGetValueIndex()</span> is for?<br>
</div>
<div></div>
<div></div>
<div id="m_-2506333726718493817divtagdefaultwrapper" dir="ltr" style="font-size:12pt;font-family:Calibri,Helvetica,sans-serif;color:rgb(0,0,0)">
<p style="margin-top:0px;margin-bottom:0px">
</p>
<div>
<p style="margin:0px 0px 10.66px">
</p>
<div>
<p style="background:none 0% 0% repeat scroll white;margin:0px 0px 11px;line-height:normal">
<span style="margin:0px;font-family:"Times New Roman",Times,serif;font-size:12pt;color:black">Sincerely:</span></p>
<p style="background:none 0% 0% repeat scroll white;margin:0px;line-height:normal">
<u><span style="margin:0px;font-family:"Courier New",monospace;font-size:14pt;color:red"><b><span style="font-family:"Courier New",monospace">J.A. Ferrand</span></b></span><span style="margin:0px;font-family:"Swis721 BlkCn BT",sans-serif;font-size:12pt;color:red"></span></u></p>
<p style="background:none 0% 0% repeat scroll white;margin:0px;line-height:normal">
<span style="margin:0px;font-family:"Times New Roman",Times,serif;font-size:12pt;color:black">Embry-Riddle Aeronautical University - Daytona Beach - FL<br>
Ph.D. Candidate, Aerospace Engineering<br>
</span></p>
<p style="background:none 0% 0% repeat scroll white;margin:0px;line-height:normal">
<span style="font-family:"Times New Roman",Times,serif"></span><span style="margin:0px;font-family:"Times New Roman",Times,serif;font-size:12pt;color:black">M.Sc.</span><span style="margin:0px;font-family:"Times New Roman",Times,serif;font-size:12pt;color:black">
 Aerospace Engineering<br>
</span></p>
<p style="background:none 0% 0% repeat scroll white;margin:0px;line-height:normal">
<span style="font-family:"Times New Roman",Times,serif"></span><span style="margin:0px;font-family:"Times New Roman",Times,serif;font-size:12pt;color:black">B.Sc.</span><span style="margin:0px;font-family:"Times New Roman",Times,serif;font-size:12pt;color:black">
 Aerospace Engineering</span></p>
<p style="background:none 0% 0% repeat scroll white;margin:0px;line-height:normal">
<span style="font-family:"Times New Roman",Times,serif"></span><span style="margin:0px;font-family:"Times New Roman",Times,serif;font-size:12pt;color:black">B.Sc.</span><span style="margin:0px;font-family:"Times New Roman",Times,serif;font-size:12pt;color:black">
 Computational Mathematics</span></p>
<p style="background:none 0% 0% repeat scroll white;margin:0px;line-height:normal">
<span style="font-family:"Times New Roman",Times,serif"></span><span style="margin:0px;font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)"><br>
</span></p>
<span style="margin:0px;font-family:"Times New Roman",Times,serif;font-size:12pt;color:rgb(0,0,0)"></span><span style="margin:0px;font-family:"Times New Roman",Times,serif;font-size:12pt;color:black"></span>
<p style="background:none 0% 0% repeat scroll white;margin:0px;line-height:normal">
<span style="font-family:"Times New Roman",Times,serif"></span><u><span style="margin:0px;font-family:"Times New Roman",Times,serif;font-size:12pt;color:black">Phone:</span></u><span style="margin:0px;font-family:"Times New Roman",Times,serif;font-size:12pt;color:black">
 (386)-843-1829</span></p>
<p style="background:none 0% 0% repeat scroll white;margin:0px;line-height:normal">
<span style="font-family:"Times New Roman",Times,serif"></span><u><span style="margin:0px;font-family:"Times New Roman",Times,serif;font-size:12pt;color:black">Email(s):</span></u><span style="margin:0px;font-family:"Times New Roman",Times,serif;font-size:12pt;color:black">
 <a href="mailto:ferranj2@my.erau.edu" target="_blank">ferranj2@my.erau.edu</a></span></p>
<p style="background:none 0% 0% repeat scroll white;margin:0px;line-height:normal;text-indent:0.5in">
<span style="font-family:"Times New Roman",Times,serif"></span><span style="margin:0px;font-family:Courant;font-size:12pt;color:black"><span style="margin:0px;font-family:"Times New Roman",Times,serif">   
</span></span><span style="margin:0px;font-family:"Times New Roman",Times,serif;font-size:12pt;color:black"><a href="mailto:jesus.ferrand@gmail.com" target="_blank">jesus.ferrand@gmail.com</a></span></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

</div></blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><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>