← Back to team overview

dolfin team mailing list archive

Re: [Question #144411]: How do I compute the distance from a cell to a given point?

 

Question #144411 on DOLFIN changed:
https://answers.launchpad.net/dolfin/+question/144411

    Status: Open => Answered

Andre Massing proposed the following answer:
Den 07.02.11 02.42, skrev James Avery:
> New question #144411 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/144411
>
> Dear all,
>
> For refinement reasons, I need to compute the distances from each cell in the mesh to each of a number of points.
>
> Ideally, I would like:
>
>   cell.distance(point) = 0 iff point is contained in the cell or on the border, and
>   cell.distance(point) = min{ dist(x,point) | x \in cell }, that is the smallest distance to the nearest face, if point is outside the cell.
>
> I have not been able to find this functionality in the documentation; is there a quick and easy way to do this? In theory, I can write this myself for tetrahedra, but it gets a bit messy, and I don't want to reinvent the deep plate, if the functionality or part of it already exists.
>
> Thanks very much in advance!

Do you need that functionality in 3D for tetrahedrons?
Otherwise you have probably already discovered the
std::pair<Point, dolfin::uint> closest_point_and_cell(const Point& 
point) const

member function of the mesh class?

This functionality for 3D is not yet implemented since some 
functionality is missing in the computational geometry library CGAL 
which we rely on. It is on the (my) TODO list, but I don't think I have 
time to implement it before the 0.9.10 release (which will be next 
week?). I remember vaguely CGAL needs also some function to compute the 
distance from a point to a tetrahedon, but I can provide you some more 
precise pointer if you interested to supply the missing functionality it 
yourself.

Cheers,
Andre


>
>


-- 
André Massing       		email: massing@xxxxxxxxx
Ph.D. student			mobile: +47 469 57 401
Simula Research Laboratory
NO-1367 Fornebu, Norway

You received this question notification because you are a member of
DOLFIN Team, which is an answer contact for DOLFIN.