dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #18625
Re: Function::Vector()
On Thu, Jun 17, 2010 at 08:23:56PM +0200, Mehdi wrote:
> On Thu, 2010-06-17 at 11:13 +0200, Mehdi wrote:
> > 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?
>
> What about using ">" instead of "!=" in the check?
>
> if (_vector->size() > _function_space->dofmap().global_dimension())
>
> While this prevent us form having access to the underlying non-const
> vector of sub function, it allows me to have access to the underlying
> vector when the function space is updated.
>
> Yours,
> Mehdi
I think the check could be improved. Garth?
--
Anders
Attachment:
signature.asc
Description: Digital signature
Follow ups
References