Quadrature

A quadrature rule consists of a set of points (coordinates of evaluation points in the reference geometry) and associated weights. Constructors are provided for various AbstractElementGeometries (from ExtendableGrids) and for different orders; some element types support generic formulas for arbitrary order. See below for a detailed list.

ExtendableFEMBase.QuadratureRuleType
abstract type QuadratureRule{T<:Real, ET<:ExtendableGrids.AbstractElementGeometry}

Abstract type for quadrature rules for a certain NumberType and element geometry

source
ExtendableFEMBase.QuadratureRuleMethod
function QuadratureRule{T,ET}(order::Int) where {T<:Real, ET <: AbstractElementGeometry0D}

Constructs 0D quadrature rule of specified order (always point evaluation).

source
ExtendableFEMBase.QuadratureRuleMethod
function QuadratureRule{T,ET}(order::Int) where {T<:Real, ET <: Parallelepiped3D}

Constructs quadrature rule on Parallelepiped3D of specified order.

source
ExtendableFEMBase.QuadratureRuleMethod
function QuadratureRule{T,ET}(order::Int) where {T<:Real, ET <: Parallelogram2D}

Constructs quadrature rule on Parallelogram2D of specified order.

source
ExtendableFEMBase.QuadratureRuleMethod
function QuadratureRule{T,ET}(order::Int) where {T<:Real, ET <: Tetrahedron3D}

Constructs quadrature rule on Tetrahedron3D of specified order.

source
ExtendableFEMBase.SQuadratureRuleType
struct SQuadratureRule{T<:Real, ET<:ExtendableGrids.AbstractElementGeometry, dim, npoints} <: QuadratureRule{T<:Real, ET<:ExtendableGrids.AbstractElementGeometry}

A concrete quadrature rule for a given element geometry and number type.

It represents a set of quadrature (integration) points and weights for a specific reference element geometry (such as an interval, triangle, quadrilateral, tetrahedron, or hexahedron) and number type.

Fields

  • name::String: A descriptive name for the quadrature rule (e.g., "midpoint rule", "Gauss rule order 3").
  • xref::Vector{Vector{T}}: Reference coordinates of the quadrature points, given as a vector of coordinate vectors (one per point, each of length dim).
  • w::Vector{T}: Weights associated with each quadrature point, typically summing to the measure of the reference element.

Type Parameters

  • T <: Real: Number type for coordinates and weights (e.g., Float64, Rational{Int}).
  • ET <: AbstractElementGeometry: The reference element geometry type (e.g., Edge1D, Triangle2D).
  • dim: The topological dimension of the element geometry.
  • npoints: The number of quadrature points.
source
Base.eltypeMethod
eltype(
    _::QuadratureRule{T<:Real, ET<:ExtendableGrids.AbstractElementGeometry}
) -> Any

Custom eltype function for QuadratureRule{T,ET}.

source
Base.showMethod
show(io::IO, Q::QuadratureRule)

Custom show function for QuadratureRule{T,ET} that prints some information.

source
ExtendableFEMBase.VertexRuleFunction
VertexRule(
    ET::Type{ExtendableGrids.Edge1D};
    ...
) -> ExtendableFEMBase.SQuadratureRule{Float64, ExtendableGrids.Edge1D, 1}
VertexRule(
    ET::Type{ExtendableGrids.Edge1D},
    order;
    T
) -> ExtendableFEMBase.SQuadratureRule{Float64, ExtendableGrids.Edge1D, 1}

Constructs a quadrature rule that evaluates at the vertices of the reference element geometry ET.

This rule is not optimal for numerical integration, but is especially useful for nodal interpolation, visualization, and extracting nodal values in finite element computations. The order parameter determines the inclusion of higher-order nodes (e.g., edge, face or cell nodes for higher-order Lagrange elements).

Arguments

  • ET::Type{<:AbstractElementGeometry}: The reference element geometry (e.g., Edge1D, Triangle2D, Parallelogram2D, Tetrahedron3D, Parallelepiped3D).
  • order::Integer: Polynomial order of the finite element (default: 1). Higher orders include additional points corresponding to edge, face, or cell dofs.
  • T: Number type for the coordinates and weights (default: Float64).

Returns

  • A quadrature rule containing the nodal points (xref) and equal weights (w), matching the dof structure of the corresponding Lagrange element.
source
ExtendableFEMBase.integrate!Method
integrate!(
    integral4items::AbstractArray{T},
    grid::ExtendableGrids.ExtendableGrid{Tv, Ti},
    AT::Type{<:ExtendableGrids.AssemblyType},
    integrand;
    offset,
    bonus_quadorder,
    quadorder,
    regions,
    time,
    items,
    force_quadrature_rule,
    kwargs...
)

Compute cellwise (or per-entity) integrals of a user-supplied integrand over entities of type AT in the given grid, writing the result for each entity into integral4items.

Arguments

  • integral4items::AbstractArray{T}: Preallocated array to store the integral for each entity (e.g., cell, edge, or face). The shape should be compatible with the number of entities and the integrand's output dimension.
  • grid::ExtendableGrid{Tv, Ti}: The grid or mesh over which to integrate.
  • AT::Type{<:AssemblyType}: The entity type to integrate over (e.g., ON_CELLS, ON_EDGES, ON_FACES).
  • integrand!: A function with signature integrand!(result, qpinfo) that computes the integrand at a quadrature point. The function should write its output into result (a preallocated vector) and use qpinfo to access quadrature point data.

Keyword Arguments

  • offset: Offset(s) for writing into integral4items (default: [0]).
  • bonus_quadorder: Additional quadrature order to add to quadorder (default: 0).
  • quadorder: Quadrature order (default: 0).
  • regions: Restrict integration to these region indices (default: [], meaning all regions).
  • items: Restrict integration to these item numbers (default: [], meaning all items).
  • time: Time value to be passed to qpinfo (default: 0).
  • force_quadrature_rule: Use this quadrature rule instead of the default (default: nothing).
  • Additional keyword arguments (kwargs...) are forwarded to the quadrature point info constructor.

Notes

  • The function loops over all specified entities (cells, edges, or faces), applies the quadrature rule, and accumulates the result for each entity in integral4items.
  • The integrand function is called at each quadrature point and should write its output in-place to the provided result vector.
  • For total (global) integrals, use integrate instead, which is more memory-efficient.
  • The shape of integral4items determines whether the result is stored as a vector per entity or as a matrix (e.g., for multiple components).
source
ExtendableFEMBase.integrateMethod
integrate(
    grid::ExtendableGrids.ExtendableGrid,
    AT::Type{<:ExtendableGrids.AssemblyType},
    integrand!,
    resultdim::Int64;
    T,
    kwargs...
) -> Union{Float64, Vector{Float64}}

Compute the total integral of a user-supplied integrand over entities of type AT in the given grid.

Arguments

  • grid::ExtendableGrid: The grid or mesh over which to integrate.
  • AT::Type{<:AssemblyType}: The entity type to integrate over (e.g., ON_CELLS, ON_EDGES).
  • integrand!: A function with signature integrand!(result, qpinfo) that computes the integrand at a quadrature point. The function should write its output into result (a preallocated vector) and use qpinfo to access quadrature point data.
  • resultdim::Int: The length of the result vector expected from integrand! (i.e., the number of components to integrate).

Keyword Arguments

  • T: The number type for accumulation (default: Float64).
  • quadorder: Quadrature order (default: 0).
  • regions: Restrict integration to these region indices (default: [], meaning all regions).
  • items: Restrict integration to these item numbers (default: [], meaning all items).
  • time: Time value to be passed to qpinfo (default: 0).
  • params: Parameter array to be passed to qpinfo (default: []).
  • Additional keyword arguments are forwarded to the quadrature point info constructor.

Returns

  • If resultdim == 1, returns a scalar value (the total integral).
  • If resultdim > 1, returns a vector of length resultdim (componentwise integrals).

Notes

  • This function is memory-efficient and accumulates the total integral directly, without storing per-entity results. For cellwise or per-entity integration, use integrate! instead.
source
ExtendableFEMBase.ref_integrate!Method
ref_integrate!(
    integral::AbstractArray,
    EG::Type{<:ExtendableGrids.AbstractElementGeometry},
    order::Int64,
    integrand::Function
)

Integration for reference basis functions on reference domains (merely for testing stuff).

Note: area of reference geometry is not multiplied

source

Accumulating Vector (internal, for completeness)

Internally, global integration uses an accumulating vector and calls cell-wise integration routines.

ExtendableFEMBase.AccumulatingVectorType
struct AccumulatingVector{T} <: AbstractArray{T, 2}

vector that is acting as an AbstractArray{T, 2} and automatically accumulates all values from the second dimension

AV[k,j] += s for any j results in AV.entries[k] += s

source