How to implement custom quadrature rule?

Hello,

I would like to know if it is possible and if so, how to implement a custom quadrature rule in dolfinx?

I am currently working on the third medium contact method and need the Gauss-Lobatto-Legendre quadrature. It is already implemented (and working) for quadrangle elements but is missing for triangular elements. I am therefore aiming at implementing it myself but after searching for a little while, I haven’t been able to find any recent/good resources on how to do it. I would gladly appreciate any kind of help.

I would want to avoid sharing any personal code for now but it is based on the hyperelasticity example and should therefore be enough as a test base, if needed: jsdokken. com/dolfinx-tutorial/chapter2/hyperelasticity

I am using dolfinx version 0.10.0.post2

Thanks in advance!

You can supply the quadrature points and weights to the UFL integration measure, as done in ffcx/test/test_jit_forms.py at 5dcb90eadd56cff96b826c9395b1ea939cd1640d · FEniCS/ffcx · GitHub

Thanks for the quick answer, that seems to be working. Here is my implementation following the solution given in the link above for anyone else trying to implement a custom quadrature rule:

points = np.array([[p1x,p1y],[p2x,p2y],...,[pnx,pny]]) #Coordinates of every quadrature points
weights = np.array([w1,w2,...,wn]) #Weights of every quadratures points
metadata={"quadrature_rule": "custom", "quadrature_points": points, "quadrature_weights": weights} #metadata to use in ufl.Measure