dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #26287
Re: DofMap.tabulate_vertex_map
On 01/28/2013 11:08 PM, Anders Logg wrote:
> On Mon, Jan 28, 2013 at 10:37:46PM +0100, Johan Hake wrote:
>> On 01/28/2013 10:22 PM, Anders Logg wrote:
>>> On Mon, Jan 28, 2013 at 10:10:40PM +0100, Johan Hake wrote:
>>>> Hello!
>>>>
>>>> I have now added a method to DofMap, which tabulate a map between
>>>> vertices and dofs. It will only work for DofMaps with dofs on vertices.
>>>> So basically for any CG 1 FunctionSpaces and will raise error else wise.
>>>>
>>>> Usage:
>>>>
>>>> from dolfin import *
>>>> import numpy as np
>>>> mesh = UnitSquareMesh(10,10)
>>>> V = VectorFunctionSpace(mesh, "CG", 1)
>>>> u = Function(V)
>>>> u.interpolate(Constant((1,2)))
>>>> vert_values = np.zeros(mesh.num_vertices()*2)
>>>> vert_values[V.dofmap().tabulate_vertex_map(mesh)] = \
>>>> u.vector().array()
>>>> print vert_values
>>>>
>>>> In parallel the map will follow the local dofs. This means that some
>>>> values in vert_values above will still be 0. The 0 values will then
>>>> correspond to vertex values which are owned by another process.
>>>>
>>>> In C++ the method returns a std::vector<std::size_t>.
>>>>
>>>> Questions:
>>>> Does the name "tabulate_vertex_map" work?
>>>
>>> Sounds ok.
>>>
>>>> Should a version of this method exist in other classes. FunctionSpace,
>>>> Function (without the mesh argument of course)?
>>>
>>> Yes, would be good to have for convenience.
>>>
>>> What is the relation to Function::compute_vertex_values?
>>
>> compute_vertex_values works on any GenericFunction. However, for all
>> Functions from CG 1 families I guess one could use this map to just
>> tabulate the entries.
>
> What does the tabulate_vertex_map method do which
> compute_vertex_values doesn't? Enable writing to dofs?
RTFC! ;)
tabulate_vertex_map only computes a map based on the prior knowledge of
the dofs coinciding with the vertices. compute_vertex_values are much
more general and used
element.interpolate_vertex_values
to do the heavy lifting.
I see tabulate_vertex_map as a convenience mapping for users who want
their data on a vertex based format, or users who want data which
resides on vertices into dolfin la structures.
Johan
Follow ups
References