Exactly, and also SubFunction to SubFunction: w[0] = v[1];
Then I could extract a row from a tensor field: v[0] = A[3]; v[1] = A[4]; v[2] = A[5]; Martin 2009/3/21 Anders Logg <[email protected]>: > On Sat, Mar 21, 2009 at 08:53:55PM +0100, Martin Sandve Alnæs wrote: >> I want to do the opposite, assign to a subfunction. > > You mean things like > > w[0] = u; > w[1] = p > > w[0][0] = ux; > w[0][1] = uy; > > ? > > That can be implemented. The indexing operator [] returns an object of > class SubFunction which is a temporary object holding a reference to > the Function (here w) and the component (stored as std::vector<uint>). > > The constructor for Function is overloaded so that one may > assign a SubFunction to a Function: > > u = w[0]; > > We could also overload the constructor for SubFunction to > allow the opposite: > > w[0] = u; > > While we're at it, we should also move the implementation to the > assignment operator in both cases and call the assignment operator in > the copy constructor to avoid duplication of code. > > -- > Anders > > >> 2009/3/21, Anders Logg <[email protected]>: >> > On Sat, Mar 21, 2009 at 05:05:53PM +0100, Martin Sandve Alnæs wrote: >> >> Hi, >> >> now that we can use tensor elements in dolfin through UFL, >> >> what would be the easiest way to extract a row of a tensor >> >> field (Function over a TensorElement) as a vector field? >> >> I think scalar subcomponents can easily be extracted, >> >> but is it possible to piece these together to a vector field? >> >> Something like: >> >> >> >> Function v(V); >> >> Function a = A[0]; >> >> Function b = A[1]; >> >> v[0] = a; >> >> v[0] = b; >> > >> > I don't understand. What is A and what dimension does v have? >> > >> > We already have some support for this. For any mixed space one may >> > extract sub spaces and sub functions. Here's the favorite Stokes >> > example: >> > >> > (W = V + Q) >> > >> > Function w(W); >> > >> > Function u = w[0]; // u vector-valued with d components >> > Function p = w[1]; // p scalar >> > >> > Function ux = u[0]; // ux scalar >> > Function uy = u[1]; // uy scalar >> > >> > >> > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.9 (GNU/Linux) > > iEYEARECAAYFAknFaV4ACgkQTuwUCDsYZdGMXACeLFbnf05laT2tMy9r0wmRBp0S > l8EAn1axkiq9n+SQlXZwYTCJPCU/ll/w > =TwD2 > -----END PGP SIGNATURE----- > > _______________________________________________ > DOLFIN-dev mailing list > [email protected] > http://www.fenics.org/mailman/listinfo/dolfin-dev > > _______________________________________________ DOLFIN-dev mailing list [email protected] http://www.fenics.org/mailman/listinfo/dolfin-dev
