archimedes.approximation.PiecewiseBasis¶

class archimedes.approximation.PiecewiseBasis(
element_basis: Basis | tuple[Basis, ...],
breakpoints: ndarray,
continuity: int = 0,
)¶

A Basis constructed by tiling a local basis across elements.

This constructs a finite (or spectral) element basis by partitioning the domain into subintervals, each of which has a basis of local support.

The domain partitioning is determined by breakpoints, defined on the reference domain \([-1, 1]\).

Continuity. Tiling alone produces a discontinuous (\(C^{-1}\)) basis. A \(C^0\) basis is continuous at element boundaries, i.e. neighboring elements share endpoint DOFs. A \(C^1\) basis additionally has continuous first derivatives at element boundaries. These choices correspond to continuity={-1, 0, 1}.

Element ownership at a breakpoint. When the basis functions are two-valued at interior breakpoints (e.g. the value of a \(C^{-1}\) function or the derivative of a \(C^0\) function), the side argument ("left" or "right") of evaluation determines which value is returned. This is useful for instance with discontinuous Galerkin (DG) numerical flux construction, which uses \(u^-\) and \(u^+\) at each interface.

This class is typically not used directly; instead, it is constructed as part of the FunctionSpace.piecewise() constructor. However, it can be used for customized piecewise bases not supported by that high-level constructor.

See also

FunctionSpace.piecewise

Convenience constructor for a FunctionSpace using common piecewise bases (e.g. “lagrange”, “legendre”, “hermite”).

Methods

boundary_dofs([order])

Indices of the degrees of freedom at the left/right ends of the domain.

evaluate(x[, deriv, a, b, side])

Evaluate at arbitrary points, resolving breakpoints by side.

Attributes

Parameters

The target-domain parameters this basis expects.

continuity

Continuity at element boundaries.

density

Whether this basis is orthonormal with respect to a probability measure (unit mass) rather than the raw weight of the associated Measure.

n_basis

n_elements

Number of elements.

ndim

Number of independent variables the basis functions take.

element_basis

Local basis, defined on the reference interval [-1, 1].

breakpoints

Element boundaries on the reference domain

__init__(
element_basis: Basis | tuple[Basis, ...],
breakpoints: ndarray,
continuity: int = 0,
) → None¶
boundary_dofs(order: int = 0) → tuple[int | None, int | None]¶

Indices of the degrees of freedom at the left/right ends of the domain.

Can be used for example to set boundary conditions or enforce continuity at the domain endpoints.

Parameters:

order (int, optional) – Derivative order to look up. Default 0 (the endpoint value).

Returns:

left, right – Index into this basis’s functions, or None where there is no degree of freedom of that order at that end.

Return type:

int or None

Notes

Only meaningful for nodal families (e.g. LagrangeBasis) with nodes at the endpoints. Modal families (e.g. OrthogonalPolynomialBasis) and nodal bases with interior-only nodes (Gauss-Legendre points, for instance) do not have boundary DOFs.

evaluate(x, deriv: int = 0, *, a=None, b=None, side: str = RIGHT)¶

Evaluate at arbitrary points, resolving breakpoints by side.

Parameters:
  • x (array_like, int, optional) – As for Basis.evaluate().

  • deriv (array_like, int, optional) – As for Basis.evaluate().

  • a (float, optional) – Target-domain endpoints; default the reference domain [-1, 1].

  • b (float, optional) – Target-domain endpoints; default the reference domain [-1, 1].

  • side ({"right", "left"}, optional) – Which one-sided limit to take at a point lying exactly on an interior breakpoint, where this basis is two-valued. "right" (default) makes ownership half-open [lo, hi); "left" makes it (lo, hi]. Irrelevant away from breakpoints and for deriv=0 on a \(C^0\) basis. See the class docstring.

property Parameters: type¶

The target-domain parameters this basis expects.

A Parameters subclass (e.g. UnitInterval.Parameters). Returns the type, not an instance.

Determines which reference domain the basis is defined on, for example:

breakpoints: ndarray¶

Element boundaries on the reference domain

Shape (k + 1,) for k elements. Must be strictly increasing and span [-1, 1] exactly.

continuity: int = 0¶

Continuity at element boundaries.

-1 for discontinuous, 0 for value continuity, 1 for first-derivative continuity.

density: bool = False¶

Whether this basis is orthonormal with respect to a probability measure (unit mass) rather than the raw weight of the associated Measure.

Only meaningful for orthogonal polynomial families based on a Measure (in particular OrthogonalPolynomialBasis); other families should leave this False.

element_basis: Basis | tuple[Basis, ...]¶

Local basis, defined on the reference interval [-1, 1].

property n_basis: int¶
property n_elements: int¶

Number of elements.

ndim: int = 1¶

Number of independent variables the basis functions take.

Typically 1, since most bases are univariate. TensorBasis is the exception, with one variable per tensored factor.