basix.finite_element

Functions for creating finite elements.

Functions

string_to_family(family, cell)

Get a Basix ElementFamily enum representing the family type on the given cell.

class basix.finite_element.FiniteElement

Bases: pybind11_object

Finite Element

property M
apply_dof_transformation(self: basix._basixcpp.FiniteElement, arg0: numpy.ndarray[numpy.float64], arg1: int, arg2: int) numpy.ndarray[numpy.float64]

Apply DOF transformations to some data

NOTE: This function is designed to be called at runtime, so its performance is critical.

Parameters
  • data – The data

  • block_size – The number of data points per DOF

  • cell_info – The permutation info for the cell

Returns

The data

Return type

data

apply_dof_transformation_to_transpose(self: basix._basixcpp.FiniteElement, arg0: numpy.ndarray[numpy.float64], arg1: int, arg2: int) numpy.ndarray[numpy.float64]

Apply DOF transformations to some transposed data

NOTE: This function is designed to be called at runtime, so its performance is critical.

Parameters
  • data – The data

  • block_size – The number of data points per DOF

  • cell_info – The permutation info for the cell

Returns

The data

Return type

data

apply_inverse_transpose_dof_transformation(self: basix._basixcpp.FiniteElement, arg0: numpy.ndarray[numpy.float64], arg1: int, arg2: int) numpy.ndarray[numpy.float64]

Apply inverse transpose DOF transformations to some data

NOTE: This function is designed to be called at runtime, so its performance is critical.

Parameters
  • data – The data

  • block_size – The number of data points per DOF

  • cell_info – The permutation info for the cell

Returns

The data

Return type

data

base_transformations(self: basix._basixcpp.FiniteElement) numpy.ndarray[numpy.float64]

@brief Get the base transformations.

The base transformations represent the effect of rotating or reflecting a subentity of the cell on the numbering and orientation of the DOFs. This returns a list of matrices with one matrix for each subentity permutation in the following order: Reversing edge 0, reversing edge 1, … Rotate face 0, reflect face 0, rotate face 1, reflect face 1, …

Example: Order 3 Lagrange on a triangle

This space has 10 dofs arranged like:

2
|\
6 4
|  \
5 9 3
|    \
0-7-8-1

For this element, the base transformations are: [Matrix swapping 3 and 4, Matrix swapping 5 and 6, Matrix swapping 7 and 8] The first row shows the effect of reversing the diagonal edge. The second row shows the effect of reversing the vertical edge. The third row shows the effect of reversing the horizontal edge.

Example: Order 1 Raviart-Thomas on a triangle

This space has 3 dofs arranged like:

  |\
  | \
  |  \
<-1   0
  |  / \
  | L ^ \
  |   |  \
   ---2---

These DOFs are integrals of normal components over the edges: DOFs 0 and 2 are oriented inward, DOF 1 is oriented outwards. For this element, the base transformation matrices are:

0: [[-1, 0, 0],
    [ 0, 1, 0],
    [ 0, 0, 1]]
1: [[1,  0, 0],
    [0, -1, 0],
    [0,  0, 1]]
2: [[1, 0,  0],
    [0, 1,  0],
    [0, 0, -1]]

The first matrix reverses DOF 0 (as this is on the first edge). The second matrix reverses DOF 1 (as this is on the second edge). The third matrix reverses DOF 2 (as this is on the third edge).

Example: DOFs on the face of Order 2 Nedelec first kind on a tetrahedron

On a face of this tetrahedron, this space has two face tangent DOFs:

|\        |\
| \       | \
|  \      | ^\
|   \     | | \
| 0->\    | 1  \
|     \   |     \
 ------    ------

For these DOFs, the subblocks of the base transformation matrices are:

rotation: [[-1, 1],
           [ 1, 0]]
reflection: [[0, 1],
             [1, 0]]
Returns

The base transformations for this element. The shape is (ntranformations, ndofs, ndofs)

property cell_type
property coefficient_matrix
property degree
property dim
property discontinuous
property dof_transformations_are_identity
property dof_transformations_are_permutations
property dpc_variant
property dual_matrix
property entity_closure_dofs
property entity_dofs
entity_transformations(self: basix._basixcpp.FiniteElement) dict

Return the entity dof transformation matrices

Returns

The base transformations for this element. The shape is (ntranformations, ndofs, ndofs)

property family
get_tensor_product_representation(self: basix._basixcpp.FiniteElement) List[Tuple[List[basix._basixcpp.FiniteElement], List[int]]]

Get the tensor product representation of this element, or throw an error if no such factorisation exists.

The tensor product representation will be a vector of tuples. Each tuple contains a vector of finite elements, and a vector of integers. The vector of finite elements gives the elements on an interval that appear in the tensor product representation. The vector of integers gives the permutation between the numbering of the tensor product DOFs and the number of the DOFs of this Basix element.

Returns

The tensor product representation

property has_tensor_product_factorisation
property highest_complete_degree
property highest_degree
property interpolation_is_identity
property interpolation_matrix
property interpolation_nderivs
property lagrange_variant
property map_type
property num_entity_closure_dofs
property num_entity_dofs
property points
pull_back(self: basix._basixcpp.FiniteElement, arg0: numpy.ndarray[numpy.float64], arg1: numpy.ndarray[numpy.float64], arg2: numpy.ndarray[numpy.float64], arg3: numpy.ndarray[numpy.float64]) numpy.ndarray[numpy.float64]

Map function values from a physical cell to the reference

Parameters
  • u – The function values on the cell

  • J – The Jacobian of the mapping

  • detJ – The determinant of the Jacobian of the mapping

  • K – The inverse of the Jacobian of the mapping

Returns

The function values on the reference. The indices are [Jacobian index, point index, components].

push_forward(self: basix._basixcpp.FiniteElement, arg0: numpy.ndarray[numpy.float64], arg1: numpy.ndarray[numpy.float64], arg2: numpy.ndarray[numpy.float64], arg3: numpy.ndarray[numpy.float64]) numpy.ndarray[numpy.float64]

Map function values from the reference to a physical cell. This function can perform the mapping for multiple points, grouped by points that share a common Jacobian.

Parameters
  • U – The function values on the reference. The indices are [Jacobian index, point index, components].

  • J – The Jacobian of the mapping. The indices are [Jacobian index, J_i, J_j].

  • detJ – The determinant of the Jacobian of the mapping. It has length J.shape(0)

  • K – The inverse of the Jacobian of the mapping. The indices are [Jacobian index, K_i, K_j].

Returns

The function values on the cell. The indices are [Jacobian index, point index, components].

tabulate(self: basix._basixcpp.FiniteElement, arg0: int, arg1: numpy.ndarray[numpy.float64]) numpy.ndarray[numpy.float64]

@brief Compute basis values and derivatives at set of points.

NOTE: The version of FiniteElement::tabulate with the basis data as an out argument should be preferred for repeated call where performance is critical

Parameters
  • nd – The order of derivatives, up to and including, to compute. Use 0 for the basis functions only.

  • x – The points at which to compute the basis functions. The shape of x is (number of points, geometric dimension).

Returns

The basis functions (and derivatives). The shape is (derivative, point, basis fn index, value index). - The first index is the derivative, with higher derivatives are stored in triangular (2D) or tetrahedral (3D) ordering, ie for the (x,y) derivatives in 2D: (0,0), (1,0), (0,1), (2,0), (1,1), (0,2), (3,0)… The function basix::indexing::idx can be used to find the appropriate derivative. - The second index is the point index - The third index is the basis function index - The fourth index is the basis function component. Its has size one for scalar basis functions.

property value_shape
property value_size
property wcoeffs
property x
basix.finite_element.string_to_family(family: str, cell: str) ElementFamily

Get a Basix ElementFamily enum representing the family type on the given cell.

Parameters
  • family – The element family as a string.

  • cell – The cell type as a string.

Returns

The element family.