dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #18569
Re: Function::Vector()
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
>
> 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
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~dolfin
> Post to : dolfin@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~dolfin
> More help : https://help.launchpad.net/ListHelp
Follow ups
References