Modes (Basis functions)

Function Spaces

class modepy.FunctionSpace

An opaque object representing a finite-dimensional function space of functions \(\mathbb R^n \to \mathbb R\).

spatial_dim

\(n\) in the above definition, the number of spatial dimensions in which the functions in the space operate.

space_dim

The number of dimensions of the function space.

class modepy.PN(spatial_dim, order)

The function space of polynomials with total degree \(N\) = order.

\[P^N:=\operatorname{span}\left\{\prod_{i=1}^d x_i^{n_i}:\sum n_i\le N\right\}.\]
order
__init__(spatial_dim, order)

Initialize self. See help(type(self)) for accurate signature.

class modepy.QN(spatial_dim, order)

The function space of polynomials with maximum degree \(N\) = order:

\[Q^N:=\operatorname{span} \left \{\prod_{i=1}^d x_i^{n_i}:\max n_i\le N\right\}.\]
order
__init__(spatial_dim, order)

Initialize self. See help(type(self)) for accurate signature.

modepy.space_for_shape(shape, order)
modepy.space_for_shape(shape, order)
modepy.space_for_shape(shape, order)

Return an unspecified instance of FunctionSpace suitable for approximation on shape attaining interpolation error of \(O(h^{\text{order}+1})\).

Parameters
Return type

modepy.spaces.FunctionSpace

Redirections to Canonical Names

class modepy.spaces.FunctionSpace

See modepy.FunctionSpace.

class modepy.spaces.PN

See modepy.PN.

class modepy.spaces.QN

See modepy.QN.

This functionality provides sets of basis functions for the reference elements in modepy.shapes.

Basis Retrieval

exception modepy.BasisNotOrthonormal
class modepy.Basis
orthonormality_weight()
mode_ids

Return a tuple of of mode (basis function) identifiers, one for each basis function. Mode identifiers should generally be viewed as opaque. They are hashable. For some bases, they are tuples of length matching the number of dimensions and indicating the order along each reference axis.

functions

Return a tuple of (callable) basis functions of length matching mode_ids. Each function takes a vector of (r,s,t) reference coordinates as input.

gradients

Return a tuple of basis functions of length matching mode_ids. Each function takes a vector of (r,s,t) reference coordinates as input.

modepy.basis_for_space(space, shape)
modepy.basis_for_space(space, shape)
modepy.basis_for_space(space, shape)
Parameters
Return type

modepy.modes.Basis

modepy.orthonormal_basis_for_space(space, shape)
modepy.orthonormal_basis_for_space(space, shape)
modepy.orthonormal_basis_for_space(space, shape)
Parameters
Return type

modepy.modes.Basis

modepy.monomial_basis_for_space(space, shape)
modepy.monomial_basis_for_space(space, shape)
modepy.monomial_basis_for_space(space, shape)
Parameters
Return type

modepy.modes.Basis

Jacobi polynomials

modepy.jacobi(alpha, beta, n, x)

Evaluate Jacobi polynomials of type \((\alpha, \beta)\) with \(\alpha, \beta > -1\) and \(\alpha+\beta \ne -1\) at a vector of points x for order n. The points x must lie on the interval \([-1,1]\).

Returns

a vector of \(P^{(\alpha, \beta)}_n\) evaluated at all x.

The polynomials are normalized to be orthonormal with respect to the Jacobi weight \((1-x)^\alpha(1+x)^\beta\).

Observe that choosing \(\alpha=\beta=0\) will yield the Legendre polynomials.

modepy.grad_jacobi(alpha, beta, n, x)

Evaluate the derivative of jacobi(), with the same meanings and restrictions for all arguments.

Conversion to Symbolic

modepy.symbolicize_function(f, dim, ref_coord_var_name='r')

For a function f (basis or gradient) returned by one of the functions in this module, return a pymbolic expression representing the same function.

Parameters

dim – the number of dimensions of the reference element on which basis is defined.

New in version 2020.2.

Tensor product adapter

class modepy.TensorProductBasis(bases_1d, grad_bases_1d, orth_weight)

Adapts multiple one-dimensional bases into a tensor product basis.

__init__(bases_1d, grad_bases_1d, orth_weight)
Parameters
  • bases_1d – a sequence (one entry per axis/dimension) of sequences (representing the basis) of 1D functions representing the approximation basis.

  • grad_bases_1d – a sequence (one entry per axis/dimension) representing the derivatives of bases_1d.

PKDO basis functions

modepy.modes.pkdo_2d(order, rs)

Evaluate a 2D orthonormal (with weight 1) polynomial on the unit simplex.

Parameters
  • order – A tuple (i, j) representing the order of the polynomial.

  • rsrs[0], rs[1] are arrays of \((r,s)\) coordinates. (See Coordinates on the triangle)

Returns

a vector of values of the same length as the rs arrays.

See the following publications:

  • Proriol, Joseph. “Sur une famille de polynomes á deux variables orthogonaux dans un triangle.” CR Acad. Sci. Paris 245 (1957): 2459-2461.

  • Koornwinder, T. “Two-variable analogues of the classical orthogonal polynomials.” Theory and Applications of Special Functions. 1975, pp. 435-495.

  • Dubiner, Moshe. “Spectral Methods on Triangles and Other Domains.” Journal of Scientific Computing 6, no. 4 (December 1, 1991): 345–390. http://dx.doi.org/10.1007/BF01060030

modepy.modes.grad_pkdo_2d(order, rs)

Evaluate the derivatives of pkdo_2d().

Parameters
  • order – A tuple (i, j) representing the order of the polynomial.

  • rsrs[0], rs[1] are arrays of \((r,s)\) coordinates. (See Coordinates on the triangle)

Returns

a tuple of vectors (dphi_dr, dphi_ds), each of the same length as the rs arrays.

See the following publications:

  • Proriol, Joseph. “Sur une famille de polynomes á deux variables orthogonaux dans un triangle.” CR Acad. Sci. Paris 245 (1957): 2459-2461.

  • Koornwinder, T. “Two-variable analogues of the classical orthogonal polynomials.” Theory and Applications of Special Functions. 1975, pp. 435-495.

  • Dubiner, Moshe. “Spectral Methods on Triangles and Other Domains.” Journal of Scientific Computing 6, no. 4 (December 1, 1991): 345–390. http://dx.doi.org/10.1007/BF01060030

modepy.modes.pkdo_3d(order, rst)

Evaluate a 2D orthonormal (with weight 1) polynomial on the unit simplex.

Parameters
  • order – A tuple (i, j, k) representing the order of the polynomial.

  • rsrst[0], rst[1], rst[2] are arrays of \((r,s,t)\) coordinates. (See Coordinates on the tetrahedron)

Returns

a vector of values of the same length as the rst arrays.

See the following publications:

  • Proriol, Joseph. “Sur une famille de polynomes á deux variables orthogonaux dans un triangle.” CR Acad. Sci. Paris 245 (1957): 2459-2461.

  • Koornwinder, T. “Two-variable analogues of the classical orthogonal polynomials.” Theory and Applications of Special Functions. 1975, pp. 435-495.

  • Dubiner, Moshe. “Spectral Methods on Triangles and Other Domains.” Journal of Scientific Computing 6, no. 4 (December 1, 1991): 345–390. http://dx.doi.org/10.1007/BF01060030

modepy.modes.grad_pkdo_3d(order, rst)

Evaluate the derivatives of pkdo_3d().

Parameters
  • order – A tuple (i, j, k) representing the order of the polynomial.

  • rsrs[0], rs[1], rs[2] are arrays of \((r,s,t)\) coordinates. (See Coordinates on the tetrahedron)

Returns

a tuple of vectors (dphi_dr, dphi_ds, dphi_dt), each of the same length as the rst arrays.

See the following publications:

  • Proriol, Joseph. “Sur une famille de polynomes á deux variables orthogonaux dans un triangle.” CR Acad. Sci. Paris 245 (1957): 2459-2461.

  • Koornwinder, T. “Two-variable analogues of the classical orthogonal polynomials.” Theory and Applications of Special Functions. 1975, pp. 435-495.

  • Dubiner, Moshe. “Spectral Methods on Triangles and Other Domains.” Journal of Scientific Computing 6, no. 4 (December 1, 1991): 345–390. http://dx.doi.org/10.1007/BF01060030

Monomials

modepy.modes.monomial(order, rst)

Evaluate the monomial of order order at the points rst.

Parameters
  • order – A tuple (i, j,…) representing the order of the polynomial.

  • rstrst[0], rst[1] are arrays of \((r,s,...)\) coordinates. (See Coordinates on the triangle)

modepy.modes.grad_monomial(order, rst)

Evaluate the derivative of the monomial of order order at the points rst.

Parameters
  • order – A tuple (i, j,…) representing the order of the polynomial.

  • rstrst[0], rst[1] are arrays of \((r,s,...)\) coordinates. (See Coordinates on the triangle)

Returns

a tuple of vectors (dphi_dr, dphi_ds, dphi_dt), each of the same length as the rst arrays.

New in version 2016.1.

Redirections to Canonical Names

class modepy.modes.Basis

See modepy.Basis.