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.QuadratureRule
— Typeabstract type QuadratureRule{T<:Real, ET<:ExtendableGrids.AbstractElementGeometry}
Abstract type for quadrature rules for a certain NumberType and element geometry
ExtendableFEMBase.QuadratureRule
— Methodconstructor that puts the provided xref and weights w into a quadrature rule
ExtendableFEMBase.QuadratureRule
— Methodfunction QuadratureRule{T,ET}(order::Int) where {T<:Real, ET <: AbstractElementGeometry0D}
Constructs 0D quadrature rule of specified order (always point evaluation).
ExtendableFEMBase.QuadratureRule
— Methodfunction QuadratureRule{T,ET}(order::Int) where {T<:Real, ET <: AbstractElementGeometry1D}
Constructs 1D quadrature rule of specified order.
ExtendableFEMBase.QuadratureRule
— Methodfunction QuadratureRule{T,ET}(order::Int) where {T<:Real, ET <: Parallelepiped3D}
Constructs quadrature rule on Parallelepiped3D of specified order.
ExtendableFEMBase.QuadratureRule
— Methodfunction QuadratureRule{T,ET}(order::Int) where {T<:Real, ET <: Parallelogram2D}
Constructs quadrature rule on Parallelogram2D of specified order.
ExtendableFEMBase.QuadratureRule
— Methodfunction QuadratureRule{T,ET}(order::Int) where {T<:Real, ET <: Tetrahedron3D}
Constructs quadrature rule on Tetrahedron3D of specified order.
ExtendableFEMBase.QuadratureRule
— Methodfunction QuadratureRule{T,ET}(order::Int) where {T<:Real, ET <: Triangle2D}
Constructs quadrature rule on Triangle2D of specified order.
ExtendableFEMBase.SQuadratureRule
— Typestruct 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 lengthdim
).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.
Base.eltype
— Methodeltype(
_::QuadratureRule{T<:Real, ET<:ExtendableGrids.AbstractElementGeometry}
) -> Any
Custom eltype
function for QuadratureRule{T,ET}
.
Base.show
— Methodshow(io::IO, Q::QuadratureRule)
Custom show
function for QuadratureRule{T,ET}
that prints some information.
ExtendableFEMBase.VertexRule
— FunctionVertexRule(
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.
ExtendableFEMBase.integrate!
— Methodintegrate!(
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 signatureintegrand!(result, qpinfo)
that computes the integrand at a quadrature point. The function should write its output intoresult
(a preallocated vector) and useqpinfo
to access quadrature point data.
Keyword Arguments
offset
: Offset(s) for writing intointegral4items
(default:[0]
).bonus_quadorder
: Additional quadrature order to add toquadorder
(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 toqpinfo
(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).
ExtendableFEMBase.integrate
— Methodintegrate(
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 signatureintegrand!(result, qpinfo)
that computes the integrand at a quadrature point. The function should write its output intoresult
(a preallocated vector) and useqpinfo
to access quadrature point data.resultdim::Int
: The length of the result vector expected fromintegrand!
(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 toqpinfo
(default:0
).params
: Parameter array to be passed toqpinfo
(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 lengthresultdim
(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.
ExtendableFEMBase.ref_integrate!
— Methodref_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
Accumulating Vector (internal, for completeness)
Internally, global integration uses an accumulating vector and calls cell-wise integration routines.
ExtendableFEMBase.AccumulatingVector
— Typestruct 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