basix.ufl

Functions to directly wrap Basix elements in UFL.

Functions

blocked_element(sub_element, shape[, ...])

Create a UFL compatible blocked element.

convert_ufl_element(ufl_element)

Convert a UFL element to a UFL compatible Basix element.

custom_element(cell_type, value_shape, ...)

Create a UFL compatible custom Basix element.

element(family, cell, degree[, ...])

Create a UFL compatible element using Basix.

enriched_element(elements[, map_type, gdim])

Create an UFL compatible enriched element from a list of elements.

mixed_element(elements[, gdim])

Create a UFL compatible mixed element from a list of elements.

quadrature_element(cell, value_shape[, ...])

Create a quadrature element.

real_element(cell, value_shape)

Create a real element.

basix.ufl.blocked_element(sub_element: _ElementBase, shape: Tuple[int, ...], symmetry: Optional[bool] = None, gdim: Optional[int] = None) _ElementBase

Create a UFL compatible blocked element.

Parameters:
  • sub_element – Element used for each block.

  • shape – Value shape of the element. For scalar-valued families, this can be used to create vector and tensor elements.

  • symmetry – Set to True if the tensor is symmetric. Valid for rank 2 elements only.

  • gdim – Geometric dimension. If not set the geometric dimension is set equal to the topological dimension of the cell.

Returns:

A blocked finite element.

basix.ufl.convert_ufl_element(ufl_element: FiniteElementBase) _ElementBase

Convert a UFL element to a UFL compatible Basix element.

basix.ufl.custom_element(cell_type: ~basix._basixcpp.CellType, value_shape: ~typing.Union[~typing.List[int], ~typing.Tuple[int, ...]], wcoeffs: ~numpy.ndarray[~typing.Any, ~numpy.dtype[~numpy.float64]], x: ~typing.List[~typing.List[~numpy.ndarray[~typing.Any, ~numpy.dtype[~numpy.float64]]]], M: ~typing.List[~typing.List[~numpy.ndarray[~typing.Any, ~numpy.dtype[~numpy.float64]]]], interpolation_nderivs: int, map_type: ~basix._basixcpp.MapType, sobolev_space: ~basix._basixcpp.SobolevSpace, discontinuous: bool, highest_complete_degree: int, highest_degree: int, polyset_type: ~basix._basixcpp.PolysetType = <PolysetType.standard: 0>, gdim: ~typing.Optional[int] = None) _ElementBase

Create a UFL compatible custom Basix element.

Parameters:
  • cell_type – The cell type

  • value_shape – The value shape of the element

  • wcoeffs – Matrices for the kth value index containing the expansion coefficients defining a polynomial basis spanning the polynomial space for this element. Shape is (dim(finite element polyset), dim(Legenre polynomials)).

  • x – Interpolation points. Indices are (tdim, entity index, point index, dim)

  • M – The interpolation matrices. Indices are (tdim, entity index, dof, vs, point_index, derivative).

  • interpolation_nderivs – The number of derivatives that need to be used during interpolation.

  • map_type – The type of map to be used to map values from the reference to a cell.

  • sobolev_space – Underlying Sobolev space for the element.

  • discontinuous – Indicates whether or not this is the discontinuous version of the element.

  • highest_complete_degree – The highest degree n such that a Lagrange (or vector Lagrange) element of degree n is a subspace of this element.

  • highest_degree – The degree of a polynomial in this element’s polyset.

  • polyset_type – Polyset type for the element.

  • gdim – Geometric dimension. If not set the geometric dimension is set equal to the topological dimension of the cell.

Returns:

A custom finite element.

basix.ufl.element(family: ~typing.Union[~basix._basixcpp.ElementFamily, str], cell: ~typing.Union[~basix._basixcpp.CellType, str], degree: int, lagrange_variant: ~basix._basixcpp.LagrangeVariant = <LagrangeVariant.unset: -1>, dpc_variant: ~basix._basixcpp.DPCVariant = <DPCVariant.unset: -1>, discontinuous: bool = False, shape: ~typing.Optional[~typing.Tuple[int, ...]] = None, symmetry: ~typing.Optional[bool] = None, gdim: ~typing.Optional[int] = None) _ElementBase

Create a UFL compatible element using Basix.

Parameters:
  • family – Element family/type.

  • cell – Element cell type.

  • degree – Degree of the finite element.

  • lagrange_variant – Variant of Lagrange to be used.

  • dpc_variant – Variant of DPC to be used.

  • discontinuous – If True, the discontinuous version of the element is created.

  • shape – Value shape of the element. For scalar-valued families, this can be used to create vector and tensor elements.

  • symmetry – Set to True if the tensor is symmetric. Valid for rank 2 elements only.

  • gdim – Geometric dimension. If not set the geometric dimension is set equal to the topological dimension of the cell.

Returns:

A finite element.

basix.ufl.enriched_element(elements: List[_ElementBase], map_type: Optional[MapType] = None, gdim: Optional[int] = None) _ElementBase

Create an UFL compatible enriched element from a list of elements.

Parameters:
  • elements – The list of elements

  • map_type – The map type for the enriched element.

  • gdim – Geometric dimension. If not set the geometric dimension is set equal to the topological dimension of the cell.

Returns:

An enriched finite element.

basix.ufl.mixed_element(elements: List[_ElementBase], gdim: Optional[int] = None) _ElementBase

Create a UFL compatible mixed element from a list of elements.

Parameters:
  • elements – The list of elements

  • gdim – Geometric dimension. If not set the geometric dimension is set equal to the topological dimension of the cell.

Returns:

A mixed finite element.

basix.ufl.quadrature_element(cell: Union[str, CellType], value_shape: Tuple[int, ...], scheme: Optional[str] = None, degree: Optional[int] = None, points: Optional[ndarray[Any, dtype[float64]]] = None, weights: Optional[ndarray[Any, dtype[float64]]] = None, mapname: str = 'identity') _ElementBase

Create a quadrature element.

When creating this element, either the quadrature scheme and degree must be input or the quadrature points and weights must be.

Parameters:
  • cell – Cell to create the element on.

  • value_shape – Value shape of the element.

  • scheme – Quadrature scheme.

  • degree – Quadrature degree.

  • points – Quadrature points.

  • weights – Quadrature weights.

  • mapname – Map name.

Returns:

A ‘quadrature’ finite element.

basix.ufl.real_element(cell: Union[CellType, str], value_shape: Tuple[int, ...]) _ElementBase

Create a real element.

Parameters:
  • cell – Cell to create the element on.

  • value_shape – Value shape of the element.

Returns:

A ‘real’ finite element.