← Back to team overview

dolfin team mailing list archive

Re: ufc dof map

 

On Wed, Mar 14, 2007 at 11:02:15AM +0100, Garth N. Wells wrote:
> I want to add a function to DofMaps which returns the sparsity pattern, 
> but I'm struggling with the UFC interface. How can I get the dof map for 
>    a cell without creating a UFC object? I would like to do
> 
>    for (CellIterator cell(mesh); !cell.end(); ++cell)
>    {
>      dof_maps[0]->dof_map().tabulate_dofs(dofs, mesh, cell);
>    }
> 
> (I have added the function dof_map() to DofMap which returns its 
> ufc_dof_map.) The problem is that tabulate_dofs wants ufc::mesh and 
> ufc::cell, and not dolfin::Mesh and dolfin::Cell.
> 
> Garth

Yes, the UFC interface assumes its own data structures which can be
thought of as simple views of the corresponding DOLFIN data structures
(or other implementations).

So when you have a DOLFIN::Cell, you need to create a UFC::cell copy
of the data. This needs to be done frequently so I added a simple
utility for this. The class DOLFIN::UFCCell inherits from UFC::cell
and you can simply do:

    UFCCell ufc_cell(cell);

to create a UFC::cell from a DOLFIN::Cell.

To speed this up a little, you can first create the UFCCell and then
update it in the loop, so this would be

    UFCCell ufc_cell;
    for (CellIterator cell(mesh); !cell.end(); ++cell)
    {
        ufc_cell.update(*cell);

    }

For the mesh, you can just do

    UFCMesh ufc_mesh(mesh);

/Anders


References