22namespace dolfinx::fem::impl
61template <dolfinx::scalar T, std::
floating_po
int U>
62void tabulate_expression(
64 std::array<std::size_t, 2> Xshape, std::size_t value_size,
65 std::size_t num_argument_dofs,
66 md::mdspan<
const std::int32_t, md::dextents<std::size_t, 2>> x_dofmap,
67 std::span<
const scalar_value_t<T>> x,
68 md::mdspan<
const T, md::dextents<std::size_t, 2>> coeffs,
69 std::span<const T> constants,
fem::MDSpan2 auto entities,
70 std::span<const std::uint32_t> cell_info,
73 static_assert(entities.rank() == 1 or entities.rank() == 2);
76 std::vector<U> coord_dofs(3 * x_dofmap.extent(1));
79 int size0 = Xshape[0] * value_size;
80 std::vector<T> values_local(size0 * num_argument_dofs, 0);
81 std::size_t offset = values_local.size();
82 for (std::size_t e = 0; e < entities.extent(0); ++e)
84 std::ranges::fill(values_local, 0);
85 if constexpr (entities.rank() == 1)
87 std::int32_t entity = entities(e);
88 auto x_dofs = md::submdspan(x_dofmap, entity, md::full_extent);
89 for (std::size_t i = 0; i < x_dofs.size(); ++i)
91 std::copy_n(std::next(x.begin(), 3 * x_dofs[i]), 3,
92 std::next(coord_dofs.begin(), 3 * i));
94 fn(values_local.data(), &coeffs(e, 0), constants.data(),
95 coord_dofs.data(),
nullptr,
nullptr,
nullptr);
99 std::int32_t entity = entities(e, 0);
100 auto x_dofs = md::submdspan(x_dofmap, entity, md::full_extent);
101 for (std::size_t i = 0; i < x_dofs.size(); ++i)
103 std::copy_n(std::next(x.begin(), 3 * x_dofs[i]), 3,
104 std::next(coord_dofs.begin(), 3 * i));
106 fn(values_local.data(), &coeffs(e, 0), constants.data(),
107 coord_dofs.data(), &entities(e, 1),
nullptr,
nullptr);
110 P0(values_local, cell_info, e, size0);
111 for (std::size_t j = 0; j < values_local.size(); ++j)
112 values[e * offset + j] = values_local[j];
148template <dolfinx::scalar T, std::
floating_po
int U>
149void tabulate_expression(
151 std::array<std::size_t, 2> Xshape, std::size_t value_size,
152 md::mdspan<
const T, md::dextents<std::size_t, 2>> coeffs,
159 std::function<void(std::span<T>, std::span<const std::uint32_t>, std::int32_t,
162 = [](std::span<T>, std::span<const std::uint32_t>, std::int32_t, int)
167 std::shared_ptr<const mesh::Topology> topology = mesh.topology();
169 std::size_t num_argument_dofs = 1;
170 std::span<const std::uint32_t> cell_info;
173 num_argument_dofs = element->second;
174 if (element->first.get().needs_dof_transformations())
176 mesh.topology_mutable()->create_entity_permutations();
177 cell_info = std::span(topology->get_cell_permutation_info());
179 = element->first.get().template dof_transformation_right_fn<T>(
184 tabulate_expression<T, U>(values, fn, Xshape, value_size, num_argument_dofs,
185 mesh.geometry().dofmap(), mesh.geometry().x(),
186 coeffs, constants, entities, cell_info,