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

Matthew Knepley knepley at gmail.com
Tue Sep 15 18:44:57 CDT 2020


On Tue, Sep 15, 2020 at 6:18 PM Jeremy Theler <jeremy at seamplex.com> wrote:

> 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." :-)
>

Crap. I need to do 3D. It's not hard, just work.


> > 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?
>

So you can imagine both a topological search and a geometric search.
Generally, people want geometric.
The geometric hash we use is just to bin elements on a regular grid.


> >  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?
>

That is the only one in PETSc. The PyLith code uses this to interpolate to
seismic stations.

  Thanks,

     Matt


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

-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20200915/4cb55f76/attachment.html>


More information about the petsc-users mailing list