10 #include <basix/finite-element.h>
11 #include <dolfinx/mesh/cell_types.h>
18 struct ufcx_finite_element;
101 std::span<const std::
size_t>
value_shape() const noexcept;
105 std::
string family() const noexcept;
118 void tabulate(std::span<
double> values, std::span<const
double> X,
119 std::array<std::
size_t, 2> shape,
int order) const;
130 std::pair<std::vector<
double>, std::array<std::
size_t, 4>>
131 tabulate(std::span<const
double> X, std::array<std::
size_t, 2> shape,
181 std::pair<std::vector<
double>, std::array<std::
size_t, 2>>
193 std::pair<std::vector<
double>, std::array<std::
size_t, 2>>
208 std::pair<std::vector<
double>, std::array<std::
size_t, 2>>
259 template <typename T>
260 std::function<
void(const std::span<T>&, const std::span<const std::uint32_t>&,
263 bool scalar_element = false)
const
268 return [](
const std::span<T>&,
const std::span<const std::uint32_t>&,
275 if (_sub_elements.size() != 0)
280 std::vector<std::function<void(
const std::span<T>&,
281 const std::span<const std::uint32_t>&,
283 sub_element_functions;
284 std::vector<int> dims;
285 for (std::size_t i = 0; i < _sub_elements.size(); ++i)
287 sub_element_functions.push_back(
288 _sub_elements[i]->get_dof_transformation_function<T>(inverse,
293 return [dims, sub_element_functions](
294 const std::span<T>& data,
295 const std::span<const std::uint32_t>& cell_info,
298 std::size_t offset = 0;
299 for (std::size_t e = 0; e < sub_element_functions.size(); ++e)
301 const std::size_t width = dims[e] *
block_size;
302 sub_element_functions[e](data.subspan(offset, width), cell_info,
308 else if (!scalar_element)
311 const std::function<void(
const std::span<T>&,
312 const std::span<const std::uint32_t>&,
314 sub_function = _sub_elements[0]->get_dof_transformation_function<T>(
318 [ebs, sub_function](
const std::span<T>& data,
319 const std::span<const std::uint32_t>& cell_info,
320 std::int32_t
cell,
int data_block_size)
321 { sub_function(data, cell_info,
cell, ebs * data_block_size); };
328 return [
this](
const std::span<T>& data,
329 const std::span<const std::uint32_t>& cell_info,
338 return [
this](
const std::span<T>& data,
339 const std::span<const std::uint32_t>& cell_info,
349 return [
this](
const std::span<T>& data,
350 const std::span<const std::uint32_t>& cell_info,
357 return [
this](
const std::span<T>& data,
358 const std::span<const std::uint32_t>& cell_info,
383 template <
typename T>
384 std::function<void(
const std::span<T>&,
const std::span<const std::uint32_t>&,
387 bool transpose =
false,
394 return [](
const std::span<T>&,
const std::span<const std::uint32_t>&,
400 else if (_sub_elements.size() != 0)
405 std::vector<std::function<void(
const std::span<T>&,
406 const std::span<const std::uint32_t>&,
408 sub_element_functions;
409 for (std::size_t i = 0; i < _sub_elements.size(); ++i)
411 sub_element_functions.push_back(
412 _sub_elements[i]->get_dof_transformation_to_transpose_function<T>(
413 inverse, transpose));
416 return [
this, sub_element_functions](
417 const std::span<T>& data,
418 const std::span<const std::uint32_t>& cell_info,
421 std::size_t offset = 0;
422 for (std::size_t e = 0; e < sub_element_functions.size(); ++e)
424 sub_element_functions[e](data.subspan(offset, data.size() - offset),
426 offset += _sub_elements[e]->space_dimension();
430 else if (!scalar_element)
433 const std::function<void(
const std::span<T>&,
434 const std::span<const std::uint32_t>&,
436 sub_function = _sub_elements[0]->get_dof_transformation_function<T>(
439 sub_function](
const std::span<T>& data,
440 const std::span<const std::uint32_t>& cell_info,
441 std::int32_t
cell,
int data_block_size)
444 const std::size_t dof_count = data.size() / data_block_size;
445 for (
int block = 0; block < data_block_size; ++block)
447 sub_function(data.subspan(block * dof_count, dof_count), cell_info,
458 return [
this](
const std::span<T>& data,
459 const std::span<const std::uint32_t>& cell_info,
468 return [
this](
const std::span<T>& data,
469 const std::span<const std::uint32_t>& cell_info,
481 return [
this](
const std::span<T>& data,
482 const std::span<const std::uint32_t>& cell_info,
491 return [
this](
const std::span<T>& data,
492 const std::span<const std::uint32_t>& cell_info,
507 template <
typename T>
509 std::uint32_t cell_permutation,
513 _element->apply_dof_transformation(data,
block_size, cell_permutation);
524 template <
typename T>
527 std::uint32_t cell_permutation,
531 _element->apply_inverse_transpose_dof_transformation(data,
block_size,
542 template <
typename T>
544 std::uint32_t cell_permutation,
548 _element->apply_transpose_dof_transformation(data,
block_size,
559 template <
typename T>
561 std::uint32_t cell_permutation,
565 _element->apply_inverse_dof_transformation(data,
block_size,
575 template <
typename T>
577 std::uint32_t cell_permutation,
581 _element->apply_dof_transformation_to_transpose(data,
block_size,
591 template <
typename T>
594 std::uint32_t cell_permutation,
598 _element->apply_inverse_dof_transformation_to_transpose(data,
block_size,
608 template <
typename T>
610 const std::span<T>& data, std::uint32_t cell_permutation,
614 _element->apply_transpose_dof_transformation_to_transpose(data,
block_size,
624 template <
typename T>
626 const std::span<T>& data, std::uint32_t cell_permutation,
630 _element->apply_inverse_transpose_dof_transformation_to_transpose(
638 void permute_dofs(
const std::span<std::int32_t>& doflist,
639 std::uint32_t cell_permutation)
const;
646 std::uint32_t cell_permutation)
const;
659 std::function<void(
const std::span<std::int32_t>&, std::uint32_t)>
661 bool scalar_element =
false)
const;
664 std::string _signature, _family;
671 std::vector<std::shared_ptr<const FiniteElement>> _sub_elements;
674 std::vector<std::size_t> _value_shape;
681 bool _needs_dof_permutations;
682 bool _needs_dof_transformations;
685 std::unique_ptr<basix::FiniteElement> _element;
Finite Element, containing the dof layout on a reference element, and various methods for evaluating ...
Definition: FiniteElement.h:25
void apply_inverse_dof_transformation(const std::span< T > &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:560
std::string family() const noexcept
The finite element family.
Definition: FiniteElement.cpp:345
std::pair< std::vector< double >, 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:450
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:502
void apply_inverse_dof_transformation_to_transpose(const std::span< T > &data, std::uint32_t cell_permutation, int block_size) const
Apply inverse of DOF transformation to some transposed data.
Definition: FiniteElement.h:593
basix::maps::type map_type() const
Get the map type used by the element.
Definition: FiniteElement.cpp:401
int space_dimension() const noexcept
Dimension of the finite element function space (the number of degrees-of-freedom for the element)
Definition: FiniteElement.cpp:324
void apply_transpose_dof_transformation(const std::span< T > &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:543
bool needs_dof_transformations() const noexcept
Check if DOF transformations are needed for this element.
Definition: FiniteElement.cpp:492
FiniteElement(const FiniteElement &element)=delete
Copy constructor.
FiniteElement(const ufcx_finite_element &e)
Create finite element from UFC finite element.
Definition: FiniteElement.cpp:104
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:508
void apply_transpose_dof_transformation_to_transpose(const std::span< T > &data, std::uint32_t cell_permutation, int block_size) const
Apply transpose of transformation to some transposed data.
Definition: FiniteElement.h:609
std::string signature() const noexcept
String identifying the finite element.
Definition: FiniteElement.cpp:317
bool needs_dof_permutations() const noexcept
Check if DOF permutations are needed for this element.
Definition: FiniteElement.cpp:497
void apply_dof_transformation_to_transpose(const std::span< T > &data, std::uint32_t cell_permutation, int block_size) const
Apply DOF transformation to some transposed data.
Definition: FiniteElement.h:576
void apply_dof_transformation(const std::span< T > &data, std::uint32_t cell_permutation, int block_size) const
Apply DOF transformation to some data.
Definition: FiniteElement.h:508
std::pair< std::vector< double >, 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:438
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:368
std::pair< std::vector< double >, std::array< std::size_t, 2 > > interpolation_points() const
Points on the reference cell at which an expression need to be evaluated in order to interpolate the ...
Definition: FiniteElement.cpp:425
std::shared_ptr< const FiniteElement > extract_sub_element(const std::vector< int > &component) const
Extract sub finite element for component.
Definition: FiniteElement.cpp:380
FiniteElement & operator=(FiniteElement &&element)=default
Move assignment.
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:332
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:326
virtual ~FiniteElement()=default
Destructor.
bool operator!=(const FiniteElement &e) const
Check if two elements are not equivalent.
Definition: FiniteElement.cpp:312
void tabulate(std::span< double > values, std::span< const double > 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:347
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:340
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:363
FiniteElement & operator=(const FiniteElement &element)=delete
Copy assignment.
const basix::FiniteElement & basix_element() const
Return underlying basix element (if it exists)
Definition: FiniteElement.cpp:390
int block_size() const noexcept
Block size of the finite element function space. For VectorElements and TensorElements,...
Definition: FiniteElement.cpp:338
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:515
const std::vector< std::shared_ptr< const FiniteElement > > & sub_elements() const noexcept
Subelements (if any)
Definition: FiniteElement.cpp:374
bool interpolation_ident() const noexcept
Check if interpolation into the finite element space is an identity operation given the evaluation on...
Definition: FiniteElement.cpp:418
std::function< void(const std::span< T > &, 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:262
void apply_inverse_transpose_dof_transformation_to_transpose(const std::span< T > &data, std::uint32_t cell_permutation, int block_size) const
Apply inverse transpose transformation to some transposed data.
Definition: FiniteElement.h:625
void apply_inverse_transpose_dof_transformation(const std::span< T > &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:526
std::function< void(const std::span< T > &, 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:386
bool operator==(const FiniteElement &e) const
Check if two elements are equivalent.
Definition: FiniteElement.cpp:302
mesh::CellType cell_shape() const noexcept
Cell shape.
Definition: FiniteElement.cpp:319
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:412
Finite element method functionality.
Definition: assemble_matrix_impl.h:25
CellType
Cell type identifier.
Definition: cell_types.h:22