10#include "ElementDofLayout.h"
13#include <basix/element-families.h>
14#include <basix/mdspan.hpp>
18#include <dolfinx/common/math.h>
19#include <dolfinx/mesh/cell_types.h>
26template <std::
floating_po
int T>
37template <std::
floating_po
int T>
58 basix::element::lagrange_variant type
59 = basix::element::lagrange_variant::unset,
60 bool discontinuous =
false);
82 basix::element::lagrange_variant
variant()
const;
87 std::uint64_t
hash()
const;
98 std::size_t num_points)
const;
108 void tabulate(
int nd, std::span<const T> X, std::array<std::size_t, 2> shape,
109 std::span<T> basis)
const;
128 std::uint32_t cell_info,
130 int entity_index)
const;
140 template <
typename U,
typename V,
typename W>
143 math::dot(cell_geometry, dphi, J,
true);
149 template <
typename U,
typename V>
152 int gdim = J.extent(0);
153 int tdim = K.extent(0);
165 template <
typename U>
169 static_assert(U::rank() == 2,
"Must be rank 2");
170 if (J.extent(0) == J.extent(1))
174 assert(w.size() >= 2 * J.extent(0) * J.extent(1));
175 using X =
typename U::element_type;
176 using mdspan2_t = md::mdspan<X, md::dextents<std::size_t, 2>>;
177 mdspan2_t B(w.data(), J.extent(1), J.extent(0));
178 mdspan2_t BA(w.data() + J.extent(0) * J.extent(1), B.extent(0),
180 for (std::size_t i = 0; i < B.extent(0); ++i)
181 for (std::size_t j = 0; j < B.extent(1); ++j)
185 std::fill_n(BA.data_handle(), BA.size(), 0);
187 return std::sqrt(math::det(BA));
201 template <
typename U,
typename V,
typename W>
204 for (std::size_t i = 0; i < x.extent(0); ++i)
205 for (std::size_t j = 0; j < x.extent(1); ++j)
209 math::dot(phi, cell_geometry, x);
222 template <
typename U,
typename V,
typename W>
226 assert(X.extent(0) == x.extent(0));
227 assert(X.extent(1) == K.extent(0));
228 assert(x.extent(1) == K.extent(1));
229 for (std::size_t i = 0; i < X.extent(0); ++i)
230 for (std::size_t j = 0; j < X.extent(1); ++j)
234 for (std::size_t p = 0; p < x.extent(0); ++p)
235 for (std::size_t i = 0; i < K.extent(0); ++i)
236 for (std::size_t j = 0; j < K.extent(1); ++j)
237 X(p, i) += K(i, j) * (x(p, j) - x0[j]);
241 template <
typename X>
242 using mdspan2_t = md::mdspan<X, md::dextents<std::size_t, 2>>;
260 std::span<T> working_array,
double tol,
279 void permute(std::span<std::int32_t> dofs, std::uint32_t cell_perm)
const;
286 void permute_inv(std::span<std::int32_t> dofs, std::uint32_t cell_perm)
const;
315 std::shared_ptr<const basix::FiniteElement<T>> _element;
Definition CoordinateElement.h:27
ElementDofLayout create_dof_layout() const
Compute and return the dof layout.
Definition CoordinateElement.cpp:92
void permute_subentity_closure(std::span< std::int32_t > d, std::uint32_t cell_info, mesh::CellType entity_type, int entity_index) const
Given the closure DOFs of a cell sub-entity in reference ordering, this function computes the permut...
Definition CoordinateElement.cpp:80
static void compute_jacobian(const U &dphi, const V &cell_geometry, W &&J)
Definition CoordinateElement.h:141
void tabulate(int nd, std::span< const T > X, std::array< std::size_t, 2 > shape, std::span< T > basis) const
Evaluate basis values and derivatives at set of points.
Definition CoordinateElement.cpp:71
CoordinateElement(std::shared_ptr< const basix::FiniteElement< T > > element)
Create a coordinate element from a Basix element.
Definition CoordinateElement.cpp:25
void permute_inv(std::span< std::int32_t > dofs, std::uint32_t cell_perm) const
Reverses a DOF permutation.
Definition CoordinateElement.cpp:213
basix::element::lagrange_variant variant() const
Variant of the element.
Definition CoordinateElement.cpp:244
std::size_t pull_back_working_size(std::size_t gdim) const
Compute the working array size required for pull back.
Definition CoordinateElement.cpp:265
mesh::CellType cell_shape() const
Cell shape.
Definition CoordinateElement.cpp:57
static void compute_jacobian_inverse(const U &J, V &&K)
Compute the inverse of the Jacobian.
Definition CoordinateElement.h:150
~CoordinateElement()=default
Destructor.
bool is_discontinuous() const
Check if the element is the discontinuous version of the coordinate element.
Definition CoordinateElement.cpp:258
std::uint64_t hash() const
Element hash.
Definition CoordinateElement.cpp:251
void pull_back_nonaffine(mdspan2_t< T > X, mdspan2_t< const T > x, mdspan2_t< const T > cell_geometry, std::span< T > working_array, double tol, int maxit) const
Compute reference coordinates X for physical coordinates x for a non-affine map.
Definition CoordinateElement.cpp:100
std::array< std::size_t, 4 > tabulate_shape(std::size_t nd, std::size_t num_points) const
Shape of array to fill when calling tabulate.
Definition CoordinateElement.cpp:64
int degree() const
The polynomial degree of the element.
Definition CoordinateElement.cpp:230
void permute(std::span< std::int32_t > dofs, std::uint32_t cell_perm) const
Permute a list of DOF numbers on a cell.
Definition CoordinateElement.cpp:204
md::mdspan< X, md::dextents< std::size_t, 2 > > mdspan2_t
mdspan typedef
Definition CoordinateElement.h:242
int dim() const
The dimension of the coordinate element space.
Definition CoordinateElement.cpp:237
bool is_affine() const noexcept
Check if geometry map is affine.
Definition CoordinateElement.h:297
static void push_forward(U &&x, const V &cell_geometry, const W &phi)
Compute physical coordinates x for points X in the reference configuration.
Definition CoordinateElement.h:202
static double compute_jacobian_determinant(const U &J, std::span< typename U::value_type > w)
Compute the determinant of the Jacobian.
Definition CoordinateElement.h:167
bool needs_dof_permutations() const
Indicates whether the geometry DOF numbers on each cell need permuting.
Definition CoordinateElement.cpp:222
static void pull_back_affine(U &&X, const V &K, std::array< T, 3 > x0, const W &x)
Compute reference coordinates X for physical coordinates x for an affine map. For the affine case,...
Definition CoordinateElement.h:223
Definition ElementDofLayout.h:31
Finite element method functionality.
Definition assemble_expression_impl.h:28
CellType
Cell type identifier.
Definition cell_types.h:24