dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #05185
Re: operations on solution 'u'
On Tue, Jun 19, 2007 at 12:06:49AM +0200, Garth N. Wells wrote:
>
>
> Jake Ostien wrote:
> > Hi,
> >
> > I'd like to use a subset of the solution vector to calculate other
> > quantities. For example, if I have solved for the displacement field on
> > a 2D mesh, how can a get at the displacement in the x direction on a
> > subset of the mesh. I was think along the lines of populating a
> > std::vector<real> which contains u[0] for a subset (possibly a
> > SubDomain) of the mesh. What I can't figure out is how to access the
> > actual values of u[0] inside of DOLFIN.
>
> This is not supported directly. The best way to extract just the
> component to be used in other calculations is to project u[0] onto
> another Function, so the FFC form file should look something like
>
> element_u = VectorElement("triangle", 1)
> element_ux = FiniteElement("triangle", 1)
>
> v = TestFunction(element_ux)
> ux = TrialFunction(element_ux)
> u = Function(element_u)
>
> a = v*ux*dx
> L = v*u[0]*dx
>
> If you want the Function to act only in a subdomain, you could introduce
> a user-defined function using a DG0 basis and set it to one in the
> domain of interest, and zero elsewhere. Then multiply your problem by
> this function.
>
> Garth
This has been fixed so it should be possible to just do
Function u0 = u[0];
Function u1 = u[1];
in DOLFIN and then you can use u0 and u1 as you would any other scalar
Functions. For example, you should be able to plot them and use them
as coefficients in other PDEs. They will be Functions just as much as
the original u. (And won't share any data other than the mesh with
u. This has changed from previous versions of DOLFIN.)
/Anders
References