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

is that possible to identify a facet by its vertices?

0 votes

Hello!

is that possible to identify a facet by its vertices?

thank you in advance.
Fotini

asked Sep 3, 2014 by fotini.karakatsani FEniCS Novice (500 points)
edited Sep 3, 2014 by fotini.karakatsani

Please rephrase the title as a question.

1 Answer

0 votes

Hi, if you plan to refer to vertices by their index then you could use the following map

from dolfin import *

mesh = UnitSquareMesh(10, 10)
tdim = mesh.topology().dim()

# Init connectivity from facets to vertices
mesh.init(tdim-1, 0)

# Custom dictionary that always looks up sorted key
class MyDict(dict):
    def get(self, key):
        return dict.get(self, sorted(key))

v_2_f = MyDict((tuple(facet.entities(0)), facet.index())
             for facet in facets(mesh))

print v_2_f[(5, 4)]  
answered Sep 3, 2014 by MiroK FEniCS Expert (80,920 points)
...