I am trying to understand how grid edges/faces are numbered internally (in order to set boundary conditions on the correct local external edges/faces with the xml domains/mesh_value_collection property). To test I have created a simple 2d xml test grid with six nodes and four triangles
<dolfin>
<mesh celltype="triangle" dim="2">
<vertices size="6">
<vertex index="0" x="0.0" y="0.0" z="0.0"/>
<vertex index="1" x="1.0" y="0.0" z="0.0"/>
<vertex index="2" x="0.0" y="1.0" z="0.0"/>
<vertex index="3" x="1.0" y="1.0" z="0.0"/>
<vertex index="4" x="0.5" y="0.0" z="0.0"/>
<vertex index="5" x="0.5" y="1.0" z="0.0"/>
</vertices>
<cells size="4">
<cell index="0" v0="0" v1="5" v2="2"/>
<cell index="1" v0="0" v1="4" v2="5"/>
<cell index="2" v0="4" v1="3" v2="5"/>
<cell index="3" v0="4" v1="1" v2="3"/>
</cells>
</mesh>
</dolfin>
http://imgur.com/a/35pFw
3---6---4
|\ |\ |
|1\2|3\4|
| \| \|
1---5---2
And after importing the grid into fenics and inspecting it with
from fenics import *
mesh = Mesh("test.xml")
print "\n cell connectivity:\n"
delements = dict((cell.index(), cell.entities(0)) for cell in cells(mesh))
for element in range(mesh.num_cells()):
print " " + repr(element+1) + " : " + str(delements[element]+1)
print "\n cell edges:\n"
dfacets = dict((facet.index(), facet.entities(0)) for facet in facets(mesh))
for facet in range(len(dfacets)):
print " " + repr(facet+1) + " : " + str(dfacets[facet]+1)
print "\n"
for cell in cells(mesh):
print " cell : " + repr(cell.index()+1)
dfacetsi = dict((faceti.index(), faceti.entities(0)) for faceti in facets(cell))
for faceti in range(len(dfacetsi)):
key = dfacetsi.keys()[faceti]
print " " + repr(key+1) + " : " + str(dfacetsi[key]+1)
results in
cell connectivity:
1 : [1 3 6]
2 : [1 5 6]
3 : [4 5 6]
4 : [2 4 5]
global edges [vertices]:
1 : [1 3]
2 : [1 5]
3 : [1 6]
4 : [2 4]
5 : [2 5]
6 : [3 6]
7 : [4 5]
8 : [4 6]
9 : [5 6]
this is all fine since I understand that the vertices are ordered with increasing vertex number. However, I cannot find the logic in how the edges are ordered on each cell
local cell and global edges [vertices]:
cell : 1
local edge 1: global edge 1 : [1 3]
local edge 2: global edge 3 : [1 6]
local edge 3: global edge 6 : [3 6]
cell : 2
local edge 1: global edge 9 : [5 6]
local edge 2: global edge 2 : [1 5]
local edge 3: global edge 3 : [1 6]
cell : 3
local edge 1: global edge 9 : [5 6]
local edge 2: global edge 7 : [4 5]
local edge 3: global edge 8 : [4 6]
cell : 4
local edge 1: global edge 4 : [2 4]
local edge 2: global edge 5 : [2 5]
local edge 3: global edge 7 : [4 5]
From reading the Fenics/Dolfin docs and manual I see that local edge 1 should be correlated with local vertices 2 and 3 (edge 2 with vertices 1 and 3 etc.). This does not seem to be the case here since for example cell 1 should have global edge ordering 6-3-1 not 1-3-6. Furthermore, for cells 2 and 3 the edges do neither seem to be ordered with increasing global edge numbering or respect the local edge 1 -> vertices2/3 relation at all.
Is there any clear reference where one can see how the local edges/faces will be ordered (after xml grid import)?