xref: /libCEED/julia/LibCEED.jl/src/Quadrature.jl (revision 06988bf74cc6ac18eacafe7930f080803395ba29) !
1*44554ea0SWill Pazner@doc raw"""
2*44554ea0SWill Pazner    gauss_quadrature(q)
3*44554ea0SWill Pazner
4*44554ea0SWill PaznerReturn the Gauss-Legendre quadrature rule with `q` points (integrates polynomials of degree
5*44554ea0SWill Pazner$2q-1$ exactly).
6*44554ea0SWill Pazner
7*44554ea0SWill PaznerA tuple `(x,w)` is returned.
8*44554ea0SWill Pazner"""
9*44554ea0SWill Paznerfunction gauss_quadrature(q)
10*44554ea0SWill Pazner    x = zeros(CeedScalar, q)
11*44554ea0SWill Pazner    w = zeros(CeedScalar, q)
12*44554ea0SWill Pazner    C.CeedGaussQuadrature(q, x, w)
13*44554ea0SWill Pazner    x, w
14*44554ea0SWill Paznerend
15*44554ea0SWill Pazner
16*44554ea0SWill Paznerstruct QuadratureMode{T} end
17*44554ea0SWill Paznerconst Abscissa = QuadratureMode{:Abscissa}()
18*44554ea0SWill Paznerconst AbscissaAndWeights = QuadratureMode{:AbscissaAndWeights}()
19*44554ea0SWill Pazner
20*44554ea0SWill Pazner@doc raw"""
21*44554ea0SWill Pazner    lobatto_quadrature(q, mode::Mode=Abscissa)
22*44554ea0SWill Pazner
23*44554ea0SWill PaznerReturn the Gauss-Lobatto quadrature rule with `q` points (integrates polynomials of degree
24*44554ea0SWill Pazner$2q-3$ exactly).
25*44554ea0SWill Pazner
26*44554ea0SWill PaznerIf `mode` is `AbscissaAndWeights`, then both the weights and abscissa are returned as a
27*44554ea0SWill Paznertuple `(x,w)`.
28*44554ea0SWill Pazner
29*44554ea0SWill PaznerOtherwise, (if `mode` is `Abscissa`), then only the abscissa `x` are returned.
30*44554ea0SWill Pazner"""
31*44554ea0SWill Paznerfunction lobatto_quadrature(q, mode::Mode=Abscissa) where {Mode}
32*44554ea0SWill Pazner    return_weights = (mode == AbscissaAndWeights)
33*44554ea0SWill Pazner    x = zeros(CeedScalar, q)
34*44554ea0SWill Pazner    w = (return_weights) ? zeros(CeedScalar, q) : C_NULL
35*44554ea0SWill Pazner    C.CeedLobattoQuadrature(q, x, w)
36*44554ea0SWill Pazner    return_weights ? (x, w) : x
37*44554ea0SWill Paznerend
38