<div dir="ltr">For functions like this (only for one impl), should this new check be considered new best practices (as opposed to the composition approach, defining things with names like DMDASetUniformCoordinates_DMDA())? It seems like less boilerplate, as well as avoiding a function on the stack (and the check itself if it's turned off in optimized mode).</div><div class="gmail_extra"><br><div class="gmail_quote">2018-04-28 22:38 GMT+02:00 Smith, Barry F. <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Added runtime error checking for such incorrect calls in barry/dmda-calls-type-check<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
> On Apr 28, 2018, at 9:19 AM, Matthew Knepley <<a href="mailto:knepley@gmail.com">knepley@gmail.com</a>> wrote:<br>
> <br>
> On Sat, Apr 28, 2018 at 2:08 AM, Danyang Su <<a href="mailto:danyang.su@gmail.com">danyang.su@gmail.com</a>> wrote:<br>
> Hi All,<br>
> <br>
> I use DMPlex and need to get coordinates back after distribution. However, I always get segmentation violation in getting coords values in the following codes if using multiple processors. If only one processor is used, it works fine.<br>
> <br>
> For each processors, the off value starts from 0 which looks good. I also tried 0-based index, which gives the same error. Would any one help to check what is wrong here?<br>
> <br>
> idof 1 off 0<br>
> idof 2 off 0<br>
> idof 1 off 2<br>
> idof 2 off 2<br>
> idof 1 off 4<br>
> idof 2 off 4<br>
> idof 1 off 6<br>
> idof 2 off 6<br>
> idof 1 off 8<br>
> idof 2 off 8<br>
> <br>
> <br>
> DM :: distributedMesh, cda<br>
> Vec :: gc<br>
> PetscScalar, pointer :: coords(:)<br>
> PetscSection :: cs<br>
> <br>
> ...<br>
> <br>
> call DMGetCoordinatesLocal(dmda_<wbr>flow%da,gc,ierr)<br>
> CHKERRQ(ierr)<br>
> <br>
> call DMGetCoordinateDM(dmda_flow%<wbr>da,cda,ierr)<br>
> CHKERRQ(ierr)<br>
> <br>
> call DMGetDefaultSection(cda,cs,<wbr>ierr)<br>
> CHKERRQ(ierr)<br>
> <br>
> call PetscSectionGetChart(cs,<wbr>istart,iend,ierr)<br>
> CHKERRQ(ierr)<br>
> <br>
> !c get coordinates array<br>
> call DMDAVecGetArrayF90(cda,gc,<wbr>coords,ierr)<br>
> <br>
> You cannot call DMDA function if you have a DMPlex. You jsut call VecGetArrayF90()<br>
> <br>
> Matt<br>
> <br>
> CHKERRQ(ierr)<br>
> <br>
> do ipoint = istart, iend-1<br>
> <br>
> call PetscSectionGetDof(cs,ipoint,<wbr>dof,ierr)<br>
> CHKERRQ(ierr)<br>
> <br>
> call PetscSectionGetOffset(cs,<wbr>ipoint,off,ierr)<br>
> CHKERRQ(ierr)<br>
> <br>
> inode = ipoint-istart+1<br>
> <br>
> if (cell_coords == coords_xyz) then<br>
> nodes(inode)%x = coords(off+1)<br>
> nodes(inode)%y = coords(off+2)<br>
> nodes(inode)%z = coords(off+3)<br>
> else if (cell_coords == coords_xy) then<br>
> nodes(inode)%x = coords(off+1)<br>
> nodes(inode)%y = coords(off+2)<br>
> nodes(inode)%z = 0.0d0<br>
> else if (cell_coords == coords_yz) then<br>
> nodes(inode)%x = 0.0d0<br>
> nodes(inode)%y = coords(off+1)<br>
> nodes(inode)%z = coords(off+2)<br>
> else if (cell_coords ==coords_xz) then<br>
> nodes(inode)%x = coords(off+1)<br>
> nodes(inode)%y = 0.0d0<br>
> nodes(inode)%z = coords(off+2)<br>
> end if<br>
> end do<br>
> <br>
> call DMDAVecRestoreArrayF90(cda,gc,<wbr>coords,ierr)<br>
> CHKERRQ(ierr)<br>
> <br>
> Thanks,<br>
> <br>
> Danyang<br>
> <br>
> <br>
> <br>
> <br>
> <br>
> -- <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<br>
> <br>
> <a href="https://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">https://www.cse.buffalo.edu/~<wbr>knepley/</a><br>
<br>
</div></div></blockquote></div><br></div>