chebyshev_m Module


Uses


Functions

public function cheb_eval(n, x) result(res)

Evaluates a Chebyshev polynomial of degree n at x (-1 <= x <= 1).

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n
real(kind=rp), intent(in) :: x

Return Value real(kind=rp)

public function cheb_ser_eval(n, c, x) result(res)

f(x), x E [-1,1] is given by the following appproximation formula in terms of Chebyshev polynomials:

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n

Highest degree of T_n (x).

real(kind=rp), intent(in), dimension(0:n) :: c

Chebyshev coefficients

real(kind=rp), intent(in) :: x

x E [-1,1] the point where the sum is to be evaluated.

Return Value real(kind=rp)

public function cheb_ser_eval2(nx, ny, c, x, y, rwrk) result(res)

f(x,y), (x,y) E [-1,1]x[-1,1] is given by the following appproximation formula in terms of Chebyshev polynomials:

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: nx

Highest degree of polynomial along x and y.

integer, intent(in) :: ny

Highest degree of polynomial along x and y.

real(kind=rp), intent(in), dimension(:) :: c

Chebyshev coefficients

real(kind=rp), intent(in) :: x

(x,y) E [-1,1]x[-1,1] the point where the series is to be evaluated.

real(kind=rp), intent(in) :: y

(x,y) E [-1,1]x[-1,1] the point where the series is to be evaluated.

real(kind=rp), intent(inout), dimension(:) :: rwrk

Work array of size at least ny+1

Return Value real(kind=rp)

public function cheb_ser_eval3(nx, ny, nz, c, x, y, z, rwrk) result(res)

f(x,y), (x,y) E [-1,1]x[-1,1] is given by the following appproximation formula in terms of Chebyshev polynomials:

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: nx

Highest degree of polynomial along x and y.

integer, intent(in) :: ny

Highest degree of polynomial along x and y.

integer, intent(in) :: nz

Highest degree of polynomial along x and y.

real(kind=rp), intent(in), dimension(:) :: c

Chebyshev coefficients

real(kind=rp), intent(in) :: x

(x,y) E [-1,1]x[-1,1]x[-1,1] the point where the series is to be evaluated.

real(kind=rp), intent(in) :: y

(x,y) E [-1,1]x[-1,1]x[-1,1] the point where the series is to be evaluated.

real(kind=rp), intent(in) :: z

(x,y) E [-1,1]x[-1,1]x[-1,1] the point where the series is to be evaluated.

real(kind=rp), intent(inout), dimension(:) :: rwrk

Work array of size at least nz + 1 + (max(ny,nz)+1)

Return Value real(kind=rp)

public function cheb_quad(tag, a, b, n, x, f) result(valint)

This subroutine evaluates an integral using Gauss-Chebyshev (CGL/CGR/CG) quadrature for a single variable.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: tag

{'CGL', 'CG', 'CGR'}
Type of nodes, where 'CGL': Chebyshev-Gauss-Lobatto, 'CG': Chebyshev-Gauss, and 'CGR': Chebyshev-Gauss-Radau.

real(kind=rp), intent(in) :: a

Domain bounds [a, b]

real(kind=rp), intent(in) :: b

Domain bounds [a, b]

integer, intent(in) :: n

Number of nodes is n+1

real(kind=rp), intent(in), dimension(0:n) :: x

Nodal coordinates in [-1, 1]

real(kind=rp), intent(in), dimension(0:n) :: f

Value of the function at the nodes

Return Value real(kind=rp)

public function cheb_quad2(tag, x0, x1, y0, y1, nx, ny, x, y, f, rwrk) result(valint)

This subroutine evaluates an integral using Gauss-Chebyshev (CGL/CGR/CG) quadrature for two variables.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: tag

{'CGL', 'CG', 'CGR'}
Type of nodes, where 'CGL': Chebyshev-Gauss-Lobatto, 'CG': Chebyshev-Gauss, and 'CGR': Chebyshev-Gauss-Radau.

real(kind=rp), intent(in) :: x0

Domain bounds [x0, x1]x[y0, y1] along x and y directions.

real(kind=rp), intent(in) :: x1

Domain bounds [x0, x1]x[y0, y1] along x and y directions.

real(kind=rp), intent(in) :: y0

Domain bounds [x0, x1]x[y0, y1] along x and y directions.

real(kind=rp), intent(in) :: y1

Domain bounds [x0, x1]x[y0, y1] along x and y directions.

integer, intent(in) :: nx

Number of nodes along x and y directions are (nx+1) and (ny+1)

integer, intent(in) :: ny

Number of nodes along x and y directions are (nx+1) and (ny+1)

real(kind=rp), intent(in), dimension(:) :: x

(nx+1,). Nodal coordinates along x direction in [-1, 1]

real(kind=rp), intent(in), dimension(:) :: y

(ny+1,). Nodal coordinates along y direction in [-1, 1]

real(kind=rp), intent(in), dimension(:) :: f

((nx+1)*(ny+1),). Value of the function at the nodes

real(kind=rp), intent(inout), dimension(:) :: rwrk

Workspace array of size at least (ny+1)

Return Value real(kind=rp)

public function cheb_quad3(tag, x0, x1, y0, y1, z0, z1, nx, ny, nz, x, y, z, f, rwrk) result(valint)

This subroutine evaluates an integral using Gauss-Chebyshev (CGL/CGR/CG) quadrature for three variables.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: tag

{'CGL', 'CG', 'CGR'}
Type of nodes, where 'CGL': Chebyshev-Gauss-Lobatto, 'CG': Chebyshev-Gauss, and 'CGR': Chebyshev-Gauss-Radau.

real(kind=rp), intent(in) :: x0

Domain bounds [x0, x1]x[y0, y1]x[z0, z1] along x, y, and z directions.

real(kind=rp), intent(in) :: x1

Domain bounds [x0, x1]x[y0, y1]x[z0, z1] along x, y, and z directions.

real(kind=rp), intent(in) :: y0

Domain bounds [x0, x1]x[y0, y1]x[z0, z1] along x, y, and z directions.

real(kind=rp), intent(in) :: y1

Domain bounds [x0, x1]x[y0, y1]x[z0, z1] along x, y, and z directions.

real(kind=rp), intent(in) :: z0

Domain bounds [x0, x1]x[y0, y1]x[z0, z1] along x, y, and z directions.

real(kind=rp), intent(in) :: z1

Domain bounds [x0, x1]x[y0, y1]x[z0, z1] along x, y, and z directions.

integer, intent(in) :: nx

Number of nodes along x, y, and z directions are (nx+1), (ny+1), and (nz+1).

integer, intent(in) :: ny

Number of nodes along x, y, and z directions are (nx+1), (ny+1), and (nz+1).

integer, intent(in) :: nz

Number of nodes along x, y, and z directions are (nx+1), (ny+1), and (nz+1).

real(kind=rp), intent(in), dimension(:) :: x

(nx+1,). Nodal coordinates along x direction in [-1,1]

real(kind=rp), intent(in), dimension(:) :: y

(ny+1,). Nodal coordinates along y direction in [-1,1]

real(kind=rp), intent(in), dimension(:) :: z

(nz+1,). Nodal coordinates along z direction in [-1,1]

real(kind=rp), intent(in), dimension(:) :: f

((nx+1)(ny+1)(nz+1),). Value of the function at the nodes

real(kind=rp), intent(inout), dimension(:) :: rwrk

Workspace array of size at least nz + 1 + (max(ny,nz)+1)

Return Value real(kind=rp)

public function lag_intrp(n, x, w, f, p) result(res)

Evaluates the Lagrange interpolant (barycentric) at a given point p from nodal coordinates and nodal function values in 1D.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n

Number of interpolant nodes = n+1.

real(kind=rp), intent(in), dimension(:) :: x

(n,). Nodal coordinates in strictly ascending order

real(kind=rp), intent(in), dimension(:) :: w

(n,). Barycentric weights

real(kind=rp), intent(in), dimension(:) :: f

(n,). Value of the function at the nodes

real(kind=rp), intent(in) :: p

Coordinate of the interpolation point.

Return Value real(kind=rp)


Subroutines

public subroutine cheb_node(tag, a, b, n, xcol, is_descending)

This subroutine returns coordinates of the Chebyshev nodes in [a,b].

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: tag

{'CGL', 'CG', 'CGR'}
Type of nodes, where 'CGL': Chebyshev-Gauss-Lobatto, 'CG': Chebyshev-Gauss, and 'CGR': Chebyshev-Gauss-Radau.

real(kind=rp), intent(in) :: a

Domain bounds [a, b]

real(kind=rp), intent(in) :: b

Domain bounds [a, b]

integer, intent(in) :: n

Degree of polynomial.

real(kind=rp), intent(out), dimension(0:n) :: xcol

(n+1,). Vector of nodal coordinates.

logical, intent(in), optional :: is_descending

{T,F} Coordinates in ascending (default) or descending order.

public subroutine cheb_n1dmat(x0, x1, n, rwrk, dm)

Calculates the nodal first derivative matrix for CGL nodes in [x0,x1] Assumes the nodal coordinates to be in ascending order in the domain [-1,1].

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in) :: x0

Domain bounds [x0, x1]

real(kind=rp), intent(in) :: x1

Domain bounds [x0, x1]

integer, intent(in) :: n

Degree of the polynomial

real(kind=rp), intent(inout), dimension(:), target :: rwrk

Workspace array of minimum size 2*(n+1)

real(kind=rp), intent(out), dimension(:,:) :: dm

(n+1,n+1). Nodal first derivative matrix

public subroutine cheb_n2dmat(n, dm1, dm2)

Calculates the nodal second derivative matrix for CGL/CG/CGR nodes.

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n

Degree of the polynomial

real(kind=rp), intent(in), dimension(:,:) :: dm1

(n+1,n+1). Nodal first derivative matrix

real(kind=rp), intent(out), dimension(:,:) :: dm2

(n+1,n+1). Nodal second derivative matrix

public subroutine cheb_tensorize_ndm2(var, nx, ny, dmat, tdm)

Tensorize the nodal derivative matrix for two variables in the domain [-1,1]x[-1,1].

Arguments

Type IntentOptional Attributes Name
character(len=1), intent(in) :: var

Independent variable {'x', 'y'}

integer, intent(in) :: nx

Degree of the polynomial along x and y directions

integer, intent(in) :: ny

Degree of the polynomial along x and y directions

real(kind=rp), intent(in), dimension(:,:) :: dmat

(nx+1, nx+1) or (ny+1, ny+1) Nodal derivative matrix in the domain [-1,1].

real(kind=rp), intent(out), dimension(:,:) :: tdm

Tensorized derivative matrix with nrows = ncols = (nx+1)*(ny+1)

public subroutine cheb_tensorize_ndm3(var, nx, ny, nz, dmat, tdm)

Tensorize the nodal derivative matrix for three variables in the domain [-1,1]x[-1,1]X[-1,1].

Arguments

Type IntentOptional Attributes Name
character(len=1), intent(in) :: var

Independent variable {'x', 'y', 'z'}

integer, intent(in) :: nx

Degree of the polynomial along x, y, and z directions

integer, intent(in) :: ny

Degree of the polynomial along x, y, and z directions

integer, intent(in) :: nz

Degree of the polynomial along x, y, and z directions

real(kind=rp), intent(in), dimension(:,:) :: dmat

(nx+1, nx+1) or (ny+1, ny+1) or (nz+1, nz+1). Nodal derivative matrix in the domain [-1,1].

real(kind=rp), intent(out), dimension(:,:) :: tdm

Tensorized derivative matrix with nrows = ncols = (nx+1)(ny+1)(nz+1)

public subroutine cheb_nod_deriv(dm, f, fp)

Calculates the derivative of a 1D function at the nodes.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(:,:) :: dm

((n+1),(n+1)) Differentiation matrix, where the number of nodes = n+1

real(kind=rp), intent(in), dimension(:) :: f

(n+1,). Value of the function at the nodes.

real(kind=rp), intent(out), dimension(:) :: fp

(n+1,). Value of the derivative at the nodes.

public subroutine cheb_nod_deriv2(nx, ny, dmx, dmy, f, fpx, fpy)

Calculates the derivative of a 2D function at the nodes.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: nx

Number of nodes along x = nx+1 and along y = ny+1

integer, intent(in) :: ny

Number of nodes along x = nx+1 and along y = ny+1

real(kind=rp), intent(in), dimension(:,:) :: dmx

((nx+1),(nx+1)) Differentiation matrix along x

real(kind=rp), intent(in), dimension(:,:) :: dmy

((ny+1),(ny+1)) Differentiation matrix along y

real(kind=rp), intent(in), dimension(:) :: f

(m,), where m = (nx+1)*(ny+1). Value of the function at the nodes.

real(kind=rp), intent(out), dimension(:) :: fpx

(m,), where m = (nx+1)*(ny+1). Value of the derivatives at the nodes.

real(kind=rp), intent(out), dimension(:) :: fpy

(m,), where m = (nx+1)*(ny+1). Value of the derivatives at the nodes.

public subroutine cheb_nod_deriv3(nx, ny, nz, dmx, dmy, dmz, f, fpx, fpy, fpz)

Calculates the derivative of a 3D function at the nodes.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: nx

Number of nodes along x = nx+1, along y = ny+1, and along z = nz+1

integer, intent(in) :: ny

Number of nodes along x = nx+1, along y = ny+1, and along z = nz+1

integer, intent(in) :: nz

Number of nodes along x = nx+1, along y = ny+1, and along z = nz+1

real(kind=rp), intent(in), dimension(:,:) :: dmx

((nx+1),(nx+1)) Differentiation matrix along x

real(kind=rp), intent(in), dimension(:,:) :: dmy

((ny+1),(ny+1)) Differentiation matrix along y

real(kind=rp), intent(in), dimension(:,:) :: dmz

((nz+1),(nz+1)) Differentiation matrix along z

real(kind=rp), intent(in), dimension(:) :: f

(m,), where m = (nx+1)(ny+1)(nz+1). Value of the function at the nodes.

real(kind=rp), intent(out), dimension(:) :: fpx

(m,), where m = (nx+1)(ny+1)(nz+1). Value of the derivatives at the nodes.

real(kind=rp), intent(out), dimension(:) :: fpy

(m,), where m = (nx+1)(ny+1)(nz+1). Value of the derivatives at the nodes.

real(kind=rp), intent(out), dimension(:) :: fpz

(m,), where m = (nx+1)(ny+1)(nz+1). Value of the derivatives at the nodes.

public subroutine cheb_dctmat(n, mat, rwrk)

Calculates the discrete Chebyshev transform matrix for a single variable. The matrix is not symmetric and assumes the nodal coordinates to be in ascending order.

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n

Degree of polynomial

real(kind=rp), intent(out), dimension(:,:) :: mat

((n+1),(n+1)) Transform matrix.

real(kind=rp), intent(inout), dimension(:) :: rwrk

Workspace array of minimum size (n+1)

public subroutine cheb_dctmat2(nx, ny, mat, rwrk)

This subroutine transforms the function values at the CGL points to the coefficients of the Chebyshev series for two variables. The matrix is not symmetric and assumes the nodal coordinates to be in ascending order.

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: nx

Degree of polynomial along x direction

integer, intent(in) :: ny

Degree of polynomial along y direction

real(kind=rp), intent(out), dimension(:,:) :: mat

((nx+1)(ny+1),(nx+1)(ny+1)) matrix. Transform matrix.

real(kind=rp), intent(inout), dimension(:), target :: rwrk

Workspace array of minimum size (nx+1) + (ny+1)

public subroutine cheb_dictmat(n, mat)

Calculates the discrete inverse Chebyshev transform matrix. The matrix is not symmetric and yields the nodal function values assuming the nodal coordinates are in ascending order.

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n

Degree of polynomial

real(kind=rp), intent(out), dimension(:,:) :: mat

(n+1,n+1). Inverse transform matrix.

public subroutine bary_weights(n, w)

Calculates the barycentric weights for a given set of nodes. As of now, assumues CGL nodes. TODO: extend stably for the general case (CGL, CGR, CG)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n

Number of interpolation nodes = n+1.

real(kind=rp), intent(out), dimension(:) :: w

(n+1,). Barycentric weights

public subroutine lag_intrp_mat(n, m, x, w, z, mat)

Computes the Lagrange interpolation (barycentric) matrix.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n

Number of nodes = n+1

integer, intent(in) :: m

Number of interpolation points = m+1

real(kind=rp), intent(in), dimension(:) :: x

(n+1,). Nodal coordinates in strictly ascending order

real(kind=rp), intent(in), dimension(:) :: w

(n+1,). Barycentric weights

real(kind=rp), intent(in), dimension(:) :: z

(m+1,). Coordinates at which the function is to be interpolated

real(kind=rp), intent(out), dimension(:,:) :: mat

(m+1,n+1). Interpolation matrix

public subroutine lag_intrp_grd(mat, f, fintrp)

Interpolates nodal function values to a grid using barycentric lagrange interpolation.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(:,:) :: mat

(np,n). Interpolation matrix

real(kind=rp), intent(in), dimension(:) :: f

(n,). Value of the function at the nodes

real(kind=rp), intent(out), dimension(:) :: fintrp

(np,). Value of the function at the nodes

public subroutine lag_intrp_grd2(nx, ny, npx, npy, matx, maty, f, fintrp, rwrk)

Interpolates nodal function values to a grid using barycentric lagrange interpolation in two variables.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: nx

Number of nodes along x = nx+1 and along y = ny+1

integer, intent(in) :: ny

Number of nodes along x = nx+1 and along y = ny+1

integer, intent(in) :: npx

Number of interpolating points along x = npx+1 and along y = npy+1

integer, intent(in) :: npy

Number of interpolating points along x = npx+1 and along y = npy+1

real(kind=rp), intent(in), dimension(:,:) :: matx

(npx+1,nx+1). Interpolation matrix along x

real(kind=rp), intent(in), dimension(:,:) :: maty

(npy+1,npy+1). Interpolation matrix along y

real(kind=rp), intent(in), dimension(:) :: f

((nx+1)*(ny+1),). Value of the function at the nodes

real(kind=rp), intent(out), dimension(:) :: fintrp

((npx+1)*(npy+1),). Value of the function at the nodes

real(kind=rp), intent(inout), dimension(:) :: rwrk

Workspace array of minimum size (npx+1)*(ny+1).

public subroutine lag_intrp_grd3(nx, ny, nz, npx, npy, npz, matx, maty, matz, f, fintrp, rwrk)

Interpolates nodal function values to a grid using barycentric lagrange interpolation in three variables.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: nx

Number of nodes along x = nx+1, along y = ny+1, and along z = nz+1

integer, intent(in) :: ny

Number of nodes along x = nx+1, along y = ny+1, and along z = nz+1

integer, intent(in) :: nz

Number of nodes along x = nx+1, along y = ny+1, and along z = nz+1

integer, intent(in) :: npx

Number of interpolating points along x = npx+1, along y = npy+1, and along z = npz+1

integer, intent(in) :: npy

Number of interpolating points along x = npx+1, along y = npy+1, and along z = npz+1

integer, intent(in) :: npz

Number of interpolating points along x = npx+1, along y = npy+1, and along z = npz+1

real(kind=rp), intent(in), dimension(:,:) :: matx

(npx+1,nx+1). Interpolation matrix along x

real(kind=rp), intent(in), dimension(:,:) :: maty

(npy+1,ny+1). Interpolation matrix along y

real(kind=rp), intent(in), dimension(:,:) :: matz

(npz+1,nz+1). Interpolation matrix along z

real(kind=rp), intent(in), dimension(:) :: f

(nx+1)(ny+1)(nz+1), ). Value of the function at the nodes

real(kind=rp), intent(out), dimension(:) :: fintrp

(npx+1)(npy+1)(npz+1), ). Value of the function at the interpolation points.

real(kind=rp), intent(inout), dimension(:) :: rwrk

Workspace array, minimum size (npx+1)(npy+1)(nz+1)+(npx+1)*(ny+1)