dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #22907
Re: [Question #154756]: grad f evaluation
Question #154756 on DOLFIN changed:
https://answers.launchpad.net/dolfin/+question/154756
Status: Open => Answered
Johan Hake proposed the following answer:
Chaffra!
There are some distinctions you need to make:
1) DOLFIN Constants, Expressions and Functions
2) UFL Coefficients and math expressions
Constants and Expressions are spatial functions that can be evaluated at any
point. A Function is a function which is defined on a Finite element space,
given by its basis functions and a vector of expansion coefficients.
Evaluation of a Function is done by interpolation of the basis functions.
UFL provides a mathematical language to define integrals over spatial domains
of finite element functions. In its form the integral is purely abstract and
just destribe a set of operations. A Coefficient in UFL is just an abstract
representation which can not be evaluated at any spatial point, but should
only be used to described integrals within UFL. UFL integrals, or forms, can
be assembled over a specific domain (mesh) in DOLFIN to produce a scalar,
vector or matrix. A user need to provide a map of what the ufl Coefficients
whould represent, eg, a particular DOLFIN Constant.
In the python interface of DOLFIN we have let DOLIN Constant, Expression and
Function inherit from ufl.Coefficient. By this we automatically associate the
DOLFIN entity with the ufl Coefficient, and the user do not have to provide
the map. This means that eventhough these entities can be evaluated, they are
evaluated as DOLFIN objects. When you then take grad on a function:
f = Functions(V)
gf = grad(f)
you get a pure ufl enitity that cannot be evaluated, because the grad here
just represent an operation on f. The only way to actually evaluate grad(f) is
to project it (and ) to a Finite element space.
gf = project(grad(f))
gf is now a DOLFIN Function and can be evaluated:
gf(0)
In Python you can also do:
plot(grad())
But this involves a call to project behind the scenes.
Johan
On Friday April 29 2011 10:59:20 Chaffra wrote:
> Question #154756 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/154756
>
> Chaffra gave more information on the question:
> I guess I am a little confused about the way expressions get evaluated.
> It looks like Function and Expression objects do not call
> ufl.terminal.Terminal.evaluate. Where is their evaluation defined?
--
You received this question notification because you are a member of
DOLFIN Team, which is an answer contact for DOLFIN.