firedrakeproject / firedrake

Firedrake is an automated system for the portable solution of partial differential equations using the finite element method (FEM)
https://firedrakeproject.org
Other
516 stars 160 forks source link

Degree is not assumed when assembling a form with Quadrature elements on quadrilateral meshes. #1954

Open pbrubeck opened 3 years ago

pbrubeck commented 3 years ago

The following snippet tries to assemble the simplest linear form with Quadrature elements on a quadrilateral mesh, throwing ValueError: Mismatch of quadrature points!:

from firedrake import *
mesh = UnitSquareMesh(1,1,quadrilateral=True)
element = FiniteElement("Quadrature", mesh.ufl_cell(), 
        degree=2, quad_scheme="default")
Q = FunctionSpace(mesh, element)
q = TestFunction(Q)
Bq = assemble(q*dx)

The code runs fine if quadrilateral=False. In order to have consistent behaviour in the quadrialteral case, the degree must also be assumed from the Quadrature element.

wence- commented 3 years ago

What is the right thing to do here? If one of the coefficients is on a quadrature element, should we short-circuit degree estimation and always just use that as the quad-rule?

What is happening is that I think that we're estimating the degree as 2, but then somehow constructing different quadrature rules down two different codepaths (not sure how exactly) when coming to compile the code in tsfc.