dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #23380
Re: [Question #158285]: grad f evaluation with C++
Question #158285 on DOLFIN changed:
https://answers.launchpad.net/dolfin/+question/158285
Status: Open => Answered
Anders Logg proposed the following answer:
On Fri, May 20, 2011 at 03:25:47AM -0000, James Avery wrote:
> New question #158285 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/158285
>
> In https://answers.launchpad.net/dolfin/+question/154756 , Chaffra is told to obtain a vector valued finite element function corresponding to the gradient of the function f by writing
>
> gf = project(grad(f)).
>
> This yields a DOLFIN FE-function using the Python dolfin.fem.project function. I need to do the very same thing, but from C++, and am having trouble finding the corresponding functionality. Even a recursive, case insensitive grep for 'project' of /usr/include/dolfin yields nothing. Which leads me to my question:
>
> How does one efficiently obtain the derivatives of a calculated finite-element function when working with DOLFIN from C++?
>
> Thank you very much in advance.
You need to create a .ufl form file where you define the variational
problem for the projection:
# Projection from V to W
V = FiniteElement(...)
W = VectorElement(...)
u = TrialFunction(W)
v = TestFunction(W)
f = Function(V)
a = inner(u, v)*dx
L = inner(grad(f), v)*dx
Then use this in the normal way with VariationalProblem in C++.
--
Anders
--
You received this question notification because you are a member of
DOLFIN Team, which is an answer contact for DOLFIN.