Basix Python interface documentation

basix

Basix is a finite element definition and tabulation runtime library.

The core of the library is written in C++, but the majority of Basix’s functionality can be used via this Python interface.

class basix.CellType(self: basix._basixcpp.CellType, value: int) None

Bases: pybind11_builtins.pybind11_object

Members:

point

interval

triangle

tetrahedron

quadrilateral

hexahedron

prism

pyramid

hexahedron = <CellType.hexahedron: 5>
interval = <CellType.interval: 1>
property name
point = <CellType.point: 0>
prism = <CellType.prism: 6>
pyramid = <CellType.pyramid: 7>
quadrilateral = <CellType.quadrilateral: 4>
tetrahedron = <CellType.tetrahedron: 3>
triangle = <CellType.triangle: 2>
property value
class basix.LatticeType(self: basix._basixcpp.LatticeType, value: int) None

Bases: pybind11_builtins.pybind11_object

Members:

equispaced

gll_warped

equispaced = <LatticeType.equispaced: 0>
gll_warped = <LatticeType.gll_warped: 1>
property name
property value
class basix.MappingType(self: basix._basixcpp.MappingType, value: int) None

Bases: pybind11_builtins.pybind11_object

Members:

identity

covariantPiola

contravariantPiola

doubleCovariantPiola

doubleContravariantPiola

contravariantPiola = <MappingType.contravariantPiola: 2>
covariantPiola = <MappingType.covariantPiola: 1>
doubleContravariantPiola = <MappingType.doubleContravariantPiola: 4>
doubleCovariantPiola = <MappingType.doubleCovariantPiola: 3>
identity = <MappingType.identity: 0>
property name
property value
basix.cell_to_str(arg0: basix._basixcpp.CellType) str

Convert a cell type to a string.

basix.compute_jacobi_deriv(arg0: float, arg1: int, arg2: int, arg3: numpy.ndarray[numpy.float64]) numpy.ndarray[numpy.float64]

Compute jacobi polynomial and derivatives at points

basix.create_element(arg0: str, arg1: str, arg2: int) basix._basixcpp.FiniteElement

Create a FiniteElement of a given family, celltype and degree

basix.create_lattice(arg0: basix::cell::type, arg1: int, arg2: basix._basixcpp.LatticeType, arg3: bool) numpy.ndarray[numpy.float64]

Create a uniform lattice of points on a reference cell

basix.family_to_str(arg0: basix._basixcpp.ElementFamily) str

Convert a family type to a string.

basix.geometry(arg0: basix::cell::type) numpy.ndarray[numpy.float64]

Geometric points of a reference cell

basix.index(*args, **kwargs)

Overloaded function.

  1. index(arg0: int) -> int

Indexing for 1D arrays

  1. index(arg0: int, arg1: int) -> int

Indexing for triangular arrays

  1. index(arg0: int, arg1: int, arg2: int) -> int

Indexing for tetrahedral arrays

basix.make_quadrature(arg0: str, arg1: basix._basixcpp.CellType, arg2: int) Tuple[numpy.ndarray[numpy.float64], numpy.ndarray[numpy.float64]]

Compute quadrature points and weights on a reference cell

basix.mapping_to_str(arg0: basix._basixcpp.MappingType) str

Convert a mapping type to a string.

basix.tabulate_polynomial_set(arg0: basix._basixcpp.CellType, arg1: int, arg2: int, arg3: numpy.ndarray[numpy.float64]) numpy.ndarray[numpy.float64]

Tabulate orthonormal polynomial expansion set

basix.topology(arg0: basix::cell::type) List[List[List[int]]]

Topological description of a reference cell

basix.cell

Functions to get cell geometry information.

basix.cell.facet_jacobians()

cell_facet_jacobians(arg0: basix._basixcpp.CellType) -> numpy.ndarray[numpy.float64]

Get the jacobians of the facets of a cell

basix.cell.facet_normals()

cell_facet_normals(arg0: basix._basixcpp.CellType) -> numpy.ndarray[numpy.float64]

Get the normals to the facets of a cell

basix.cell.facet_orientations()

cell_facet_orientations(arg0: basix._basixcpp.CellType) -> List[bool]

Get the orientations of the facets of a cell

basix.cell.facet_outward_normals()

cell_facet_outward_normals(arg0: basix._basixcpp.CellType) -> numpy.ndarray[numpy.float64]

Get the outward normals to the facets of a cell

basix.cell.facet_reference_volumes()

cell_facet_reference_volumes(arg0: basix._basixcpp.CellType) -> numpy.ndarray[numpy.float64]

Get the reference volumes of the facets of a cell

basix.cell.sub_entity_connectivity(arg0: basix::cell::type) List[List[List[List[int]]]]

Connectivity between subentities of a reference cell

basix.cell.volume()

cell_volume(arg0: basix._basixcpp.CellType) -> float

Get the volume of a cell

basix.numba_helpers

Helper functions for writing DOLFINx custom kernels using Numba.

class basix.numba_helpers.List(lsttype=None, meminfo=None, allocated=0, **kwargs)

Bases: collections.abc.MutableSequence, Generic[numba.typed.typedlist.T]

A typed-list usable in Numba compiled functions.

Implements the MutableSequence interface.

For users, the constructor does not take any parameters. The keyword arguments are for internal use only.

Parameters
  • args (iterable) – The iterable to intialize the list from

  • lsttype (numba.core.types.ListType; keyword-only) – Used internally for the list type.

  • meminfo (MemInfo; keyword-only) – Used internally to pass the MemInfo object when boxing.

  • allocated (int; keyword-only) – Used internally to pre-allocate space for items

append(item: numba.typed.typedlist.T) None

S.append(value) – append value to the end of the sequence

clear() None remove all items from S
copy()
count(value) integer return number of occurrences of value
classmethod empty_list(item_type, allocated=0)

Create a new empty List.

Parameters
  • item_type (Numba type) – type of the list item.

  • allocated (int) – number of items to pre-allocate

extend(iterable: numba.typed.typedlist._Sequence[numba.typed.typedlist.T]) None

S.extend(iterable) – extend sequence by appending elements from the iterable

index(value[, start[, stop]]) integer return first index of value.

Raises ValueError if the value is not present.

Supporting start and stop arguments is optional, but recommended.

insert(i: int, item: numba.typed.typedlist.T) None

S.insert(index, value) – insert value before index

pop([index]) item remove and return item at index (default last).

Raise IndexError if list is empty or index is out of range.

remove(item: numba.typed.typedlist.T) None

S.remove(value) – remove first occurrence of value. Raise ValueError if the value is not present.

reverse()

S.reverse() – reverse IN PLACE

sort(key=None, reverse=False)

Sort the list inplace.

See also list.sort()

basix.numba_helpers.apply_dof_transformation(tdim, edge_count, face_count, entity_transformations, entity_dofs, data, cell_info, face_types)

Apply dof transformations to some data.

Parameters
  • tdim (int) – The topological dimension of the cell.

  • edge_cout (int) – The number of edges the cell has.

  • face_count (int) – The number of faces the cell has.

  • entity_transformations (list) – The DOF transformations for each entity.

  • entity_dofs (list) – The number of DOFs on each entity.

  • data (np.array) – The data. This will be changed by this function.

  • cell_info (int) – An integer representing the orientations of the subentities of the cell.

basix.numba_helpers.apply_dof_transformation_hexahedron(entity_transformations, entity_dofs, data, cell_info)

Apply dof transformations to some data on a hexahedron.

Parameters
  • entity_transformations (Dict(ndarray(float64))) – The DOF transformations for each entity.

  • entity_dofs (Dict(ndarray(int32))) – The number of DOFs on each entity.

  • data (np.array) – The data. This will be changed by this function.

  • cell_info (int) – An integer representing the orientations of the subentities of the cell.

basix.numba_helpers.apply_dof_transformation_interval(entity_transformations, entity_dofs, data, cell_info)

Apply dof transformations to some data on an interval.

Parameters
  • entity_transformations (Dict(ndarray(float64))) – The DOF transformations for each entity.

  • entity_dofs (Dict(ndarray(int32))) – The number of DOFs on each entity.

  • data (np.array) – The data. This will be changed by this function.

  • cell_info (int) – An integer representing the orientations of the subentities of the cell.

basix.numba_helpers.apply_dof_transformation_prism(entity_transformations, entity_dofs, data, cell_info)

Apply dof transformations to some data on an prism.

Parameters
  • entity_transformations (Dict(ndarray(float64))) – The DOF transformations for each entity.

  • entity_dofs (Dict(ndarray(int32))) – The number of DOFs on each entity.

  • data (np.array) – The data. This will be changed by this function.

  • cell_info (int) – An integer representing the orientations of the subentities of the cell.

basix.numba_helpers.apply_dof_transformation_pyramid(entity_transformations, entity_dofs, data, cell_info)

Apply dof transformations to some data on an prism.

Parameters
  • entity_transformations (Dict(ndarray(float64))) – The DOF transformations for each entity.

  • entity_dofs (Dict(ndarray(int32))) – The number of DOFs on each entity.

  • data (np.array) – The data. This will be changed by this function.

  • cell_info (int) – An integer representing the orientations of the subentities of the cell.

basix.numba_helpers.apply_dof_transformation_quadrilateral(entity_transformations, entity_dofs, data, cell_info)

Apply dof transformations to some data on an quadrilateral.

Parameters
  • entity_transformations (Dict(ndarray(float64))) – The DOF transformations for each entity.

  • entity_dofs (Dict(ndarray(int32))) – The number of DOFs on each entity.

  • data (np.array) – The data. This will be changed by this function.

  • cell_info (int) – An integer representing the orientations of the subentities of the cell.

basix.numba_helpers.apply_dof_transformation_tetrahedron(entity_transformations, entity_dofs, data, cell_info)

Apply dof transformations to some data on a tetrahedron.

Parameters
  • entity_transformations (Dict(ndarray(float64))) – The DOF transformations for each entity.

  • entity_dofs (Dict(ndarray(int32))) – The number of DOFs on each entity.

  • data (np.array) – The data. This will be changed by this function.

  • cell_info (int) – An integer representing the orientations of the subentities of the cell.

basix.numba_helpers.apply_dof_transformation_triangle(entity_transformations, entity_dofs, data, cell_info)

Apply dof transformations to some data on a triangle.

Parameters
  • entity_transformations (Dict(ndarray(float64))) – The DOF transformations for each entity.

  • entity_dofs (Dict(ndarray(int32))) – The number of DOFs on each entity.

  • data (np.array) – The data. This will be changed by this function.

  • cell_info (int) – An integer representing the orientations of the subentities of the cell.