LagrangeCoeff
Returns the coefficients of Lagrange polynomials for monomial basis.
A Lagrange polynomial in terms of monomials is given by
A Lagrange polynomial in terms of general basis is given by
This subroutine returns for Lagrange polynomial.
For example, if we select monomial basis:
then for order = 1 (linear), we have following results:
coeff
basis | ||||||||
---|---|---|---|---|---|---|---|---|
1 | 0.125 | 0.125 | 0.125 | 0.125 | 0.125 | 0.125 | 0.125 | 0.125 |
x | -0.125 | 0.125 | 0.125 | -0.125 | -0.125 | 0.125 | 0.125 | -0.125 |
y | -0.125 | -0.125 | 0.125 | 0.125 | -0.125 | -0.125 | 0.125 | 0.125 |
xy | 0.125 | -0.125 | 0.125 | -0.125 | 0.125 | -0.125 | 0.125 | -0.125 |
z | -0.125 | -0.125 | -0.125 | -0.125 | 0.125 | 0.125 | 0.125 | 0.125 |
xz | 0.125 | -0.125 | -0.125 | 0.125 | -0.125 | 0.125 | 0.125 | -0.125 |
yz | 0.125 | 0.125 | -0.125 | -0.125 | -0.125 | -0.125 | 0.125 | 0.125 |
xyz | -0.125 | 0.125 | -0.125 | 0.125 | 0.125 | -0.125 | 0.125 | -0.125 |
Interface 1
INTERFACE LagrangeCoeff_Hexahedron
MODULE FUNCTION LagrangeCoeff_Hexahedron1(order, i, xij) RESULT(ans)
INTEGER(I4B), INTENT(IN) :: order
!! order of polynomial
INTEGER(I4B), INTENT(IN) :: i
!! ith coefficients for lagrange polynomial
REAL(DFP), INTENT(IN) :: xij(:, :)
!! interpolation points in xij format
!! number of rows in xij is 3
!! number of columns should be equal to the number degree of freedom
REAL(DFP) :: ans(SIZE(xij, 2))
!! coefficients
END FUNCTION LagrangeCoeff_Hexahedron1
END INTERFACE LagrangeCoeff_Hexahedron
Interface 2
INTERFACE LagrangeCoeff_Hexahedron
MODULE FUNCTION LagrangeCoeff_Hexahedron2(order, i, v, isVandermonde) &
& RESULT(ans)
INTEGER(I4B), INTENT(IN) :: order
!! order of polynomial, it should be SIZE(v,2)-1
INTEGER(I4B), INTENT(IN) :: i
!! coefficient for ith lagrange polynomial
REAL(DFP), INTENT(IN) :: v(:, :)
!! vandermonde matrix size should be (order+1,order+1)
LOGICAL(LGT), INTENT(IN) :: isVandermonde
!! This is just to resolve interface issue
REAL(DFP) :: ans(SIZE(v, 1))
!! coefficients
END FUNCTION LagrangeCoeff_Hexahedron2
END INTERFACE LagrangeCoeff_Hexahedron
Interface 3
INTERFACE LagrangeCoeff_Hexahedron
MODULE FUNCTION LagrangeCoeff_Hexahedron3(order, i, v, ipiv) RESULT(ans)
INTEGER(I4B), INTENT(IN) :: order
!! order of polynomial, it should be SIZE(x,2)-1
INTEGER(I4B), INTENT(IN) :: i
!! ith coefficients for lagrange polynomial
REAL(DFP), INTENT(INOUT) :: v(:, :)
!! LU decomposition of vandermonde matrix
INTEGER(I4B), INTENT(IN) :: ipiv(:)
!! inverse pivoting mapping, compes from LU decomposition
REAL(DFP) :: ans(SIZE(v, 1))
!! coefficients
END FUNCTION LagrangeCoeff_Hexahedron3
END INTERFACE LagrangeCoeff_Hexahedron
Interface 4
- ܀ Interface
- ️܀ See example
- ↢
INTERFACE LagrangeCoeff_Hexahedron
MODULE FUNCTION LagrangeCoeff_Hexahedron4(order, xij, basisType, &
& refHexahedron, alpha, beta, lambda) RESULT(ans)
INTEGER(I4B), INTENT(IN) :: order
!! order of polynomial
REAL(DFP), INTENT(IN) :: xij(:, :)
!! points in xij format, size(xij,2)
INTEGER(I4B), OPTIONAL, INTENT(IN) :: basisType
!! Monomials
!! Jacobi
!! Legendre
!! Chebyshev
!! Ultraspherical
!! Heirarchical
CHARACTER(*), OPTIONAL, INTENT(IN) :: refHexahedron
!! UNIT
!! BIUNIT
REAL(DFP), OPTIONAL, INTENT(IN) :: alpha
!! This parameter is needed when basisType is Jacobi
REAL(DFP), OPTIONAL, INTENT(IN) :: beta
!! This parameter is needed when basisType is Jacobi
REAL(DFP), OPTIONAL, INTENT(IN) :: lambda
!! This parameter is needed when basisType is Ultraspherical
REAL(DFP) :: ans(SIZE(xij, 2), SIZE(xij, 2))
!! coefficients
END FUNCTION LagrangeCoeff_Hexahedron4
END INTERFACE LagrangeCoeff_Hexahedron
order
order of polynomial
xij
interpolation points for Lagrange polynomials. The number of rows of xij should be 3. The number of columns of xij should be equal to the total number of degrees of freedom.
basisType
- Monomials
- Jacobi
- Legendre
- Chebyshev
- Ultraspherical
- Heirarchical
refHexahedron
Reference hexahedron can be UNIT
or BIUNIT
.
alpha, beta, lambda
alpha
andbeta
are needed when basisType is Jacobilambda
is needed when basisType is Ultraspherical
PROGRAM main
USE easifembase
IMPLICIT NONE
INTEGER(i4b) :: i1, i2, order, basisType
REAL(dfp), ALLOCATABLE :: xij(:, :), coeff(:, :)
TYPE(string) :: astr
REAL( DFP ) :: alpha, beta, lambda
CHARACTER(*), parameter :: refHexahedron="BIUNIT"
INTEGER( I4B ), ALLOCATABLE :: deg(:, :)
order = 1
basisType = Monomial
deg = LagrangeDegree_Hexahedron(order)
xij = InterpolationPoint_Hexahedron( &
& order=order, &
& ipType=Equidistance, &
& layout="VEFC")
coeff = LagrangeCoeff_Hexahedron(&
& order=order, &
& xij=xij, &
& basisType=basisType, &
& refHexahedron=refHexahedron, &
& alpha=alpha, &
& beta=beta, &
& lambda=lambda)
CALL Display(Mdencode(deg), "monomial degrees: " )
CALL Display(Mdencode(coeff), "coeff : " )
END PROGRAM main
See results
degrees:
a | b | c |
---|---|---|
0 | 0 | 0 |
1 | 0 | 0 |
0 | 1 | 0 |
1 | 1 | 0 |
0 | 0 | 1 |
1 | 0 | 1 |
0 | 1 | 1 |
1 | 1 | 1 |
coeff
basis | ||||||||
---|---|---|---|---|---|---|---|---|
1 | 0.125 | 0.125 | 0.125 | 0.125 | 0.125 | 0.125 | 0.125 | 0.125 |
x | -0.125 | 0.125 | 0.125 | -0.125 | -0.125 | 0.125 | 0.125 | -0.125 |
y | -0.125 | -0.125 | 0.125 | 0.125 | -0.125 | -0.125 | 0.125 | 0.125 |
xy | 0.125 | -0.125 | 0.125 | -0.125 | 0.125 | -0.125 | 0.125 | -0.125 |
z | -0.125 | -0.125 | -0.125 | -0.125 | 0.125 | 0.125 | 0.125 | 0.125 |
xz | 0.125 | -0.125 | -0.125 | 0.125 | -0.125 | 0.125 | 0.125 | -0.125 |
yz | 0.125 | 0.125 | -0.125 | -0.125 | -0.125 | -0.125 | 0.125 | 0.125 |
xyz | -0.125 | 0.125 | -0.125 | 0.125 | 0.125 | -0.125 | 0.125 | -0.125 |
Interface 5
- ܀ Interface
- ️܀ See example
- ↢
INTERFACE LagrangeCoeff_Hexahedron
MODULE FUNCTION LagrangeCoeff_Hexahedron5(&
& p, &
& q, &
& r, &
& xij, &
& basisType1, &
& basisType2, &
& basisType3, &
& alpha1, &
& beta1, &
& lambda1, &
& alpha2, &
& beta2, &
& lambda2, &
& alpha3, &
& beta3, &
& lambda3, &
& refHexahedron &
& ) RESULT(ans)
INTEGER(I4B), INTENT(IN) :: p
!! order of polynomial
INTEGER(I4B), INTENT(IN) :: q
!! order of polynomial
INTEGER(I4B), INTENT(IN) :: r
!! order of polynomial
REAL(DFP), INTENT(IN) :: xij(:, :)
!! These are interpolation points in xij format, size(xij,2)
INTEGER(I4B), INTENT(IN) :: basisType1
!! basis type in x direction
!! Monomials
!! Jacobi
!! Legendre
!! Chebyshev
!! Ultraspherical
!! Heirarchical
INTEGER(I4B), INTENT(IN) :: basisType2
!! basis type in y direction
!! Monomials
!! Jacobi
!! Legendre
!! Chebyshev
!! Ultraspherical
!! Heirarchical
INTEGER(I4B), INTENT(IN) :: basisType3
!! basis type in z direction
!! Monomials
!! Jacobi
!! Legendre
!! Chebyshev
!! Ultraspherical
!! Heirarchical
REAL(DFP), INTENT(IN) :: alpha1
!! This parameter is needed when basisType1 is Jacobi
REAL(DFP), INTENT(IN) :: beta1
!! This parameter is needed when basisType1 is Jacobi
REAL(DFP), INTENT(IN) :: lambda1
!! This parameter is needed when basisType1 is Ultraspherical
REAL(DFP), INTENT(IN) :: alpha2
!! This parameter is needed when basisType2 is Jacobi
REAL(DFP), INTENT(IN) :: beta2
!! This parameter is needed when basisType2 is Jacobi
REAL(DFP), INTENT(IN) :: lambda2
!! This parameter is needed when basisType2 is Ultraspherical
REAL(DFP), INTENT(IN) :: alpha3
!! This parameter is needed when basisType3 is Jacobi
REAL(DFP), INTENT(IN) :: beta3
!! This parameter is needed when basisType3 is Jacobi
REAL(DFP), INTENT(IN) :: lambda3
!! This parameter is needed when basisType3 is Ultraspherical
CHARACTER(*), OPTIONAL, INTENT(IN) :: refHexahedron
!! UNIT
!! BIUNIT
REAL(DFP) :: ans(SIZE(xij, 2), SIZE(xij, 2))
!! coefficients
END FUNCTION LagrangeCoeff_Hexahedron5
END INTERFACE LagrangeCoeff_Hexahedron
p, q, r
- p is order in x direction
- q is order in y direction
- r is order in z direction
xij
xij is the interpolation points. The number of rows in xij is 3, and the number of columns in xij should be equal to the total number of degrees of freedom.
basisType1, basisType2, basisType3
basisType in x, y, and z direction. It can take following values:
- Monomials
- Jacobi
- Legendre
- Chebyshev
- Ultraspherical
- Heirarchical
alpha1, beta1, lambda1
alpha1
andbeta1
are needed when basisType1 is Jacobilambda1
is needed when basisType1 is Ultraspherical
alpha2, beta2, lambda2
alpha2
andbeta2
are needed when basisType2 is Jacobilambda2
is needed when basisType2 is Ultraspherical
alpha3, beta, lambda3
alpha3
andbeta3
are needed when basisType3 is Jacobilambda3
is needed when basisType3 is Ultraspherical
refHexahedron
Reference hexahedron can be UNIT
or BIUNIT
.
PROGRAM main
USE easifembase
IMPLICIT NONE
INTEGER(i4b) :: i1, i2, p, q, r, basisType1, basisType2, basisType3
REAL(dfp), ALLOCATABLE :: xij(:, :), coeff(:, :)
TYPE(string) :: astr
REAL( DFP ) :: alpha1, beta1, lambda1
REAL( DFP ) :: alpha2, beta2, lambda2
REAL( DFP ) :: alpha3, beta3, lambda3
CHARACTER(*), parameter :: refHexahedron="BIUNIT"
INTEGER( I4B ), ALLOCATABLE :: deg(:, :)
p = 1
q = 1
r = 1
basisType1 = Monomial
basisType2 = Monomial
basisType3 = Monomial
deg = LagrangeDegree_Hexahedron(p, q, r)
xij = InterpolationPoint_Hexahedron( &
& p=p, &
& q=q, &
& r=r, &
& ipType1=Equidistance, &
& ipType2=Equidistance, &
& ipType3=Equidistance, &
& layout="VEFC")
coeff = LagrangeCoeff_Hexahedron(&
& p=p, &
& q=q, &
& r=r, &
& xij=xij, &
& basisType1=basisType1, &
& basisType2=basisType2, &
& basisType3=basisType3, &
& refHexahedron=refHexahedron, &
& alpha1=alpha1, &
& beta1=beta1, &
& lambda1=lambda1, &
& alpha2=alpha2, &
& beta2=beta2, &
& lambda2=lambda2, &
& alpha3=alpha3, &
& beta3=beta3, &
& lambda3=lambda3 &
& )
CALL Display(Mdencode(deg), "monomial degrees: " )
CALL Display(Mdencode(coeff), "coeff : " )
END PROGRAM main
See results
degrees:
a | b | c |
---|---|---|
0 | 0 | 0 |
1 | 0 | 0 |
0 | 1 | 0 |
1 | 1 | 0 |
0 | 0 | 1 |
1 | 0 | 1 |
0 | 1 | 1 |
1 | 1 | 1 |
coeff
basis | ||||||||
---|---|---|---|---|---|---|---|---|
1 | 0.125 | 0.125 | 0.125 | 0.125 | 0.125 | 0.125 | 0.125 | 0.125 |
x | -0.125 | 0.125 | 0.125 | -0.125 | -0.125 | 0.125 | 0.125 | -0.125 |
y | -0.125 | -0.125 | 0.125 | 0.125 | -0.125 | -0.125 | 0.125 | 0.125 |
xy | 0.125 | -0.125 | 0.125 | -0.125 | 0.125 | -0.125 | 0.125 | -0.125 |
z | -0.125 | -0.125 | -0.125 | -0.125 | 0.125 | 0.125 | 0.125 | 0.125 |
xz | 0.125 | -0.125 | -0.125 | 0.125 | -0.125 | 0.125 | 0.125 | -0.125 |
yz | 0.125 | 0.125 | -0.125 | -0.125 | -0.125 | -0.125 | 0.125 | 0.125 |
xyz | -0.125 | 0.125 | -0.125 | 0.125 | 0.125 | -0.125 | 0.125 | -0.125 |