Quadrature
All docstrings from Mantis.Quadrature
Mantis.Quadrature.AbstractElementQuadratureRule Type
AbstractElementQuadratureRule{manifold_dim} <: AbstractQuadratureRule{manifold_dim}A quadrature rule on a single quadrature element.
sourceMantis.Quadrature.AbstractGlobalQuadratureRule Type
AbstractGlobalQuadratureRule{manifold_dim} <: AbstractQuadratureRule{manifold_dim}A quadrature rule on a global domain.
sourceMantis.Quadrature.AbstractQuadratureRule Type
AbstractQuadratureRule{manifold_dim}Abstract type for a quadrature rule on an entire domain of dimension manifold_dim.
Type parameters
manifold_dim: Dimension of the domain
Mantis.Quadrature.CanonicalQuadratureRule Type
CanonicalQuadratureRule{manifold_dim} <: ElementQuadratureRule{manifold_dim}Represents a quadrature rule on a canonical element of dimension manifold_dim.
Fields
nodes::NTuple{manifold_dim, Vector{Float64}}: Quadrature nodes per dimension.weights::Vector{Float64}: Tensor product of quadrature rules. The shape is consistent with the output of the evaluate methods forFunctionSpaces.rule_label::String: Name or type of quadrature rule. Used for human verification.
Type parameters
manifold_dim: Dimension of the domain
Inner Constructors
CanonicalQuadratureRule(nodes::NTuple{manifold_dim, Vector{Float64}}, weights::Vector{Float64}): General constructor.
Outer Constructors
Mantis.Quadrature.StandardQuadrature Type
StandardQuadrature{manifold_dim, Q} <: AbstractGlobalQuadratureRule{manifold_dim}Represents a standard quadrature rule for a given manifold dimension, where each element has the same canonical rule Q.
Fields
canonical_qrule::Q: The canonical quadrature rule used for the elements.num_elements::Int: The number of elements in the quadrature rule.
Type parameters
manifold_dim: Dimension of the domainQ: Type of the canonical quadrature rule.
Inner Constructors
StandardQuadrature(canonical_qrule::Q, num_elements::Int): Creates a newStandardQuadratureinstance with the specified canonical quadrature rule and number of elements.
Mantis.Quadrature._compute_tensor_product Method
_compute_tensor_product(weights_1d::NTuple{manifold_dim, Vector{T}}) where {
manifold_dim, T <: Number
}Compute the tensor product of the given 1D quadrature weights.
Arguments
weights_1d::NTuple{manifold_dim, Vector{T}}: Quadrature weights per dimension.
Returns
::Vector{T}: Tensor product of the quadrature weights.
Mantis.Quadrature.clenshaw_curtis Method
clenshaw_curtis(p::Integer)Find the roots and weights for Clenshaw-Curtis quadrature on the interval [0, 1]. The roots include the endpoints 0 and 1 and Clenshaw-Curtis quadrature is exact for polynomials up to degree p. However, in practise, this quadrature rule can obtain results comparable to Gauss quadrature (in some cases), see (Trefethen, 2008) and (Trefethen, 2022).
Arguments
p::Integer: Degree of the quadrature rule.
Returns
::CanonicalQuadratureRule{1}: 1 dimensional quadrature rule containing the nodes and weights. There will bep+1nodes and weights.
Notes
See (Waldvogel, 2006) for the algorithm based on fast fourier transforms. The algorithm used here is a direct translation from the given MATLAB code on page 201.
sourceMantis.Quadrature.gauss_legendre Method
gauss_legendre(N::Integer)Computes the nodes ξ and weights w of Gauss-Legendre quadrature.
Note that here the quadrature rule is valid for the interval
Arguments
N::Integer: Number of nodes used in the quadrature rule.
Returns
::CanonicalQuadratureRule{1}: 1 dimensional quadrature rule containing the nodes and weights. There will beNnodes and weights.
Throws
DomainError: IfNis less than or equal to zero.
Notes
Uses the FastGaussQuadrature.jl package. We only linearly map the nodes and weights to the interval [0, 1].
sourceMantis.Quadrature.gauss_lobatto Method
gauss_lobatto(N::Integer)Computes the nodes ξ and weights w of Gauss-Lobatto quadrature.
Note that here the quadrature rule is valid for the interval
Arguments
N::Integer: Number of nodes used in the quadrature rule.
Returns
::CanonicalQuadratureRule{1}: 1 dimensional quadrature rule containing the nodes and weights. There will beNnodes and weights.
Throws
DomainError: IfNis less than or equal to 1. This is handled by the FastGaussQuadrature.jl package.
Notes
Uses the FastGaussQuadrature.jl package. We only linearly map the nodes and weights to the interval [0, 1].
sourceMantis.Quadrature.get_canonical_quadrature_rule Method
get_canonical_quadrature_rule(standard_quadrature::StandardQuadrature)Get the canonical quadrature rule of the standard quadrature.
Arguments
standard_quadrature::StandardQuadrature: The standard quadrature rule.
Returns
CanonicalQuadratureRule: The canonical quadrature rule of the standard quadrature.
Mantis.Quadrature.get_canonical_quadrature_rules Method
get_canonical_quadrature_rules(
q_rule::Function,
nq_single::NTuple{manifold_dim, Int},
nq_others::NTuple{manifold_dim, Int}...,
) where {manifold_dim}Returns a tuple of tensor-product quadrature rules, of the type q_rule, for the given number of quadrature points in each dimension.
Arguments
q_rule::Function: The type of univariate quadrature rule to use.nq_single::NTuple{manifold_dim, Int}: Number of quadrature points per dimension for the first quadrature rule.nq_others::NTuple{manifold_dim, Int}...: Number of quadrature points per dimension for the other quadrature rules.
Returns
::NTuple{num_rules, CanonicalQuadratureRule{manifold_dim}}: A tuple of quadrature rules wherenum_rulesis the number of other quadrature rules given plus the single rule.
Mantis.Quadrature.get_element_idxs Method
get_element_idxs(global_quad_rule::AbstractGlobalQuadratureRule, element_idx::Int)Get the indices of the quadrature elements in a given base element.
Arguments
global_quad_rule::AbstractGlobalQuadratureRule: The global quadrature rule.element_idx::Int: The index of the base element.
Returns
Vector{Int}: The indices of the quadrature elements in the specified base element.
Mantis.Quadrature.get_element_quadrature_rule Method
get_element_quadrature_rule(global_quad_rule::AbstractGlobalQuadratureRule, element_idx::Int)Get the quadrature rule for a specific quadrature element index .
Arguments
global_quad_rule::AbstractGlobalQuadratureRule: The global quadrature rule.element_idx::Int: The index of the quadrature element.
Returns
AbstractElementQuadratureRule: The quadrature rule for the specified quadrature element.
Mantis.Quadrature.get_label Method
get_label(qr::AbstractElementQuadratureRule{manifold_dim}) where {manifold_dim}Returns the label of a quadrature rule.
Arguments
qr::AbstractElementQuadratureRule{manifold_dim}: Rule to get the label from.
Returns
rule_label::String: Label of the quadrature rule.
Mantis.Quadrature.get_nodes Method
get_nodes(qr::AbstractElementQuadratureRule{manifold_dim}) where {manifold_dim}Returns the quadrature nodes of a quadrature rule.
Arguments
qr::AbstractElementQuadratureRule{manifold_dim}: Rule to get the nodes from.
Returns
nodes::NTuple{manifold_dim, Vector{Float64}}: Nodes of the quadrature rule.
Mantis.Quadrature.get_num_base_elements Method
get_num_base_elements(global_quad_rule::AbstractGlobalQuadratureRule)Get the number of base elements in the global quadrature rule. Each base element can have several sub-elements on which quadrature is performed.
Arguments
global_quad_rule::AbstractGlobalQuadratureRule: The global quadrature rule.
Returns
Int: The number of base elements in the global quadrature rule.
Mantis.Quadrature.get_num_base_elements Method
get_num_base_elements(standard_quadrature::StandardQuadrature)Returns the number of base elements in the standard quadrature.
Arguments
standard_quadrature::StandardQuadrature: The standard quadrature rule.
Returns
::Int: The number of base elements in the standard quadrature.
Mantis.Quadrature.get_num_evaluation_elements Method
get_num_evaluation_elements(global_quad_rule::AbstractGlobalQuadratureRule)Get the number of quadrature elements in the global quadrature rule. These are the smallest element units on which quadrature is performed.
Arguments
global_quad_rule::AbstractGlobalQuadratureRule: The global quadrature rule.
Returns
Int: The number of quadrature elements in the global quadrature rule.
Mantis.Quadrature.get_weights Method
get_weights(qr::AbstractElementQuadratureRule{manifold_dim}) where {manifold_dim}Returns the quadrature weights of a quadrature rule.
Arguments
qr::AbstractElementQuadratureRule{manifold_dim}: Rule to get the weights from.
Returns
weights::Vector{Float64}: Weights of the quadrature rule.
Mantis.Quadrature.newton_cotes Method
newton_cotes(num_points::Integer, type::String="closed")Computes the nodes ξ and weights w of a Newton-Cotes quadrature rule.
Newton-Cotes quadrature rules are based on equally spaced nodes. There are two types of Newton-Cotes rules: closed and open. Closed Newton-Cotes rules include the endpoints of the interval, while open Newton-Cotes rules do not.
The algorithm used to compute the weights is not the most efficient nor the most accurate.
Arguments
num_points::Integer: Number of points in the quadrature rule.type::String: Type of the Newton-Cotes rule. Valid types are "closed" and "open".
Returns
::CanonicalQuadratureRule{1}: 1 dimensional quadrature rule containing the nodes and weights.
Mantis.Quadrature.tensor_product_rule Method
tensor_product_rule(p::NTuple{manifold_dim, Integer}, quad_rule::F, rule_args_1d...) where {
manifold_dim, F <: Function
}Returns a tensor product quadrature rule of given degree and rule type.
Arguments
p::NTuple{manifold_dim, Integer}: Degree of the quadrature rule per dimension.quad_rule::F: The function that returns aCanonicalQuadratureRule{1}given an integer degree. May take additional arguments.rule_args_1d...: Additional arguments for the 1D quadrature rule. Optional.
Returns
::CanonicalQuadratureRule{manifold_dim}: CanonicalQuadratureRule of the new dimension.
Mantis.Quadrature.tensor_product_rule Method
tensor_product_rule(qrules_1d::NTuple{manifold_dim, CanonicalQuadratureRule{1}}) where {
manifold_dim
}Returns a tensor product quadrature rule from the given rules.
Arguments
qrules_1d::NTuple{manifold_dim, CanonicalQuadratureRule{1}}: Quadrature rules per dimension.
Returns
::CanonicalQuadratureRule{manifold_dim}: CanonicalQuadratureRule of the new dimension.