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_basisis the product ofn_basisfor each factor. AFunctionon 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 ofTensorQuadratureRule. 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
derivis a tuple specifying the order in each variable. For example,deriv=(1, 0)specifies \(\partial_x\) andderiv=(1, 1)specifies \(\partial_x \partial_y\). The scalar0is 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 thanTensorBasis((a, TensorBasis((b, c)))).This class is typically not used directly; instead a set of
FunctionSpacefactors can be constructed and combined using theFunctionSpace.tensor()constructor, which internally creates an instance of this class.See also
archimedes.quadrature.tensor_quadThe matching quadrature construction.
FunctionSpace.tensorConstruct a tensor product of multiple function spaces, which internally creates a
TensorBasisinstance.
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_basisproduct functions atx.Attributes
The target-domain parameters this basis expects.
bool(x) -> bool
int([x]) -> integer int(x, base=10) -> integer
Per-dimension sizes, so
coefficients.reshape(basis.shape)gives the natural multi-index array.The factors comprising this tensor basis.
- 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
Nonewhere 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_basisproduct functions atx.- 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
Parameterssubclass (e.g.UnitInterval.Parameters). Returns the type, not an instance.Determines which reference domain the basis is defined on, for example:
UnitIntervalfor \([-1, 1]\).HalfLinefor \([0, \infty)\).RealLinefor \((-\infty, \infty)\).
- 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
densitysince 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.