symfem.basis_functions

Abstract basis function classes and functions.

Classes

BasisFunction

A basis function of a finite element.

SubbedBasisFunction

A basis function following a substitution.

Module Contents

class symfem.basis_functions.BasisFunction(scalar=False, vector=False, matrix=False)

Bases: symfem.functions.Function

A basis function of a finite element.

This basis function can be used before the element’s basis functions have been computed. When the explicit basis function is needed, only then will it be computed.

abstractmethod get_function() symfem.functions.Function

Get the actual basis function.

Returns:

The basis function

__add__(other: Any) symfem.functions.Function

Add.

Parameters:

other – A function to add to this function.

Returns:

The sum of two functions

__radd__(other: Any) symfem.functions.Function

Add.

Parameters:

other – A function to add to this function.

Returns:

The sum of two functions

__sub__(other: Any) symfem.functions.Function

Subtract.

Parameters:

other – A function to subtract this function.

Returns:

The difference of two functions

__rsub__(other: Any) symfem.functions.Function

Subtract.

Parameters:

other – A function to subtract this function from.

Returns:

The difference of two functions

__neg__() symfem.functions.Function

Negate.

Returns:

Negated function

__truediv__(other: Any) symfem.functions.Function

Divide.

Parameters:

other – A function to divide this function by.

Returns:

The ratio of two functions

__rtruediv__(other: Any) symfem.functions.Function

Divide.

Parameters:

other – A function to divide by this function.

Returns:

The ratio of two functions

__mul__(other: Any) symfem.functions.Function

Multiply.

Parameters:

other – A function to multiply by this function.

Returns:

The product of two functions

__rmul__(other: Any) symfem.functions.Function

Multiply.

Parameters:

other – A function to multiply by this function.

Returns:

The product of two functions

__matmul__(other: Any) symfem.functions.Function

Multiply.

Parameters:

other – A function to matrix multiply by this function.

Returns:

The product of two matrix functions

__rmatmul__(other: Any) symfem.functions.Function

Multiply.

Parameters:

other – A function to matrix multiply by this function.

Returns:

The product of two matrix functions

__pow__(other: Any) symfem.functions.Function

Raise to a power.

Parameters:

other – A power to raise this function to.

Returns:

This function to the power of other

as_sympy() symfem.functions.SympyFormat

Convert to a sympy expression.

Returns:

This function as a Sympy expression

as_tex() str

Convert to a TeX expression.

Returns:

A TeX representation of this function

diff(variable: sympy.core.symbol.Symbol) symfem.functions.Function

Differentiate the function.

Parameters:

variable – The variable to differentiate with respect to

Returns:

The derivative

directional_derivative(direction: symfem.geometry.PointType) symfem.functions.Function

Compute a directional derivative.

Parameters:

direction – The direction of the derivative

Returns:

The derivative

jacobian_component(component: tuple[int, int]) symfem.functions.Function

Compute a component of the jacobian.

Parameters:

component – The component to compute

Returns:

Component of the Jacobian

jacobian(dim: int) symfem.functions.Function

Compute the jacobian.

Parameters:

dim – The dimension of the Jacobian

Returns:

The Jabobian

dot(other_in: symfem.functions.FunctionInput) symfem.functions.Function

Compute the dot product with another function.

Parameters:

other_in – The function to dot with

Returns:

The dot product

cross(other_in: symfem.functions.FunctionInput) symfem.functions.Function

Compute the cross product with another function.

Parameters:

other_in – The function to cross with

Returns:

The cross product

div() symfem.functions.Function

Compute the divergence of the function.

Returns:

The divergence

grad(dim: int) symfem.functions.Function

Compute the gradient of the function.

Returns:

The gradient

curl() symfem.functions.Function

Compute the curl of the function.

Returns:

The curl

norm() symfem.functions.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) symfem.functions.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

subs(vars: symfem.symbols.AxisVariables, values: symfem.functions.ValuesToSubstitute) BasisFunction

Substitute values into the function.

Parameters:
  • vars – The variable(s) to substitute

  • values – The value(s) to substitute

Returns:

Substituted function

__getitem__(key) symfem.functions.Function

Forward all other function calls to symbolic function.

__len__() int

Get length.

Returns:

The length

det() symfem.functions.ScalarFunction

Compute the determinant.

Returns:

The determinant

transpose() symfem.functions.ScalarFunction

Compute the transpose.

Returns:

The transpose

with_floats() symfem.functions.Function

Return a version the function with floats as coefficients.

Returns:

The function with floats as coefficients

__iter__() Iterator[symfem.functions.Function]

Iterate through components of vector function.

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.basis_functions.SubbedBasisFunction(f: BasisFunction, vars: symfem.symbols.AxisVariables, values: symfem.functions.ValuesToSubstitute)

Bases: BasisFunction

A basis function following a substitution.

f
_vars
_values
get_function() symfem.functions.Function

Return the symbolic function.

Returns:

Symbolic function

property shape: tuple[int, Ellipsis]

Get the value shape of the function.

Returns:

shape

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 domain to plot the function on

  • img – The image to plot the values on

  • value_scale – The factor to scale values by

  • n – The number of plotting points

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