archimedes.approximation.TensorBasis

class archimedes.approximation.TensorBasis(bases: tuple[Basis, ...])

Tensor product of univariate bases, one per dimension.

The basis functions are all products of one factor from each dimension,

\[\Phi_{(i_1, \ldots, i_d)}(\mathbf{x}) = \phi^{(1)}_{i_1}(x_1) \cdots \phi^{(d)}_{i_d}(x_d),\]

The number of basis functions n_basis is the product of n_basis for each factor. A Function on this basis spans the full (n_1, ..., n_d) coefficient array.

The multi-index is flattened in C order, with last dimension varying fastest (the default of np.ravel_multi_index). This matches the node ordering of TensorQuadratureRule. As a result, coefficients.reshape(n_1, ..., n_d) recovers the natural array layout.

Derivatives are multi-indices. In more than one dimension “the derivative” is ambiguous, so deriv is a tuple specifying the order in each variable. For example, deriv=(1, 0) specifies \(\partial_x\) and deriv=(1, 1) specifies \(\partial_x \partial_y\). The scalar 0 is accepted as shorthand for no derivative at all; any other integer is rejected as ambiguous.

Factors must be univariate. Tensor products are associative, so nesting adds no expressive power; write TensorBasis((a, b, c)) rather than TensorBasis((a, TensorBasis((b, c)))).

This class is typically not used directly; instead a set of FunctionSpace factors can be constructed and combined using the FunctionSpace.tensor() constructor, which internally creates an instance of this class.

See also

archimedes.quadrature.tensor_quad

The matching quadrature construction.

FunctionSpace.tensor

Construct a tensor product of multiple function spaces, which internally creates a TensorBasis instance.

Methods

boundary_dofs([order])

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

evaluate(x[, deriv, dims, side])

Evaluate all n_basis product functions at x.

Attributes

Parameters

The target-domain parameters this basis expects.

density

bool(x) -> bool

n_basis

ndim

int([x]) -> integer int(x, base=10) -> integer

shape

Per-dimension sizes, so coefficients.reshape(basis.shape) gives the natural multi-index array.

bases

The factors comprising this tensor basis.

__init__(
bases: tuple[Basis, ...],
) → 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=0, *, dims=None, side=RIGHT)

Evaluate all n_basis product functions at x.

Parameters:
  • x (array_like) – Evaluation points, shape (npts, ndim) with one row per point and one column per dimension.

  • deriv (tuple of int, optional) – Multi-index of derivative orders, one per dimension. The scalar 0 (the default) means no derivative.

  • dims (sequence, optional) – Per-dimension target-domain parameters.

  • side (str or sequence of str, optional) – One-sided limit per dimension, where a factor is two-valued. A bare string broadcasts to every dimension. Default "right".

Returns:

phi – Shape (npts, n_basis), with the multi-index flattened in C order.

Return type:

ndarray

property Parameters: type[ProductParameters]

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:

bases: tuple[Basis, ...]

The factors comprising this tensor basis.

One univariate basis per dimension, in order. The families may differ, and so may their reference domains. All factors must have the same value of density since quadrature weights are normalized (or not) for the product measure as a whole.

property density: bool

bool(x) -> bool

Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.

property n_basis: int
property ndim: int

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

property shape: tuple[int, ...]

Per-dimension sizes, so coefficients.reshape(basis.shape) gives the natural multi-index array.