# FEniCS: custom quadrature rule

For the numerical integration of reaction terms in my PDE on a 2D triangular mesh, I would like to use the scheme $$\int_T \Phi(x) \approx \frac{|T|}{3} (\Phi(x_0) + \Phi(x_1) + \Phi(x_2))$$ where the $x_i$ are the triangle nodes.

How to specify this when assembleing the system?

Actually you don't specify quadrature rule to assembler but to form compiler. You can tweak ffc/quadrature_schemes.py for your needs or you can adjust generated code. In both cases you just supply your quadrature points and weights.

• Luckily, assemble() has an form_compiler_parameters argument. – Nico Schlömer May 17 '13 at 13:25
• @Nico: Yes, but FFC seems to accept only default and canonical which is a scheme supplied by FIAT. – Jan Blechta May 17 '13 at 13:28
• Indeed, quadrature_schemes.py doesn't seem to permit custom schemes. – Nico Schlömer May 17 '13 at 13:55

You can adjust the quadrature degree by setting

parameters["form_compiler_parameters"]["quadrature_degree"] = q


This will change the quadrature degree such that polynomials of degree q are integrated exactly.

FEniCS will try to autodetect the necessary quadrature degree so this should normally not be needed. However, in some cases you might want to underintegrate by setting a lower value of q.

• I skimmed through FFC/ffc/quadrature_schemes.py to see what schemes are used for the particular degrees, but the "lumping" scheme that I'd like to use is not implemented. – Nico Schlömer May 17 '13 at 13:54