It’s not clear what’s going on from the given code, but the “Mismatch of quadrature points!” error usually occurs when a Form
's integrand involves a Function
in a "Quadrature"
-type FunctionSpace
, but the Form
is integrated with a different quadrature degree than that of the "Quadrature"
-type Function
. To clarify, here is an annotated snippet of code to illustrate:
from dolfin import *
from ufl.algorithms.compute_form_data \
import estimate_total_polynomial_degree
# Set up a quadrature function space:
mesh = UnitIntervalMesh(1)
q_deg = 3
print("Degree of quadrature element: "+str(q_deg))
Qe = FiniteElement("Quadrature", mesh.ufl_cell(),
degree=q_deg,
quad_scheme="default")
Q = FunctionSpace(mesh, Qe)
# Create a simple integrand for demonstration:
q_func = Function(Q)
q_func.interpolate(Expression("1",degree=0))
x = SpatialCoordinate(mesh)
f = x[0]*q_func
# Estimated degree is higher than the degree
# of the quadrature element; without forcing
# quadrature of forms to use a lower degree,
# this will result in an error.
f_deg = estimate_total_polynomial_degree(f)
print("Estimated degree of `f`: "+str(f_deg))
# Would cause "Mismatch of quadrature points",
# since `dx` defaults to using the estimated
# polynomial degree of the integrand:
#int_f = assemble(f*dx)
# Error avoided by manually setting quadrature
# degree for forms to match that of
# quadrature element:
dx = dx(metadata={"quadrature_degree":q_deg})
int_f = assemble(f*dx)
# Sanity check:
print("Result = " + str(int_f))
As shown in the code snippet, the usual way around this is to set the degree of the integration Measure
to match the degree of the "Quadrature"
-type Function
needed in the integrand.