29 namespace unstructured_impl {
46 template<
size_t from_dim,
size_t to_dim,
size_t thru_dim,
size_t D>
53 std::set<size_t> neighbors;
59 if(from_dim == to_dim && e == entity_id) {
67 auto intersect = util::set_intersection(vertices, other);
71 if(intersect.size() > thru_dim) {
95 template<
size_t from_dim,
100 typename = std::enable_if_t<util::is_iterative_container_v<U>>>
103 flog_assert(from_dim == to_dim,
"from_dim does not equal to to_dim");
106 std::set<size_t> closure(
107 std::forward<U>(indices).begin(), std::forward<U>(indices).end());
109 using entityid = size_t;
110 using vertexid = size_t;
114 std::map<vertexid, std::vector<entityid>> vertex2entities;
118 for(
size_t cell(0); cell < md.
num_entities(from_dim); ++cell) {
119 std::map<entityid, size_t> cell_counts;
120 for(
auto vertex : md.
entities(from_dim, 0, cell)) {
123 vertex2entities[vertex].push_back(cell);
127 for(
auto other : vertex2entities[vertex]) {
130 cell_counts[other] += 1;
134 for(
auto count : cell_counts) {
135 if(count.second > thru_dim) {
138 entity_neighbors[cell].push_back(count.first);
139 entity_neighbors[count.first].push_back(cell);
144 for(
auto i : indices) {
145 for(
auto n : entity_neighbors[i]) {
164 template<
size_t from_dim,
size_t to_dim,
size_t D>
167 std::set<size_t> referencers;
174 const auto & eset = md.
entities(from_dim, to_dim, e);
177 if(std::find(eset.begin(), eset.end(), id) != eset.end())
178 referencers.insert(e);
197 template<
size_t from_dim,
size_t to_dim,
size_t D,
typename U>
200 std::set<size_t> closure;
204 for(
auto i : std::forward<U>(indices)) {
205 const auto & vset = md.
entities(from_dim, to_dim, i);
206 closure.insert(vset.begin(), vset.end());
std::set< size_t > entity_closure(const definition< D > &md, U &&indices)
Definition: closure_utils.hh:199
Definition: definition.hh:35
virtual std::set< size_t > entities_set(size_t from_dimension, size_t to_dimension, size_t id) const
Definition: definition.hh:101
#define flog_assert(test, message)
Definition: flog.hh:411
virtual std::vector< size_t > entities(size_t from_dimension, size_t to_dimension, size_t id) const =0
std::set< size_t > entity_referencers(const definition< D > &md, size_t id)
Definition: closure_utils.hh:166
virtual size_t num_entities(size_t dimension) const =0
std::set< size_t > entity_neighbors(const definition< D > &md, size_t entity_id)
Definition: closure_utils.hh:48
Definition: control.hh:31