basix.ufl_wrapper

Functions to directly wrap Basix elements in UFL.

Functions

convert_ufl_element(element)

Convert a UFL element to a wrapped Basix element.

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

Create a UFL element using Basix.

create_tensor_element(family, cell, degree)

Create a UFL tensor element using Basix.

create_vector_element(family, cell, degree)

Create a UFL vector element using Basix.

ufl_sobolev_space_from_enum(s)

Convert a Basix Sobolev space enum to a UFL Sobolev space.

Classes

BasixElement(element[, gdim])

A wrapper allowing Basix elements to be used directly with UFL.

BlockedElement(repr, sub_element, block_size)

An element with a block size that contains multiple copies of a sub element.

ComponentElement(element, component[, gdim])

An element representing one component of a BasixElement.

MixedElement(sub_elements[, gdim])

A mixed element that combines two or more elements.

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

A tensor element.

VectorElement(sub_element[, size, gdim])

A vector element.

class basix.ufl_wrapper.BasixElement(element: FiniteElement, gdim: Optional[int] = None)

Bases: _BasixElementBase

A wrapper allowing Basix elements to be used directly with UFL.

Create a Basix element.

property basix_sobolev_space

Return a Basix enum representing the underlying Sobolev space.

property cell_type: CellType

Basix cell type used to initialise the element.

property dim: int

Number of DOFs the element has.

property discontinuous: bool

True if the discontinuous version of the element is used.

property dpc_variant: Optional[DPCVariant]

Basix DPC variant used to initialise the element.

element: FiniteElement
property element_family: Optional[ElementFamily]

Basix element family used to initialise the element.

property entity_closure_dofs: List[List[List[int]]]

DOF numbers associated with the closure of each entity.

property entity_dofs: List[List[List[int]]]

DOF numbers associated with each entity.

property family_name: str

Family name of the element.

get_component_element(flat_component: int) Tuple[_BasixElementBase, int, int]

Get element that represents a component of the element, and the offset and stride of the component.

For example, for a MixedElement, this will return the sub-element that represents the given component, the offset of that sub-element, and a stride of 1. For a BlockedElement, this will return the sub-element, an offset equal to the component number, and a stride equal to the block size. For vector-valued element (eg H(curl) and H(div) elements), this returns a ComponentElement (and as offset of 0 and a stride of 1). When tabulate is called on the ComponentElement, only the part of the table for the given component is returned.

Parameters

flat_component – The component

Returns

component element, offset of the component, stride of the component

get_tensor_product_representation()

Get the element’s tensor product factorisation.

has_tensor_product_factorisation() bool

Indicates whether or not this element has a tensor product factorisation.

If this value is true, this element’s basis functions can be computed as a tensor product of the basis elements of the elements in the factoriaation.

property highest_complete_degree: int

The highest complete degree of the element.

property highest_degree: int

The highest degree of the element.

property interpolation_nderivs: int

The number of derivatives needed when interpolating.

property is_custom_element: bool

True if the element is a custom Basix element.

property lagrange_variant: Optional[LagrangeVariant]

Basix Lagrange variant used to initialise the element.

property map_type: MapType

The Basix map type.

property num_entity_closure_dofs: List[List[int]]

Number of DOFs associated with the closure of each entity.

property num_entity_dofs: List[List[int]]

Number of DOFs associated with each entity.

property num_global_support_dofs: int

Get the number of global support DOFs.

property reference_geometry: ndarray[Any, dtype[float64]]

Geometry of the reference element.

property reference_topology: List[List[List[int]]]

Topology of the reference element.

tabulate(nderivs: int, points: ndarray[Any, dtype[float64]]) ndarray[Any, dtype[float64]]

Tabulate the basis functions of the element.

Parameters
  • nderivs – Number of derivatives to tabulate.

  • points – Points to tabulate at

Returns

Tabulated basis functions

property ufcx_element_type: str

Element type.

class basix.ufl_wrapper.BlockedElement(repr: str, sub_element: _BasixElementBase, block_size: int, block_shape: Optional[Tuple[int, ...]] = None, symmetric: bool = False, gdim: Optional[int] = None)

Bases: _BasixElementBase

An element with a block size that contains multiple copies of a sub element.

Initialise the element.

property basix_sobolev_space

Return a Basix enum representing the underlying Sobolev space.

block_shape: Tuple[int, ...]
property block_size: int

The block size of the element.

property cell_type: CellType

Basix cell type used to initialise the element.

property dim: int

Number of DOFs the element has.

property discontinuous: bool

True if the discontinuous version of the element is used.

property dpc_variant: Optional[DPCVariant]

Basix DPC variant used to initialise the element.

property element_family: Optional[ElementFamily]

Basix element family used to initialise the element.

property entity_closure_dofs: List[List[List[int]]]

DOF numbers associated with the closure of each entity.

property entity_dofs: List[List[List[int]]]

DOF numbers associated with each entity.

property family_name: str

Family name of the element.

get_component_element(flat_component: int) Tuple[_BasixElementBase, int, int]

Get element that represents a component of the element, and the offset and stride of the component.

Parameters

flat_component – The component

Returns

component element, offset of the component, stride of the component

get_tensor_product_representation()

Get the element’s tensor product factorisation.

has_tensor_product_factorisation() bool

Indicates whether or not this element has a tensor product factorisation.

If this value is true, this element’s basis functions can be computed as a tensor product of the basis elements of the elements in the factoriaation.

property highest_complete_degree: int

The highest complete degree of the element.

property highest_degree: int

The highest degree of the element.

property interpolation_nderivs: int

The number of derivatives needed when interpolating.

property lagrange_variant: Optional[LagrangeVariant]

Basix Lagrange variant used to initialise the element.

property map_type: MapType

The Basix map type.

property num_entity_closure_dofs: List[List[int]]

Number of DOFs associated with the closure of each entity.

property num_entity_dofs: List[List[int]]

Number of DOFs associated with each entity.

property num_global_support_dofs: int

Get the number of global support DOFs.

property reference_geometry: ndarray[Any, dtype[float64]]

Geometry of the reference element.

property reference_topology: List[List[List[int]]]

Topology of the reference element.

reference_value_shape() Tuple[int, ...]

Reference value shape of the element basis function.

sub_element: _BasixElementBase
sub_elements() List[_BasixElementBase]

Return a list of sub elements.

tabulate(nderivs: int, points: ndarray[Any, dtype[float64]]) ndarray[Any, dtype[float64]]

Tabulate the basis functions of the element.

Parameters
  • nderivs – Number of derivatives to tabulate.

  • points – Points to tabulate at

Returns

Tabulated basis functions

property ufcx_element_type: str

Element type.

class basix.ufl_wrapper.ComponentElement(element: _BasixElementBase, component: int, gdim: Optional[int] = None)

Bases: _BasixElementBase

An element representing one component of a BasixElement.

Initialise the element.

property basix_sobolev_space

Return a Basix enum representing the underlying Sobolev space.

property cell_type: CellType

Basix cell type used to initialise the element.

component: int
property dim: int

Number of DOFs the element has.

property discontinuous: bool

True if the discontinuous version of the element is used.

property dpc_variant: Optional[DPCVariant]

Basix DPC variant used to initialise the element.

element: _BasixElementBase
property element_family: Optional[ElementFamily]

Basix element family used to initialise the element.

property entity_closure_dofs: List[List[List[int]]]

DOF numbers associated with the closure of each entity.

property entity_dofs: List[List[List[int]]]

DOF numbers associated with each entity.

property family_name: str

Family name of the element.

get_component_element(flat_component: int) Tuple[_BasixElementBase, int, int]

Get element that represents a component of the element, and the offset and stride of the component.

Parameters

flat_component – The component

Returns

component element, offset of the component, stride of the component

property interpolation_nderivs: int

The number of derivatives needed when interpolating.

property lagrange_variant: Optional[LagrangeVariant]

Basix Lagrange variant used to initialise the element.

property map_type: MapType

The Basix map type.

property num_entity_closure_dofs: List[List[int]]

Number of DOFs associated with the closure of each entity.

property num_entity_dofs: List[List[int]]

Number of DOFs associated with each entity.

property num_global_support_dofs: int

Get the number of global support DOFs.

property reference_geometry: ndarray[Any, dtype[float64]]

Geometry of the reference element.

property reference_topology: List[List[List[int]]]

Topology of the reference element.

tabulate(nderivs: int, points: ndarray[Any, dtype[float64]]) ndarray[Any, dtype[float64]]

Tabulate the basis functions of the element.

Parameters
  • nderivs – Number of derivatives to tabulate.

  • points – Points to tabulate at

Returns

Tabulated basis functions

property ufcx_element_type: str

Element type.

class basix.ufl_wrapper.MixedElement(sub_elements: List[_BasixElementBase], gdim: Optional[int] = None)

Bases: _BasixElementBase

A mixed element that combines two or more elements.

Initialise the element.

property basix_sobolev_space

Return a Basix enum representing the underlying Sobolev space.

property cell_type: CellType

Basix cell type used to initialise the element.

property dim: int

Number of DOFs the element has.

property discontinuous: bool

True if the discontinuous version of the element is used.

property dpc_variant: Optional[DPCVariant]

Basix DPC variant used to initialise the element.

property element_family: Optional[ElementFamily]

Basix element family used to initialise the element.

property entity_closure_dofs: List[List[List[int]]]

DOF numbers associated with the closure of each entity.

property entity_dofs: List[List[List[int]]]

DOF numbers associated with each entity.

property family_name: str

Family name of the element.

get_component_element(flat_component: int) Tuple[_BasixElementBase, int, int]

Get element that represents a component of the element, and the offset and stride of the component.

Parameters

flat_component – The component

Returns

component element, offset of the component, stride of the component

property interpolation_nderivs: int

The number of derivatives needed when interpolating.

property lagrange_variant: Optional[LagrangeVariant]

Basix Lagrange variant used to initialise the element.

property map_type: MapType

The Basix map type.

property num_entity_closure_dofs: List[List[int]]

Number of DOFs associated with the closure of each entity.

property num_entity_dofs: List[List[int]]

Number of DOFs associated with each entity.

property num_global_support_dofs: int

Get the number of global support DOFs.

property reference_geometry: ndarray[Any, dtype[float64]]

Geometry of the reference element.

property reference_topology: List[List[List[int]]]

Topology of the reference element.

sub_elements() List[_BasixElementBase]

Return a list of sub elements.

tabulate(nderivs: int, points: ndarray[Any, dtype[float64]]) ndarray[Any, dtype[float64]]

Tabulate the basis functions of the element.

Parameters
  • nderivs – Number of derivatives to tabulate.

  • points – Points to tabulate at

Returns

Tabulated basis functions

property ufcx_element_type: str

Get the element type.

class basix.ufl_wrapper.TensorElement(sub_element: _BasixElementBase, shape: Optional[Tuple[int, int]] = None, symmetric: bool = False, gdim: Optional[int] = None)

Bases: BlockedElement

A tensor element.

Initialise the element.

class basix.ufl_wrapper.VectorElement(sub_element: _BasixElementBase, size: Optional[int] = None, gdim: Optional[int] = None)

Bases: BlockedElement

A vector element.

Initialise the element.

basix.ufl_wrapper.convert_ufl_element(element: FiniteElementBase) _BasixElementBase

Convert a UFL element to a wrapped Basix element.

basix.ufl_wrapper.create_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, gdim: ~typing.Optional[int] = None) BasixElement

Create a UFL element using Basix.

Parameters
  • family – The element’s family as a Basix enum or a string.

  • cell – The cell type as a Basix enum or a string.

  • degree – The degree of the finite element.

  • lagrange_variant – The variant of Lagrange to be used.

  • dpc_variant – The variant of DPC to be used.

  • discontinuous – If set to True, the discontinuous version of this element will be created.

  • gdim – The geometric dimension of the cell.

basix.ufl_wrapper.create_tensor_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, int]] = None, symmetry: bool = False, gdim: ~typing.Optional[int] = None) TensorElement

Create a UFL tensor element using Basix.

A tensor element is an element which uses multiple copies of a scalar element to represent a tensor-valued function.

Parameters
  • family – The element’s family as a Basix enum or a string.

  • cell – The cell type as a Basix enum or a string.

  • degree – The degree of the finite element.

  • lagrange_variant – The variant of Lagrange to be used.

  • dpc_variant – The variant of DPC to be used.

  • discontinuous – If set to True, the discontinuous version of this element will be created.

  • shape – The shape of the tensor.

  • symmetry – Is the tensor symmetric?

  • gdim – The geometric dimension of the cell.

basix.ufl_wrapper.create_vector_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, dim: ~typing.Optional[int] = None, gdim: ~typing.Optional[int] = None) VectorElement

Create a UFL vector element using Basix.

A vector element is an element which uses multiple copies of a scalar element to represent a vector-valued function.

Parameters
  • family – The element’s family as a Basix enum or a string.

  • cell – The cell type as a Basix enum or a string.

  • degree – The degree of the finite element.

  • lagrange_variant – The variant of Lagrange to be used.

  • dpc_variant – The variant of DPC to be used.

  • discontinuous – If set to True, the discontinuous version of this element will be created.

  • dim – The length of the vector.

  • gdim – The geometric dimension of the cell.

basix.ufl_wrapper.ufl_sobolev_space_from_enum(s: SobolevSpace)

Convert a Basix Sobolev space enum to a UFL Sobolev space.

Parameters

s – The Basix Sobolev space

Returns

UFL Sobolev space

basix.ufl_wrapper.warn(message, category=None, stacklevel=1, source=None)

Issue a warning, or maybe ignore it or raise an exception.