symfem.functions¶
Basis function classes.
Attributes¶
Classes¶
A function. |
|
A scalar-valued function. |
|
A vector-valued function. |
|
A matrix-valued function. |
Functions¶
|
Parse a function. |
|
Parse a list of functions. |
Module Contents¶
- symfem.functions.SingleSympyFormat¶
- symfem.functions.SympyFormat¶
- class symfem.functions.Function(scalar: bool = False, vector: bool = False, matrix: bool = False)¶
Bases:
abc.ABCA function.
- is_scalar = False¶
- is_vector = False¶
- is_matrix = False¶
- abstractmethod __add__(other: Any)¶
Add.
- abstractmethod __radd__(other: Any)¶
Add.
- abstractmethod __sub__(other: Any)¶
Subtract.
- abstractmethod __rsub__(other: Any)¶
Subtract.
- abstractmethod __neg__()¶
Negate.
- abstractmethod __truediv__(other: Any)¶
Divide.
- abstractmethod __rtruediv__(other: Any)¶
Divide.
- abstractmethod __mul__(other: Any)¶
Multiply.
- abstractmethod __rmul__(other: Any)¶
Multiply.
- abstractmethod __matmul__(other: Any)¶
Multiply.
- abstractmethod __rmatmul__(other: Any)¶
Multiply.
- abstractmethod __pow__(other: Any)¶
Raise to a power.
- abstractmethod as_sympy() SympyFormat¶
Convert to a Sympy expression.
- Returns:
A Sympy expression
- abstractmethod as_tex() str¶
Convert to a TeX expression.
- Returns:
A TeX string
- abstractmethod subs(vars: symfem.symbols.AxisVariables, values: Function | _ValuesToSubstitute)¶
Substitute values into the function.
- Parameters:
vars – The variables to substitute out
values – The value to substitute in
- Returns:
The substituted function
- abstractmethod diff(variable: sympy.core.symbol.Symbol)¶
Differentiate the function.
- Parameters:
variable – The variable to differentiate with respect to
- Returns:
The differentiated function
- abstractmethod directional_derivative(direction: symfem.geometry.PointType)¶
Compute a directional derivative.
- Parameters:
direction – The diection
- Returns:
The directional differentiate
- abstractmethod jacobian_component(component: tuple[int, int])¶
Compute a component of the jacobian.
- Parameters:
component – The component
- Returns:
The component of the jacobian
- abstractmethod jacobian(dim: int)¶
Compute the jacobian.
- Parameters:
dim – The topological dimension of the cell
- Returns:
The jacobian
- abstractmethod dot(other_in: FunctionInput)¶
Compute the dot product with another function.
- Parameters:
other_in – The function to multiply with
- Returns:
The product
- abstractmethod cross(other_in: FunctionInput)¶
Compute the cross product with another function.
- Parameters:
other_in – The function to multiply with
- Returns:
The cross product
- abstractmethod div()¶
Compute the div of the function.
- Returns:
The divergence
- abstractmethod curl()¶
Compute the curl of the function.
- Returns:
The curl
- abstractmethod norm()¶
Compute the norm of the function.
- Returns:
The norm
- abstractmethod integral(domain: symfem.references.Reference, vars: symfem.symbols.AxisVariablesNotSingle = x, dummy_vars: symfem.symbols.AxisVariablesNotSingle = t) Function¶
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
- abstractmethod with_floats() Function¶
Return a version the function with floats as coefficients.
- Returns:
A version the function with floats as coefficients
- abstractmethod 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
- integrate(*limits: tuple[sympy.core.symbol.Symbol, int | sympy.core.expr.Expr, int | sympy.core.expr.Expr])¶
Integrate the function.
- Parameters:
limits – The variables and limits
- Returns:
The integral
- det()¶
Compute the determinant.
- Returns:
The deteminant
- transpose()¶
Compute the transpose.
- Returns:
The transpose
- property shape: tuple[int, Ellipsis]¶
Get the value shape of the function.
- Returns:
The value shape
- plot(reference: symfem.references.Reference, filename: str | list[str], dof_point: symfem.geometry.PointType | None = None, dof_direction: symfem.geometry.PointType | None = None, dof_entity: tuple[int, int] | None = None, dof_n: int | None = None, value_scale: sympy.core.expr.Expr = sympy.Integer(1), plot_options: dict[str, Any] = {}, **kwargs: Any)¶
Plot the function.
- Parameters:
reference – The reference cell
filename – The file name
dof_point – The DOF point
dof_direction – The direction of the DOF
dof_entity – The entity the DOF is associated with
dof_n – The number of the DOF
value_scale – The scale factor for the function values
plot_options – Options for the plot
kwargs – Keyword arguments
- 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
- __len__()¶
Compute the determinant.
- _sympy_() SympyFormat¶
Convert to Sympy format.
- __float__() float¶
Convert to a float.
- __lt__(other: Any) bool¶
Check inequality.
- __le__(other: Any) bool¶
Check inequality.
- __gt__(other: Any) bool¶
Check inequality.
- __ge__(other: Any) bool¶
Check inequality.
- __repr__() str¶
Representation.
- __eq__(other: Any) bool¶
Check if two functions are equal.
- __ne__(other: Any) bool¶
Check if two functions are not equal.
- symfem.functions.ValuesToSubstitute¶
- class symfem.functions.ScalarFunction(f: int | sympy.core.expr.Expr)¶
Bases:
FunctionA scalar-valued function.
- _f: sympy.core.expr.Expr¶
- _plot_beziers: dict[tuple[symfem.references.Reference, int], list[tuple[symfem.geometry.PointType, symfem.geometry.PointType, symfem.geometry.PointType, symfem.geometry.PointType]]]¶
- __add__(other: Any) ScalarFunction¶
Add.
- __radd__(other: Any) ScalarFunction¶
Add.
- __sub__(other: Any) ScalarFunction¶
Subtract.
- __rsub__(other: Any) ScalarFunction¶
Subtract.
- __truediv__(other: Any) ScalarFunction¶
Divide.
- __rtruediv__(other: Any) ScalarFunction¶
Divide.
- __mul__(other: Any) ScalarFunction¶
Multiply.
- __rmul__(other: Any) ScalarFunction¶
Multiply.
- __matmul__(other: Any)¶
Multiply.
- __rmatmul__(other: Any)¶
Multiply.
- __pow__(other: Any) ScalarFunction¶
Raise to a power.
- __neg__() ScalarFunction¶
Negate.
- as_sympy() SympyFormat¶
Convert to a sympy expression.
- Returns:
A Sympy expression
- as_tex() str¶
Convert to a TeX expression.
- Returns:
A TeX string
- subs(vars: symfem.symbols.AxisVariables, values: ValuesToSubstitute) ScalarFunction¶
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) ScalarFunction¶
Differentiate the function.
- Parameters:
variable – The variable to differentiate with respect to
- Returns:
The differentiated function
- directional_derivative(direction: symfem.geometry.PointType) ScalarFunction¶
Compute a directional derivative.
- Parameters:
direction – The diection
- Returns:
The directional derivatve
- jacobian_component(component: tuple[int, int]) ScalarFunction¶
Compute a component of the jacobian.
- Parameters:
component – The component
- Returns:
The component of the jacobian
- jacobian(dim: int) MatrixFunction¶
Compute the jacobian.
- Parameters:
dim – The topological dimension of the cell
- Returns:
The jacobian
- dot(other_in: FunctionInput) ScalarFunction¶
Compute the dot product with another function.
- Parameters:
other_in – The function to multiply with
- Returns:
The product
- cross(other_in: FunctionInput)¶
Compute the cross product with another function.
- Parameters:
other_in – The function to multiply with
- Returns:
The cross product
- div()¶
Compute the div of the function.
- Returns:
The divergence
- curl()¶
Compute the curl of the function.
- Returns:
The curl
- norm() ScalarFunction¶
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) Function¶
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
- integrate(*limits: tuple[sympy.core.symbol.Symbol, int | sympy.core.expr.Expr, int | sympy.core.expr.Expr])¶
Integrate the function.
- Parameters:
limits – The variables and limits
- Returns:
The integral
- 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() Function¶
Return a version the function with floats as coefficients.
- Returns:
A version the function with floats as coefficients
- 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
- class symfem.functions.VectorFunction(vec: tuple[Function | int | sympy.core.expr.Expr, Ellipsis] | list[Function | int | sympy.core.expr.Expr])¶
Bases:
FunctionA vector-valued function.
- _vec: tuple[ScalarFunction, Ellipsis]¶
- _plot_arrows: dict[tuple[symfem.references.Reference, int], list[tuple[tuple[sympy.core.expr.Expr, Ellipsis], VectorFunction, float]]]¶
- __len__()¶
Get the length of the vector.
- property shape: tuple[int, Ellipsis]¶
Get the value shape of the function.
- Returns:
The value shape
- __getitem__(key) ScalarFunction | VectorFunction¶
Get a component or slice of the function.
- __add__(other: Any) VectorFunction¶
Add.
- __radd__(other: Any) VectorFunction¶
Add.
- __sub__(other: Any) VectorFunction¶
Subtract.
- __rsub__(other: Any) VectorFunction¶
Subtract.
- __neg__() VectorFunction¶
Negate.
- __truediv__(other: Any) VectorFunction¶
Divide.
- __rtruediv__(other: Any) VectorFunction¶
Divide.
- __mul__(other: Any) VectorFunction¶
Multiply.
- __rmul__(other: Any) VectorFunction¶
Multiply.
- __matmul__(other: Any) VectorFunction¶
Multiply.
- __rmatmul__(other: Any) VectorFunction¶
Multiply.
- __pow__(other: Any) VectorFunction¶
Raise to a power.
- as_sympy() SympyFormat¶
Convert to a sympy expression.
- Returns:
A Sympy expression
- as_tex() str¶
Convert to a TeX expression.
- Returns:
A TeX string
- subs(vars: symfem.symbols.AxisVariables, values: ValuesToSubstitute) VectorFunction¶
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) VectorFunction¶
Differentiate the function.
- Parameters:
variable – The variable to differentiate with respect to
- Returns:
The differentiated function
- abstractmethod directional_derivative(direction: symfem.geometry.PointType)¶
Compute a directional derivative.
- Parameters:
direction – The diection
- Returns:
The directional derivatve
- abstractmethod jacobian_component(component: tuple[int, int])¶
Compute a component of the jacobian.
- Parameters:
component – The component
- Returns:
The component of the jacobian
- abstractmethod jacobian(dim: int) MatrixFunction¶
Compute the jacobian.
- Parameters:
dim – The topological dimension of the cell
- Returns:
The jacobian
- dot(other_in: FunctionInput) ScalarFunction¶
Compute the dot product with another function.
- Parameters:
other_in – The function to multiply with
- Returns:
The product
- cross(other_in: FunctionInput) VectorFunction | ScalarFunction¶
Compute the cross product with another function.
- Parameters:
other_in – The function to multiply with
- Returns:
The cross product
- div() ScalarFunction¶
Compute the div of the function.
- Returns:
The divergence
- curl() VectorFunction¶
Compute the curl of the function.
- Returns:
The curl
- norm() ScalarFunction¶
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) Function¶
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
- __iter__()¶
Get iterable.
- __next__()¶
Get next item.
- 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() Function¶
Return a version the function with floats as coefficients.
- Returns:
A version the function with floats as coefficients
- 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
- class symfem.functions.MatrixFunction(mat: tuple[tuple[Function | int | sympy.core.expr.Expr, Ellipsis], Ellipsis] | tuple[list[Function | int | sympy.core.expr.Expr], Ellipsis] | list[tuple[Function | int | sympy.core.expr.Expr, Ellipsis]] | list[list[Function | int | sympy.core.expr.Expr]] | sympy.matrices.dense.MutableDenseMatrix)¶
Bases:
FunctionA matrix-valued function.
- _mat: tuple[tuple[ScalarFunction, Ellipsis], Ellipsis]¶
- _shape¶
- property shape: tuple[int, Ellipsis]¶
Get the value shape of the function.
- Returns:
The value shape
- __getitem__(key) ScalarFunction | VectorFunction¶
Get a component or slice of the function.
- row(n: int) VectorFunction¶
Get a row of the matrix.
- Parameters:
n – The row number
- Returns:
The row of the matrix
- col(n: int) VectorFunction¶
Get a colunm of the matrix.
- Parameters:
n – The column number
- Returns:
The column of the matrix
- __add__(other: Any) MatrixFunction¶
Add.
- __radd__(other: Any) MatrixFunction¶
Add.
- __sub__(other: Any) MatrixFunction¶
Subtract.
- __rsub__(other: Any) MatrixFunction¶
Subtract.
- __neg__() MatrixFunction¶
Negate.
- __truediv__(other: Any) MatrixFunction¶
Divide.
- __rtruediv__(other: Any) MatrixFunction¶
Divide.
- __mul__(other: Any) MatrixFunction¶
Multiply.
- __rmul__(other: Any) MatrixFunction¶
Multiply.
- __matmul__(other: Any) MatrixFunction¶
Multiply.
- __rmatmul__(other: Any) MatrixFunction¶
Multiply.
- __pow__(other: Any) MatrixFunction¶
Raise to a power.
- as_sympy() SympyFormat¶
Convert to a sympy expression.
- Returns:
A Sympy expression
- as_tex() str¶
Convert to a TeX expression.
- Returns:
A TeX string
- subs(vars: symfem.symbols.AxisVariables, values: ValuesToSubstitute) MatrixFunction¶
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) MatrixFunction¶
Differentiate the function.
- Parameters:
variable – The variable to differentiate with respect to
- Returns:
The differentiated function
- abstractmethod directional_derivative(direction: symfem.geometry.PointType)¶
Compute a directional derivative.
- Parameters:
direction – The diection
- Returns:
The directional derivatve
- abstractmethod jacobian_component(component: tuple[int, int])¶
Compute a component of the jacobian.
- Parameters:
component – The component
- Returns:
The component of the jacobian
- abstractmethod jacobian(dim: int)¶
Compute the jacobian.
- Parameters:
dim – The topological dimension of the cell
- Returns:
The jacobian
- dot(other_in: FunctionInput) ScalarFunction¶
Compute the dot product with another function.
- Parameters:
other_in – The function to multiply with
- Returns:
The product
- cross(other_in: FunctionInput)¶
Compute the cross product with another function.
- Parameters:
other_in – The function to multiply with
- Returns:
The cross product
- div()¶
Compute the div of the function.
- Returns:
The divergence
- curl()¶
Compute the curl of the function.
- Returns:
The curl
- abstractmethod norm() ScalarFunction¶
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) Function¶
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() ScalarFunction¶
Compute the determinant.
- Returns:
The deteminant
- transpose() MatrixFunction¶
Compute the transpose.
- Returns:
The transpose
- with_floats() Function¶
Return a version the function with floats as coefficients.
- Returns:
A version the function with floats as coefficients
- 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.functions.FunctionInput¶
- symfem.functions.parse_function_input(f: FunctionInput) Function¶
Parse a function.
- Parameters:
f – A function
- Returns:
The function as a Symfem function
- symfem.functions.parse_function_list_input(functions: list[FunctionInput] | tuple[FunctionInput, Ellipsis]) list[Function]¶
Parse a list of functions.
- Parameters:
functions – The functions
- Returns:
The functions as Symfem functions