[petsc-users] Finding which cell an arbitrary point belongs to in DMPlex

Jeremy Theler jeremy at seamplex.com
Tue Sep 15 17:17:57 CDT 2020


On Mon, 2020-09-14 at 20:28 -0400, Matthew Knepley wrote:
> On Mon, Sep 14, 2020 at 6:15 PM Jeremy Theler <jeremy at seamplex.com>
> wrote:
> > Hello all
> > 
> > Say I have a fully-interpolated 3D DMPlex and a point with
> > arbitrary
> > coordinates x,y,z. What's the most efficient way to know which cell
> > this point belongs to in parallel? Cells can be either tets or
> > hexes.
> 
> I should make a tutorial on this, but have not had time so far.

Thank you very much for this mini-tutorial.

> 
> The intention is that you use
> 
>   
> https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DM/DMLocatePoints.html
> 
> This will just brute force search unless you also give
> 
>   -dm_plex_hash_location

Well, for a 3D DMplex PETSc (and git blame) tells me that you "have
only coded this for 2D." :-)


> which builds a grid hash to accelerate it. I should probably expose
> 
>   DMPlexLocatePoint_Internal()
> 
> which handles the single cell queries. If you just had one point,
> that might make it simpler,
> although you would still write your own loop.

I see that DMLocatePoints() loops over all the cells until it finds the
right one. I was thinking about finding first the nearest vertex to the
point and then sweeping over all the cells that share this vertex
testing for DMPlexLocatePoint_Internal(). The nearest node ought to be
found using an octree or similar. Any direction regarding this idea?


>  If your intention is to interpolate a field at these
> locations, I created
> 
>   
> https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/SNES/DMInterpolationCreate.html
> 
> which no one but me uses so far, but I think it is convenient.

Any other example apart from src/snes/tutorials/ex63.c?


Thank you.

> 
>   Thanks,
> 
>     Matt
>  
> > Regards
> > --
> > jeremy theler
> > www.seamplex.com
> > 
> > 
> 
> 
> 



More information about the petsc-users mailing list