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

Relationship between DOFS and Vertices for DG elements

+2 votes

I was wondering if the entries of dofmap.cell_dofs(cell.index()) correspond to the entries of dofmap.tabulate_coordinates(cell) for DG elements of order 1? In particular, is the following true?

from dolfin import *

mesh = UnitSquareMesh(10, 10)
V = FunctionSpace(mesh, "DG", 1)
dofmap = V.dofmap()

for cell in cells(mesh):
    verts = dofmap.tabulate_coordinates(cell)
    dofs = dofmap.cell_dofs(cell.index())
    for j in range(3):
        print "Does vertex ", verts[j], " correspond to DOF ", dofs[j]

If not, is there some way I can obtain a relationship between DOFs and vertices for this particular function space? What I need in particular is to be able to map DOFs of a cell T onto the DOFs of the translated cell T + n.h, where n is a positive integer, and h is the (uniform) mesh size.

Thanks for any help!

asked Apr 4, 2014 by radonnikodym FEniCS Novice (280 points)

1 Answer

+3 votes
 
Best answer

Yes, what you print is true.

If I understand correctly, then to map dofs on cells you need to locate the translated cell. For example

# Get cell 0 as an example
c0 = Cell(mesh, 0)
midpoint = c0.midpoint() # modpoint of cell 0
h = 1. / 10. # uniform mesh size

# Find translated cell c1 located 3*h to the right of c0
translated_point = Point(midpoint.x() + 3*h, midpoint.y())
tree = mesh.bounding_box_tree()
c1 = tree.compute_first_entity_collision(translated_point)
c1 = Cell(mesh, c1)

# Now these dofs of c0:
print dofmap.cell_dofs(c0.index())

# are located exactly 3*h to the left of these
print dofmap.cell_dofs(c1.index())

Note that this only works for the uniform mesh.

answered Apr 4, 2014 by mikael-mortensen FEniCS Expert (29,340 points)
selected Apr 4, 2014 by radonnikodym

I have indeed implemented the exact same code you mention, but I was unsure of the relationship between the DOFs at c0 and the DOFs at c1 in your code. Many thanks for confirming this!

...