← Back to team overview

dolfin team mailing list archive

Re: SubFunction

 



Kristian Oelgaard wrote:

Hello,

Given the new Function interface, is it possible to get a reference to the part
of the Function vector belonging to a SubFunction?


No.

GenericVector* U0 = &U[0].vector(); (this doesn't work)

I need to inspect the solution values in a Newton solve and set any negative
values to zero.


If you do

  Function U0 = U[0];

the Function U0 will have a copy of part of the vector that belongs to U, therefore changing the vector that belongs to U0 won't affect the vector that belongs to U.

Take a look inside

  Function::Function(const SubFunction& v)

to see how to determine which components of the vector are associated with a particular subspace. This way, you can work with the Function U directly.

Garth


Kristian
_______________________________________________
DOLFIN-dev mailing list
DOLFIN-dev@xxxxxxxxxx
http://www.fenics.org/mailman/listinfo/dolfin-dev




Follow ups

References