Basix
Public Member Functions | Public Attributes | List of all members
basix::FiniteElement Class Reference

#include <finite-element.h>

Public Member Functions

 FiniteElement (element::family family, cell::type cell_type, int degree, const std::vector< std::size_t > &value_shape, const xt::xtensor< double, 3 > &coeffs, const std::vector< xt::xtensor< double, 2 >> &entity_transformations, const std::array< std::vector< xt::xtensor< double, 2 >>, 4 > &x, const std::array< std::vector< xt::xtensor< double, 3 >>, 4 > &M, maps::type map_type=maps::type::identity)
 
 FiniteElement (const FiniteElement &element)=default
 Copy constructor.
 
 FiniteElement (FiniteElement &&element)=default
 Move constructor.
 
 ~FiniteElement ()=default
 Destructor.
 
FiniteElementoperator= (const FiniteElement &element)=default
 Assignment operator.
 
FiniteElementoperator= (FiniteElement &&element)=default
 Move assignment operator.
 
xt::xtensor< double, 4 > tabulate (int nd, const xt::xarray< double > &x) const
 
void tabulate (int nd, const xt::xarray< double > &x, double *basis_data) const
 
cell::type cell_type () const
 
int degree () const
 
int value_size () const
 
const std::vector< int > & value_shape () const
 
int dim () const
 
element::family family () const
 
maps::type mapping_type () const
 
bool dof_transformations_are_permutations () const
 
bool dof_transformations_are_identity () const
 
xt::xtensor< double, 3 > map_push_forward (const xt::xtensor< double, 3 > &U, const xt::xtensor< double, 3 > &J, const tcb::span< const double > &detJ, const xt::xtensor< double, 3 > &K) const
 
template<typename T , typename E >
void map_push_forward_m (const xt::xtensor< T, 3 > &U, const xt::xtensor< double, 3 > &J, const tcb::span< const double > &detJ, const xt::xtensor< double, 3 > &K, E &&u) const
 
xt::xtensor< double, 3 > map_pull_back (const xt::xtensor< double, 3 > &u, const xt::xtensor< double, 3 > &J, const tcb::span< const double > &detJ, const xt::xtensor< double, 3 > &K) const
 
template<typename T , typename E >
void map_pull_back_m (const xt::xtensor< T, 3 > &u, const xt::xtensor< double, 3 > &J, const tcb::span< const double > &detJ, const xt::xtensor< double, 3 > &K, E &&U) const
 
const std::vector< std::vector< int > > & entity_dofs () const
 
xt::xtensor< double, 3 > base_transformations () const
 
void permute_dofs (tcb::span< std::int32_t > &dofs, std::uint32_t cell_info) const
 
void unpermute_dofs (tcb::span< std::int32_t > &dofs, std::uint32_t cell_info) const
 
const xt::xtensor< double, 2 > & points () const
 
int num_points () const
 Return the number of interpolation points.
 
const xt::xtensor< double, 2 > & interpolation_matrix () const
 

Public Attributes

maps::type map_type
 Element map type.
 

Detailed Description

Finite Element The basis is stored as a set of coefficients, which are applied to the underlying expansion set for that cell type, when tabulating.

Constructor & Destructor Documentation

◆ FiniteElement()

FiniteElement::FiniteElement ( element::family  family,
cell::type  cell_type,
int  degree,
const std::vector< std::size_t > &  value_shape,
const xt::xtensor< double, 3 > &  coeffs,
const std::vector< xt::xtensor< double, 2 >> &  entity_transformations,
const std::array< std::vector< xt::xtensor< double, 2 >>, 4 > &  x,
const std::array< std::vector< xt::xtensor< double, 3 >>, 4 > &  M,
maps::type  map_type = maps::type::identity 
)
Todo:
Document A finite element
Parameters
[in]family
[in]cell_type
[in]degree
[in]value_shape
[in]coeffsExpansion coefficients. The shape is (num_dofs, value_size, basis_dim)
[in]entity_transformationsEntity transformations
[in]xInterpolation points. Shape is (tdim, entity index, point index, dim)
[in]MThe interpolation matrices. Indices are (tdim, entity index, dof, vs, point_index)
[in]map_type

Member Function Documentation

◆ base_transformations()

xt::xtensor< double, 3 > FiniteElement::base_transformations ( ) const

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]]

◆ cell_type()

cell::type FiniteElement::cell_type ( ) const

Get the element cell type

Returns
The cell type

◆ degree()

int FiniteElement::degree ( ) const

Get the element polynomial degree

Returns
Polynomial degree

◆ dim()

int FiniteElement::dim ( ) const

Dimension of the finite element space (number of degrees of freedom for the element)

Returns
Number of degrees of freedom

◆ dof_transformations_are_identity()

bool FiniteElement::dof_transformations_are_identity ( ) const

Indicates whether the dof transformations are all the identity

Returns
True or False

◆ dof_transformations_are_permutations()

bool FiniteElement::dof_transformations_are_permutations ( ) const

Indicates whether the dof transformations are all permutations

Returns
True or False

◆ entity_dofs()

const std::vector< std::vector< int > > & FiniteElement::entity_dofs ( ) const

Get the number of dofs on each topological entity: (vertices, edges, faces, cell) in that order. For example, Lagrange degree 2 on a triangle has vertices: [1, 1, 1], edges: [1, 1, 1], cell: [0] The sum of the entity dofs must match the total number of dofs reported by FiniteElement::dim,

Returns
List of entity dof counts on each dimension. The shape is (tdim + 1, num_entities).

◆ family()

element::family FiniteElement::family ( ) const

Get the finite element family

Returns
The family

◆ interpolation_matrix()

const xt::xtensor< double, 2 > & FiniteElement::interpolation_matrix ( ) const

Return a matrix of weights interpolation To interpolate a function in this finite element, the functions should be evaluated at each point given by FiniteElement::points(). These function values should then be multiplied by the weight matrix to give the coefficients of the interpolated function.

◆ map_pull_back()

xt::xtensor< double, 3 > FiniteElement::map_pull_back ( const xt::xtensor< double, 3 > &  u,
const xt::xtensor< double, 3 > &  J,
const tcb::span< const double > &  detJ,
const xt::xtensor< double, 3 > &  K 
) const

Map function values from a physical cell to the reference

Parameters
uThe function values on the cell
JThe Jacobian of the mapping
detJThe determinant of the Jacobian of the mapping
KThe inverse of the Jacobian of the mapping
Returns
The function values on the reference

◆ map_pull_back_m()

template<typename T , typename E >
void basix::FiniteElement::map_pull_back_m ( const xt::xtensor< T, 3 > &  u,
const xt::xtensor< double, 3 > &  J,
const tcb::span< const double > &  detJ,
const xt::xtensor< double, 3 > &  K,
E &&  U 
) const
Todo:
Weirdly, the u and U Map function values from a physical cell to the reference
Parameters
uThe function values on the cell
JThe Jacobian of the mapping
detJThe determinant of the Jacobian of the mapping
KThe inverse of the Jacobian of the mapping
UMemory location to fill

◆ map_push_forward()

xt::xtensor< double, 3 > FiniteElement::map_push_forward ( const xt::xtensor< double, 3 > &  U,
const xt::xtensor< double, 3 > &  J,
const tcb::span< const double > &  detJ,
const xt::xtensor< double, 3 > &  K 
) const

Map function values from the reference to a physical cell

Parameters
UThe function values on the reference
JThe Jacobian of the mapping
detJThe determinant of the Jacobian of the mapping
KThe inverse of the Jacobian of the mapping
Returns
The function values on the cell

◆ map_push_forward_m()

template<typename T , typename E >
void basix::FiniteElement::map_push_forward_m ( const xt::xtensor< T, 3 > &  U,
const xt::xtensor< double, 3 > &  J,
const tcb::span< const double > &  detJ,
const xt::xtensor< double, 3 > &  K,
E &&  u 
) const

Direct to memory push forward

Parameters
UThe function values on the reference
JThe Jacobian of the mapping
detJThe determinant of the Jacobian of the mapping
KThe inverse of the Jacobian of the mapping
uMemory location to fill

◆ mapping_type()

maps::type FiniteElement::mapping_type ( ) const

Get the mapping type used for this element

Returns
The mapping

◆ permute_dofs()

void FiniteElement::permute_dofs ( tcb::span< std::int32_t > &  dofs,
std::uint32_t  cell_info 
) const

Permute the dof numbering on a cell

Parameters
[in,out]dofsThe dof numbering for the cell
cell_infoThe permutation info for the cell

◆ points()

const xt::xtensor< double, 2 > & FiniteElement::points ( ) const

Return the interpolation points, i.e. the coordinates on the reference element where a function need to be evaluated in order to interpolate it in the finite element space.

Returns
Array of coordinate with shape (num_points, tdim)

◆ tabulate() [1/2]

xt::xtensor< double, 4 > FiniteElement::tabulate ( int  nd,
const xt::xarray< double > &  x 
) const

Compute basis values and derivatives at set of points.

Parameters
[in]ndThe order of derivatives, up to and including, to compute. Use 0 for the basis functions only.
[in]xThe 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, i.e. for the (x,y) derivatives in 2D: (0,0), (1,0), (0,1), (2,0), (1,1), (0,2), (3,0)... The function basix::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.

◆ tabulate() [2/2]

void FiniteElement::tabulate ( int  nd,
const xt::xarray< double > &  x,
double *  basis_data 
) const

Direct to memory block tabulation

Parameters
ndNumber of derivatives
xPoints
basis_dataMemory location to fill

◆ unpermute_dofs()

void FiniteElement::unpermute_dofs ( tcb::span< std::int32_t > &  dofs,
std::uint32_t  cell_info 
) const

Unpermute the dof numbering on a cell

Parameters
[in,out]dofsThe dof numbering for the cell
cell_infoThe permutation info for the cell

◆ value_shape()

const std::vector< int > & FiniteElement::value_shape ( ) const

Get the element value tensor shape, e.g. returning [1] for scalars.

Returns
Value shape

◆ value_size()

int FiniteElement::value_size ( ) const

Get the element value size This is just a convenience function returning product(value_shape)

Returns
Value size

The documentation for this class was generated from the following files: