← Back to team overview

dolfin team mailing list archive

Re: Extracting vector field from a tensor field

 

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 <logg@xxxxxxxxx>:
> > 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
> >
> >
> 

Attachment: signature.asc
Description: Digital signature


Follow ups

References