dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #17256
Re: GenericVector assignment in PyDOLFIN
On Saturday 23 January 2010 08:42:14 Garth N. Wells wrote:
> Is it correct that behind the scenes that
>
> U0 = Function(V)
> U = Function(V)
> U0.vector()[:] = U.vector()[:]
>
> involves a GenericVector::get(..) call and a GenericVector::set(..)
> call? If so, it isn't ideal since it introduces unnecessary new/delete
> operations and unnecessary copying of data.
None of GenericVector::get(..) or GenericVector::set(..) are invoked, see
__getslice__ and __setslice__ in la_post.i.
U0.vector()[:]
involves
GenericVector::operator =(..)
and
U.vector()[:]
involves
GenericVector::copy()
However the latter is unnecessary as you instead can do:
U0.vector()[:] = U.vector()
invoking the assignment operator of U0's vector with U's vector.
Johan
Follow ups
References