Dag Lindbo skrev den 09/04-2008 følgende:
Dag Lindbo wrote:
Ola Skavhaug wrote:
Dag Lindbo skrev den 09/04-2008 følgende:
Hello again!
Why is it not possible any longer to get the Vector associated with
a Function? E.g:
#include <dolfin.h>
using namespace dolfin;
int main()
{
Function u;
Vector& v = u.vector();
}
int main()
{
Function u;
Vector v;
v = u.vector();
return 0;
}
Should work. A Function returns a GenericVector reference, and the Vector
reference needs to be a Vector. Then the operator= in Vector is
applied in the
assignment.
Ola
Ola,
Sorry if I'm this is a stupid/incorrect observation. What you propose
is a a deep copy of the vector. So something like
uBlasVector& vv = *(v.instance());
vv[0] = 1000.32;
has no impact on the data owned by u. uBlas only has deep copy
semantics, which are invoked in dolfin::Vector::operator= (i.e. *vector
= *x; )
Is this really what we want?
/Dag
Seems I'm also sloppy with grammar today. My previous post may sound
offensive towards Ola, but I only meant to pre-excuse _myself_ in case
my understanding of C++ has deserted me this evening. /Dag
No offence taken :) My point was simply that since the underlying
GenericVector is not a Vector, the lines:
Function u;
Vector& v = u.vector();
does not work. But the compiler told you that already. Do you want a method
for rebinding the DefaultVector* vector attribute of Vector? That way, the
deep copy will be avoided.
Ola