symfem.piecewise_functions
¶
Piecewise basis function classes.
Module Contents¶
Classes¶
A piecewise function. |
Functions¶
|
Create a reference element for a single piece. |
- class symfem.piecewise_functions.PiecewiseFunction(pieces: Dict[symfem.geometry.SetOfPointsInput, symfem.functions.FunctionInput], tdim: int)¶
Bases:
symfem.functions.AnyFunction
A piecewise function.
- property pieces: Dict[symfem.geometry.SetOfPoints, symfem.functions.AnyFunction]¶
Get the pieces of the function.
- Returns:
The function pieces
- property shape: Tuple[int, Ellipsis]¶
Get the value shape of the function.
- Returns:
The value shape
- _pieces: Dict[symfem.geometry.SetOfPoints, symfem.functions.AnyFunction]¶
- __len__()¶
Get the length of the vector.
- as_sympy() symfem.functions.SympyFormat ¶
Convert to a sympy expression.
- Returns:
A Sympy expression
- as_tex() str ¶
Convert to a TeX expression.
- Returns:
A TeX string
- get_piece(point: symfem.geometry.PointType) symfem.functions.AnyFunction ¶
Get a piece of the function.
- Parameters:
point – The point to get the piece at
- Returns:
The piece of the function that is valid at that point
- __getitem__(key) PiecewiseFunction ¶
Get a component or slice of the function.
- __eq__(other: Any) bool ¶
Check if two functions are equal.
- __add__(other: Any) PiecewiseFunction ¶
Add.
- __radd__(other: Any) PiecewiseFunction ¶
Add.
- __sub__(other: Any) PiecewiseFunction ¶
Subtract.
- __rsub__(other: Any) PiecewiseFunction ¶
Subtract.
- __truediv__(other: Any) PiecewiseFunction ¶
Divide.
- __rtruediv__(other: Any) PiecewiseFunction ¶
Divide.
- __mul__(other: Any) PiecewiseFunction ¶
Multiply.
- __rmul__(other: Any) PiecewiseFunction ¶
Multiply.
- __matmul__(other: Any) PiecewiseFunction ¶
Multiply.
- __rmatmul__(other: Any) PiecewiseFunction ¶
Multiply.
- __pow__(other: Any) PiecewiseFunction ¶
Raise to a power.
- __neg__() PiecewiseFunction ¶
Negate.
- subs(vars: symfem.symbols.AxisVariables, values: symfem.functions.ValuesToSubstitute) PiecewiseFunction ¶
Substitute values into the function.
- Parameters:
vars – The variables to substitute out
values – The value to substitute in
- Returns:
The substituted function
- diff(variable: sympy.core.symbol.Symbol) PiecewiseFunction ¶
Differentiate the function.
- Parameters:
variable – The variable to differentiate with respect to
- Returns:
The differentiated function
- directional_derivative(direction: symfem.geometry.PointType) PiecewiseFunction ¶
Compute a directional derivative.
- Parameters:
direction – The diection
- Returns:
The directional derivative
- jacobian_component(component: Tuple[int, int]) PiecewiseFunction ¶
Compute a component of the jacobian.
- Parameters:
component – The component
- Returns:
The component of the jacobian
- jacobian(dim: int) PiecewiseFunction ¶
Compute the jacobian.
- Parameters:
dim – The topological dimension of the cell
- Returns:
The jacobian
- dot(other_in: symfem.functions.FunctionInput) PiecewiseFunction ¶
Compute the dot product with another function.
- Parameters:
other_in – The function to multiply with
- Returns:
The product
- cross(other_in: symfem.functions.FunctionInput) PiecewiseFunction ¶
Compute the cross product with another function.
- Parameters:
other_in – The function to multiply with
- Returns:
The cross product
- div() PiecewiseFunction ¶
Compute the div of the function.
- Returns:
The divergence
- grad(dim: int) PiecewiseFunction ¶
Compute the grad of the function.
- Returns:
The gradient
- curl() PiecewiseFunction ¶
Compute the curl of the function.
- Returns:
The curl
- norm() PiecewiseFunction ¶
Compute the norm of the function.
- Returns:
The norm
- integral(domain: symfem.references.Reference, vars: symfem.symbols.AxisVariablesNotSingle = x, dummy_vars: symfem.symbols.AxisVariablesNotSingle = t) symfem.functions.ScalarFunction ¶
Compute the integral of the function.
- Parameters:
domain – The domain of the integral
vars – The variables to integrate with respect to
dummy_vars – The dummy variables to use inside the integral
- Returns:
The integral
- det() PiecewiseFunction ¶
Compute the determinant.
- Returns:
The deteminant
- transpose() PiecewiseFunction ¶
Compute the transpose.
- Returns:
The transpose
- map_pieces(fwd_map: symfem.geometry.PointType)¶
Map the function’s pieces.
- Parameters:
fwd_map – The map from the reference cell to a physical cell
- Returns:
The mapped pieces
- plot_values(reference: symfem.references.Reference, img: Any, value_scale: sympy.core.expr.Expr = sympy.Integer(1), n: int = 6)¶
Plot the function’s values.
- Parameters:
reference – The reference cell
img – The image to plot on
value_scale – The scale factor for the function values
n – The number of points per side for plotting
- with_floats() symfem.functions.AnyFunction ¶
Return a version the function with floats as coefficients.
- Returns:
A version the function with floats as coefficients
- abstract maximum_degree(cell: symfem.references.Reference) int ¶
Return the maximum degree of the function on a reference cell.
This function returns the order of the lowerst order Lagrange space on the input cell that includes this function.
- Parameters:
cell – The cell
- Returns:
A version the function with floats as coefficients
- symfem.piecewise_functions._piece_reference(tdim, shape)¶
Create a reference element for a single piece.