From b185f65ad5b58dceaf0bd2d6dbcee45ef2d87d65 Mon Sep 17 00:00:00 2001 From: Jukka Aho Date: Sat, 9 May 2026 18:32:52 +0300 Subject: [PATCH] feat(quadrature): integrate basis degree into quadrature selection Add `basis_quadrature_order` and an `integration_points(topology, basis)` overload so assembly can match Gauss rules to `Lagrange{P}` / `Serendipity{P}` instead of inferring order only from topology node counts. - Delegate rule choice to `default_quadrature(T, ord)` with `ord` from the basis. --- src/quadrature/integration_basis.jl | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/quadrature/integration_basis.jl diff --git a/src/quadrature/integration_basis.jl b/src/quadrature/integration_basis.jl new file mode 100644 index 0000000..536c6cb --- /dev/null +++ b/src/quadrature/integration_basis.jl @@ -0,0 +1,33 @@ +# This file is a part of JuliaFEM. +# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md + +""" + basis_quadrature_order(basis::AbstractBasis) -> Int + +Polynomial order passed to [`default_quadrature(::Type{<:AbstractTopology}, ::Int)`](@ref) +when building [`integration_points(topology, basis)`](@ref). + +Extensible: add methods for new [`AbstractBasis`](@ref) subtypes used in assembly caches. +Patch/tensor-product bases used in IGA (B-spline/NURBS on a parameter cell) should +implement this hook so quadrature matches the quadrature rule degree of the weak form, +analogous to [`Lagrange`](@ref) / [`Serendipity`](@ref). +""" +basis_quadrature_order(::Lagrange{P}) where {P} = P +basis_quadrature_order(::Serendipity{P}) where {P} = P + +""" + integration_points(topology::AbstractTopology, basis::AbstractBasis) + +Like [`integration_points(topology)`](@ref), but selects [`default_quadrature`](@ref) +from **`basis`** via [`basis_quadrature_order`](@ref) instead of inferring order only +from [`nnodes`](@ref). Use this when the mesh topology node count does not reflect +the polynomial degree of the active basis (or to force a consistent rule with +[`create_element_cache`](@ref)). +""" +function integration_points(topology::T, basis::AbstractBasis) where {T<:AbstractTopology} + ord = basis_quadrature_order(basis) + rule = default_quadrature(T, ord) + quad_topo = _quadrature_topology_type(T) + quad_points = get_quadrature_points(quad_topo, rule) + return Tuple(quad_points) +end