A data structure for working with Lagrange Interpolating Polynomials in one, two, and three dimensions. The Lagrange data-structure stores the information necessary to interpolate between two sets of grid-points and to estimate the derivative of data at native grid points. Routines for multidimensional interpolation are based on the tensor product of 1-D interpolants. It is assumed that the polynomial degree (and the interpolation nodes) are the same in each direction. This assumption permits the storage of only one array of interpolation nodes and barycentric weights and is what allows this data structure to be flexible.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | public | :: | M | The number of target points. |
|||
| integer, | public | :: | N | The number of control points. |
|||
| real(kind=prec), | public, | pointer, contiguous, dimension(:,:) | :: | bMatrix | The boundary interpolation matrix that is used to map a grid of nodal values at the control points to the element boundaries. |
||
| real(kind=prec), | public, | pointer, contiguous, dimension(:) | :: | bWeights | The barycentric weights that are calculated from the controlPoints and used for interpolation. |
||
| integer, | public | :: | controlNodeType | ||||
| real(kind=prec), | public, | pointer, contiguous, dimension(:) | :: | controlPoints | The set of nodes in one dimension where data is known. To create higher dimension interpolation and differentiation operators, structured grids in two and three dimensions are created by tensor products of the controlPoints. This design decision implies that all spectral element methods supported by the Lagrange class have the same polynomial degree in each computational/spatial dimension. In practice, the controlPoints are the Legendre-Gauss, Legendre-Gauss-Lobatto, Legendre-Gauss-Radau, Chebyshev-Gauss, Chebyshev-Gauss-Lobatto, or Chebyshev-Gauss-Radau quadrature points over the domain [-1,1] (computational space). The Init routine for this class restricts controlPoints to one of these quadrature types or uniform points on [-1,1]. |
||
| real(kind=prec), | public, | pointer, contiguous, dimension(:,:) | :: | dMatrix | The derivative matrix for mapping function nodal values to a nodal values of the derivative estimate. The dMatrix is based on a strong form of the derivative. |
||
| real(kind=prec), | public, | pointer, contiguous, dimension(:,:) | :: | dSplitMatrix | The split-form derivative matrix D_split = D - 0.5M^{-1}B, where B is the SBP boundary operator. D_split is skew-symmetric under the M inner product: MD_split + D_split^TM = 0. Unlike D, it is NOT an SBP operator (the weighted symmetric part is zero, not the boundary term B). This property makes D_split ideal for the EC-DGSEM split-form volume integral: du/dt = -(2/J) sum_n D_split[n,i] * F_EC(u_i, u_n) + (1/J) M^{-1} B^T f_Riemann The skew-symmetry of the volume term guarantees it contributes zero to the entropy rate, so all entropy change passes through the surface term. An entropy-dissipative Riemann solver then makes the full scheme entropy-stable. Using D_split in the volume combined with plain f_Riemann on the surface is algebraically identical to using D in the volume with the penalty (f_Riemann - f_local) on the surface (Trixi.jl convention). In SELF index convention (dSplitMatrix(ii,i) = D_split[i-1, ii-1]): dSplitMatrix(ii,i) = dMatrix(ii,i) - 0.5(bMatrix(i,2)bMatrix(ii,2) - bMatrix(i,1)*bMatrix(ii,1)) / qWeights(i) |
||
| real(kind=prec), | public, | pointer, contiguous, dimension(:,:) | :: | dgMatrix | The derivative matrix for mapping function nodal values to a nodal values of the derivative estimate. The dgMatrix is based on a weak form of the derivative. It must be used with bMatrix to account for boundary contributions in the weak form. |
||
| real(kind=prec), | public, | pointer, contiguous, dimension(:,:) | :: | iMatrix | The interpolation matrix (transpose) for mapping data from the control grid to the target grid. |
||
| real(kind=prec), | public, | pointer, contiguous, dimension(:,:,:) | :: | mortarP | Mortar L2-projection matrices, the adjoints of mortarR under the exact L2 inner product on [-1,1]: given traces g_k(s) on the two sub-edges, the projected big-side trace is u(i) = sum_k sum_ii mortarP(ii,i,k)*g_k(ii). The matrices are built as P_k = M^{-1} B_k with the exact (dense) 1-D mass matrix M(m,i) = int l_m l_i dxi and B_k(m,j) = (1/2) int l_m(xi_k(s)) l_j(s) ds, evaluated with an internal Gauss rule that is exact for the degree 2N integrands. Consequently sum_k matmul(P_k,R_k) = I (a polynomial split across both sub-edges is recovered) sum_m w_m (P_k g)_m = (1/2) sum_j w_j g_k(j) (discrete conservation) for any control node type. mortarP carries the 1/2 sub-edge Jacobian appropriate for projecting solution traces; when projecting surface-flux integrands (which carry the small side's nScale = nScale_big/2), scale by 2 (see MortarFluxCollect in the 2-D mapped data classes). |
||
| real(kind=prec), | public, | pointer, contiguous, dimension(:,:,:) | :: | mortarR | Mortar restriction matrices for 2:1 nonconforming (mortar) interfaces. An element edge trace u(xi) = sum_i u_i l_i(xi) on [-1,1] ("big" side) is restricted to the two half-edges ("small" sides) of its 2:1 neighbors. Sub-edge k=1 occupies xi in [-1,0] and k=2 occupies xi in [0,1], with the sub-edge coordinate s in [-1,1] related to the big-edge coordinate through xi_1(s) = (s-1)/2 and xi_2(s) = (s+1)/2. mortarR(ii,i,k) = l_ii( xi_k(s_i) ), where s_i are the control points; following the SELF matrix convention, the restricted trace is u_k(i) = sum_ii mortarR(ii,i,k)*u(ii). Restriction of a degree N polynomial is exact. |
||
| real(kind=prec), | public, | pointer, contiguous, dimension(:) | :: | qWeights | The quadrature weights for discrete integration. The quadradture weights depend on the type of controlPoints provided; one of Legendre-Gauss, Legendre-Gauss-Lobatto, Legendre-Gauss-Radau, Chebyshev-Gauss, Chebyshev-Gauss-Lobatto, Chebyshev-Gauss Radau, or Uniform. If Uniform, the quadrature weights are constant . |
||
| integer, | public | :: | targetNodeType | ||||
| real(kind=prec), | public, | pointer, contiguous, dimension(:) | :: | targetPoints | The set of nodes in one dimension where data is to be interpolated to. To create higher dimension interpolation and differentiation operators, structured grids in two and three dimensions are created by tensor products of the targetPoints. In practice, the targetPoints are set to a uniformly distributed set of points between [-1,1] (computational space) to allow for interpolation from unevenly spaced quadrature points to a plotting grid. |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(Lagrange_t), | intent(inout) | :: | this |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(Lagrange_t), | intent(inout) | :: | this |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(Lagrange_t), | intent(inout) | :: | this |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(Lagrange_t) | :: | this | ||||
| real(kind=prec) | :: | sE |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(Lagrange_t), | intent(inout) | :: | this |
Frees all memory (host and device) associated with an instance of the Lagrange_t class
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(Lagrange_t), | intent(inout) | :: | this | Lagrange_t class instance |
Initialize an instance of the Lagrange_t class On output, all of the attributes for the Lagrange_t class are allocated and values are initialized according to the number of control points, number of target points, and the types for the control and target nodes. If a GPU is available, device pointers for the Lagrange_t attributes are allocated and initialized.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(Lagrange_t), | intent(out) | :: | this | Lagrange_t class instance |
||
| integer, | intent(in) | :: | N | The number of control points for interpolant |
||
| integer, | intent(in) | :: | controlNodeType | The integer code specifying the type of control points. Parameters are defined in SELF_Constants.f90. One of GAUSS(=1), GAUSS_LOBATTO(=2), or UNIFORM(=3) |
||
| integer, | intent(in) | :: | M | The number of target points for the interpolant |
||
| integer, | intent(in) | :: | targetNodeType | The integer code specifying the type of target points. Parameters are defined in SELF_Constants.f90. One of GAUSS(=1), GAUSS_LOBATTO(=2), or UNIFORM(=3) |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(Lagrange_t), | intent(in) | :: | this | |||
| integer(kind=HID_T), | intent(in) | :: | fileId |
type,public :: Lagrange_t
!! A data structure for working with Lagrange Interpolating Polynomials in one, two, and three dimensions.
!! The Lagrange data-structure stores the information necessary to interpolate between two
!! sets of grid-points and to estimate the derivative of data at native grid points. Routines for
!! multidimensional interpolation are based on the tensor product of 1-D interpolants. It is
!! assumed that the polynomial degree (and the interpolation nodes) are the same in each direction.
!! This assumption permits the storage of only one array of interpolation nodes and barycentric
!! weights and is what allows this data structure to be flexible.
integer :: N
!! The number of control points.
integer :: controlNodeType
integer :: M
!! The number of target points.
integer :: targetNodeType
real(prec),pointer,contiguous,dimension(:) :: controlPoints
!! The set of nodes in one dimension where data is known.
!! To create higher dimension interpolation and differentiation operators, structured grids in two and three
!! dimensions are created by tensor products of the controlPoints. This design decision implies that all
!! spectral element methods supported by the Lagrange class have the same polynomial degree in each
!! computational/spatial dimension. In practice, the controlPoints are the Legendre-Gauss, Legendre-Gauss-Lobatto,
!! Legendre-Gauss-Radau, Chebyshev-Gauss, Chebyshev-Gauss-Lobatto, or Chebyshev-Gauss-Radau quadrature points over
!! the domain [-1,1] (computational space). The Init routine for this class restricts controlPoints to one of
!! these quadrature types or uniform points on [-1,1].
real(prec),pointer,contiguous,dimension(:) :: targetPoints
!! The set of nodes in one dimension where data is to be interpolated to. To create higher dimension interpolation
!! and differentiation operators, structured grids in two and three dimensions are created by tensor products of
!! the targetPoints. In practice, the targetPoints are set to a uniformly distributed set of points between [-1,1]
!! (computational space) to allow for interpolation from unevenly spaced quadrature points to a plotting grid.
real(prec),pointer,contiguous,dimension(:) :: bWeights
!! The barycentric weights that are calculated from the controlPoints and used for interpolation.
real(prec),pointer,contiguous,dimension(:) :: qWeights
!! The quadrature weights for discrete integration. The quadradture weights depend on the type of controlPoints
!! provided; one of Legendre-Gauss, Legendre-Gauss-Lobatto, Legendre-Gauss-Radau, Chebyshev-Gauss,
!! Chebyshev-Gauss-Lobatto, Chebyshev-Gauss Radau, or Uniform. If Uniform, the quadrature weights are constant
!! $$dx = \frac{2.0}{N+1}$$.
real(prec),pointer,contiguous,dimension(:,:) :: iMatrix
!! The interpolation matrix (transpose) for mapping data from the control grid to the target grid.
real(prec),pointer,contiguous,dimension(:,:) :: dMatrix
!! The derivative matrix for mapping function nodal values to a nodal values of the derivative estimate. The
!! dMatrix is based on a strong form of the derivative.
real(prec),pointer,contiguous,dimension(:,:) :: dgMatrix
!! The derivative matrix for mapping function nodal values to a nodal values of the derivative estimate. The dgMatrix is based
!! on a weak form of the derivative. It must be used with bMatrix to account for boundary contributions in the weak form.
real(prec),pointer,contiguous,dimension(:,:) :: dSplitMatrix
!! The split-form derivative matrix D_split = D - 0.5*M^{-1}*B, where B is the SBP boundary operator.
!!
!! D_split is skew-symmetric under the M inner product: M*D_split + D_split^T*M = 0. Unlike D, it is
!! NOT an SBP operator (the weighted symmetric part is zero, not the boundary term B). This property
!! makes D_split ideal for the EC-DGSEM split-form volume integral:
!!
!! du/dt = -(2/J) sum_n D_split[n,i] * F_EC(u_i, u_n) + (1/J) M^{-1} B^T f_Riemann
!!
!! The skew-symmetry of the volume term guarantees it contributes zero to the entropy rate, so all
!! entropy change passes through the surface term. An entropy-dissipative Riemann solver then makes
!! the full scheme entropy-stable.
!!
!! Using D_split in the volume combined with plain f_Riemann on the surface is algebraically identical
!! to using D in the volume with the penalty (f_Riemann - f_local) on the surface (Trixi.jl convention).
!!
!! In SELF index convention (dSplitMatrix(ii,i) = D_split[i-1, ii-1]):
!! dSplitMatrix(ii,i) = dMatrix(ii,i)
!! - 0.5*(bMatrix(i,2)*bMatrix(ii,2)
!! - bMatrix(i,1)*bMatrix(ii,1)) / qWeights(i)
real(prec),pointer,contiguous,dimension(:,:) :: bMatrix
!! The boundary interpolation matrix that is used to map a grid of nodal values at the control points to the element boundaries.
real(prec),pointer,contiguous,dimension(:,:,:) :: mortarR
!! Mortar restriction matrices for 2:1 nonconforming (mortar) interfaces.
!!
!! An element edge trace u(xi) = sum_i u_i l_i(xi) on [-1,1] ("big" side) is restricted to
!! the two half-edges ("small" sides) of its 2:1 neighbors. Sub-edge k=1 occupies
!! xi in [-1,0] and k=2 occupies xi in [0,1], with the sub-edge coordinate s in [-1,1]
!! related to the big-edge coordinate through xi_1(s) = (s-1)/2 and xi_2(s) = (s+1)/2.
!!
!! mortarR(ii,i,k) = l_ii( xi_k(s_i) ), where s_i are the control points; following the
!! SELF matrix convention, the restricted trace is u_k(i) = sum_ii mortarR(ii,i,k)*u(ii).
!! Restriction of a degree N polynomial is exact.
real(prec),pointer,contiguous,dimension(:,:,:) :: mortarP
!! Mortar L2-projection matrices, the adjoints of mortarR under the exact L2 inner
!! product on [-1,1]: given traces g_k(s) on the two sub-edges, the projected big-side
!! trace is u(i) = sum_k sum_ii mortarP(ii,i,k)*g_k(ii).
!!
!! The matrices are built as P_k = M^{-1} B_k with the exact (dense) 1-D mass matrix
!! M(m,i) = int l_m l_i dxi and B_k(m,j) = (1/2) int l_m(xi_k(s)) l_j(s) ds, evaluated
!! with an internal Gauss rule that is exact for the degree 2N integrands. Consequently
!! sum_k matmul(P_k,R_k) = I (a polynomial split across both sub-edges is recovered)
!! sum_m w_m (P_k g)_m = (1/2) sum_j w_j g_k(j) (discrete conservation)
!! for any control node type. mortarP carries the 1/2 sub-edge Jacobian appropriate for
!! projecting *solution* traces; when projecting surface-flux integrands (which carry the
!! small side's nScale = nScale_big/2), scale by 2 (see MortarFluxCollect in the 2-D
!! mapped data classes).
contains
procedure,public :: Init => Init_Lagrange_t
procedure,public :: Free => Free_Lagrange_t
procedure,public :: WriteHDF5 => WriteHDF5_Lagrange_t
procedure,public :: CalculateBarycentricWeights
procedure,public :: CalculateInterpolationMatrix
procedure,public :: CalculateDerivativeMatrix
procedure,public :: CalculateLagrangePolynomials
procedure,public :: CalculateMortarMatrices
endtype Lagrange_t