Skip to content

Reduce the estimated degree only on simplex cells - #506

Merged
jorgensd merged 2 commits into
FEniCS:mainfrom
firedrakeproject:pbrubeck/reduce-degree-on-simplex-only
Aug 24, 2026
Merged

Reduce the estimated degree only on simplex cells#506
jorgensd merged 2 commits into
FEniCS:mainfrom
firedrakeproject:pbrubeck/reduce-degree-on-simplex-only

Conversation

@pbrubeck

@pbrubeck pbrubeck commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

The problem

_reduce_degree() lowers the degree by one for each derivative. Its docstring
says that it does not do this when tensor product elements or quadrilateral
elements are involved. The code does not agree with the docstring. It tests the
name of the cell against quadrilateral and hexahedron only. A tensor product
cell has the name quadrilateral * interval, which is not in that list. UFL
therefore lowers the degree on a tensor product cell.

A derivative lowers the degree in one direction only. On a cell that is not a
simplex, the degree is a degree for each direction. The degree for each
direction therefore stays the same. To lower it gives a rule that is too coarse.

Prism cells and pyramid cells have the same problem.

The change

_reduce_degree() now lowers the degree only on a simplex cell. This is the
behaviour that the docstring describes.

Rules on prism cells and on pyramid cells become finer. Rules on simplex cells,
on quadrilateral cells and on hexahedron cells do not change.

Effect

Firedrake gives an element on a tensor product cell a degree for each direction.
The numbers below also need a change in FIAT, which makes
TensorProductElement.embedded_superdegree give the degree for each direction.
This pull request on its own does not change them.

Before that pair of changes, a Q7 space on a quadrilateral * interval cell got a
quadrature rule of degree 29, which has 3375 points. After this change, the same
space gets a rule of degree 17, which has 729 points. The rule with 729 points
integrates the form to machine precision.

form points before points after flops before flops after
Q7 inner(grad(u), grad(v))*dx 3375 729 33,516,981 15,941,187
NCE7 inner(curl(u), curl(v))*dx 3375 729 253,603,812 115,918,062

Each matrix agrees with a rule of degree 32 to machine precision.

Tests

test_tensor_product_degree_estimation puts a Lagrange element of degree 7 on a
quadrilateral * interval cell. It shows that a derivative does not lower the
degree. The test fails before this change, with a degree of 6 in place of 7.

AI declaration: written with Claude Code (Claude Opus 5).

A derivative lowers the polynomial degree in one direction only. On a cell
that is not a simplex the degree is a degree for each direction, so that
degree stays the same.

The docstring of _reduce_degree already says that it does not lower the
degree for tensor product or quadrilateral elements. The test only compared
the cell name against quadrilateral and hexahedron, so it missed tensor
product, prism and pyramid cells.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@jorgensd
jorgensd added this pull request to the merge queue Aug 24, 2026
Merged via the queue into FEniCS:main with commit f2d6fec Aug 24, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants