27namespace dolfinx::fem::impl
70template <dolfinx::scalar T, std::
floating_po
int U>
73 std::array<std::size_t, 2> Xshape, std::size_t value_size,
74 std::size_t num_argument_dofs,
75 md::mdspan<
const std::int32_t, md::dextents<std::size_t, 2>> x_dofmap,
77 md::mdspan<
const T, md::dextents<std::size_t, 2>> coeffs,
78 std::span<const T> constants,
fem::MDSpan2 auto entities,
79 std::span<const std::uint32_t> cell_info,
80 std::span<const std::int32_t> argument_cells,
82 md::mdspan<
const std::uint8_t, md::dextents<std::size_t, 2>> perms)
84 static_assert(entities.rank() == 1 or entities.rank() == 2);
87 std::vector<U> coord_dofs(3 * x_dofmap.extent(1));
90 md::mdspan<const U, md::extents<std::size_t, md::dynamic_extent, 3>>(
91 x.data(), x.size() / 3, 3)};
94 int size0 = Xshape[0] * value_size;
95 std::vector<T> values_local(size0 * num_argument_dofs, 0);
96 std::size_t offset = values_local.size();
98 const T* coeffs_data = coeffs.data_handle();
99 const std::size_t cstride = coeffs.extent(1);
101 for (std::size_t e = 0; e < entities.extent(0); ++e)
103 std::ranges::fill(values_local, T(0));
104 if constexpr (entities.rank() == 1)
106 std::int32_t entity = entities(e);
107 gather_cell_coordinates(
geometry, entity, coord_dofs.data());
108 fn(values_local.data(), coeffs_data + e * cstride, constants.data(),
109 coord_dofs.data(),
nullptr,
nullptr,
nullptr);
111 P0(values_local, cell_info,
112 argument_cells.empty() ? entity : argument_cells[e], size0);
116 std::int32_t entity = entities(e, 0);
117 std::int32_t local_entity = entities(e, 1);
118 std::uint8_t perm = perms.empty() ? 0 : perms(entity, local_entity);
119 gather_cell_coordinates(
geometry, entity, coord_dofs.data());
120 fn(values_local.data(), coeffs_data + e * cstride, constants.data(),
121 coord_dofs.data(), &local_entity, &perm,
nullptr);
122 P0(values_local, cell_info,
123 argument_cells.empty() ? entity : argument_cells[e], size0);
126 for (std::size_t j = 0; j < values_local.size(); ++j)
127 values[e * offset + j] = values_local[j];
168template <dolfinx::scalar T, std::
floating_po
int U>
171 std::array<std::size_t, 2> Xshape, std::size_t value_size,
172 md::mdspan<
const T, md::dextents<std::size_t, 2>> coeffs,
178 std::span<const std::uint32_t> cell_info,
179 std::span<const std::int32_t> argument_cells)
181 assert(argument_cells.empty() or argument_cells.size() == entities.extent(0));
183 std::function<void(std::span<T>, std::span<const std::uint32_t>, std::int32_t,
186 = [](std::span<T>, std::span<const std::uint32_t>, std::int32_t, int)
191 std::size_t num_argument_dofs = 1;
194 num_argument_dofs = element->second;
195 if (element->first.get().needs_dof_transformations())
198 = element->first.get().template dof_transformation_right_fn<T>(
204 md::mdspan<const std::uint8_t, md::dextents<std::size_t, 2>> facet_perms;
205 if constexpr (std::remove_cvref_t<
decltype(entities)>::rank() == 2)
207 const int facet_dim =
mesh.topology()->dim() - 1;
210 mesh.topology_mutable()->create_entity_permutations(facet_dim);
211 const std::vector<std::uint8_t>& p
212 =
mesh.topology()->get_entity_permutations(facet_dim);
213 facet_perms = md::mdspan(p.data(), p.size() / num_facets_per_cell,
214 num_facets_per_cell);
217 mesh.geometry().dofmaps().front(),
mesh.geometry().x(),
218 coeffs, constants, entities, cell_info, argument_cells,
219 post_dof_transform, facet_perms);
void tabulate_expression(std::span< T > values, const fem::Expression< T, U > &e, md::mdspan< const T, md::dextents< std::size_t, 2 > > coeffs, std::span< const T > constants, const mesh::Mesh< U > &mesh, fem::MDSpan2 auto entities, std::optional< std::pair< std::reference_wrapper< const FiniteElement< U > >, std::size_t > > element)
Evaluate an Expression on cells or facets.
Definition expression_evaluate.h:75