22namespace dolfinx::fem::impl
62template <dolfinx::scalar T, std::
floating_po
int U>
65 std::array<std::size_t, 2> Xshape, std::size_t value_size,
66 std::size_t num_argument_dofs,
67 md::mdspan<
const std::int32_t, md::dextents<std::size_t, 2>> x_dofmap,
68 std::span<
const scalar_value_t<T>> x,
69 md::mdspan<
const T, md::dextents<std::size_t, 2>> coeffs,
70 std::span<const T> constants,
fem::MDSpan2 auto entities,
71 std::span<const std::uint32_t> cell_info,
73 md::mdspan<
const std::uint8_t, md::dextents<std::size_t, 2>> perms)
75 static_assert(entities.rank() == 1 or entities.rank() == 2);
78 std::vector<U> coord_dofs(3 * x_dofmap.extent(1));
81 int size0 = Xshape[0] * value_size;
82 std::vector<T> values_local(size0 * num_argument_dofs, 0);
83 std::size_t offset = values_local.size();
84 for (std::size_t e = 0; e < entities.extent(0); ++e)
86 std::ranges::fill(values_local, 0);
87 if constexpr (entities.rank() == 1)
89 std::int32_t entity = entities(e);
90 auto x_dofs = md::submdspan(x_dofmap, entity, md::full_extent);
91 for (std::size_t i = 0; i < x_dofs.size(); ++i)
93 std::copy_n(std::next(x.begin(), 3 * x_dofs[i]), 3,
94 std::next(coord_dofs.begin(), 3 * i));
96 fn(values_local.data(), &coeffs(e, 0), constants.data(),
97 coord_dofs.data(),
nullptr,
nullptr,
nullptr);
99 P0(values_local, cell_info, entity, size0);
103 std::int32_t entity = entities(e, 0);
104 std::int32_t local_entity = entities(e, 1);
105 std::uint8_t perm = perms.empty() ? 0 : perms(entity, local_entity);
106 auto x_dofs = md::submdspan(x_dofmap, entity, md::full_extent);
107 for (std::size_t i = 0; i < x_dofs.size(); ++i)
109 std::copy_n(std::next(x.begin(), 3 * x_dofs[i]), 3,
110 std::next(coord_dofs.begin(), 3 * i));
112 fn(values_local.data(), &coeffs(e, 0), constants.data(),
113 coord_dofs.data(), &local_entity, &perm,
nullptr);
114 P0(values_local, cell_info, entity, size0);
117 for (std::size_t j = 0; j < values_local.size(); ++j)
118 values[e * offset + j] = values_local[j];
154template <dolfinx::scalar T, std::
floating_po
int U>
157 std::array<std::size_t, 2> Xshape, std::size_t value_size,
158 md::mdspan<
const T, md::dextents<std::size_t, 2>> coeffs,
165 std::function<void(std::span<T>, std::span<const std::uint32_t>, std::int32_t,
168 = [](std::span<T>, std::span<const std::uint32_t>, std::int32_t, int)
173 std::shared_ptr<const mesh::Topology> topology =
mesh.topology();
175 std::size_t num_argument_dofs = 1;
176 std::span<const std::uint32_t> cell_info;
179 num_argument_dofs = element->second;
180 if (element->first.get().needs_dof_transformations())
182 mesh.topology_mutable()->create_entity_permutations();
183 cell_info = std::span(topology->get_cell_permutation_info());
185 = element->first.get().template dof_transformation_right_fn<T>(
190 md::mdspan<const std::uint8_t, md::dextents<std::size_t, 2>> facet_perms;
191 if constexpr (entities.rank() == 2)
194 int num_facets_per_cell
196 mesh.topology_mutable()->create_entity_permutations();
197 const std::vector<std::uint8_t>& p
198 =
mesh.topology()->get_facet_permutations();
199 facet_perms = md::mdspan(p.data(), p.size() / num_facets_per_cell,
200 num_facets_per_cell);
203 mesh.geometry().dofmaps().front(),
204 mesh.geometry().x(), coeffs, constants, entities,
205 cell_info, 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 assembler.h:65