@@ -322,8 +322,11 @@ mesh::create_submesh(const Mesh& mesh, int dim,
322
322
// NOTE: Unclear what this return for prisms
323
323
const std::size_t num_entity_dofs = layout.num_entity_closure_dofs (dim);
324
324
325
- std::vector<std::int32_t > geometry_indices (num_entity_dofs
326
- * submesh_to_mesh_map.size ());
325
+ std::vector<std::int32_t > geometry_indices;
326
+ geometry_indices.reserve (num_entity_dofs * submesh_to_mesh_map.size ());
327
+ std::vector<std::int32_t > submesh_x_dofmap_offsets;
328
+ submesh_x_dofmap_offsets.reserve (submesh_to_mesh_map.size () + 1 );
329
+ submesh_x_dofmap_offsets.push_back (0 );
327
330
{
328
331
const graph::AdjacencyList<std::int32_t >& xdofs = geometry.dofmap ();
329
332
const int tdim = topology.dim ();
@@ -354,8 +357,9 @@ mesh::create_submesh(const Mesh& mesh, int dim,
354
357
= closure_dofs[dim][local_entity];
355
358
356
359
auto xc = xdofs.links (cell);
357
- for (std::size_t j = 0 ; j < num_entity_dofs; ++j)
358
- geometry_indices[i * num_entity_dofs + j] = xc[entity_dofs[j]];
360
+ for (std::int32_t entity_dof : entity_dofs)
361
+ geometry_indices.push_back (xc[entity_dof]);
362
+ submesh_x_dofmap_offsets.push_back (geometry_indices.size ());
359
363
}
360
364
}
361
365
@@ -413,26 +417,18 @@ mesh::create_submesh(const Mesh& mesh, int dim,
413
417
mesh_to_submesh_x_dof_map[submesh_to_mesh_x_dof_map[i]] = i;
414
418
415
419
// Create submesh geometry dofmap
416
- std::vector<std::int32_t > entity_x_dofs;
417
420
std::vector<std::int32_t > submesh_x_dofmap_vec;
418
421
submesh_x_dofmap_vec.reserve (geometry_indices.size ());
419
- std::vector<std::int32_t > submesh_x_dofmap_offsets (1 , 0 );
420
- submesh_x_dofmap_offsets.reserve (submesh_to_mesh_map.size () + 1 );
421
- for (std::size_t i = 0 ; i < submesh_to_mesh_map.size (); ++i)
422
- {
423
- // Get the mesh geometry dofs for ith entity in entities
424
- auto it = std::next (geometry_indices.begin (), i * num_entity_dofs);
425
- entity_x_dofs.assign (it, std::next (it, num_entity_dofs));
422
+ std::transform (geometry_indices.cbegin (), geometry_indices.cend (),
423
+ std::back_inserter (submesh_x_dofmap_vec),
424
+ [&mesh_to_submesh_x_dof_map](auto x_dof)
425
+ {
426
+ std::int32_t x_dof_submesh
427
+ = mesh_to_submesh_x_dof_map[x_dof];
428
+ assert (x_dof_submesh != -1 );
429
+ return x_dof_submesh;
430
+ });
426
431
427
- // For each mesh dof of the entity, get the submesh dof
428
- for (std::int32_t x_dof : entity_x_dofs)
429
- {
430
- std::int32_t x_dof_submesh = mesh_to_submesh_x_dof_map[x_dof];
431
- assert (x_dof_submesh != -1 );
432
- submesh_x_dofmap_vec.push_back (x_dof_submesh);
433
- }
434
- submesh_x_dofmap_offsets.push_back (submesh_x_dofmap_vec.size ());
435
- }
436
432
graph::AdjacencyList<std::int32_t > submesh_x_dofmap (
437
433
std::move (submesh_x_dofmap_vec), std::move (submesh_x_dofmap_offsets));
438
434
0 commit comments