Subject: [Ffc] Selection of element degree

From: Anders Logg <[email-masked]>
Date: Mon, 30 Nov 2009 21:08:54 +0100

We still haven't decided on the correct strategy for choosing the
degree of an unspecified element.

What we have now looks at the total degree of the form and then sets
the degree accordingly. This doesn't really work well and the reason
is quite simple: We can't figure out the total degree correctly if we
don't know the degree of the coefficient.

So my new suggestion is the following. We simply scan all elements in
the form with specified degrees and set the degree to the maximum
degree among the elements.

Here are some use cases:

1. v*f*dx

If v is an element of degree q, then the degree for the approximation
of f is set to q.

For quadrature elements, this means that we get a quadrature error in
the integral of order q + 1 which in many cases is the same as the
convergence of the finite element method.

For Lagrange elements, we get an interpolation error when
approximating f of degree q + 1 so the situation is the same.

2. v*f*g*dx

Same as above here if f and g have unspecified degrees. But if f or g
should happen to have a degree higher than q, than that degree will be
used for the other coefficient if unspecified.

I'll go ahead and make this change in FFC. It's rather easy to change
the strategy and FFC is being very verbose about the choices it makes,
at least until we have settled on an acceptable strategy.

--
Anders

---

From: Anders Logg <[email-masked]>
Date: Mon, 30 Nov 2009 21:58:19 +0100

This is now implemented. Watch out for the messages printed by FFC
during compilation:

  Adjusting element degree from ? to 3

Let me know you spot any cases where the degree selection does not
make sense.

Note that quadrature and tensor representation use different ways to
estimate the degree. For tensor representation, coefficients are
always interpolated so the integrand is always a polynomial.

Therefore, quadrature representation looks at the UFL function

  estimate_max_polynomial_degree

which now actually computes the maximum not degree (not the sum),
while tensor representation looks at the UFL function

  estimate_total_polynomial_degree

New versions of FFC and UFL needed.

--
Anders

> _______________________________________________
> Mailing list: https://launchpad.net/~ffc
> Post to     : [email-masked]
> Unsubscribe : https://launchpad.net/~ffc
> More help   : https://help.launchpad.net/ListHelp

---

From: "Garth N. Wells" <[email-masked]>
Date: Mon, 30 Nov 2009 23:01:59 +0000

Anders Logg wrote:
> the degree accordingly. This doesn't really work weoull and the reason

Or should it be the maximum degree of the test and trial functions?

Do you take into accout derivatives, e.g. for

  w*dot(grad(v), grad(u))*dx

would w be of the same order as v and u, or one order lower?

Garth

> For quadrature elements, this means thatd we get a quadrature error in
> ------------------------------------------------------------------------
>

---

From: Anders Logg <[email-masked]>
Date: Tue, 1 Dec 2009 00:07:56 +0100

> Or should it be the maximum degree of the test and trial functions?

Yes, that's basically what happens now. It looks at everything that
has a degree so it looks at the test and trial functions but also at
any coefficients that may happen to have a degree.

That's useful for say v*f*g*dx if one of f and g happen to have a
degree specified. Then the degree for the other needs to be the same.

> would w be of the same order as v and u, or one order lower?

Yes, derivatives are taken into account, but that's maybe not what we
want. In the above case, the results will be q = 1 for w coming from

  max((1, 0, 0))

The 1 comes from the default degree q = 1 used when estimating the
max degree for a form with an unknown coefficient.

Perhaps we should not look at derivatives at all when selecting the
quadrature degree?

--
Anders

---

From: Marie Rognes <[email-masked]>
Date: Tue, 01 Dec 2009 09:15:53 +0100

> degree specified. Then the degree for the other needs to be the same.

Why?

--
Marie

---

From: Anders Logg <[email-masked]>
Date: Tue, 1 Dec 2009 00:33:26 +0100

> >degree specified. Then the degree for the other needs to be the same.

Since that's how the generated quadrature code works. It loops over
quadrature points for an integrand and then it's useful if everything
in the integrand is evaluated at those points.

--
Anders

---

From: Marie Rognes <[email-masked]>
Date: Tue, 01 Dec 2009 09:41:04 +0100

> in the integrand is evaluated at those points.

Ok.

--
Marie

---

From: Anders Logg <[email-masked]>
Date: Tue, 1 Dec 2009 11:30:46 +0100

> >in the integrand is evaluated at those points.

I have made a new change of the selection strategy.

For quadrature, FFC now looks at the maximum degree of anything in the
form (including test and trial functions and coefficients).

For tensor representation, FFC first looks at the maximum degree to
select the degree but then looks at the total degree to select the
quadrature it uses at compile time.

I think this looks ok now and both FFC and UFL are ready for a new
release. There's still the bug fix Kristian is working on for using
quadrature elements for coefficients instead of Lagrange, but we
don't need to wait with the release.

FFC is still verbose about its selection of degrees so keep an eye on
what FFC prints during compilation and report any strange behavior.

--
Anders

---

From: "Garth N. Wells" <[email-masked]>
Date: Tue, 01 Dec 2009 10:36:42 +0000

> I have made a new change of the selection strategy.

Does the change in UFL affect the polynomial degree of the integrand as
computed by UFL?  I see that it's no longer taking into account
derivatives, so if v and u1 are P1, will UFL tell the form compiler that

   dot(grad(v), grad(u))

is zero-order or second-order?

> don't need to wait with the release.

OK.

> what FFC prints during compilation and report any strange behavior.

Yes, good to keep it on initially.

Garth

> Mailing list: https://launchpad.net/~dolfin
> Post to     : [email-masked]
> Unsubscribe : https://launchpad.net/~dolfin

---

From: Anders Logg <[email-masked]>
Date: Tue, 1 Dec 2009 11:57:26 +0100

> is zero-order or second-order?

It does now.

For the above case, the quadrature degree is chosen to

  2*(q - 1) = 2q - 2 = 0 for q = 1

There are still some problems when "Quadrature" is selected instead of
"Lagrange" for coefficients, but I need Kristian's help to sort that
out.

I expect we will need to modify the degree selection further when
people start using it.

--
Anders