← Back to team overview

dolfin team mailing list archive

Function::Vector()

 

Hello,

We have constant and non-constant versions for Function::Vector(). The
non-constant one has a check to prevent us having access to non-constant
vector from a sub-function. 

GenericVector& Function::vector()
{
  // Check that this is not a sub function.
  if (_vector->size() != _function_space->dofmap().global_dimension())
  {
    cout << "Size of vector: " << _vector->size() << endl;
    cout << "Size of function space: " <<
_function_space->dofmap().global_dimension() << endl;
    error("You are attempting to access a non-const vector from a
sub-Function.");
  }
  return *_vector;
}

Do we really need to have this check?

If so, I don't think comparing vector size and global dimension of
function space is proper check for this purpose.  How this check can be
improved to just perform what we expect? 

Since it prevents a user to extract underlying vector and resize it,
when the underlying function space has been updated because of new
degrees of freedom.

Mehdi




Follow ups