symfem.finite_element
¶
Abstract finite element classes and functions.
Module Contents¶
Classes¶
Abstract finite element. |
|
Finite element defined using the Ciarlet definition. |
|
Finite element defined directly. |
|
Finite element defined directly. |
|
A basis function of a finite element. |
Attributes¶
- symfem.finite_element.TabulatedBasis¶
- exception symfem.finite_element.NoTensorProduct¶
Bases:
Exception
Error for element without a tensor representation.
- class symfem.finite_element.FiniteElement(reference: symfem.references.Reference, order: int, space_dim: int, domain_dim: int, range_dim: int, range_shape: Tuple[int, Ellipsis] | None = None)¶
Bases:
abc.ABC
Abstract finite element.
- abstract property maximum_degree: int¶
Get the maximum degree of this polynomial set for the element.
- property name: str¶
Get the name of the element.
- Returns:
The name of the element’s family
- _float_basis_functions: None | List[symfem.functions.AnyFunction]¶
- _value_scale: None | sympy.core.expr.Expr¶
- names: List[str] = []¶
- references: List[str] = []¶
- last_updated¶
- cache = True¶
- _max_continuity_test_order = 4¶
- abstract dof_plot_positions() List[symfem.geometry.PointType] ¶
Get the points to plot each DOF at on a DOF diagram.
- Returns:
The DOF positions
- abstract dof_directions() List[symfem.geometry.PointType | None] ¶
Get the direction associated with each DOF.
- Returns:
The DOF directions
- abstract dof_entities() List[Tuple[int, int]] ¶
Get the entities that each DOF is associated with.
- Returns:
The entities
- plot_dof_diagram(filename: str | List[str], plot_options: Dict[str, Any] = {}, **kwargs: Any)¶
Plot a diagram showing the DOFs of the element.
- Parameters:
filename – The file name
plot_options – Options for the plot
kwargs – Keyword arguments
- abstract entity_dofs(entity_dim: int, entity_number: int) List[int] ¶
Get the numbers of the DOFs associated with the given entity.
- Parameters:
entity_dim – The dimension of the entity
entity_number – The number of the entity
- Returns:
The numbers of the DOFs associated with the entity
- abstract get_basis_functions(use_tensor_factorisation: bool = False) List[symfem.functions.AnyFunction] ¶
Get the basis functions of the element.
- Parameters:
use_tensor_factorisation – Should a tensor factorisation be used?
- Returns:
The basis functions
- get_basis_function(n: int) symfem.basis_functions.BasisFunction ¶
Get a single basis function of the element.
- Parameters:
n – The number of the basis function
- Returns:
The basis function
- tabulate_basis(points_in: symfem.geometry.SetOfPointsInput, order: str = 'xyzxyz') TabulatedBasis ¶
Evaluate the basis functions of the element at the given points.
- Parameters:
points_in – The points
order – The order to return the values
- Returns:
The tabulated basis functions
- tabulate_basis_float(points_in: symfem.geometry.SetOfPointsInput) TabulatedBasis ¶
Evaluate the basis functions of the element at the given points in xyz,xyz order.
- Parameters:
points_in – The points
- Returns:
The tabulated basis functions
- plot_basis_function(n: int, filename: str | List[str], cell: symfem.references.Reference | None = None, **kwargs: Any)¶
Plot a diagram showing a basis function.
- Parameters:
n – The basis function number
filename – The file name
cell – The cell to push the basis function to and plot on
kwargs – Keyword arguments
- abstract map_to_cell(vertices_in: symfem.geometry.SetOfPointsInput, basis: List[symfem.functions.AnyFunction] | None = None, forward_map: symfem.geometry.PointType | None = None, inverse_map: symfem.geometry.PointType | None = None) List[symfem.functions.AnyFunction] ¶
Map the basis onto a cell using the appropriate mapping for the element.
- Parameters:
vertices_in – The vertices of the cell
basis – The basis functions
forward_map – The map from the reference to the cell
inverse_map – The map to the reference from the cell
- Returns:
The basis functions mapped to the cell
- abstract get_polynomial_basis() List[symfem.functions.AnyFunction] ¶
Get the symbolic polynomial basis for the element.
- Returns:
The polynomial basis
- test()¶
Run tests for this element.
- test_continuity()¶
Test that this element has the correct continuity.
- get_tensor_factorisation() List[Tuple[str, List[FiniteElement], List[int]]] ¶
Get the representation of the element as a tensor product.
- Returns:
The tensor factorisation
- _get_basis_functions_tensor() List[symfem.functions.AnyFunction] ¶
Compute the basis functions using the space’s tensor product factorisation.
- Returns:
The basis functions
- init_kwargs() Dict[str, Any] ¶
Return the keyword arguments used to create this element.
- Returns:
Keyword arguments dictionary
- class symfem.finite_element.CiarletElement(reference: symfem.references.Reference, order: int, basis: List[symfem.functions.FunctionInput], dofs: symfem.functionals.ListOfFunctionals, domain_dim: int, range_dim: int, range_shape: Tuple[int, Ellipsis] | None = None)¶
Bases:
FiniteElement
Finite element defined using the Ciarlet definition.
- property maximum_degree: int¶
Get the maximum degree of this polynomial set for the element.
- entity_dofs(entity_dim: int, entity_number: int) List[int] ¶
Get the numbers of the DOFs associated with the given entity.
- Parameters:
entity_dim – The dimension of the entity
entity_number – The number of the entity
- Returns:
The numbers of the DOFs associated with the entity
- dof_plot_positions() List[symfem.geometry.PointType] ¶
Get the points to plot each DOF at on a DOF diagram.
- Returns:
The DOF positions
- dof_directions() List[symfem.geometry.PointType | None] ¶
Get the direction associated with each DOF.
- Returns:
The DOF directions
- dof_entities() List[Tuple[int, int]] ¶
Get the entities that each DOF is associated with.
- Returns:
The entities
- get_polynomial_basis() List[symfem.functions.AnyFunction] ¶
Get the symbolic polynomial basis for the element.
- Returns:
The polynomial basis
- get_dual_matrix(inverse=False, caching=True) sympy.matrices.dense.MutableDenseMatrix ¶
Get the dual matrix.
- Parameters:
inverse – Should the dual matrix be inverted?
caching – Should the result be cached
- Returns:
The dual matrix
- get_basis_functions(use_tensor_factorisation: bool = False) List[symfem.functions.AnyFunction] ¶
Get the basis functions of the element.
- Parameters:
use_tensor_factorisation – Should a tensor factorisation be used?
- Returns:
The basis functions
- plot_basis_function(n: int, filename: str | List[str], cell: symfem.references.Reference | None = None, **kwargs: Any)¶
Plot a diagram showing a basis function.
- Parameters:
n – The basis function number
filename – The file name
cell – The cell to push the basis function to and plot on
kwargs – Keyword arguments
- map_to_cell(vertices_in: symfem.geometry.SetOfPointsInput, basis: List[symfem.functions.AnyFunction] | None = None, forward_map: symfem.geometry.PointType | None = None, inverse_map: symfem.geometry.PointType | None = None) List[symfem.functions.AnyFunction] ¶
Map the basis onto a cell using the appropriate mapping for the element.
- Parameters:
vertices_in – The vertices of the cell
basis – The basis functions
forward_map – The map from the reference to the cell
inverse_map – The map to the reference from the cell
- Returns:
The basis functions mapped to the cell
- test()¶
Run tests for this element.
- test_dof_points()¶
Test that DOF points are valid.
- test_functional_entities()¶
Test that the dof entities are valid and match the references of integrals.
- test_functionals()¶
Test that the functionals are satisfied by the basis functions.
- class symfem.finite_element.DirectElement(reference: symfem.references.Reference, order: int, basis_functions: List[symfem.functions.FunctionInput], basis_entities: List[Tuple[int, int]], domain_dim: int, range_dim: int, range_shape: Tuple[int, Ellipsis] | None = None)¶
Bases:
FiniteElement
Finite element defined directly.
- abstract property maximum_degree: int¶
Get the maximum degree of this polynomial set for the element.
- _basis_functions: List[symfem.functions.AnyFunction]¶
- entity_dofs(entity_dim: int, entity_number: int) List[int] ¶
Get the numbers of the DOFs associated with the given entity.
- Parameters:
entity_dim – The dimension of the entity
entity_number – The number of the entity
- Returns:
The numbers of the DOFs associated with the entity
- dof_plot_positions() List[symfem.geometry.PointType] ¶
Get the points to plot each DOF at on a DOF diagram.
- Returns:
The DOF positions
- dof_directions() List[symfem.geometry.PointType | None] ¶
Get the direction associated with each DOF.
- Returns:
The DOF directions
- dof_entities() List[Tuple[int, int]] ¶
Get the entities that each DOF is associated with.
- Returns:
The entities
- get_basis_functions(use_tensor_factorisation: bool = False) List[symfem.functions.AnyFunction] ¶
Get the basis functions of the element.
- Parameters:
use_tensor_factorisation – Should a tensor factorisation be used?
- Returns:
The basis functions
- map_to_cell(vertices_in: symfem.geometry.SetOfPointsInput, basis: List[symfem.functions.AnyFunction] | None = None, forward_map: symfem.geometry.PointType | None = None, inverse_map: symfem.geometry.PointType | None = None) List[symfem.functions.AnyFunction] ¶
Map the basis onto a cell using the appropriate mapping for the element.
- Parameters:
vertices_in – The vertices of the cell
basis – The basis functions
forward_map – The map from the reference to the cell
inverse_map – The map to the reference from the cell
- Returns:
The basis functions mapped to the cell
- abstract get_polynomial_basis() List[symfem.functions.AnyFunction] ¶
Get the symbolic polynomial basis for the element.
- Returns:
The polynomial basis
- test()¶
Run tests for this element.
- test_independence()¶
Test that the basis functions of this element are linearly independent.
- class symfem.finite_element.EnrichedElement(subelements: List[FiniteElement])¶
Bases:
FiniteElement
Finite element defined directly.
- abstract property maximum_degree: int¶
Get the maximum degree of this polynomial set for the element.
- _basis_functions: List[symfem.functions.AnyFunction] | None¶
- entity_dofs(entity_dim: int, entity_number: int) List[int] ¶
Get the numbers of the DOFs associated with the given entity.
- Parameters:
entity_dim – The dimension of the entity
entity_number – The number of the entity
- Returns:
The numbers of the DOFs associated with the entity
- dof_plot_positions() List[symfem.geometry.PointType] ¶
Get the points to plot each DOF at on a DOF diagram.
- Returns:
The DOF positions
- dof_directions() List[symfem.geometry.PointType | None] ¶
Get the direction associated with each DOF.
- Returns:
The DOF directions
- dof_entities() List[Tuple[int, int]] ¶
Get the entities that each DOF is associated with.
- Returns:
The entities
- get_basis_functions(use_tensor_factorisation: bool = False) List[symfem.functions.AnyFunction] ¶
Get the basis functions of the element.
- Parameters:
use_tensor_factorisation – Should a tensor factorisation be used?
- Returns:
The basis functions
- map_to_cell(vertices_in: symfem.geometry.SetOfPointsInput, basis: List[symfem.functions.AnyFunction] | None = None, forward_map: symfem.geometry.PointType | None = None, inverse_map: symfem.geometry.PointType | None = None) List[symfem.functions.AnyFunction] ¶
Map the basis onto a cell using the appropriate mapping for the element.
- Parameters:
vertices_in – The vertices of the cell
basis – The basis functions
forward_map – The map from the reference to the cell
inverse_map – The map to the reference from the cell
- Returns:
The basis functions mapped to the cell
- abstract get_polynomial_basis() List[symfem.functions.AnyFunction] ¶
Get the symbolic polynomial basis for the element.
- Returns:
The polynomial basis
- test()¶
Run tests for this element.
- class symfem.finite_element.ElementBasisFunction(element: FiniteElement, n: int)¶
Bases:
symfem.basis_functions.BasisFunction
A basis function of a finite element.
- get_function() symfem.functions.AnyFunction ¶
Get the actual basis function.
- Returns:
The basis function