fenics team mailing list archive
-
fenics team
-
Mailing list archive
-
Message #01018
Re: misleading message with interpolate?
On Fri, Jun 25, 2010 at 08:53:55AM +0200, Anders Logg wrote:
> On Thu, Jun 24, 2010 at 05:57:57PM -0500, Douglas Arnold wrote:
> > If we run this simple program, which interpolates the quadratic x*y
> > onto a mesh of the unit square and then integrate it, it gives
> > the exact answer .25. This is not surprising, but the warning
> > message
> >
> > Automatic selection of expression element: <CG? on a <? of degree 1>>
> >
> > is. What does the "degree 1" refer to. I interpreted it to be warning
> > me that the expression was interpolated into the P1 element space, but
> > that cannot be correct, since then I would not have gotten the exat
> > integral.
> >
> > Code:
> >
> > from dolfin import *
> > mesh = UnitSquare(4,4)
> > V = FunctionSpace(mesh,'CG',2)
> > f = interpolate(Expression("x[0]*x[1]"),V)
> > print(assemble(f*dx, mesh=mesh))
> >
> >
> > Output:
> >
> > Warning: Converting real-valued parameter to double, might loose precision.
> > Automatic selection of expression element: <CG? on a <? of degree 1>>
> > Warning: Converting real-valued parameter to double, might loose precision.
> > 0.25
>
> Degree 1 means here the degree of the mapping of the geometry (which
> is almost always 1). It's there in UFL to enable higher order
> (isoparametric) mapping.
>
> The ? means that DOLFIN does not know the appropriate polynomial
> degree of the function space at the time the message is written. The
> degree is selected later by the form compiler. This is more of a debug
> message that was introduced when we implemented the automatic
> selection (to remove the need for the V=V argument).
>
> I've removed that output now. What would be more interesting would be
> for the form compiler to print the degree it selects. It does print
> that but it gets lost somewhere in the communication between DOLFIN
> and FFC. I'll see if it can be fixed.
I looked a bit more at this.
To get more information from the form compiler, set the following parameter:
parameters["form_compiler"]["log_level"] = DEBUG
Then look for "Adjust element..." in the output.
With your script above (a bit modified)
from dolfin import *
parameters["form_compiler"]["log_level"] = DEBUG
mesh = UnitSquare(4,4)
V = FunctionSpace(mesh,'CG',2)
f = interpolate(Expression("x[0]*x[1]"),V)
no elements need to be adjusted since DOLFIN will just evaluate x*y at
the nodal points to get the dofs.
But if we change the last line to
f = project(Expression("x[0]*x[1]"),V)
then DOLFIN will need to compute an integral containing x*y and then
it needs to know how to approximate x*y in that integral. The output
is now
Adjusting element degree from ? to 2
Adjusting element cell from <? of degree 1> to <triangle of degree 1>.
So FFC figures out it should approximate x*y with piecewise quadratics
which happens to be correct in the above case. Try other expressions
and see what happens.
--
Anders
Attachment:
signature.asc
Description: Digital signature
References