On Fri, 30 Aug 2013 16:57:42 +0200
Jan Blechta <[email protected]> wrote:

> On Fri, 30 Aug 2013 15:47:28 +0100
> "Garth N. Wells" <[email protected]> wrote:
> 
> > The functions GenericDofmap::vertex_to_dof_map and
> > GenericDofMap::dof_to_vertex_map are not properly documented (the
> > doc string is the same for both), and I think that they are back to
> > front. The docstring in DofMap has inconsistencies. I would expect
> > that
> > 
> >     map0 =  GenericDofmap::vertex_to_dof_map(...)
> > 
> > would mean a map from vertex to dof, i.e.
> > 
> >     map0[vertex_index] -> dof index
> > 
> > and  that
> > 
> >     map1 =  GenericDofmap::dof_to_vertex_map(...)
> > 
> > would mean a map from dof index to
> > 
> >     map1[dof_index] -> vertex index
> > 
> > Tests (see below code) and the return types also indicate that
> > things are back to front. Can someone clarify the situation?
> 
> If you have some map defined on dofs, i.e. it returns whatever from
> dofs, for example Vector()[:], then composition with dof_to_vertex_map
> makes it a map on vertices (modulo dofs per vertex).

To make it clear

    u = Function(V)
    x = u.vector()
    values_on_vertices = x[dof_to_vertex_map]

for CG1 space values_on_vertices are x's values indexed by local vertex
numbers. For other spaces (where the concept has a meaning - I'm not
sure which are these) it should be indexed by

    local_vertex_index*dofs_per_vertex + i

for i = 0, ..., dofs_per_vertex-1

Jan

> 
> vertex_to_dof_map is just an inversion of dof_to_vertex_map.
> 
> Jan
> 
> > 
> > Garth
> > 
> > 
> > 
> > from dolfin import *
> > 
> > mesh = UnitSquareMesh(4, 4)
> > V = FunctionSpace(mesh, "Lagrange", 1)
> > 
> > dof_to_vertex = V.dofmap().dof_to_vertex_map(mesh)
> > vertex_to_dof = V.dofmap().vertex_to_dof_map(mesh)
> > 
> > for c in cells(mesh):
> >     print "Cell index:", c.index()
> > 
> >     # Get cell dofs
> >     dofs = V.dofmap().cell_dofs(c.index())
> >     print "  Cell dofs:", dofs
> > 
> >     # Get vertices from cell
> >     cell_vertices0 = sorted([v.index() for v in vertices(c)])
> >     print "  Cell vertex indices (from cell):", cell_vertices0
> > 
> >     # Get vertices from dof_to_vertex
> >     cell_vertices1 = sorted([dof_to_vertex[dof] for dof in dofs])
> >     print "  Cell vertex indices (from dof_to_vertex_map):",
> > cell_vertices1
> > 
> >     # Get vertices from vertex_to_dof_map
> >     cell_vertices2 = sorted([vertex_to_dof[dof] for dof in dofs])
> >     print "  Cell vertex indices (from vertex_to_dof_map):",
> > cell_vertices2 _______________________________________________
> > fenics mailing list
> > [email protected]
> > http://fenicsproject.org/mailman/listinfo/fenics
> 
> _______________________________________________
> fenics mailing list
> [email protected]
> http://fenicsproject.org/mailman/listinfo/fenics

_______________________________________________
fenics mailing list
[email protected]
http://fenicsproject.org/mailman/listinfo/fenics

Reply via email to