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$ |
SUBROUTINE qAndLEvaluation(N_in,x,q,qder,L) IMPLICIT NONE !---------------------------------------------------------------------------------------------------------------------------------- ! INPUT/OUTPUT VARIABLES INTEGER,INTENT(IN) :: N_in !! polynomial degree REAL(wp),INTENT(IN) :: x !! coordinate value in the interval [-1,1] REAL(wp),INTENT(OUT) :: L !! \f$ L_N(\xi) \f$ REAL(wp),INTENT(OUT) :: q !! \f$ q_N(\xi) \f$ REAL(wp),INTENT(OUT) :: qder !! \f$ \partial/\partial\xi \; L_N(\xi) \f$ !---------------------------------------------------------------------------------------------------------------------------------- ! LOCAL VARIABLES INTEGER :: iLegendre REAL(wp) :: L_Nm1,L_Nm2 ! L_{N_in-2},L_{N_in-1} REAL(wp) :: Lder,Lder_Nm1,Lder_Nm2 ! Lder_{N_in-2},Lder_{N_in-1} !================================================================================================================================== L_Nm2=1.0_wp L_Nm1=x Lder_Nm2=0.0_wp Lder_Nm1=1.0_wp DO iLegendre=2,N_in L=(REAL(2*iLegendre-1,wp)*x*L_Nm1 - REAL(iLegendre-1,wp)*L_Nm2)/REAL(iLegendre,wp) Lder=Lder_Nm2 + REAL(2*iLegendre-1,wp)*L_Nm1 L_Nm2=L_Nm1 L_Nm1=L Lder_Nm2=Lder_Nm1 Lder_Nm1=Lder END DO ! iLegendre q=REAL(2*N_in+1,wp)/REAL(N_in+1,wp)*(x*L -L_Nm2) !L_{N_in+1}-L_{N_in-1} !L_Nm2 is L_Nm1, L_Nm1 was overwritten! qder= REAL(2*N_in+1,wp)*L !Lder_{N_in+1}-Lder_{N_in-1} END SUBROUTINE qAndLEvaluation