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

Is there an analog of dofmap.cell_dofs(cell.index()) for facets?

+1 vote

Having constructed a dofmap from a FunctionSpace the global dof indices can be obtained of any cell "cell" by using dofmap.cell_dofs(cell.index()).

Is there an analog of dofmap.cell_dofs(cell.index()) for facets, i.e. dofmap.facet_dofs(facet_index())? How can it be constructed in an efficient way?

asked Jan 20, 2014 by monien FEniCS Novice (790 points)
edited Jan 20, 2014 by monien

1 Answer

0 votes

That would not be well defined for an arbitrary function space (consider DG spaces for example). However, for other spaces I guess you could define it through something like this (not very effective though):

from dolfin import *

mesh = UnitCubeMesh(4,4,4)
mesh.init(3,2)
V = FunctionSpace(mesh, "CG", 2)
D = mesh.topology().dim()

dm = V.dofmap()
facet_dofs = [None]*mesh.num_facets()

for cell_idx in xrange(mesh.num_cells()):
    cell = Cell(mesh, cell_idx)

    facets = cell.entities(D-1)
    for local_facet_idx, global_facet_idx in enumerate(facets):
        local_facet_dofs = dm.tabulate_facet_dofs(local_facet_idx)
        facet_dofs[global_facet_idx] = dm.cell_dofs(cell_idx)[local_facet_dofs]

print facet_dofs
answered Jan 20, 2014 by Øyvind Evju FEniCS Expert (17,700 points)
...