Quadratures
VortexPasta.Quadratures Module
QuadraturesModule defining quadrature rules for numerical integration along filaments.
Quadrature rules are determined using the FastGaussQuadrature.jl package.
See the Wikipedia page on Gaussian quadratures for more details.
For convenience, quadrature rules in this module are defined on the
Quadrature rules
VortexPasta.Quadratures.AbstractQuadrature Type
AbstractQuadratureAbstract type defining a quadrature rule.
sourceFixed-size quadratures
These quadrature rules are meant to have a small size (typically less than 10). They have virtually zero creation cost, i.e. doing quad = GaussLegendre(4) is basically free.
VortexPasta.Quadratures.StaticSizeQuadrature Type
StaticSizeQuadrature{N} <: AbstractQuadratureAbstract type defining an
These quadrature rules can be created basically for free.
sourceVortexPasta.Quadratures.GaussLegendre Type
GaussLegendre(N) <: StaticSizeQuadrature{N}VortexPasta.Quadratures.NoQuadrature Type
NoQuadrature() <: StaticSizeQuadrature{1}Inexpensive 1-point quadrature rule.
When integrating, evaluates approximated values at the segment midpoint. However, unlike a 1-point Gauss–Legendre quadrature, midpoint values are interpolated using a basic linear interpolation. In other words, segments are assumed to be straight.
sourceVariable-size quadratures
These quadrature rules should be constructed just once, as they allocate vectors. These are usually adaptive quadratures.
VortexPasta.Quadratures.PreallocatedQuadrature Type
PreallocatedQuadrature{T <: AbstractFloat} <: AbstractQuadratureAbstract type defining a preallocated quadrature with element type T.
This is generally used for adaptive quadratures.
sourceVortexPasta.Quadratures.AdaptiveTanhSinh Type
AdaptiveTanhSinh([T = Float64]; nlevels = 10, rtol = sqrt(eps(T))) <: PreallocatedQuadrature{T}Adaptive tanh-sinh quadrature.
Behaves well when there are singularities at (or near) the endpoints.
It can be easily made adaptive because it can be written as a simple trapezoidal rule after a change of variables.
Optional arguments
T = Float64: quadrature precision;nlevels = 10: maximum number of adaptivity levels. Must be≥ 2;rtol = sqrt(eps(T)): relative tolerance.
Computations are stopped either when the maximum adaptivity level is reached, or when the difference between two levels falls below the relative tolerance rtol.
Note that the maximum number of function evaluations is 2^nlevels, so it can make sense to use a small number of levels (or a large tolerance) when function evaluations are expensive.
Estimating integrals
VortexPasta.Quadratures.integrate Function
Quadratures.integrate(f::Function, quad::AbstractQuadrature, lims::NTuple{2,T})
Quadratures.integrate(f::Function, quad::AbstractQuadrature, ::Type{T})Integrate f(x) using the chosen quadrature.
There are two variants:
The first one requires passing the limits
(a, b), which should be floats of the desired accuracy;the second one assumes the default limits
(0, 1), but requires setting the float typeT. It may avoid some operations when the limits are(0, 1).
In both cases T must be a subtype of AbstractFloat (e.g. Float64).
Note that T is simply ignored for adaptive quadratures such as AdaptiveTanhSinh, which preallocate the quadrature coefficients with a possibly different element type T′ (which can be chosen when creating the quadrature).
Computing quadrature rules
VortexPasta.Quadratures.quadrature Function
quadrature([T = Float64], q::StaticSizeQuadrature{N}) -> (xs, ws)Return
Quadrature nodes xs and weights ws are returned as tuples.
This only works for fixed-size (non-adaptive) quadrature rules such as GaussLegendre.
Other functions
Base.length Function
Base.length(q::StaticSizeQuadrature{N}) -> NReturn the number of points associated to the quadrature.
sourceBase.length(s::SegmentIterator{<:AbstractFilament}) -> IntReturn the number of segments in a filament.
source