symfem.basis_functions

Abstract basis function classes and functions.

Module Contents

Classes

BasisFunction

A basis function of a finite element.

SubbedBasisFunction

A basis function following a substitution.

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

Bases: symfem.functions.AnyFunction

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.

abstract get_function() symfem.functions.AnyFunction

Get the actual basis function.

Returns:

The basis function

__add__(other: Any) symfem.functions.AnyFunction

Add.

Parameters:

other – A function to add to this function.

Returns:

The sum of two functions

__radd__(other: Any) symfem.functions.AnyFunction

Add.

Parameters:

other – A function to add to this function.

Returns:

The sum of two functions

__sub__(other: Any) symfem.functions.AnyFunction

Subtract.

Parameters:

other – A function to subtract this function.

Returns:

The difference of two functions

__rsub__(other: Any) symfem.functions.AnyFunction

Subtract.

Parameters:

other – A function to subtract this function from.

Returns:

The difference of two functions

__neg__() symfem.functions.AnyFunction

Negate.

Returns:

Negated function

__truediv__(other: Any) symfem.functions.AnyFunction

Divide.

Parameters:

other – A function to divide this function by.

Returns:

The ratio of two functions

__rtruediv__(other: Any) symfem.functions.AnyFunction

Divide.

Parameters:

other – A function to divide by this function.

Returns:

The ratio of two functions

__mul__(other: Any) symfem.functions.AnyFunction

Multiply.

Parameters:

other – A function to multiply by this function.

Returns:

The product of two functions

__rmul__(other: Any) symfem.functions.AnyFunction

Multiply.

Parameters:

other – A function to multiply by this function.

Returns:

The product of two functions

__matmul__(other: Any) symfem.functions.AnyFunction

Multiply.

Parameters:

other – A function to matrix multiply by this function.

Returns:

The product of two matrix functions

__rmatmul__(other: Any) symfem.functions.AnyFunction

Multiply.

Parameters:

other – A function to matrix multiply by this function.

Returns:

The product of two matrix functions

__pow__(other: Any) symfem.functions.AnyFunction

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.AnyFunction

Differentiate the function.

Parameters:

variable – The variable to differentiate with respect to

Returns:

The derivative

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

Compute a directional derivative.

Parameters:

direction – The direction of the derivative

Returns:

The derivative

jacobian_component(component: Tuple[int, int]) symfem.functions.AnyFunction

Compute a component of the jacobian.

Parameters:

component – The component to compute

Returns:

Component of the Jacobian

jacobian(dim: int) symfem.functions.AnyFunction

Compute the jacobian.

Parameters:

dim – The dimension of the Jacobian

Returns:

The Jabobian

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

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.AnyFunction

Compute the cross product with another function.

Parameters:

other_in – The function to cross with

Returns:

The cross product

div() symfem.functions.AnyFunction

Compute the divergence of the function.

Returns:

The divergence

grad(dim: int) symfem.functions.AnyFunction

Compute the gradient of the function.

Returns:

The gradient

curl() symfem.functions.AnyFunction

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.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

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.AnyFunction

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.AnyFunction

Return a version the function with floats as coefficients.

Returns:

The function with floats as coefficients

__iter__() Iterator[symfem.functions.AnyFunction]

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.

property shape: Tuple[int, Ellipsis]

Get the value shape of the function.

Returns:

shape

get_function() symfem.functions.AnyFunction

Return the symbolic function.

Returns:

Symbolic function

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