polynomials_on_simplices.piecewise_polynomial.continuous_piecewise_polynomial_bernstein_basis module

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

class ContinuousPiecewisePolynomialBernstein(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_bernstein_basis.PiecewisePolynomialBernstein, polynomials_on_simplices.piecewise_polynomial.continuous_piecewise_polynomial.ContinuousPiecewisePolynomialBase

Implementation of the abstract continuous piecewise polynomial base class using the Bernstein 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 continuous piecewise polynomials is constructed from the Bernstein 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 continuous piecewise polynomial in the \(\{ \phi_i \}_{i = 1}^N\) basis derived from the Bernstein 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 continuous 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, in a way that makes sure that the piecewise polynomial is continuous. Will be generated if not supplied.
  • boundary_simplices (List[List[int]]) – List of simplices or subsimplices on which the continuous piecewise polynomial function should vanish (for an element of \(C\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 \(C\mathcal{P}_{r, 0} (\mathcal{T})\) as a subset of \(C\mathcal{P}_r (\mathcal{T})\) in a practical way.
  • support (Optional[Set[int]]) – Indices of the triangles in the triangulation where the continuous 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[ PolynomialBernsteinSimplex]]]) – Precomputed basis polynomials for each triangle in the given triangulation. Will be generated where necessary if not supplied.
static get_unit_piecewise_polynomial_bernstein(triangles, vertices, n=1, tau=None, boundary_simplices=None, keep_boundary_dofs_last=False, bsp_tree=None)[source]

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

weak_partial_derivative(i=0)[source]

Compute the i:th weak partial derivative of the continuous piecewise polynomial.

Parameters:i (int) – Index of partial derivative.
Returns:i:th weak partial derivative of this continuous piecewise polynomial.
Return type:PiecewisePolynomialBernstein.
continuous_piecewise_polynomial_bernstein_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 continuous piecewise polynomials of degree r on the given triangulation \(\mathcal{T}\), where the polynomials on each simplex is expressed in the Bernstein 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 continuous 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 continuous 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 continuous piecewise polynomial functions should vanish (for \(C\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 \(C\mathcal{P}_{r, 0} (\mathcal{T})\) as a subset of \(C\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[ContinuousPiecewisePolynomialBernstein].

continuous_piecewise_polynomial_bernstein_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 continuous piecewise polynomials of degree r on the given triangulation \(\mathcal{T}\), where the polynomials on each simplex is expressed in the Bernstein 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 continuous 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 continuous 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 continuous 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 \(C\mathcal{P}_{r, 0} (\mathcal{T})\) as a subset of \(C\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[ PolynomialBernsteinSimplex]]]) – Precomputed basis polynomials for each triangle in the given triangulation. Will be generated where necessary if not supplied.
Returns:

Basis function.

Return type:

ContinuousPiecewisePolynomialBernstein.

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

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

See dual_continuous_piecewise_polynomial_bernstein_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 continuous 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 continuous piecewise polynomials on the given triangulation. Will be computed if not supplied.
  • tau_preim (Optional[Callable \(\operatorname{preim}_{\tau}(i)\)]) – Preimage 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 continuous piecewise polynomial functions should vanish (for \(C\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 \(C\mathcal{P}_{r, 0} (\mathcal{T})\) as a subset of \(C\mathcal{P}_r (\mathcal{T})\) in a practical way.
Returns:

List of dual base functions.

Return type:

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

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

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

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

where \(\phi_j\) is the j:th Bernstein basis function for the space of continuous piecewise polynomials of degree r (see continuous_piecewise_polynomial_bernstein_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 continuous 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 continuous piecewise polynomials on the given triangulation. Will be computed if not supplied.
  • tau_preim (Optional[Callable \(\operatorname{preim}_{\tau}(i)\)]) – Preimage 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 continuous piecewise polynomial functions should vanish (for \(C\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 \(C\mathcal{P}_{r, 0} (\mathcal{T})\) as a subset of \(C\mathcal{P}_r (\mathcal{T})\) in a practical way.
Returns:

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

Return type:

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

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

Get the continuous piecewise polynomial of degree r on the given triangulation \(\mathcal{T}\), where the polynomials on each simplex is expressed in the Bernstein 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 continuous 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 continuous piecewise polynomial functions should vanish (for \(C\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 \(C\mathcal{P}_{r, 0} (\mathcal{T})\) as a subset of \(C\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 continuous piecewise polynomial.

Return type:

ContinuousPiecewisePolynomialBernstein.

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

Get the continuous piecewise polynomial of degree r on the given triangulation \(\mathcal{T}\), where the polynomials on each simplex is expressed in the Bernstein 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 continuous 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 continuous piecewise polynomial functions should vanish (for \(C\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 \(C\mathcal{P}_{r, 0} (\mathcal{T})\) as a subset of \(C\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:

ContinuousPiecewisePolynomialBernstein.