This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

find intersected cells of a mesh

+1 vote

Hi all,

I had a question when i do something about updating the mesh function. I found that for some case, I can not find the intersection cell for some given point with the intersected_cell call. I used my own mesh and for some point inside the mesh domain,

a=Point(0.8023355,0.931834,0.7110645)
mesh.intersected_cell(a)

this return -1, which mean there is no intersected cell found for that point. I did not understand why it would happen? Meanwhile, truncate the number a little bit,

a=Point(0.8,0.93,0.711)
mesh.intersected_cell(a)

then a index of cell is returned. Any suggestion about what is going on here? Further, is there a way to guarantee to find the intersected cell? Thanks a lot.

asked Sep 3, 2013 by jying FEniCS User (2,020 points)
edited Sep 4, 2013 by jying

What dolfin version are you using? Could you provide a mesh to replicate the error?

Did you move/smooth mesh before searching an intersection? If yes, you need to call

 mesh.intersection_operator().clear()

before intersection queries.

I used fenics1.2 and I did nothing else before seaching an intersection. I would like to provide the mesh I used. How to do that since I did not find how to attach a file to the web? Actually, it did not produce any error and just cannot find an intersected cell.

Ok, I upload the mesh file already. You can download at http://www.fileswap.com/dl/R1QVh3tZ9/
and then try it. Thanks

You could initialize IntersectionOperator with kernel_type='ExactPredicates'. Note that collision algorithms have been implemented directly into DOLFIN in current development version to get rid of dependency on CGAL library. Currently it suffers from similar issue.

Still cannot find the intersected cell. can you show how to do that?Thanks

1 Answer

+1 vote

Use 'ExactPredicates' CGAL geometry kernel.

from dolfin import *
mesh = Mesh('ion.pqr.xml')
mesh.intersection_operator().reset_kernel('ExactPredicates')

print mesh.intersected_cell(Point(0.8023355,0.931834,0.7110645))
print mesh.intersected_cell(Point(0.8,0.93,0.711))

Output:

15197
0
answered Sep 5, 2013 by Jan Blechta FEniCS Expert (51,420 points)
...