11#include <dolfinx/common/IndexMap.h>
37 requires std::is_convertible_v<std::remove_cvref_t<U>,
38 std::vector<std::int32_t>>
49 throw std::runtime_error(std::format(
50 "No index map for entities, call `Topology::create_entities({})",
54 std::size_t num_ents = e_imap->size_local() + e_imap->num_ghosts();
55 if (num_ents != _sub_topology_to_topology.size())
57 throw std::runtime_error(
58 "Size mismatch between `sub_topology_to_topology` and index map.");
74 std::size_t
dim()
const;
78 std::shared_ptr<const Topology>
topology()
const;
114 = std::forward<decltype(entities)>(entities)
115 | std::views::transform([
this](std::int32_t i)
116 {
return _sub_topology_to_topology[i]; });
117 return std::vector<std::int32_t>(mapped.begin(), mapped.end());
124 std::unordered_map<std::int32_t, std::int32_t> topology_to_sub_topology;
125 topology_to_sub_topology.reserve(_sub_topology_to_topology.size());
126 for (std::size_t i = 0; i < _sub_topology_to_topology.size(); ++i)
128 topology_to_sub_topology.insert(
129 {_sub_topology_to_topology[i],
static_cast<std::int32_t
>(i)});
139 auto mapped = std::forward<decltype(entities)>(entities)
140 | std::views::transform(
141 [&topology_to_sub_topology](std::int32_t i)
145 auto it = topology_to_sub_topology.find(i);
146 return (it != topology_to_sub_topology.end())
150 return std::vector<std::int32_t>(mapped.begin(), mapped.end());
159 std::shared_ptr<const Topology> _topology;
164 std::vector<std::int32_t> _sub_topology_to_topology;
168 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:104
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:39
EntityMap(const EntityMap &map)=default
Copy constructor.
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