58 auto entity_storage() {
59 return index_space_.storage();
62 template<
class STORAGE_TYPE>
63 void set_entity_storage(STORAGE_TYPE s) {
64 index_space_.set_storage(s);
81 void init(
const connection_vector_t & cv) {
87 size_t start = index_space_.begin_push_();
91 for(
size_t i = 0; i < n; ++i) {
92 const id_vector_t & iv = cv[i];
95 index_space_.batch_push_(
id);
98 offsets_.add_count(static_cast<std::uint32_t>(iv.size()));
101 index_space_.end_push_(start);
109 void resize(index_vector_t & num_conns) {
112 size_t n = num_conns.size();
116 for(
size_t i = 0; i < n; ++i) {
117 uint32_t count =
static_cast<std::uint32_t
>(num_conns[i]);
118 offsets_.add_count(count);
122 index_space_.resize_(size);
123 index_space_.fill_(
id_t(0));
130 index_space_.push_(
id);
136 std::ostream &
dump(std::ostream & stream) {
137 for(
size_t i = 0; i < offsets_.size(); ++i) {
139 for(
size_t j = 0; j < oi.
count(); ++j) {
140 stream << index_space_(oi.
start() + j).entity() << std::endl;
145 stream <<
"=== indices" << std::endl;
146 for(
id_t id : index_space_.ids()) {
147 stream <<
id.entity() << std::endl;
150 stream <<
"=== offsets" << std::endl;
151 for(
size_t i = 0; i < offsets_.size(); ++i) {
153 stream << oi.
start() <<
" : " << oi.
count() << std::endl;
166 return index_space_.id_storage();
172 assert(index < offsets_.size());
173 return index_space_.id_array() + offsets_[index].start();
180 assert(index < offsets_.size());
183 return index_space_.id_array() + o.start();
190 assert(index < offsets_.size());
192 return util::make_array_ref(index_space_.id_array() + o.start(), o.count());
199 assert(index < offsets_.size());
201 std::reverse(index_space_.index_begin_() + o.start(),
202 index_space_.index_begin_() + o.end());
210 assert(index < offsets_.size());
212 assert(order.size() == o.count());
214 order.begin(), order.end(), index_space_.id_array() + o.start());
221 return index_space_.empty();
227 void set(
size_t from_local_id,
id_t to_id,
size_t pos) {
228 index_space_(offsets_[from_local_id].
start() + pos) = to_id;
235 return offsets_.size();
242 return index_space_.size();
248 template<
size_t DOM,
size_t NUM_DOMAINS>
252 size_t n = conns.size();
256 for(
size_t i = 0; i < n; i++) {
257 uint32_t count = conns[i].size();
258 offsets_.add_count(count);
262 index_space_.begin_push_(size);
264 for(
size_t i = 0; i < n; ++i) {
265 const id_vector_t & conn = conns[i];
266 uint64_t m = conn.size();
268 for(
size_t j = 0; j < m; ++j) {
269 index_space_.batch_push_(ev[conn[j]]->
template global_id<DOM>());
274 const auto & to_id_storage()
const {
275 return index_space_.id_storage();
278 auto & to_id_storage() {
279 return index_space_.id_storage_();
282 auto & get_index_space() {
286 auto & get_index_space()
const {
290 auto range(
size_t i)
const {
291 return offsets_.range(i);
298 const auto & offsets()
const {
302 void add_count(uint32_t count) {
303 offsets_.add_count(count);
311 offsets_.add_end(index_space_.size());
connectivity_t()
Constructor.
Definition: connectivity.hh:56
size_t to_size() const
Return the number of to entities.
Definition: connectivity.hh:241
void reorder_entities(size_t index, U &&order)
Get the entities of the specified from index and return the count.
Definition: connectivity.hh:209
Definition: entity_storage.hh:28
uint32_t count() const
Get the count (number) of elements represented by this offset range.
Definition: offset.hh:91
void push(id_t id)
Push a single id into the current from group.
Definition: connectivity.hh:129
auto get_entity_vec(size_t index) const
Get the entities of the specified from index and return the count.
Definition: connectivity.hh:189
std::ostream & dump(std::ostream &stream)
Debugging method. Dump the raw vectors of the connection.
Definition: connectivity.hh:136
offset represents an offset range (a start index plus a count of elements) in a single uint64_t...
Definition: offset.hh:34
bool empty() const
True if the connectivity is empty (hasn't been populated).
Definition: connectivity.hh:220
void resize(index_vector_t &num_conns)
Definition: connectivity.hh:109
uint64_t start() const
Get the start index of the offset range.
Definition: offset.hh:82
int start(const std::function< int()> &action)
Definition: execution.hh:69
id_t * get_entities(size_t index, size_t &count)
Get the entities of the specified from index and return the count.
Definition: connectivity.hh:179
Definition: index_space.hh:85
void reverse_entities(size_t index)
Get the entities of the specified from index and return the count.
Definition: connectivity.hh:198
void init(const connection_vector_t &cv)
Definition: connectivity.hh:81
std::vector< entity_base< NUM_DOMAINS > * > entity_vector_t
Definition: utility_types.hh:167
size_t from_size() const
Return the number of from entities.
Definition: connectivity.hh:234
const auto & get_entities() const
Get the to id's vector.
Definition: connectivity.hh:165
connectivity_t provides basic connectivity information in a compressed storage format.
Definition: connectivity.hh:41
id_t * get_entities(size_t index)
Get the entities of the specified from index.
Definition: connectivity.hh:171
void clear()
Clear the storage arrays for this instance.
Definition: connectivity.hh:70
void end_from()
Definition: connectivity.hh:310
Definition: control.hh:31