← Back to team overview

dolfin team mailing list archive

DiscreteFunction::interpolate vs UFC interpolate_vertex_values definition

 

I've been debugging some boundary condition trouble with the
syfi/pydolfin combination and vector elements, and narrowed it down to
the interpolate function which is used prior to plotting.

The bug is in the assumed numbering of the vertex_values array as
returned by ufc::finite_element::interpolate_vertex_values:

void DiscreteFunction::interpolate(real* values) const
{
...

    // Copy values to array of vertex values
    for (VertexIterator vertex(*cell); !vertex.end(); ++vertex)
      for (uint i = 0; i < scratch->size; ++i)
        values[i*mesh.numVertices() + vertex->index()] =
vertex_values[i*num_cell_vertices + vertex.pos()];


By the UFC definition this should've been:

vertex_values[vertex.pos()*scratch->size + i];

i.e. the vector components are collected together in memory for each
vertex. This bug must be mirrored in FFC, and should be fixed both
places at once.

I'll let someone with write access to FFC and DOLFIN fix it.

--
Martin


Follow ups