11#include <dolfinx/common/IndexMap.h>
36 requires std::is_convertible_v<std::remove_cvref_t<U>,
37 std::vector<std::int32_t>>
48 throw std::runtime_error(
49 "No index map for entities, call `Topology::create_entities("
50 + std::to_string(_dim) +
")");
53 std::size_t num_ents = e_imap->size_local() + e_imap->num_ghosts();
54 if (num_ents != _sub_topology_to_topology.size())
56 throw std::runtime_error(
57 "Size mismatch between `sub_topology_to_topology` and index map.");
73 std::size_t
dim()
const;
77 std::shared_ptr<const Topology>
topology()
const;
113 = std::forward<decltype(entities)>(entities)
114 | std::views::transform([
this](std::int32_t i)
115 {
return _sub_topology_to_topology[i]; });
116 return std::vector<std::int32_t>(mapped.begin(), mapped.end());
123 std::unordered_map<std::int32_t, std::int32_t> topology_to_sub_topology;
124 topology_to_sub_topology.reserve(_sub_topology_to_topology.size());
125 for (std::size_t i = 0; i < _sub_topology_to_topology.size(); ++i)
127 topology_to_sub_topology.insert(
128 {_sub_topology_to_topology[i],
static_cast<std::int32_t
>(i)});
138 auto mapped = std::forward<decltype(entities)>(entities)
139 | std::views::transform(
140 [&topology_to_sub_topology](std::int32_t i)
144 auto it = topology_to_sub_topology.find(i);
145 return (it != topology_to_sub_topology.end())
149 return std::vector<std::int32_t>(mapped.begin(), mapped.end());
158 std::shared_ptr<const Topology> _topology;
163 std::vector<std::int32_t> _sub_topology_to_topology;
167 std::shared_ptr<const Topology> _sub_topology;
EntityMap(EntityMap &&map)=default
Move constructor.
std::size_t dim() const
Get the topological dimension of the entities related by this EntityMap.
Definition EntityMap.cpp:16
std::vector< std::int32_t > sub_topology_to_topology(CellRange auto &&entities, bool inverse) const
Map entities between the sub-topology and the parent topology.
Definition EntityMap.h:103
EntityMap(const EntityMap &map)=default
Copy constructor.
EntityMap(std::shared_ptr< const Topology > topology, std::shared_ptr< const Topology > sub_topology, int dim, U &&sub_topology_to_topology)
Constructor of a bidirectional map relating entities of dimension dim in topology and sub_topology.
Definition EntityMap.h:38
std::shared_ptr< const Topology > sub_topology() const
Get the sub-topology.
Definition EntityMap.cpp:23
std::shared_ptr< const Topology > topology() const
Get the (parent) topology.
Definition EntityMap.cpp:18
Requirement on range of cell indices.
Definition Topology.h:32
Mesh data structures and algorithms on meshes.
Definition DofMap.h:32