Skip to content

Commit 055b199

Browse files
Indexing of Geometry cmaps and dofmaps for multiple cell types (#4227)
* Revert changes to cmap * Revert more cmap * Fix up Python layer including deprecation warning for * Update interface to geometry::dofmaps * clang-format * clang-format * clang-format... * some fixes * Fix in demo * fixes
1 parent 60ef8be commit 055b199

45 files changed

Lines changed: 183 additions & 173 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cpp/demo/custom_kernel/main.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,10 @@ double assemble_matrix1(const mesh::Geometry<T>& g, const fem::DofMap& dofmap,
141141
common::Timer timer("Assembler1 lambda (matrix)");
142142
md::mdspan<const T, md::extents<std::size_t, md::dynamic_extent, 3>> x(
143143
g.x().data(), g.x().size() / 3, 3);
144-
fem::impl::assemble_cells_matrix<T>(
145-
A.mat_add_values(), g.dofmap(), x, cells, {dofmap.map(), 1, cells}, ident,
146-
{dofmap.map(), 1, cells}, ident, {}, {}, kernel, {}, {}, {}, {});
144+
fem::impl::assemble_cells_matrix<T>(A.mat_add_values(), g.dofmaps().front(),
145+
x, cells, {dofmap.map(), 1, cells}, ident,
146+
{dofmap.map(), 1, cells}, ident, {}, {},
147+
kernel, {}, {}, {}, {});
147148
A.scatter_rev();
148149
return A.squared_norm();
149150
}
@@ -168,8 +169,8 @@ double assemble_vector1(const mesh::Geometry<T>& g, const fem::DofMap& dofmap,
168169
g.x().data(), g.x().size() / 3, 3);
169170
common::Timer timer("Assembler1 lambda (vector)");
170171
fem::impl::assemble_cells<1>([](auto, auto, auto, auto) {}, b.array(),
171-
g.dofmap(), x, cells, {dofmap.map(), 1, cells},
172-
kernel, {}, {}, {});
172+
g.dofmaps().front(), x, cells,
173+
{dofmap.map(), 1, cells}, kernel, {}, {}, {});
173174
b.scatter_rev(std::plus<T>());
174175
return la::squared_norm(b);
175176
}

cpp/dolfinx/fem/Function.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,10 +489,11 @@ class Function
489489
auto map = mesh->topology()->index_map(tdim);
490490

491491
// Get coordinate map
492-
const CoordinateElement<geometry_type>& cmap = mesh->geometry().cmap();
492+
const CoordinateElement<geometry_type>& cmap
493+
= mesh->geometry().cmaps().front();
493494

494495
// Get geometry data
495-
auto x_dofmap = mesh->geometry().dofmap();
496+
auto x_dofmap = mesh->geometry().dofmaps().front();
496497
const std::size_t num_dofs_g = cmap.dim();
497498
auto x_g = mesh->geometry().x();
498499

cpp/dolfinx/fem/FunctionSpace.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,11 @@ class FunctionSpace
287287
const auto [X, Xshape] = _elements[i]->interpolation_points();
288288

289289
// Get coordinate map
290-
const CoordinateElement<geometry_type>& cmap = _mesh->geometry().cmap(i);
290+
const CoordinateElement<geometry_type>& cmap
291+
= _mesh->geometry().cmaps().at(i);
291292

292293
// Prepare cell geometry
293-
auto x_dofmap = _mesh->geometry().dofmap(i);
294+
auto x_dofmap = _mesh->geometry().dofmaps().at(i);
294295
const std::size_t num_dofs_g = cmap.dim();
295296
std::vector<geometry_type> coordinate_dofs_b(num_dofs_g * gdim);
296297
mdspan2_t coordinate_dofs(coordinate_dofs_b.data(), num_dofs_g, gdim);

cpp/dolfinx/fem/assemble_expression_impl.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ void tabulate_expression(
185185
}
186186

187187
tabulate_expression<T, U>(values, fn, Xshape, value_size, num_argument_dofs,
188-
mesh.geometry().dofmap(), mesh.geometry().x(),
189-
coeffs, constants, entities, cell_info,
190-
post_dof_transform);
188+
mesh.geometry().dofmaps().front(),
189+
mesh.geometry().x(), coeffs, constants, entities,
190+
cell_info, post_dof_transform);
191191
}
192192
} // namespace dolfinx::fem::impl

cpp/dolfinx/fem/assemble_matrix_impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ void assemble_matrix(
642642
for (int cell_type_idx = 0; cell_type_idx < num_cell_types; ++cell_type_idx)
643643
{
644644
// Geometry dofmap and data
645-
mdspan2_t x_dofmap = mesh->geometry().dofmap(cell_type_idx);
645+
mdspan2_t x_dofmap = mesh->geometry().dofmaps().at(cell_type_idx);
646646

647647
// Get dofmap data
648648
std::shared_ptr<const fem::DofMap> dofmap0

cpp/dolfinx/fem/assemble_vector_impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ void assemble_vector(
581581
for (int cell_type_idx = 0; cell_type_idx < num_cell_types; ++cell_type_idx)
582582
{
583583
// Geometry dofmap and data
584-
mdspan2_t x_dofmap = mesh->geometry().dofmap(cell_type_idx);
584+
mdspan2_t x_dofmap = mesh->geometry().dofmaps().at(cell_type_idx);
585585

586586
// Get dofmap data
587587
assert(L.function_spaces().at(0));

cpp/dolfinx/fem/assembler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ T assemble_scalar(
175175
{
176176
// Geometry dofmap and data
177177
md::mdspan<const std::int32_t, md::dextents<std::size_t, 2>> x_dofmap
178-
= mesh->geometry().dofmap(cell_type_idx);
178+
= mesh->geometry().dofmaps().at(cell_type_idx);
179179
if constexpr (std::is_same_v<U, scalar_value_t<T>>)
180180
{
181181
val += impl::assemble_scalar(M, x_dofmap,

cpp/dolfinx/fem/discreteoperators.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ void discrete_curl(const FunctionSpace<T>& V0, const FunctionSpace<T>& V1,
151151
const auto [X, Xshape] = e1->interpolation_points();
152152

153153
// Get/compute geometry map and evaluate at interpolation points
154-
const CoordinateElement<T>& cmap = mesh->geometry().cmap();
155-
auto x_dofmap = mesh->geometry().dofmap();
154+
const CoordinateElement<T>& cmap = mesh->geometry().cmaps().front();
155+
auto x_dofmap = mesh->geometry().dofmaps().front();
156156
const std::size_t num_dofs_g = cmap.dim();
157157
std::span<const T> x_g = mesh->geometry().x();
158158
std::array<std::size_t, 4> Phi_g_shape = cmap.tabulate_shape(1, Xshape[0]);
@@ -453,8 +453,8 @@ void interpolation_matrix(const FunctionSpace<U>& V0,
453453
const std::size_t value_size0 = V0.element()->reference_value_size();
454454

455455
// Get geometry data
456-
const CoordinateElement<U>& cmap = mesh->geometry().cmap();
457-
auto x_dofmap = mesh->geometry().dofmap();
456+
const CoordinateElement<U>& cmap = mesh->geometry().cmaps().front();
457+
auto x_dofmap = mesh->geometry().dofmaps().front();
458458
const std::size_t num_dofs_g = cmap.dim();
459459
std::span<const U> x_g = mesh->geometry().x();
460460

cpp/dolfinx/fem/interpolate.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ std::vector<T> interpolation_coords(const fem::FiniteElement<T>& element,
5454
// Find CoordinateElement appropriate to element
5555
auto cmap_index = [&geometry](mesh::CellType cell_type)
5656
{
57-
for (std::size_t i = 0; i < geometry.num_maps(); ++i)
57+
for (std::size_t i = 0; i < geometry.cmaps().size(); ++i)
5858
{
59-
if (geometry.cmap(i).cell_shape() == cell_type)
59+
if (geometry.cmaps().at(i).cell_shape() == cell_type)
6060
return i;
6161
}
6262
throw std::runtime_error("Cannot find CoordinateElement for FiniteElement");
@@ -65,10 +65,10 @@ std::vector<T> interpolation_coords(const fem::FiniteElement<T>& element,
6565

6666
// Get geometry data and the element coordinate map
6767
const std::size_t gdim = geometry.dim();
68-
auto x_dofmap = geometry.dofmap(index);
68+
auto x_dofmap = geometry.dofmaps().at(index);
6969
std::span<const T> x_g = geometry.x();
7070

71-
const CoordinateElement<T>& cmap = geometry.cmap(index);
71+
const CoordinateElement<T>& cmap = geometry.cmaps().at(index);
7272
const std::size_t num_dofs_g = cmap.dim();
7373

7474
// Get the interpolation points on the reference cells
@@ -520,8 +520,8 @@ void interpolate_nonmatching_maps(Function<T, U>& u1,
520520
const std::size_t value_size_ref0 = element0->reference_value_size();
521521
const std::size_t value_size0 = V0->element()->reference_value_size();
522522

523-
const CoordinateElement<U>& cmap = mesh0->geometry().cmap();
524-
auto x_dofmap = mesh0->geometry().dofmap();
523+
const CoordinateElement<U>& cmap = mesh0->geometry().cmaps().front();
524+
auto x_dofmap = mesh0->geometry().dofmaps().front();
525525
std::span<const U> x_g = mesh0->geometry().x();
526526

527527
// (0) is derivative index, (1) is the point index, (2) is the basis
@@ -927,10 +927,10 @@ void piola_mapped_evaluation(const FiniteElement<U>& element, bool symmetric,
927927
throw std::runtime_error("Interpolation data has the wrong shape.");
928928

929929
// Get coordinate map
930-
const CoordinateElement<U>& cmap = mesh.geometry().cmap();
930+
const CoordinateElement<U>& cmap = mesh.geometry().cmaps().front();
931931

932932
// Get geometry data
933-
auto x_dofmap = mesh.geometry().dofmap();
933+
auto x_dofmap = mesh.geometry().dofmaps().front();
934934
const int num_dofs_g = cmap.dim();
935935
std::span<const U> x_g = mesh.geometry().x();
936936

cpp/dolfinx/fem/utils.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -532,12 +532,12 @@ Form<T, U> create_form_factory(
532532
= [&geo = mesh->geometry()](const ufcx_integral& integral,
533533
std::size_t cell_idx)
534534
{
535-
if (integral.coordinate_element_hash != geo.cmap(cell_idx).hash())
535+
if (integral.coordinate_element_hash != geo.cmaps().at(cell_idx).hash())
536536
{
537537
throw std::runtime_error(
538538
"Generated integral geometry element does not match mesh geometry: "
539539
+ std::to_string(integral.coordinate_element_hash) + ", "
540-
+ std::to_string(geo.cmap(cell_idx).hash()));
540+
+ std::to_string(geo.cmaps().at(cell_idx).hash()));
541541
}
542542
};
543543

@@ -962,7 +962,7 @@ Expression<T, U> create_expression(
962962
assert(coefficients.front()->function_space());
963963
std::shared_ptr<const mesh::Mesh<U>> mesh
964964
= coefficients.front()->function_space()->mesh();
965-
if (mesh->geometry().cmap().hash() != e.coordinate_element_hash)
965+
if (mesh->geometry().cmaps().front().hash() != e.coordinate_element_hash)
966966
{
967967
throw std::runtime_error(
968968
"Expression and mesh geometric maps do not match.");
@@ -1082,7 +1082,7 @@ mesh::Mesh<T> interpolate_geometry(
10821082
const graph::AdjacencyList<std::int32_t>&)>& reorder_fn = nullptr)
10831083
{
10841084
assert(mesh);
1085-
const CoordinateElement<T>& old_cmap = mesh->geometry().cmap();
1085+
const CoordinateElement<T>& old_cmap = mesh->geometry().cmaps().front();
10861086
if (new_cmap.cell_shape() != old_cmap.cell_shape())
10871087
{
10881088
throw std::runtime_error(

0 commit comments

Comments
 (0)