polynomials_on_simplices.piecewise_polynomial.piecewise_polynomial_lagrange_basis module

Discontinuous Galerkin finite elements (piecewise polynomials) on a simplicial domain (triangulation) \(\mathcal{T}\), i.e. elements of \(D\mathcal{P}_{r, 0} (\mathcal{T})\) or \(D\mathcal{P}_r (\mathcal{T})\), expressed using the Lagrange polynomial basis.

class PiecewisePolynomialLagrange(coeff, triangles, vertices, r, tau=None, boundary_simplices=None, keep_boundary_dofs_last=False, support=None, bsp_tree=None, basis_polynomials=None)[source]

Bases: polynomials_on_simplices.piecewise_polynomial.piecewise_polynomial.PiecewisePolynomialBase

Implementation of the abstract piecewise polynomial base class using the Lagrange polynomial basis on the unit simplex.

\[p(x) = \sum_{i = 1}^N a_i \phi_i(x),\]

where the basis \(\{ \phi_i \}_{i = 1}^N\) for the space of piecewise polynomials is constructed from the Lagrange polynomial basis and the local-to-global map. See PiecewisePolynomialBase and generate_local_to_global_map() for details.

Parameters:
  • coeff (List[Union[Scalar, Vector]]) – Coefficients for the piecewise polynomial in the \(\{ \phi_i \}_{i = 1}^N\) basis derived from the Lagrange basis for \(\mathcal{P}_r (\Delta_c^m)\) and the local-to-global map \(\tau\).
  • triangles – Triangles (or in general simplices) in the mesh \(\mathcal{T}\) (num_triangles by m + 1 array of indices).
  • vertices – Vertices in the mesh \(\mathcal{T}\) (num_vertices by m array of scalars).
  • r (int) – Degree of each polynomial in the piecewise polynomial.
  • tau (Optional[Callable \(\tau(j, \nu)\)]) – Local-to-global map for mapping local basis functions to the index of the corresponding global basis function. Will be generated if not supplied.
  • boundary_simplices (List[List[int]]) – List of simplices or subsimplices on which the piecewise polynomial function should vanish (for an element of \(D\mathcal{P}_{r, 0} (\mathcal{T})\)) or which should be treated separately (if keep_boundary_dofs_last is set to True). Each simplex or subsimplex is specified as a list of vertex indices of the vertices that form the simplex.
  • keep_boundary_dofs_last (bool) – Whether or not to collect all global basis functions associated with any boundary simplex last in the enumeration of all basis functions. Enumerating basis functions associated with boundary simplices last is useful for handling \(D\mathcal{P}_{r, 0} (\mathcal{T})\) as a subset of \(D\mathcal{P}_r (\mathcal{T})\) in a practical way.
  • support (Optional[Set[int]]) – Indices of the triangles in the triangulation where the piecewise polynomial is supported. Will be generated if not supplied.
  • bsp_tree – Optional implementation detail. A binary space partitioning tree built around the triangulation for quicker lookup of triangle a point lies in. Will be generated if not supplied.
  • basis_polynomials (Optional[Dict[int, List[ PolynomialLagrangeSimplex]]]) – Precomputed basis polynomials for each triangle in the given triangulation. Will be generated where necessary if not supplied.
basis()[source]

Get basis for the space \(\mathcal{P}_r (\Delta_c^m)\) used to express the piecewise polynomial.

Returns:Unique identifier for the basis used.
Return type:str
degree_elevate(s)[source]

Express the piecewise polynomial using a higher degree polynomial basis.

Let \(p(x)\) be this piecewise polynomial. Let \(\{ \bar{\varphi}_{\nu, r} \}_{\substack{\nu \in \mathbb{N}_0^m \\ |\nu| \leq r}}\) be the polynomial basis for \(\mathcal{P}_r(\Delta_c^m)\) used for this piecewise polynomial, and let \(\{ \bar{\varphi}_{\nu, s} \}_{\substack{\nu \in \mathbb{N}_0^m \\ |\nu| \leq s}}, s \geq r\) be the corresponding higher degree polynomial basis for \(\mathcal{P}_s(\Delta_c^m)\). Then this function returns a piecewise polynomial \(q\) using the basis \(\{ \bar{\varphi}_{\nu, s} \}\) such that \(p(x) = q(x) \, \forall x \in \mathbb{R}^m\).

Parameters:s (int) – New degree for the basic polynomial basis the piecewise polynomial should use.
Returns:Elevation of this piecewise polynomial to the higher degree basis.
Return type:Instance of self.__class__
static get_unit_piecewise_polynomial_lagrange(triangles, vertices, n=1, tau=None, boundary_simplices=None, keep_boundary_dofs_last=False, bsp_tree=None)[source]

Get the piecewise polynomial of degree r on the given triangulation \(\mathcal{T}\), where the polynomials on each simplex is expressed in the Lagrange basis, which is identically one. See unit_piecewise_polynomial_lagrange().

restrict_to_simplex(i)[source]

Restriction of the piecewise polynomial to a specified simplex \(T_i \in \mathcal{T}\).

Parameters:i (int) – Index of the simplex we want to restrict the piecewise polynomial to (in \(0, 1, \ldots, | \mathcal{T} | - 1\)).
Returns:Polynomial which agrees with the piecewise polynomial on the simplex \(T_i\).
Return type:PolynomialLagrangeSimplex.
dual_piecewise_polynomial_lagrange_basis(triangles, vertices, r, tau=None, num_dofs=None, tau_inv=None, boundary_simplices=None, keep_boundary_dofs_last=False)[source]

Generate all dual basis functions to the basis of piecewise polynomials of degree r on the given triangulation \(\mathcal{T}, D \mathcal{P}_r(\mathcal{T})\) or \(D \mathcal{P}_{r, 0}(\mathcal{T})\), where the polynomials on each simplex is expressed in the Lagrange basis.

See dual_piecewise_polynomial_lagrange_basis_fn().

Parameters:
  • triangles – Triangles (or in general simplices) in the mesh \(\mathcal{T}\) (num_triangles by m + 1 array of indices).
  • vertices – Vertices in the mesh \(\mathcal{T}\) (num_vertices by m array of scalars).
  • r (int) – Degree of each polynomial in the piecewise polynomial.
  • tau (Optional[Callable \(\tau(j, \nu)\)]) – Local-to-global map for mapping local basis functions to the index of the corresponding global basis function. Will be generated if not supplied.
  • num_dofs (Optional[int]) – Dimension of the space of piecewise polynomials on the given triangulation. Will be computed if not supplied.
  • tau_inv (Optional[Callable \(\tau^{-1}(i)\)]) – Inverse of the local-to-global map. Will be generated if not supplied.
  • boundary_simplices (List[List[int]]) – List of simplices or subsimplices on which the piecewise polynomial functions should vanish (for \(D\mathcal{P}_{r, 0} (\mathcal{T})\)) or which should be treated separately (if keep_boundary_dofs_last is set to True). Each simplex or subsimplex is specified as a list of vertex indices of the vertices that form the simplex.
  • keep_boundary_dofs_last (bool) – Whether or not to collect all global basis functions associated with any boundary simplex last in the enumeration of all basis functions. Enumerating basis functions associated with boundary simplices last is useful for handling \(D\mathcal{P}_{r, 0} (\mathcal{T})\) as a subset of \(D\mathcal{P}_r (\mathcal{T})\) in a practical way.
Returns:

List of dual base functions.

Return type:

List[Callable \(\phi_i^*(p)\)].

dual_piecewise_polynomial_lagrange_basis_fn(triangles, vertices, r, i, tau=None, num_dofs=None, tau_inv=None, boundary_simplices=None, keep_boundary_dofs_last=False)[source]

Generate a dual basis function to the basis for the space of piecewise polynomials of degree r on the given triangulation \(\mathcal{T}, D \mathcal{P}_r(\mathcal{T})\) or \(D \mathcal{P}_{r, 0}(\mathcal{T})\), where the polynomials on each simplex is expressed in the Lagrange basis. I.e. the linear map \(\phi_i^* : D \mathcal{P}_r(\mathcal{T}) \to \mathbb{R}\) that satisfies

\[\phi_i^* (\phi_j) = \delta_{ij},\]

where \(\phi_j\) is the j:th Lagrange basis function for the space of piecewise polynomials of degree r (see piecewise_polynomial_lagrange_basis_fn()).

Parameters:
  • triangles – Triangles (or in general simplices) in the mesh \(\mathcal{T}\) (num_triangles by m + 1 array of indices).
  • vertices – Vertices in the mesh \(\mathcal{T}\) (num_vertices by m array of scalars).
  • r (int) – Degree of each polynomial in the piecewise polynomial.
  • i (int) – Index of the dual basis function that should be generated.
  • tau (Optional[Callable \(\tau(j, \nu)\)]) – Local-to-global map for mapping local basis functions to the index of the corresponding global basis function. Will be generated if not supplied.
  • num_dofs (Optional[int]) – Dimension of the space of piecewise polynomials on the given triangulation. Will be computed if not supplied.
  • tau_inv (Optional[Callable \(\tau^{-1}(i)\)]) – Inverse of the local-to-global map. Will be generated if not supplied.
  • boundary_simplices (List[List[int]]) – List of simplices or subsimplices on which the piecewise polynomial functions should vanish (for \(D\mathcal{P}_{r, 0} (\mathcal{T})\)) or which should be treated separately (if keep_boundary_dofs_last is set to True). Each simplex or subsimplex is specified as a list of vertex indices of the vertices that form the simplex.
  • keep_boundary_dofs_last (bool) – Whether or not to collect all global basis functions associated with any boundary simplex last in the enumeration of all basis functions. Enumerating basis functions associated with boundary simplices last is useful for handling \(D\mathcal{P}_{r, 0} (\mathcal{T})\) as a subset of \(D\mathcal{P}_r (\mathcal{T})\) in a practical way.
Returns:

The i:th dual Lagrange basis function as specified by mu and r.

Return type:

Callable \(\phi_i^*(p)\).

piecewise_polynomial_lagrange_basis(triangles, vertices, r, tau=None, num_dofs=None, boundary_simplices=None, keep_boundary_dofs_last=False, bsp_tree=None)[source]

Generate all basis functions for the space of piecewise polynomials of degree r on the given triangulation \(\mathcal{T}\), where the polynomials on each simplex is expressed in the Lagrange basis.

Parameters:
  • triangles – Triangles (or in general simplices) in the mesh \(\mathcal{T}\) (num_triangles by m + 1 array of indices).
  • vertices – Vertices in the mesh \(\mathcal{T}\) (num_vertices by m array of scalars).
  • r (int) – Degree of each polynomial in the piecewise polynomial.
  • tau (Optional[Callable \(\tau(j, \nu)\)]) – Local-to-global map for mapping local basis functions to the index of the corresponding global basis function. Will be generated if not supplied.
  • num_dofs (Optional[int]) – Dimension of the space of piecewise polynomials on the given triangulation. Will be computed if not supplied.
  • boundary_simplices (List[List[int]]) – List of simplices or subsimplices on which the piecewise polynomial functions should vanish (for \(D\mathcal{P}_{r, 0} (\mathcal{T})\)) or which should be treated separately (if keep_boundary_dofs_last is set to True). Each simplex or subsimplex is specified as a list of vertex indices of the vertices that form the simplex.
  • keep_boundary_dofs_last (bool) – Whether or not to collect all global basis functions associated with any boundary simplex last in the enumeration of all basis functions. Enumerating basis functions associated with boundary simplices last is useful for handling \(D\mathcal{P}_{r, 0} (\mathcal{T})\) as a subset of \(D\mathcal{P}_r (\mathcal{T})\) in a practical way.
  • bsp_tree – Optional implementation detail. A binary space partitioning tree built around the triangulation \(\mathcal{T}\) for quicker lookup of triangle a point lies in. Will be generated if not supplied.
Return type:

List[PiecewisePolynomialLagrange].

piecewise_polynomial_lagrange_basis_fn(triangles, vertices, r, i, tau=None, num_dofs=None, boundary_simplices=None, keep_boundary_dofs_last=False, bsp_tree=None, basis_polynomials=None)[source]

Generate a basis function for the space of piecewise polynomials of degree r on the given triangulation \(\mathcal{T}\), where the polynomials on each simplex is expressed in the Lagrange basis.

Parameters:
  • triangles – Triangles (or in general simplices) in the mesh \(\mathcal{T}\) (num_triangles by m + 1 array of indices).
  • vertices – Vertices in the mesh \(\mathcal{T}\) (num_vertices by m array of scalars).
  • r (int) – Degree of each polynomial in the piecewise polynomial.
  • i (int) – Index of the basis function that should be generated.
  • tau (Optional[Callable \(\tau(j, \nu)\)]) – Local-to-global map for mapping local basis functions to the index of the corresponding global basis function. Will be generated if not supplied.
  • num_dofs (Optional[int]) – Dimension of the space of piecewise polynomials on the given triangulation. Will be computed if not supplied.
  • boundary_simplices (List[List[int]]) – List of simplices or subsimplices on which the piecewise polynomial functions should vanish (for \(D\mathcal{P}_{r, 0} (\mathcal{T})\)) or which should be treated separately (if keep_boundary_dofs_last is set to True). Each simplex or subsimplex is specified as a list of vertex indices of the vertices that form the simplex.
  • keep_boundary_dofs_last (bool) – Whether or not to collect all global basis functions associated with any boundary simplex last in the enumeration of all basis functions. Enumerating basis functions associated with boundary simplices last is useful for handling \(D\mathcal{P}_{r, 0} (\mathcal{T})\) as a subset of \(D\mathcal{P}_r (\mathcal{T})\) in a practical way.
  • bsp_tree – Optional implementation detail. A binary space partitioning tree built around the triangulation \(\mathcal{T}\) for quicker lookup of triangle a point lies in. Will be generated if not supplied.
  • basis_polynomials (Optional[Dict[int, List[ PolynomialLagrangeSimplex]]]) – Precomputed basis polynomials for each triangle in the given triangulation. Will be generated where necessary if not supplied.
Returns:

Basis function.

Return type:

PiecewisePolynomialLagrange.

unit_piecewise_polynomial_lagrange(triangles, vertices, n=1, tau=None, boundary_simplices=None, keep_boundary_dofs_last=False, bsp_tree=None)[source]

Get the piecewise polynomial of degree r on the given triangulation \(\mathcal{T}\), where the polynomials on each simplex is expressed in the Lagrange basis, which is identically one.

Parameters:
  • triangles – Triangles (or in general simplices) in the mesh \(\mathcal{T}\) (num_triangles by m + 1 array of indices).
  • vertices – Vertices in the mesh \(\mathcal{T}\) (num_vertices by m array of scalars).
  • n (int) – Dimension of the target of the piecewise polynomial.
  • tau (Optional[Callable \(\tau(j, \nu)\)]) – Local-to-global map for mapping local basis functions to the index of the corresponding global basis function. Will be generated if not supplied.
  • boundary_simplices (List[List[int]]) – List of simplices or subsimplices on which the piecewise polynomial functions should vanish (for \(D\mathcal{P}_{r, 0} (\mathcal{T})\)) or which should be treated separately (if keep_boundary_dofs_last is set to True). Each simplex or subsimplex is specified as a list of vertex indices of the vertices that form the simplex.
  • keep_boundary_dofs_last (bool) – Whether or not to collect all global basis functions associated with any boundary simplex last in the enumeration of all basis functions. Enumerating basis functions associated with boundary simplices last is useful for handling \(D\mathcal{P}_{r, 0} (\mathcal{T})\) as a subset of \(D\mathcal{P}_r (\mathcal{T})\) in a practical way.
  • bsp_tree – Optional implementation detail. A binary space partitioning tree built around the triangulation \(\mathcal{T}\) for quicker lookup of triangle a point lies in. Will be generated if not supplied.
Returns:

The unit piecewise polynomial.

Return type:

PiecewisePolynomialLagrange.

zero_piecewise_polynomial_lagrange(triangles, vertices, n=1, tau=None, boundary_simplices=None, keep_boundary_dofs_last=False, bsp_tree=None)[source]

Get the piecewise polynomial of degree r on the given triangulation \(\mathcal{T}\), where the polynomials on each simplex is expressed in the Lagrange basis, which is identically zero.

Parameters:
  • triangles – Triangles (or in general simplices) in the mesh \(\mathcal{T}\) (num_triangles by m + 1 array of indices).
  • vertices – Vertices in the mesh \(\mathcal{T}\) (num_vertices by m array of scalars).
  • n (int) – Dimension of the target of the piecewise polynomial.
  • tau (Optional[Callable \(\tau(j, \nu)\)]) – Local-to-global map for mapping local basis functions to the index of the corresponding global basis function. Will be generated if not supplied.
  • boundary_simplices (List[List[int]]) – List of simplices or subsimplices on which the piecewise polynomial functions should vanish (for \(D\mathcal{P}_{r, 0} (\mathcal{T})\)) or which should be treated separately (if keep_boundary_dofs_last is set to True). Each simplex or subsimplex is specified as a list of vertex indices of the vertices that form the simplex.
  • keep_boundary_dofs_last (bool) – Whether or not to collect all global basis functions associated with any boundary simplex last in the enumeration of all basis functions. Enumerating basis functions associated with boundary simplices last is useful for handling \(D\mathcal{P}_{r, 0} (\mathcal{T})\) as a subset of \(D\mathcal{P}_r (\mathcal{T})\) in a practical way.
  • bsp_tree – Optional implementation detail. A binary space partitioning tree built around the triangulation \(\mathcal{T}\) for quicker lookup of triangle a point lies in. Will be generated if not supplied.
Returns:

The zero piecewise polynomial.

Return type:

PiecewisePolynomialLagrange.