FELiCS.Misc.tensorUtils#
Module Contents#
Classes#
Enumeration describing the role of each dimension in a tensor or coordinate system. |
|
The CoordinateSystem class supports two coordinate systems, |
|
Tensor object that extends UFL tensors. |
Functions#
|
Performs a single contraction between two tensors. |
|
Computes the inner product between two second-order tensors. |
|
Computes the gradient of a tensor. |
|
Computes the divergence of a tensor. |
|
Returns the transpose of a second-order tensor. |
|
Computes the trace of a second-order tensor. |
|
Returns the identity tensor corresponding to the tensor's dimension and coordinate system. |
|
Computes the complex conjugate of a tensor. |
|
Computes the outer product of two tensors. |
- class FELiCS.Misc.tensorUtils.SpectralIndicator(*args, **kwds)#
Bases:
enum.EnumEnumeration describing the role of each dimension in a tensor or coordinate system.
This enum is used to mark whether a given axis corresponds to a geometric, spectral, or inactive (zero) dimension. It is primarily used internally by the
Tensorclass to determine how derivatives and spectral terms should be handled.Members#
- SPECTRALint
Marks a dimension as a spectral dimension. Derivatives along this axis are replaced by
i * m / rterms.- NOTSPECTRALint
Marks a dimension as a regular geometric dimension.
- ZEROint
Marks a dimension that is neither geometric nor spectral (e.g. padding dimensions for tensors whose true dimension exceeds the geometric one).
- SPECTRAL = 1#
- NOTSPECTRAL = 2#
- ZERO = 3#
- class FELiCS.Misc.tensorUtils.CoordinateSystem(SpatialCoordinateObj, name: str, gdim: int, trueDim=None, m=0)#
The CoordinateSystem class supports two coordinate systems, ‘cartesian’ and ‘cylindricalfelics’.
- Parameters:
SpatialCoordinateObj (
ufl.SpatialCoordinate) – Coordinate vector of the mesh.name (
str) – Name of the coordinate system (“cartesian”, “cylindricalfelics”).gdim (
int) – Geometrical dimension of the mesh.trueDim (
int, optional) – True dimension of the system, including a possible spectral dimension.m (
int, optional) – Wave number for spectral direction.
- Raises:
ValueError – When object is initialized: if the coordinate system name is not recognized.
- property m#
Returns the wave number m, used in the spectral dimension.
- Returns:
The wave number.
- Return type:
int
- setTrueDimension(dim)#
Corrects the true dimension of the system. This has to be called if a spectral dimension is included, in which case the true dimension is higher than the geometrical dimension of the mesh.
- Parameters:
dim (
int) – True dimension of the system, including a possible spectral dimension.
- class FELiCS.Misc.tensorUtils.Tensor(ufl_tens, CoordSys: CoordinateSystem, mayHaveSpectralDimension=False, m=None)#
Tensor object that extends UFL tensors.
Supports scalar, vector, and matrix-valued tensors in both physical and spectral settings, including an optional spectral dimension.
- Variables:
ufl_tens (
ufl.Expr) – The underlying UFL tensor expression.CoordSys (
CoordinateSystem) – Coordinate system in which this tensor is defined.hasSpectralDimension (
bool) – Whether this tensor actually carries a spectral dependence (i.e. a factor ofexp(i * m * sdim)), as determined frommayHaveSpectralDimensionand the coordinate system.isSpectralDimension (
listofSpectralIndicator) – Per-dimension indicator specifying whether each axis is spectral, geometric, or zero (non-geometric, non-spectral).m (
int) – Wave number associated with the spectral dimension (if present).dim (
int) – Total dimension of the system (geometric + spectral).order (
int) – Tensor order, inferred fromufl_tens.ufl_shape(0, 1, or 2).
Example
>>> T = Tensor(u, CoordSys) >>> grad_T = iGrad(T)
- FELiCS.Misc.tensorUtils.iDot(tensorA: Tensor, tensorB: Tensor)#
Performs a single contraction between two tensors.
The function supports dot products between tensors of order 1 or 2.
- FELiCS.Misc.tensorUtils.iInner(tensorA: Tensor, tensorB: Tensor)#
Computes the inner product between two second-order tensors.
- FELiCS.Misc.tensorUtils.iDiv(tensor: Tensor)#
Computes the divergence of a tensor.
Computes the gradient and sums of the last two indices of a tensor.
- FELiCS.Misc.tensorUtils.iIdentity(tensor: Tensor)#
Returns the identity tensor corresponding to the tensor’s dimension and coordinate system.
- FELiCS.Misc.tensorUtils.iConj(tensor: Tensor)#
Computes the complex conjugate of a tensor.
The underlying UFL expression is conjugated and the sign of the spectral wave number
mis flipped.