Hello,
I would like to get the total number of integration points of the full domain or, at least, for a cell. I saw that I can use the basix or create a mesh based on “Quadrature” space.
It seems that V.tabulate_dof_coordinates()
corresponds to nodal dof. I wonder if there is a way to extract the total number of gauss points directly from the “CG” domain I create.
import ufl
from dolfinx import log, io, mesh, fem, cpp, plot
from mpi4py import MPI
#Geometry & mesh
comm = MPI.COMM_WORLD
msh = mesh.create_rectangle(comm, [[0.,0.],[1.,1.]], [2,2], mesh.CellType.quadrilateral)
FE_vector = ufl.VectorElement("CG",msh.ufl_cell(),1)
V_u = fem.FunctionSpace(msh,FE_vector)
FE_scalar = ufl.FiniteElement("CG",msh.ufl_cell(), 1)
V_alpha = fem.FunctionSpace(msh,FE_scalar)
len(V_alpha.tabulate_dof_coordinates()) #=9
Thank you for the help !
Best regards,
Lamia
dokken
August 3, 2022, 8:33am
2
The number of Gauss-points used depends on the variational form.
DOLFINx
uses ufl
to estimate the quadrature degree of the variational form, see:
Note that the demo you are considering is quite outdated, and your should consider the latest version
To estimate the polynomial degree, you can use:
from ufl.algorithms.compute_form_data \
import estimate_total_polynomial_degree
estimate_total_polynomial_degree(form)
This is in turn sent to basix which tabulates at the relevant points.
You can use basix directly to investigate the default quadrature of any order, see:Creating and using a quadrature rule — Basix 0.8.0.0 documentation
You can also by-pass the basix/ufl workflow by supplying your own quadrature rule:
points = [[0.0, 0.0], [1.0, 0.0], [0.0, 1.0], [0.5, 0.5], [0.0, 0.5], [0.5, 0.0]]
weights = [1 / 12] * 6
a = u * v * ufl.dx(metadata={"quadrature_rule": "custom",
"quadrature_points": points, "quadrature_weights": weights})
1 Like
Thank you very much for the detailed answer ! I managed to get it !
Has the syntax changed? this didn’t work for me, but changing
"quadrature_rule": "custom",
to
"quadrature_scheme": "custom",
did the trick
dokken
March 11, 2025, 4:36pm
5
No,it hasn’t changed, as far as I can tell:
a = (
u
* v
* ufl.dx(
metadata={
"quadrature_rule": "custom",
"quadrature_points": points,
"quadrature_weights": weights,
}
)
)
Could you provide your example that doesn’t work? (and what version of FEniCS are you using?)
Here is where the scheme is fetched in FFCx: ffcx/ffcx/analysis.py at cbfc0f0ec5d30217e9e9c785f6b960ea53fb00b6 · FEniCS/ffcx · GitHub