10#include <basix/finite-element.h>
12#include <dolfinx/mesh/cell_types.h>
19struct ufcx_finite_element;
25template <std::
floating_po
int T>
108 std::span<const std::
size_t>
value_shape() const noexcept;
112 std::
string family() const noexcept;
125 void tabulate(std::span<T> values, std::span<const T> X,
126 std::array<std::
size_t, 2> shape,
int order) const;
137 std::pair<std::vector<T>, std::array<std::
size_t, 4>>
138 tabulate(std::span<const T> X, std::array<std::
size_t, 2> shape,
189 std::pair<std::vector<T>, std::array<std::
size_t, 2>>
201 std::pair<std::vector<T>, std::array<std::
size_t, 2>>
216 std::pair<std::vector<T>, std::array<std::
size_t, 2>>
267 template <typename U>
268 std::function<
void(const std::span<U>&, const std::span<const std::uint32_t>&,
271 bool scalar_element = false)
const
276 return [](
const std::span<U>&,
const std::span<const std::uint32_t>&,
283 if (_sub_elements.size() != 0)
288 std::vector<std::function<void(
const std::span<U>&,
289 const std::span<const std::uint32_t>&,
291 sub_element_functions;
292 std::vector<int> dims;
293 for (std::size_t i = 0; i < _sub_elements.size(); ++i)
295 sub_element_functions.push_back(
296 _sub_elements[i]->
template get_dof_transformation_function<U>(
297 inverse, transpose));
301 return [dims, sub_element_functions](
302 const std::span<U>& data,
303 const std::span<const std::uint32_t>& cell_info,
306 std::size_t offset = 0;
307 for (std::size_t e = 0; e < sub_element_functions.size(); ++e)
309 const std::size_t width = dims[e] *
block_size;
310 sub_element_functions[e](data.subspan(offset, width), cell_info,
316 else if (!scalar_element)
319 const std::function<void(
const std::span<U>&,
320 const std::span<const std::uint32_t>&,
323 = _sub_elements[0]->template get_dof_transformation_function<U>(
327 [ebs, sub_function](
const std::span<U>& data,
328 const std::span<const std::uint32_t>& cell_info,
329 std::int32_t
cell,
int data_block_size)
330 { sub_function(data, cell_info,
cell, ebs * data_block_size); };
337 return [
this](
const std::span<U>& data,
338 const std::span<const std::uint32_t>& cell_info,
347 return [
this](
const std::span<U>& data,
348 const std::span<const std::uint32_t>& cell_info,
358 return [
this](
const std::span<U>& data,
359 const std::span<const std::uint32_t>& cell_info,
366 return [
this](
const std::span<U>& data,
367 const std::span<const std::uint32_t>& cell_info,
392 template <
typename U>
393 std::function<void(
const std::span<U>&,
const std::span<const std::uint32_t>&,
396 bool transpose =
false,
403 return [](
const std::span<U>&,
const std::span<const std::uint32_t>&,
409 else if (_sub_elements.size() != 0)
414 std::vector<std::function<void(
const std::span<U>&,
415 const std::span<const std::uint32_t>&,
417 sub_element_functions;
418 for (std::size_t i = 0; i < _sub_elements.size(); ++i)
420 sub_element_functions.push_back(
422 ->
template get_dof_transformation_to_transpose_function<U>(
423 inverse, transpose));
426 return [
this, sub_element_functions](
427 const std::span<U>& data,
428 const std::span<const std::uint32_t>& cell_info,
431 std::size_t offset = 0;
432 for (std::size_t e = 0; e < sub_element_functions.size(); ++e)
434 sub_element_functions[e](data.subspan(offset, data.size() - offset),
436 offset += _sub_elements[e]->space_dimension();
440 else if (!scalar_element)
443 const std::function<void(
const std::span<U>&,
444 const std::span<const std::uint32_t>&,
447 = _sub_elements[0]->template get_dof_transformation_function<U>(
450 sub_function](
const std::span<U>& data,
451 const std::span<const std::uint32_t>& cell_info,
452 std::int32_t
cell,
int data_block_size)
455 const std::size_t dof_count = data.size() / data_block_size;
456 for (
int block = 0; block < data_block_size; ++block)
458 sub_function(data.subspan(block * dof_count, dof_count), cell_info,
469 return [
this](
const std::span<U>& data,
470 const std::span<const std::uint32_t>& cell_info,
479 return [
this](
const std::span<U>& data,
480 const std::span<const std::uint32_t>& cell_info,
492 return [
this](
const std::span<U>& data,
493 const std::span<const std::uint32_t>& cell_info,
502 return [
this](
const std::span<U>& data,
503 const std::span<const std::uint32_t>& cell_info,
518 template <
typename U>
520 std::uint32_t cell_permutation,
524 _element->apply_dof_transformation(data,
block_size, cell_permutation);
535 template <
typename U>
538 std::uint32_t cell_permutation,
542 _element->apply_inverse_transpose_dof_transformation(data,
block_size,
553 template <
typename U>
555 std::uint32_t cell_permutation,
559 _element->apply_transpose_dof_transformation(data,
block_size,
570 template <
typename U>
572 std::uint32_t cell_permutation,
576 _element->apply_inverse_dof_transformation(data,
block_size,
586 template <
typename U>
588 std::uint32_t cell_permutation,
592 _element->apply_dof_transformation_to_transpose(data,
block_size,
602 template <
typename U>
605 std::uint32_t cell_permutation,
609 _element->apply_inverse_dof_transformation_to_transpose(data,
block_size,
619 template <
typename U>
621 const std::span<U>& data, std::uint32_t cell_permutation,
625 _element->apply_transpose_dof_transformation_to_transpose(data,
block_size,
635 template <
typename U>
637 const std::span<U>& data, std::uint32_t cell_permutation,
641 _element->apply_inverse_transpose_dof_transformation_to_transpose(
649 void permute_dofs(
const std::span<std::int32_t>& doflist,
650 std::uint32_t cell_permutation)
const;
657 std::uint32_t cell_permutation)
const;
670 std::function<void(
const std::span<std::int32_t>&, std::uint32_t)>
672 bool scalar_element =
false)
const;
675 std::string _signature, _family;
682 std::vector<std::shared_ptr<const FiniteElement<T>>> _sub_elements;
685 std::vector<std::size_t> _value_shape;
692 bool _needs_dof_permutations;
693 bool _needs_dof_transformations;
696 std::unique_ptr<basix::FiniteElement<T>> _element;
Definition CoordinateElement.h:26
Finite Element, containing the dof layout on a reference element, and various methods for evaluating ...
Definition FiniteElement.h:27
FiniteElement & operator=(const FiniteElement &element)=delete
Copy assignment.
std::string family() const noexcept
The finite element family.
Definition FiniteElement.cpp:388
const std::vector< std::shared_ptr< const FiniteElement< T > > > & sub_elements() const noexcept
Subelements (if any)
Definition FiniteElement.cpp:425
void permute_dofs(const std::span< std::int32_t > &doflist, std::uint32_t cell_permutation) const
Permute the DOFs of the element.
Definition FiniteElement.cpp:563
std::pair< std::vector< T >, std::array< std::size_t, 2 > > create_interpolation_operator(const FiniteElement &from) const
Create a matrix that maps degrees of freedom from one element to this element (interpolation).
Definition FiniteElement.cpp:508
void apply_dof_transformation(const std::span< U > &data, std::uint32_t cell_permutation, int block_size) const
Apply DOF transformation to some data.
Definition FiniteElement.h:519
basix::maps::type map_type() const
Get the map type used by the element.
Definition FiniteElement.cpp:454
int space_dimension() const noexcept
Dimension of the finite element function space (the number of degrees-of-freedom for the element)
Definition FiniteElement.cpp:356
void apply_transpose_dof_transformation_to_transpose(const std::span< U > &data, std::uint32_t cell_permutation, int block_size) const
Apply transpose of transformation to some transposed data.
Definition FiniteElement.h:620
FiniteElement & operator=(FiniteElement &&element)=default
Move assignment.
bool needs_dof_transformations() const noexcept
Check if DOF transformations are needed for this element.
Definition FiniteElement.cpp:551
FiniteElement(const FiniteElement &element)=delete
Copy constructor.
void apply_inverse_dof_transformation_to_transpose(const std::span< U > &data, std::uint32_t cell_permutation, int block_size) const
Apply inverse of DOF transformation to some transposed data.
Definition FiniteElement.h:604
std::pair< std::vector< T >, std::array< std::size_t, 2 > > interpolation_points() const
Points on the reference cell at which an expression needs to be evaluated in order to interpolate the...
Definition FiniteElement.cpp:481
void unpermute_dofs(const std::span< std::int32_t > &doflist, std::uint32_t cell_permutation) const
Unpermute the DOFs of the element.
Definition FiniteElement.cpp:570
std::shared_ptr< const FiniteElement< T > > extract_sub_element(const std::vector< int > &component) const
Extract sub finite element for component.
Definition FiniteElement.cpp:432
std::string signature() const noexcept
String identifying the finite element.
Definition FiniteElement.cpp:344
bool needs_dof_permutations() const noexcept
Check if DOF permutations are needed for this element.
Definition FiniteElement.cpp:557
bool is_mixed() const noexcept
Check if element is a mixed element, i.e. composed of two or more elements of different types....
Definition FiniteElement.cpp:418
void apply_inverse_dof_transformation(const std::span< U > &data, std::uint32_t cell_permutation, int block_size) const
Apply inverse transformation to some data. For VectorElements, this applies the transformations for t...
Definition FiniteElement.h:571
void tabulate(std::span< T > values, std::span< const T > X, std::array< std::size_t, 2 > shape, int order) const
Evaluate derivatives of the basis functions up to given order at points in the reference cell.
Definition FiniteElement.cpp:394
void apply_inverse_transpose_dof_transformation(const std::span< U > &data, std::uint32_t cell_permutation, int block_size) const
Apply inverse transpose transformation to some data. For VectorElements, this applies the transformat...
Definition FiniteElement.h:537
int reference_value_size() const
The value size, e.g. 1 for a scalar function, 2 for a 2D vector, 9 for a second-order tensor in 3D,...
Definition FiniteElement.cpp:369
int value_size() const
The value size, e.g. 1 for a scalar function, 2 for a 2D vector, 9 for a second-order tensor in 3D.
Definition FiniteElement.cpp:362
void apply_transpose_dof_transformation(const std::span< U > &data, std::uint32_t cell_permutation, int block_size) const
Apply transpose transformation to some data. For VectorElements, this applies the transformations for...
Definition FiniteElement.h:554
virtual ~FiniteElement()=default
Destructor.
bool operator!=(const FiniteElement &e) const
Check if two elements are not equivalent.
Definition FiniteElement.cpp:338
void apply_dof_transformation_to_transpose(const std::span< U > &data, std::uint32_t cell_permutation, int block_size) const
Apply DOF transformation to some transposed data.
Definition FiniteElement.h:587
std::function< void(const std::span< U > &, const std::span< const std::uint32_t > &, std::int32_t, int)> get_dof_transformation_to_transpose_function(bool inverse=false, bool transpose=false, bool scalar_element=false) const
Return a function that applies DOF transformation to some transposed data.
Definition FiniteElement.h:395
const basix::FiniteElement< T > & basix_element() const
Return underlying basix element (if it exists)
Definition FiniteElement.cpp:442
std::span< const std::size_t > value_shape() const noexcept
Shape of the value space. The rank is the size of the value_shape.
Definition FiniteElement.cpp:382
void apply_inverse_transpose_dof_transformation_to_transpose(const std::span< U > &data, std::uint32_t cell_permutation, int block_size) const
Apply inverse transpose transformation to some transposed data.
Definition FiniteElement.h:636
FiniteElement(FiniteElement &&element)=default
Move constructor.
int num_sub_elements() const noexcept
Number of sub elements (for a mixed or blocked element)
Definition FiniteElement.cpp:412
std::pair< std::vector< T >, std::array< std::size_t, 2 > > interpolation_operator() const
Interpolation operator (matrix) Pi that maps a function evaluated at the points provided by FiniteEle...
Definition FiniteElement.cpp:495
int block_size() const noexcept
Block size of the finite element function space. For BlockedElements, this is the number of DOFs colo...
Definition FiniteElement.cpp:376
std::function< void(const std::span< std::int32_t > &, std::uint32_t)> get_dof_permutation_function(bool inverse=false, bool scalar_element=false) const
Return a function that applies DOF permutation to some data.
Definition FiniteElement.cpp:578
std::function< void(const std::span< U > &, const std::span< const std::uint32_t > &, std::int32_t, int)> get_dof_transformation_function(bool inverse=false, bool transpose=false, bool scalar_element=false) const
Return a function that applies DOF transformation to some data.
Definition FiniteElement.h:270
bool interpolation_ident() const noexcept
Check if interpolation into the finite element space is an identity operation given the evaluation on...
Definition FiniteElement.cpp:473
bool operator==(const FiniteElement &e) const
Check if two elements are equivalent.
Definition FiniteElement.cpp:326
mesh::CellType cell_shape() const noexcept
Cell shape.
Definition FiniteElement.cpp:350
bool map_ident() const noexcept
Check if the push forward/pull back map from the values on reference to the values on a physical cell...
Definition FiniteElement.cpp:466
Finite element method functionality.
Definition assemble_matrix_impl.h:25
CellType
Cell type identifier.
Definition cell_types.h:22