← Back to team overview

dolfin team mailing list archive

Re: Function

 

On Thu, Nov 10, 2005 at 04:48:57PM +0100, Johan Jansson wrote:

> The overhead of subclassing is that you have to use virtual functions,
> and that means that every function call becomes a little more
> expensive (the call has to figure out which subclass the function call
> should go to). So if you have many function calls where each call does
> very little, this overhead could become significant.
> 
> But perhaps we don't have so many function calls in this case. I was
> under the impression that we had a Function for each component for
> vector-valued functions, but that's not true. So it's probably an ok
> solution.

The typical call to a Function during assembly is interpolate(), which
does something like

    real* xvals = _x->array();
    _element->dofmap(local.dofs, cell, mesh);
    for (uint i = 0; i < _element->spacedim(); i++)
      coefficients[i] = xvals[local.dofs[i]];
    _x->restore(xvals);

In addition, Function::interpolate() already needs to check the type
of function (discrete function or user-defined), so the overhead is
probably minimal.

/Anders



References