<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: times new roman,new york,times,serif; font-size: 12pt; color: #000000'>Hello,<br><br>I have a short question about the code I need to modify.<br>As far as I understand, numCorner should be replaced by an array numCorners[numCells] containing the number of vertices of each cell.<br>The body of DMPlexBuildFromCellList_Private function becomes<br>---------------------------------------------------------------------------------------------------------------------------------------<br>ierr = DMPlexSetChart(dm, 0, numCells+numVertices);CHKERRQ(ierr);
<div> for (c = 0; c < numCells; ++c) {</div><div> ierr = DMPlexSetConeSize(dm, c, numCorners[c]);CHKERRQ(ierr);</div><div> }</div><div> ierr = DMSetUp(dm);CHKERRQ(ierr);</div><div> <br></div>
<div> for (c = 0; c < numCells; ++c) {<br> ierr = DMGetWorkArray(dm, numCorners, PETSC_INT, &cone);CHKERRQ(ierr);</div><div> for (p = 0; p < numCorners[c]; ++p) {</div><div> cone[p] = cells[c*numCorners[c]+p]+numCells;</div><div> }<br> ierr = DMRestoreWorkArray(dm, numCorners, PETSC_INT, &cone);CHKERRQ(ierr);<br></div><div> ierr = DMPlexSetCone(dm, c, cone);CHKERRQ(ierr);</div>
<div> }</div><div> </div><div> ierr = DMPlexSymmetrize(dm);CHKERRQ(ierr);</div><div> ierr = DMPlexStratify(dm);CHKERRQ(ierr);<br>------------------------------------------------------------------------------------------------------------------------------------------<br>However, I am not quite sure that DMGetWorkArray and DMRestoreWorkArray should be used like this.<br>I guess that DMRestoreWorkArray behaves like free function in ansi c but I am not sure.<br>Do you think that calling DMGetWorkArray and DMRestoreWorkArray inside a loop is a good thing from the point of view of computational time and memory management?<br><br>Note: the best way to do this may be to first sort cells by numCorners to avoid many calls to DMGetWorkArray and DMRestoreWorkArray. This is actually what I have in my own code but I would like to maintain Petsc's philosophy.<br><br>Thanks,<br><br>Cédric<br></div><br><br><br><br><br><hr id="zwchr"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>De: </b>"Matthew Knepley" <knepley@gmail.com><br><b>À: </b>"Cedric Doucet" <cedric.doucet@inria.fr><br><b>Cc: </b>petsc-users@mcs.anl.gov<br><b>Envoyé: </b>Vendredi 25 Octobre 2013 16:31:59<br><b>Objet: </b>Re: [petsc-users] DMPlexCreateFromCellList and hybrid meshes<br><br><div dir="ltr">On Fri, Oct 25, 2013 at 7:23 AM, Cedric Doucet <span dir="ltr"><<a href="mailto:cedric.doucet@inria.fr" target="_blank">cedric.doucet@inria.fr</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div style="font-size:12pt;font-family:'times new roman','new york',times,serif">
Hello,<br><br>I've noticed that DMPlexCreateFromCellList assumes that cells have the same number of vertices (numcorners argument).<br>What should be done when one wants to create a DMPlex from a mesh containing different types of cells?<br>
Does one have to create several DMPlex structures and merge them?<br>Does one have to create a unique DMPlex by hand?<br></div></div></blockquote><div><br></div><div>The code is very short:</div><div><br></div><div><div> ierr = DMPlexSetChart(dm, 0, numCells+numVertices);CHKERRQ(ierr);</div>
<div> for (c = 0; c < numCells; ++c) {</div><div> ierr = DMPlexSetConeSize(dm, c, numCorners);CHKERRQ(ierr);</div><div> }</div><div> ierr = DMSetUp(dm);CHKERRQ(ierr);</div><div> ierr = DMGetWorkArray(dm, numCorners, PETSC_INT, &cone);CHKERRQ(ierr);</div>
<div> for (c = 0; c < numCells; ++c) {</div><div> for (p = 0; p < numCorners; ++p) {</div><div> cone[p] = cells[c*numCorners+p]+numCells;</div><div> }</div><div> ierr = DMPlexSetCone(dm, c, cone);CHKERRQ(ierr);</div>
<div> }</div><div> ierr = DMRestoreWorkArray(dm, numCorners, PETSC_INT, &cone);CHKERRQ(ierr);</div><div> ierr = DMPlexSymmetrize(dm);CHKERRQ(ierr);</div><div> ierr = DMPlexStratify(dm);CHKERRQ(ierr);</div></div><div>
<br></div><div>This code is all in plexcreate.c. If you want different cells, you can change numCorners for each cell.</div><div>I could make a convenience form if necessary.</div><div><br></div><div> Matt</div><div> </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div style="font-size:12pt;font-family:'times new roman','new york',times,serif">
<br>Thank you very much for your help.<br><br>Cédric<br><br><br><br></div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>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>
</blockquote><br></div></body></html>