18 #if !defined(__FLECSI_PRIVATE__) 19 #error Do not include this file directly! 22 #include "../entity_storage.hh" 23 #include "../index_space.hh" 34 template<
size_t,
size_t>
40 template<
size_t NUM_DIMS,
size_t NUM_DOMAINS,
size_t NUM_INDEX_SUBSPACES>
42 static constexpr
size_t num_partitions = 5;
46 using index_spaces_t = std::array<
58 using partition_index_spaces_t = std::array<
index_space<mesh_entity_base_ *,
67 std::array<std::array<domain_connectivity<NUM_DIMS>, NUM_DOMAINS>,
71 std::array<index_spaces_t, NUM_DOMAINS> index_spaces;
73 index_subspaces_t index_subspaces;
75 std::array<std::array<partition_index_spaces_t, NUM_DOMAINS>, num_partitions>
76 partition_index_spaces;
81 auto & context_ = run::context::instance();
82 color = context_.color();
85 void init_entities(
size_t domain,
87 mesh_entity_base_ * entities,
95 auto & is = index_spaces[domain][dim];
97 auto s = is.storage();
98 s->set_buffer(entities, num_entities, read);
100 auto & id_storage = is.id_storage();
101 id_storage.set_buffer(ids, num_entities,
true);
103 for(
auto & domain_connectivities : topology) {
105 for(
size_t d = 0; d <= NUM_DIMS; ++d) {
114 is.set_end(num_entities);
116 size_t shared_end = num_exclusive + num_shared;
117 size_t ghost_end = shared_end + num_ghost;
119 for(
size_t partition = 0; partition < num_partitions; ++partition) {
120 auto & isp = partition_index_spaces[partition][domain][dim];
122 isp.set_id_storage(&id_storage);
124 switch(partition_t(partition)) {
127 isp.set_end(num_exclusive);
130 isp.set_begin(num_exclusive);
131 isp.set_end(shared_end);
134 isp.set_begin(shared_end);
135 isp.set_end(ghost_end);
139 isp.set_end(shared_end);
147 void init_index_subspace(
size_t,
155 auto & context_ = run::context::instance();
156 auto & ssm = context_.index_subspace_info();
157 auto itr = ssm.find(index_subspace);
158 flog_assert(itr != ssm.end(),
"invalid index subspace");
161 auto & is = index_spaces[domain][dim];
162 auto & iss = index_subspaces[index_subspace];
164 iss.set_storage(is.storage());
166 auto & id_storage = iss.id_storage();
167 id_storage.set_buffer(ids, si.capacity, si.size);
173 iss.set_end(si.size);
176 void init_connectivity(
size_t from_domain,
189 auto & conn = topology[from_domain][to_domain].get(from_dim, to_dim);
191 auto & id_storage = conn.get_index_space().id_storage();
192 id_storage.set_buffer(indices, num_indices, read);
194 conn.offsets().storage().set_buffer(offsets, num_offsets, read);
197 conn.get_index_space().set_end(num_indices);
201 template<
class T,
size_t DOM,
class... ARG_TYPES>
202 T * make(ARG_TYPES &&... args) {
205 auto & is = index_spaces[DOM][T::dimension].template cast<dtype>();
206 size_t entity = is.size();
208 auto placement_ptr =
static_cast<T *
>(is.storage()->buffer()) + entity;
209 auto ent =
new(placement_ptr) T(std::forward<ARG_TYPES>(args)...);
211 id_t global_id = id_t::make<T::dimension, DOM>(entity, color);
212 ent->template set_global_id<DOM>(global_id);
214 auto & id_storage = is.id_storage();
216 id_storage[entity] = global_id;
223 template<
class T,
size_t DOM,
class... ARG_TYPES>
224 T * make(
const id_t &
id, ARG_TYPES &&... args) {
227 auto & is = index_spaces[DOM][T::dimension].template cast<dtype>();
229 size_t entity =
id.entity();
231 auto placement_ptr =
static_cast<T *
>(is.storage()->buffer()) + entity;
232 auto ent =
new(placement_ptr) T(std::forward<ARG_TYPES>(args)...);
234 ent->template set_global_id<DOM>(id);
236 auto & id_storage = is.id_storage();
238 id_storage[entity] = id;
Definition: context.hh:78
Definition: typeify.hh:31
offset represents an offset range (a start index plus a count of elements) in a single uint64_t...
Definition: offset.hh:34
Definition: array_buffer.hh:71
#define flog_assert(test, message)
Definition: flog.hh:411
mesh_entity parameterizes a mesh entity base with its dimension and number of domains ...
Definition: storage.hh:35
Definition: index_space.hh:85
Definition: storage.hh:41
domain_entity is a simple wrapper to mesh entity that associates with its a domain id ...
Definition: array_buffer.hh:24
Definition: utility_types.hh:95
Definition: control.hh:31