dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #05178
Re: operations on solution 'u'
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
Of course I can write the
solution to a file, but I am trying to avoid that post-processing step.
I have found lots of useful hooks for looking at the reference mesh, but
not for the solution (and I guess for Functions in general).
Thanks for any help.
-Jake
_______________________________________________
DOLFIN-dev mailing list
DOLFIN-dev@xxxxxxxxxx
http://www.fenics.org/mailman/listinfo/dolfin-dev
Follow ups
References