Routines to provide and evaluate 1D polynomial Lagrange basis functions, interpolation and integration points
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| real(kind=wp), | private, | parameter | :: | PP_RealTolerance | = | EPSILON(1.0_wp) |
machine precision |
| real(kind=wp), | private, | parameter | :: | PP_Pi | = | ACOS(-1.0_wp) |
Pi up to machine accuracy |
Determines if two REAL(wp) numbers are equal up to a specified tolerance (=PP_RealTolerance, normaly set to machine precision) Takes into account that x,y are located in-between [-1;1] Based on Algorithm 139, Kopriva
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(in) | :: | x |
(IN) first scalar to be compared |
||
| real(kind=wp), | intent(in) | :: | y |
(IN) second scalar to be compared |
(OUT) TRUE if |x-y| < 2*PP_RealTolerance
Determines if two REAL(wp) numbers are equal up to a given tolerance. Routine requires: x,y > tolerance
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(in) | :: | x |
(IN) first scalar to be compared |
||
| real(kind=wp), | intent(in) | :: | y |
(IN) second scalar to be compared |
||
| real(kind=wp), | intent(in) | :: | tolerance |
(IN) Tolerance to be checked against |
(OUT) TRUE if x and y are closer than tolerance
Build a 1D Vandermonde matrix from an orthonormal Legendre basis to a nodal basis and reverse
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | N_In |
input polynomial degree |
||
| real(kind=wp), | intent(in) | :: | xi_In(0:N_In) |
nodal positions [-1,1] |
||
| real(kind=wp), | intent(out) | :: | Vdm_Leg(0:N_In,0:N_In) |
Vandermonde from Legendre to nodal basis |
||
| real(kind=wp), | intent(out) | :: | sVdm_Leg(0:N_In,0:N_In) |
Vandermonde from nodal basis to Legendre |
Build a 1D Vandermonde matrix using the Lagrange basis functions of degree N_In, evaluated at the interpolation points xi_Out
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | N_In |
(IN) input polynomial degree |
||
| integer, | intent(in) | :: | N_Out |
(IN) output polynomial degree |
||
| real(kind=wp), | intent(in) | :: | wBary_In(0:N_In) |
(IN) input interpolation weights |
||
| real(kind=wp), | intent(in) | :: | xi_In(0:N_In) |
(IN) input nodal positions [-1,1] |
||
| real(kind=wp), | intent(in) | :: | xi_Out(0:N_Out) |
(IN) outout nodal positions [-1,1] |
||
| real(kind=wp), | intent(out) | :: | Vdm(0:N_Out,0:N_In) |
(OUT) nodal Vandermonde from N_In to N_out |
Evaluate the Legendre polynomial L_N and its derivative at position x[-1,1] recursive algorithm using the N_in-1 N_in-2 Legendre polynomials algorithm 22, Kopriva book
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | N_in |
(IN) polynomial degree, (N+1) CLpoints |
||
| real(kind=wp), | intent(in) | :: | x |
(IN) coordinate value in the interval [-1,1] |
||
| real(kind=wp), | intent(out) | :: | L |
(OUT) Legedre polynomial evaluated at \f$ \xi: L_N(\xi), \partial/\partial\xi L_N(\xi) \f$ |
||
| real(kind=wp), | intent(out) | :: | Lder |
(OUT) Legedre polynomial deriv. evaluated at \f$ \xi: L_N(\xi), \partial/\partial\xi L_N(\xi) \f$ |
Compute Chebychev-Gauss nodes and integration weights (algorithm 27, Kopriva book)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | N_in |
polynomial degree, (N_in+1) CLpoints |
||
| real(kind=wp), | intent(out) | :: | xGP(0:N_in) |
Gauss point positions for the reference interval [-1,1] |
||
| real(kind=wp), | intent(out), | optional | :: | wGP(0:N_in) |
Gauss point integration weights |
Compute Chebychev-Gauss-Lobatto nodes and integration weights (algorithm 27, Kopriva book)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | N_in |
polynomial degree, (N_in+1) CLpoints |
||
| real(kind=wp), | intent(out) | :: | xGP(0:N_in) |
Gauss point positions for the reference interval [-1,1] |
||
| real(kind=wp), | intent(out), | optional | :: | wGP(0:N_in) |
Gauss point weights |
Compute Clenshaw-Curtis nodes and integration weights
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | N_in |
polynomial degree, (N_in+1) CLpoints |
||
| real(kind=wp), | intent(out) | :: | xGP(0:N_in) |
Gauss point positions for the reference interval [-1,1] |
||
| real(kind=wp), | intent(out), | optional | :: | wGP(0:N_in) |
Gauss point weights |
Compute Legendre-Gauss nodes and integration weights (algorithm 23, Kopriva book)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | N_in |
polynomial degree, (N_in+1) Gausspoints |
||
| real(kind=wp), | intent(out) | :: | xGP(0:N_in) |
Gauss point positions for the reference interval [-1,1] |
||
| real(kind=wp), | intent(out), | optional | :: | wGP(0:N_in) |
Gauss point weights |
Evaluate the polynomial q=L_{N_in+1}-L_{N_in-1} and its derivative at position x in [-1,1] Recursive algorithm using the N_in-1 N_in-2 Legendre polynomials. (Algorithm 24, Kopriva book)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | N_in |
polynomial degree |
||
| real(kind=wp), | intent(in) | :: | x |
coordinate value in the interval [-1,1] |
||
| real(kind=wp), | intent(out) | :: | q |
\f$ q_N(\xi) \f$ |
||
| real(kind=wp), | intent(out) | :: | qder |
\f$ \partial/\partial\xi \; L_N(\xi) \f$ |
||
| real(kind=wp), | intent(out) | :: | L |
\f$ L_N(\xi) \f$ |
Starting with initial guess by Parter Relation, a Newton method is used to find the roots of the Legendre Polynomial Lder_(N_in), which are the positions of Gauss-Lobatto points. Uses qAndLEvaluation subroutine. algorithm 25, Kopriva
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | N_in |
polynomial degree (N_in+1) Gausspoints |
||
| real(kind=wp), | intent(out) | :: | xGP(0:N_in) |
Gauss point positions for the reference interval [-1,1] |
||
| real(kind=wp), | intent(out), | optional | :: | wGP(0:N_in) |
Gauss point weights |
Computes barycentric (interpolation) weights for interpolation polynomial given by set of nodes. (Algorithm 30, Kopriva book)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | N_in |
polynomial degree |
||
| real(kind=wp), | intent(in) | :: | xGP(0:N_in) |
Gauss point positions for the reference interval [-1,1] |
||
| real(kind=wp), | intent(out) | :: | wBary(0:N_in) |
barycentric weights |
Computes polynomial differentiation matrix for interpolation polynomial given by set of nodes. (Algorithm 37, Kopriva book)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | N_in |
polynomial degree |
||
| real(kind=wp), | intent(in) | :: | xGP(0:N_in) |
Gauss point positions for the reference interval [-1,1] |
||
| real(kind=wp), | intent(out) | :: | D(0:N_in,0:N_in) |
differentiation Matrix |
Computes mth polynomial differentiation matrix for interpolation polynomial given by set of nodes. (Algorithm 38, Kopriva book)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | N_in |
polynomial degree |
||
| real(kind=wp), | intent(in) | :: | xGP(0:N_in) |
Gauss point positions for the reference interval [-1,1] |
||
| integer, | intent(in) | :: | deriv |
derivative (starting at 1) |
||
| real(kind=wp), | intent(out) | :: | D(0:N_in,0:N_in) |
differentiation Matrix |
Computes all Lagrange functions evaluated at position x in [-1,1] For details see paper Barycentric Lagrange Interpolation by Berrut and Trefethen (SIAM 2004) Uses function ALMOSTEQUAL Algorithm 34, Kopriva book
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(in) | :: | x |
Coordinate |
||
| integer, | intent(in) | :: | N_in |
polynomial degree |
||
| real(kind=wp), | intent(in) | :: | xGP(0:N_in) |
Gauss point positions for the reference interval [-1,1] |
||
| real(kind=wp), | intent(in) | :: | wBary(0:N_in) |
Barycentric weights |
||
| real(kind=wp), | intent(out) | :: | L(0:N_in) |
Lagrange basis functions evaluated at x |
This routine was taken fom QUADRULE (http://people.sc.fsu.edu/~jburkardt/f_src/quadrule/quadrule.html)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | N_in |
polynomial degree (N_in+1) Gausspoints |
||
| real(kind=wp), | intent(out) | :: | xGR(0:N_in) |
Gauss point positions for the reference interval [-1,1] |
||
| real(kind=wp), | intent(out), | optional | :: | wGR(0:N_in) |
Gauss point weights |