dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #16907
Re: [Question #92245]: Gradients and SubFunctions
Question #92245 on DOLFIN changed:
https://answers.launchpad.net/dolfin/+question/92245
Status: Open => Answered
Garth Wells proposed the following answer:
There are two ways of creating a sub-function.
1: Function u0 = U[0];
This will make a deep copy of data. The Function u0 will have its own
vector which will contain only the coefficients for the first sub-
function (sub-function zero). This vector belonging to u0 is independent
of that which belongs to U, i.e. if U changes, u0 will not and vice-
versa.
2: Function& v0 = U[0];
This will make a shallow copy of some data, i.e. v0 and U will share data. The Function v0 will share the vector belonging to U, and this vector contains all the coefficients for U and not just for v0. The Function u0 will have its own DofMap.
If the Function U changes, then so will v0.
It is not possible to assign values to a sub-function. You can assign
values to u0, because it is effectively a Function, but assigning values
to u0 will not change U. You cannot assign values to v0 (or it is a
least untested).
--
You received this question notification because you are a member of
DOLFIN Team, which is an answer contact for DOLFIN.