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.DPCVariant(self: basix._basixcpp.DPCVariant, value: int) None

Bases: pybind11_builtins.pybind11_object

Members:

unset

simplex_equispaced

simplex_gll

horizontal_equispaced

horizontal_gll

diagonal_equispaced

diagonal_gll

legendre

diagonal_equispaced = <DPCVariant.diagonal_equispaced: 4>
diagonal_gll = <DPCVariant.diagonal_gll: 5>
horizontal_equispaced = <DPCVariant.horizontal_equispaced: 2>
horizontal_gll = <DPCVariant.horizontal_gll: 3>
legendre = <DPCVariant.legendre: 6>
property name
simplex_equispaced = <DPCVariant.simplex_equispaced: 0>
simplex_gll = <DPCVariant.simplex_gll: 1>
unset = <DPCVariant.unset: -1>
property value
class basix.ElementFamily(self: basix._basixcpp.ElementFamily, value: int) None

Bases: pybind11_builtins.pybind11_object

Members:

custom

P

BDM

RT

N1E

N2E

Regge

HHJ

bubble

serendipity

DPC

CR

BDM = <ElementFamily.BDM: 4>
CR = <ElementFamily.CR: 6>
DPC = <ElementFamily.DPC: 8>
HHJ = <ElementFamily.HHJ: 11>
N1E = <ElementFamily.N1E: 3>
N2E = <ElementFamily.N2E: 5>
P = <ElementFamily.P: 1>
RT = <ElementFamily.RT: 2>
Regge = <ElementFamily.Regge: 7>
bubble = <ElementFamily.bubble: 9>
custom = <ElementFamily.custom: 0>
property name
serendipity = <ElementFamily.serendipity: 10>
property value
class basix.LagrangeVariant(self: basix._basixcpp.LagrangeVariant, value: int) None

Bases: pybind11_builtins.pybind11_object

Members:

unset

equispaced

gll_warped

gll_isaac

gll_centroid

chebyshev_warped

chebyshev_isaac

chebyshev_centroid

gl_warped

gl_isaac

gl_centroid

legendre

vtk

chebyshev_centroid = <LagrangeVariant.chebyshev_centroid: 6>
chebyshev_isaac = <LagrangeVariant.chebyshev_isaac: 5>
chebyshev_warped = <LagrangeVariant.chebyshev_warped: 4>
equispaced = <LagrangeVariant.equispaced: 0>
gl_centroid = <LagrangeVariant.gl_centroid: 9>
gl_isaac = <LagrangeVariant.gl_isaac: 8>
gl_warped = <LagrangeVariant.gl_warped: 7>
gll_centroid = <LagrangeVariant.gll_centroid: 3>
gll_isaac = <LagrangeVariant.gll_isaac: 2>
gll_warped = <LagrangeVariant.gll_warped: 1>
legendre = <LagrangeVariant.legendre: 10>
property name
unset = <LagrangeVariant.unset: -1>
property value
vtk = <LagrangeVariant.vtk: 20>
class basix.LatticeSimplexMethod(self: basix._basixcpp.LatticeSimplexMethod, value: int) None

Bases: pybind11_builtins.pybind11_object

Members:

none

warp

isaac

centroid

centroid = <LatticeSimplexMethod.centroid: 3>
isaac = <LatticeSimplexMethod.isaac: 2>
property name
none = <LatticeSimplexMethod.none: 0>
property value
warp = <LatticeSimplexMethod.warp: 1>
class basix.LatticeType(self: basix._basixcpp.LatticeType, value: int) None

Bases: pybind11_builtins.pybind11_object

Members:

equispaced

gll

chebyshev

gl

chebyshev = <LatticeType.chebyshev: 2>
equispaced = <LatticeType.equispaced: 0>
gl = <LatticeType.gl: 4>
gll = <LatticeType.gll: 1>
property name
property value
class basix.MapType(self: basix._basixcpp.MapType, value: int) None

Bases: pybind11_builtins.pybind11_object

Members:

identity

L2Piola

covariantPiola

contravariantPiola

doubleCovariantPiola

doubleContravariantPiola

L2Piola = <MapType.L2Piola: 1>
contravariantPiola = <MapType.contravariantPiola: 3>
covariantPiola = <MapType.covariantPiola: 2>
doubleContravariantPiola = <MapType.doubleContravariantPiola: 5>
doubleCovariantPiola = <MapType.doubleCovariantPiola: 4>
identity = <MapType.identity: 0>
property name
property value
class basix.PolynomialType(self: basix._basixcpp.PolynomialType, value: int) None

Bases: pybind11_builtins.pybind11_object

Members:

legendre

legendre = <PolynomialType.legendre: 0>
property name
property value
class basix.QuadratureType(self: basix._basixcpp.QuadratureType, value: int) None

Bases: pybind11_builtins.pybind11_object

Members:

Default

gauss_jacobi

gll

xiao_gimbutas

Default = <QuadratureType.Default: 0>
gauss_jacobi = <QuadratureType.gauss_jacobi: 1>
gll = <QuadratureType.gll: 2>
property name
property value
xiao_gimbutas = <QuadratureType.xiao_gimbutas: 3>
basix.compute_interpolation_operator(arg0: basix._basixcpp.FiniteElement, arg1: basix._basixcpp.FiniteElement) numpy.ndarray[numpy.float64]

Computes a matrix that represents the interpolation between two elements.

If the two elements have the same value size, this function returns the interpolation between them.

If element_from has value size 1 and element_to has value size > 1, then this function returns a matrix to interpolate from a blocked element_from (ie multiple copies of element_from) into element_to.

If element_to has value size 1 and element_from has value size > 1, then this function returns a matrix that interpolates the components of element_from into copies of element_to.

NOTE: If the elements have different value sizes and both are greater than 1, this function throws a runtime error

In order to interpolate functions between finite element spaces on arbitrary cells, the functions must be pulled back to the reference element (this pull back includes applying DOF transformations). The matrix that this function returns can then be applied, then the result pushed forward to the cell. If element_from and element_to have the same map type, then only the DOF transformations need to be applied, as the pull back and push forward cancel each other out.

Parameters
Returns

Matrix operator that maps the ‘from’ degrees-of-freedom to the ‘to’ degrees-of-freedom

Return type

numpy.ndarray[numpy.float64]

basix.create_custom_element(arg0: basix._basixcpp.CellType, arg1: int, arg2: List[int], arg3: numpy.ndarray[numpy.float64], arg4: List[List[numpy.ndarray[numpy.float64]]], arg5: List[List[numpy.ndarray[numpy.float64]]], arg6: basix._basixcpp.MapType, arg7: bool, arg8: int) basix._basixcpp.FiniteElement

Create a custom finite element

Parameters
  • cell_type (basix.CellType) – The cell type

  • degree (int) – The degree of the element

  • value_shape (List[int]) – The value shape of the element

  • wcoeffs (numpy.ndarray[numpy.float64]) – Matrices for the kth value index containing the expansion coefficients defining a polynomial basis spanning the polynomial space for this element

  • x (List[List[numpy.ndarray[numpy.float64]]]) – Interpolation points. Shape is (tdim, entity index, point index, dim)

  • M (List[List[numpy.ndarray[numpy.float64]]]) – The interpolation matrices. Indices are (tdim, entity index, dof, vs, point_index)

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

  • discontinuous (bool) – Indicates whether or not this is the discontinuous version of the element

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

Returns

A custom finite element

Return type

basix.finite_element.FiniteElement

basix.create_element(*args, **kwargs)

Overloaded function.

  1. create_element(arg0: basix._basixcpp.ElementFamily, arg1: basix._basixcpp.CellType, arg2: int, arg3: bool) -> basix._basixcpp.FiniteElement

Create an element

Parameters
  • family (basix.ElementFamily) – The element family

  • cell (basix.CellType) – The reference cell type that the element is defined on

  • degree (int) – The degree of the element

  • discontinuous (bool) – Indicates whether the element is discontinuous between cells points of the element. The discontinuous element will have the same DOFs, but they will all be associated with the interior of the cell.

Returns

A finite element

Return type

basix.finite_element.FiniteElement

  1. create_element(arg0: basix._basixcpp.ElementFamily, arg1: basix._basixcpp.CellType, arg2: int, arg3: basix._basixcpp.LagrangeVariant, arg4: bool) -> basix._basixcpp.FiniteElement

Create an element using a given Lagrange variant

Parameters
  • family (basix.ElementFamily) – The element family

  • cell (basix.CellType) – The reference cell type that the element is defined on

  • degree (int) – The degree of the element

  • lvariant (basix.LagrangeVariant) – The variant of Lagrange to use

  • discontinuous (bool) – Indicates whether the element is discontinuous between cells points of the element. The discontinuous element will have the same DOFs, but they will all be associated with the interior of the cell.

Returns

A finite element

Return type

basix.finite_element.FiniteElement

  1. create_element(arg0: basix._basixcpp.ElementFamily, arg1: basix._basixcpp.CellType, arg2: int, arg3: basix._basixcpp.DPCVariant, arg4: bool) -> basix._basixcpp.FiniteElement

Create an element using a given DPC variant

Parameters
  • family (basix.ElementFamily) – The element family

  • cell (basix.CellType) – The reference cell type that the element is defined on

  • degree (int) – The degree of the element

  • dvariant (basix.DPCVariant) – The variant of DPC to use

  • discontinuous (bool) – Indicates whether the element is discontinuous between cells points of the element. The discontinuous element will have the same DOFs, but they will all be associated with the interior of the cell.

Returns

A finite element

Return type

basix.finite_element.FiniteElement

  1. create_element(arg0: basix._basixcpp.ElementFamily, arg1: basix._basixcpp.CellType, arg2: int, arg3: basix._basixcpp.LagrangeVariant, arg4: basix._basixcpp.DPCVariant, arg5: bool) -> basix._basixcpp.FiniteElement

Create an element using a given Lagrange variant and a given DPC variant

Parameters
  • family (basix.ElementFamily) – The element family

  • cell (basix.CellType) – The reference cell type that the element is defined on

  • degree (int) – The degree of the element

  • lvariant (basix.LagrangeVariant) – The variant of Lagrange to use

  • dvariant (basix.DPCVariant) – The variant of DPC to use

  • discontinuous (bool) – Indicates whether the element is discontinuous between cells points of the element. The discontinuous element will have the same DOFs, but they will all be associated with the interior of the cell.

Returns

A finite element

Return type

basix.finite_element.FiniteElement

  1. create_element(arg0: basix._basixcpp.ElementFamily, arg1: basix._basixcpp.CellType, arg2: int) -> basix._basixcpp.FiniteElement

Create a continuous element

Parameters
  • family (basix.ElementFamily) – The element family

  • cell (basix.CellType) – The reference cell type that the element is defined on

  • degree (int) – The degree of the element

Returns

A finite element

Return type

basix.finite_element.FiniteElement

  1. create_element(arg0: basix._basixcpp.ElementFamily, arg1: basix._basixcpp.CellType, arg2: int, arg3: basix._basixcpp.LagrangeVariant) -> basix._basixcpp.FiniteElement

Create a continuous element using a given Lagrange variant

Parameters
Returns

A finite element

Return type

basix.finite_element.FiniteElement

  1. create_element(arg0: basix._basixcpp.ElementFamily, arg1: basix._basixcpp.CellType, arg2: int, arg3: basix._basixcpp.DPCVariant) -> basix._basixcpp.FiniteElement

Create a continuous element using a given DPC variant

Parameters
Returns

A finite element

Return type

basix.finite_element.FiniteElement

  1. create_element(arg0: basix._basixcpp.ElementFamily, arg1: basix._basixcpp.CellType, arg2: int, arg3: basix._basixcpp.LagrangeVariant, arg4: basix._basixcpp.DPCVariant) -> basix._basixcpp.FiniteElement

Create a continuous element using a given Lagrange variant and a given DPC variant

Parameters
Returns

A finite element

Return type

basix.finite_element.FiniteElement

basix.create_lattice(*args, **kwargs)

Overloaded function.

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

Create a lattice of points on a reference cell optionally including the outer surface points

For a given celltype, this creates a set of points on a regular grid which covers the cell, eg for a quadrilateral, with n=2, the points are: [0,0],[0.5,0],[1,0],[0,0.5],[0.5,0.5],[1,0.5],[0,1],[0.5,1],[1,1] If the parameter exterior is set to false, the points lying on the external boundary are omitted, in this case for a quadrilateral with n=2, the points are: [0.5,0.5]. The lattice type can be chosen as “equispaced” or “gll”. The “gll” lattice has points spaced along each edge at the Gauss-Lobatto-Legendre quadrature points. These are the same as “equispaced” when n<3.

Parameters
  • celltype (basix.CellType) – The cell::type

  • n (int) – Size in each direction. There are n+1 points along each edge of the cell.

  • type (basix.LatticeType) – A lattice type

  • exterior (bool) – If set, includes outer boundaries

Returns

Set of points

Return type

numpy.ndarray[numpy.float64]

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

Create a lattice of points on a reference cell optionally including the outer surface points

For a given celltype, this creates a set of points on a regular grid which covers the cell, eg for a quadrilateral, with n=2, the points are: [0,0],[0.5,0],[1,0],[0,0.5],[0.5,0.5],[1,0.5],[0,1],[0.5,1],[1,1] If the parameter exterior is set to false, the points lying on the external boundary are omitted, in this case for a quadrilateral with n=2, the points are: [0.5,0.5]. The lattice type can be chosen as “equispaced” or “gll”. The “gll” lattice has points spaced along each edge at the Gauss-Lobatto-Legendre quadrature points. These are the same as “equispaced” when n<3.

Parameters
  • celltype (basix.CellType) – The cell::type

  • n (int) – Size in each direction. There are n+1 points along each edge of the cell.

  • type (basix.LatticeType) – A lattice type

  • exterior (bool) – If set, includes outer boundaries

  • simplex_method (basix.LatticeSimplexMethod) – The method used to generate points on simplices

Returns

Set of points

Return type

numpy.ndarray[numpy.float64]

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

Cell geometry

Parameters

celltype (basix.CellType) – Cell Type

Returns

Set of vertex points of the cell

Return type

numpy.ndarray[numpy.float64]

basix.index(*args, **kwargs)

Overloaded function.

  1. index(arg0: int) -> int

Compute trivial indexing in a 1D array (for completeness)

Parameters

p (int) – Index in x

Returns

1D Index

Return type

int

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

Compute indexing in a 2D triangular array compressed into a 1D array. This can be used to find the index of a derivative returned by FiniteElement::tabulate. For instance to find d2N/dx2, use FiniteElement::tabulate(2, points)[idx(2, 0)];

Parameters
  • p (int) – Index in x

  • q (int) – Index in y

Returns

1D Index

Return type

int

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

Compute indexing in a 3D tetrahedral array compressed into a 1D array

Parameters
  • p (int) – Index in x

  • q (int) – Index in y

  • r (int) – Index in z

Returns

1D Index

Return type

int

basix.make_quadrature(*args, **kwargs)

Overloaded function.

  1. make_quadrature(arg0: basix._basixcpp.QuadratureType, arg1: basix._basixcpp.CellType, arg2: int) -> Tuple[numpy.ndarray[numpy.float64], numpy.ndarray[numpy.float64]]

Make a quadrature rule on a reference cell

Parameters
  • rule (basix.QuadratureType) – Type of quadrature rule (or use quadrature::Default)

  • celltype (basix.CellType) – The cell type

  • m (int) – Maximum degree of polynomial that this quadrature rule will integrate exactly

Returns

List of points and list of weights. The number of points arrays has shape (num points, gdim)

Return type

numpy.ndarray[numpy.float64]

  1. make_quadrature(arg0: basix._basixcpp.CellType, arg1: int) -> Tuple[numpy.ndarray[numpy.float64], numpy.ndarray[numpy.float64]]

Make a default quadrature rule on reference cell

Parameters
  • celltype (basix.CellType) – The cell type

  • m (int) – Maximum degree of polynomial that this quadrature rule will integrate exactly

Returns

List of points and list of weights. The number of points arrays has shape (num points, gdim)

Return type

numpy.ndarray[numpy.float64]

basix.tabulate_polynomials(arg0: basix._basixcpp.PolynomialType, arg1: basix::cell::type, arg2: int, arg3: numpy.ndarray[numpy.float64]) numpy.ndarray[numpy.float64]

Tabulate a set of polynomials.

Parameters
  • polytype (basix.PolynomialType) – Polynomial type

  • celltype (basix.CellType) – Cell type

  • d (int) – Polynomial degree

  • x (numpy.ndarray[numpy.float64]) – Points at which to evaluate the basis. The shape is (number of points, geometric dimension).

Returns

Polynomial sets, for each derivative, tabulated at points. The shape is (number of points, basis index).

Return type

numpy.ndarray[numpy.float64]

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

Cell topology

Parameters

celltype (basix.CellType) – Cell Type

Returns

List of topology (vertex indices) for each dimension (0..tdim)

Return type

List[List[List[int]]]

Modules

basix.cell

Functions to get cell geometry information and manipulate cell types.

basix.finite_element

Functions for creating finite elements.

basix.lattice

Functions to manipulate lattice types.

basix.numba_helpers

Helper functions for writing DOLFINx custom kernels using Numba.

basix.quadrature

Functions to manipulate quadrature types.

basix.ufl_wrapper

Functions to directly wrap Basix elements in UFL.

basix.variants

Functions to manipulate variant types.