← Back to team overview

dolfin team mailing list archive

Re: Function::Vector()

 



On 28/06/10 11:15, Anders Logg wrote:
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?


I'll take a look. What's needed is a thorough examination of Function for adaptive methods.

Garth

--
Anders



_______________________________________________
Mailing list: https://launchpad.net/~dolfin
Post to     : dolfin@xxxxxxxxxxxxxxxxxxx
Unsubscribe : https://launchpad.net/~dolfin
More help   : https://help.launchpad.net/ListHelp



References