1 #ifndef OMEGA_H_MESH_HPP
2 #define OMEGA_H_MESH_HPP
4 #include <Omega_h_adj.hpp>
5 #include <Omega_h_comm.hpp>
6 #include <Omega_h_dist.hpp>
7 #include <Omega_h_library.hpp>
8 #include <Omega_h_tag.hpp>
23 inline ClassPair(Int t_dim, LO t_id) : dim(t_dim), id(t_id) {}
26 OMEGA_H_INLINE
bool operator<(
ClassPair const& other)
const {
27 if (dim != other.dim)
return dim < other.dim;
28 if (
id != other.id)
return id < other.id;
33 using ClassSets = std::map<std::string, std::vector<ClassPair>>;
39 void set_library(
Library* library);
40 void set_comm(CommPtr
const& comm);
41 void set_family(Omega_h_Family family);
42 void set_matched(I8 is_matched);
43 virtual void set_dim(Int dim_in);
44 void set_verts(LO nverts_in);
45 void set_ents(Int ent_dim,
Adj down);
46 void set_parents(Int ent_dim,
Parents parents);
49 Omega_h_Parting parting()
const;
50 virtual inline Int dim()
const {
51 OMEGA_H_CHECK(0 <= dim_ && dim_ <= 3);
54 inline Omega_h_Family family()
const {
return family_; }
55 inline I8 is_matched()
const {
return matched_; }
56 LO nents(Int ent_dim)
const;
62 GO nglobal_ents(Int dim);
64 void add_tag(Int dim, std::string
const& name, Int ncomps);
66 void add_tag(Int dim, std::string
const& name, Int ncomps, ArrayType array_type);
68 void add_tag(Int dim, std::string
const& name, Int ncomps,
Read<T> array,
69 bool internal =
false, ArrayType array_type = ArrayType::VectorND);
72 Int dim, std::string
const& name,
Read<T> array,
bool internal =
false, ArrayType array_type = ArrayType::VectorND);
73 TagBase const* get_tagbase(Int dim, std::string
const& name)
const;
75 Tag<T> const* get_tag(Int dim, std::string
const& name)
const;
77 Read<T> get_array(Int dim, std::string
const& name)
const;
78 void remove_tag(Int dim, std::string
const& name);
79 bool has_tag(Int dim, std::string
const& name)
const;
80 [[nodiscard]] Int ntags(Int dim)
const;
81 [[nodiscard]] Int nrctags(Int dim)
const;
82 TagBase const* get_tag(Int dim, Int i)
const;
83 bool has_ents(Int dim)
const;
84 bool has_adj(Int from, Int to)
const;
85 Adj get_adj(Int from, Int to)
const;
86 Adj ask_down(Int from, Int to);
87 LOs ask_verts_of(Int dim);
89 Adj ask_up(Int from, Int to);
90 Graph ask_star(Int dim);
132 template <
typename T>
134 LOs class_ids, Int ent_dim, std::string
const& name, Int ncomps);
139 template <
typename T>
147 [[nodiscard]]
Adj get_revClass(Int edim)
const;
154 template <
typename T>
155 void add_rcField(Int ent_dim, std::string
const& name, Int ncomps);
157 template <
typename T>
158 [[nodiscard]]
Read<T> get_rcField_array(
159 Int ent_dim, std::string
const& name)
const;
160 void reduce_rcField(Int ent_dim, std::string
const& name, Omega_h_Op op);
161 template <
typename T>
163 Int ent_dim, std::string
const& name, Int ncomps,
Read<T> array);
164 void sync_rcField(Int ent_dim, std::string
const& name);
165 [[nodiscard]]
bool has_rcField(Int ent_dim, std::string
const& name)
const;
167 template <
typename T>
168 void set_rc_from_mesh_array(Int ent_dim, Int ncomps,
LOs class_ids,
169 std::string
const& name,
Read<T> array);
172 #if defined(OMEGA_H_USE_KOKKOS)
185 [[nodiscard]]
Graph get_vtx_patches(Int minPatchSize, Int tgtDim = -1);
190 bool change_all_rcFieldsToMesh();
191 bool change_all_rcFieldsTorc();
192 template <
typename T>
193 void change_tagTorc(Int ent_dim, Int ncomps, std::string
const& name,
194 LOs class_ids,
bool remove =
true);
195 template <
typename T>
196 void change_tagToMesh(Int ent_dim, Int ncomps, std::string
const& name,
197 LOs class_ids,
bool remove =
true);
200 template <
typename T>
201 [[nodiscard]]
Read<T> get_rc_mesh_array(
202 Int ent_dim, Int ncomps, std::string
const& name,
LOs class_ids);
204 template <
typename T>
205 [[nodiscard]]
Read<T> get_rc_array_from_mesh_array(Int ent_dim, Int ncomps,
206 std::string
const& name,
LOs class_ids,
Read<T> mesh_array);
208 template <
typename T>
209 [[nodiscard]] std::unique_ptr<Tag<T>> get_rc_mesh_tag_from_rc_tag(
212 template <
typename T>
213 [[nodiscard]]
Read<T> get_rc_array(Int dim, std::string
const& name)
const;
215 template <
typename T>
216 [[nodiscard]]
Read<T> get_rc_mesh_array_from_rc_array(
217 Int ent_dim, Int ncomps,
LOs class_ids,
Read<T> rc_field);
220 typedef std::shared_ptr<const TagBase> TagPtr;
221 typedef std::shared_ptr<const Adj> AdjPtr;
222 typedef std::shared_ptr<const Dist> DistPtr;
223 typedef std::shared_ptr<const inertia::Rib> RibPtr;
224 typedef std::shared_ptr<const Parents> ParentPtr;
225 typedef std::shared_ptr<const Children> ChildrenPtr;
228 typedef std::vector<TagPtr> TagVector;
229 typedef TagVector::iterator TagIter;
230 typedef TagVector::const_iterator TagCIter;
231 struct TagIterResult {
235 struct TagCIterResult {
239 TagIter tag_iter(Int dim, std::string
const& name);
240 TagCIter tag_iter(Int dim, std::string
const& name)
const;
241 TagIterResult rc_tag_iter(Int dim, std::string
const& name);
242 TagCIterResult rc_tag_iter(Int dim, std::string
const& name)
const;
243 void check_dim(Int dim)
const;
244 void check_dim2(Int dim)
const;
245 void add_adj(Int from, Int to,
Adj adj);
246 Adj derive_adj(Int from, Int to);
247 Adj ask_adj(Int from, Int to);
248 void react_to_set_tag(Int dim, std::string
const& name);
249 Omega_h_Family family_;
255 TagVector tags_[DIMS];
257 TagVector rc_field_tags_[DIMS];
258 AdjPtr adjs_[DIMS][DIMS];
260 DistPtr dists_[DIMS];
262 ParentPtr parents_[DIMS];
263 ChildrenPtr children_[DIMS][DIMS];
266 LOs model_ents_[DIMS];
267 LOs model_matches_[DIMS - 1];
269 AdjPtr revClass_[DIMS];
271 void add_rcField(Int ent_dim, std::string
const& name, TagPtr tag);
277 void add_coords(
Reals array);
278 Reals coords()
const;
279 void set_coords(
Reals const& array);
282 Reals ask_qualities();
285 Bytes ask_levels(Int dim);
286 Bytes ask_leaves(Int dim);
287 Parents ask_parents(Int child_dim);
288 Children ask_children(Int parent_dim, Int child_dim);
289 bool has_any_parents()
const;
290 void set_owners(Int dim,
Remotes owners);
293 Dist ask_dist(Int dim);
294 Int nghost_layers()
const;
295 void set_parting(Omega_h_Parting parting_in, Int nlayers,
bool verbose);
296 void set_parting(Omega_h_Parting parting_in,
bool verbose =
false);
297 void balance(
bool predictive =
false);
298 void balance(
Reals weights);
308 Graph ask_graph(Int from, Int to);
309 template <
typename T>
311 template <
typename T>
313 template <
typename T>
315 Int ent_dim,
Read<T> a_data,
LOs a2e, T default_val, Int width);
316 template <
typename T>
317 Read<T> reduce_array(Int ent_dim,
Read<T> a, Int width, Omega_h_Op op);
318 template <
typename T>
320 template <
typename T>
322 Int ent_dim,
Read<T> a_data,
LOs a2e, T default_val, Int width);
323 void sync_tag(Int dim, std::string
const& name);
324 void reduce_tag(Int dim, std::string
const& name, Omega_h_Op op);
325 bool operator==(
Mesh& other);
328 bool could_be_shared(Int ent_dim)
const;
329 bool owners_have_all_upward(Int ent_dim)
const;
330 bool have_all_upward()
const;
331 Mesh copy_meta()
const;
332 RibPtr rib_hints()
const;
333 void set_rib_hints(RibPtr hints);
334 Real imbalance(Int ent_dim = -1)
const;
335 Adj derive_revClass(Int edim, I8 should_sort = -1);
337 void set_model_ents(Int ent_dim,
LOs Ids);
338 void set_model_matches(Int ent_dim,
LOs matches);
339 LOs get_model_ents(Int ent_dim);
340 LOs get_model_matches(Int ent_dim);
341 void set_match_owners(Int dim,
Remotes owners);
342 Remotes ask_match_owners(Int dim);
344 void set_matches(Int dim,
c_Remotes matches);
346 void swap_root_owner(Int dim);
347 void sync_tag_matched(Int dim, std::string
const& name);
348 template <
typename T>
350 Real ghosted_ratio(Int ent_dim);
351 LO nents_owned(Int ent_dim);
352 std::string string(
int verbose = 0);
354 virtual ~
Mesh() =
default;
364 [[nodiscard]]
const TagVector& get_rc_tags(Int dim)
const {
365 return rc_field_tags_[dim];
367 [[nodiscard]] std::unique_ptr<TagBase> get_rc_mesh_tag_from_rc_tag(
375 changed_here_ = mesh_.change_all_rcFieldsToMesh();
379 mesh_.change_all_rcFieldsTorc();
382 [[nodiscard]]
bool did_conversion()
const noexcept {
return changed_here_; }
389 bool can_print(
Mesh* mesh);
391 Real repro_sum_owned(
Mesh* mesh, Int dim,
Reals a);
396 using TagSet = std::array<std::set<std::string>, DIMS>;
398 void get_all_dim_tags(
Mesh* mesh, Int dim, TagSet* tags);
399 TagSet get_all_mesh_tags(
Mesh* mesh);
400 void ask_for_mesh_tags(
Mesh* mesh, TagSet
const& tags);
402 void reorder_by_hilbert(
Mesh* mesh);
403 void reorder_by_globals(
Mesh* mesh);
406 Mesh* mesh, std::set<std::string>
const& class_names, Int ent_dim);
408 LOs nodes_on_closure(
409 Mesh* mesh, std::set<std::string>
const& class_names,
Graph nodes2ents[4]);
411 bool is_rc_tag(std::string
const& name);
413 void assign(
Mesh& a,
Mesh const& b);
415 #define OMEGA_H_EXPL_INST_DECL(T) \
416 extern template Tag<T> const* Mesh::get_tag<T>( \
417 Int dim, std::string const& name) const; \
418 extern template Read<T> Mesh::get_array<T>(Int dim, std::string const& name) \
420 extern template void Mesh::add_tag<T>( \
421 Int dim, std::string const& name, Int ncomps); \
422 extern template void Mesh::add_tag<T>( \
423 Int dim, std::string const& name, Int ncomps, ArrayType array_type); \
424 extern template void Mesh::add_tag<T>(Int dim, std::string const& name, \
425 Int ncomps, Read<T> array, bool internal, ArrayType array_type); \
426 extern template void Mesh::set_tag(Int dim, std::string const& name, \
427 Read<T> array, bool internal, ArrayType array_type); \
428 extern template Read<T> Mesh::sync_array(Int ent_dim, Read<T> a, Int width); \
429 extern template Future<T> Mesh::isync_array( \
430 Int ent_dim, Read<T> a, Int width); \
431 extern template Read<T> Mesh::owned_array( \
432 Int ent_dim, Read<T> a, Int width); \
433 extern template Read<T> Mesh::sync_subset_array( \
434 Int ent_dim, Read<T> a_data, LOs a2e, T default_val, Int width); \
435 extern template Read<T> Mesh::owned_subset_array( \
436 Int ent_dim, Read<T> a_data, LOs a2e, T default_val, Int width); \
437 extern template Read<T> Mesh::reduce_array( \
438 Int ent_dim, Read<T> a, Int width, Omega_h_Op op); \
439 extern template void Mesh::change_tagTorc<T>( \
440 Int ent_dim, Int ncomps, std::string const& name, LOs class_ids, bool); \
441 extern template void Mesh::change_tagToMesh<T>( \
442 Int ent_dim, Int ncomps, std::string const& name, LOs class_ids, bool); \
443 extern template Read<T> Mesh::get_rc_mesh_array( \
444 Int ent_dim, Int ncomps, std::string const& name, LOs class_ids); \
445 extern template Read<T> Mesh::get_rc_array_from_mesh_array(Int ent_dim, \
446 Int ncomps, std::string const& name, LOs class_ids, Read<T> mesh_array); \
447 extern template Read<T> Mesh::get_rcField_array<T>( \
448 Int dim, std::string const& name) const; \
449 extern template void Mesh::add_rcField<T>( \
450 Int dim, std::string const& name, Int ncomps); \
451 extern template void Mesh::add_rcField<T>( \
452 LOs class_ids, Int dim, std::string const& name, Int ncomps); \
453 extern template void Mesh::add_rcField<T>( \
454 Int dim, std::string const& name, Int ncomps, Read<T> array); \
455 extern template void Mesh::set_rcField_array( \
456 Int dim, std::string const& name, Read<T> array); \
457 extern template void Mesh::set_rc_from_mesh_array(Int ent_dim, Int ncomps, \
458 LOs class_ids, std::string const& name, Read<T> array); \
459 extern template std::unique_ptr<Tag<T>> Mesh::get_rc_mesh_tag_from_rc_tag( \
460 Int, Tag<T> const*); \
461 extern template Read<T> Mesh::get_rc_array(Int dim, std::string const& name) \
463 extern template Read<T> Mesh::get_rc_mesh_array_from_rc_array( \
464 Int ent_dim, Int ncomps, LOs class_ids, Read<T> rc_field);
465 OMEGA_H_EXPL_INST_DECL(I8)
466 OMEGA_H_EXPL_INST_DECL(I32)
467 OMEGA_H_EXPL_INST_DECL(I64)
468 OMEGA_H_EXPL_INST_DECL(Real)
469 #undef OMEGA_H_EXPL_INST_DECL
an MPI distributor object which encapsulates the idea of a communication pattern between lots of smal...
Definition: Omega_h_dist.hpp:119
Abstraction for asynchronous communication.
Definition: Omega_h_future.hpp:19
Definition: Omega_h_library.hpp:10
Definition: Omega_h_mesh.hpp:35
void add_rcField(LOs class_ids, Int ent_dim, std::string const &name, Int ncomps)
Definition: Omega_h_rcFields.cpp:356
Adj ask_revClass_downAdj(Int from, Int to)
Definition: Omega_h_rcFields.cpp:496
Reals ask_sizes()
Definition: Omega_h_mesh.cpp:445
bool has_revClass(Int edim) const
Definition: Omega_h_rcFields.cpp:62
void migrate(Remotes &owners)
Definition: Omega_h_mesh.cpp:652
ClassSets class_sets
Definition: Omega_h_mesh.hpp:363
void set_rcField_array(Int ent_dim, std::string const &name, Read< T > array)
Definition: Omega_h_rcFields.cpp:397
void remove_rcField(Int ent_dim, std::string const &name)
Definition: Omega_h_rcFields.cpp:388
Adj ask_revClass(Int edim, LOs class_ids)
Definition: Omega_h_rcFields.cpp:154
Definition: Omega_h_array.hpp:89
Definition: Omega_h_mesh.hpp:371
Definition: Omega_h_tag.hpp:31
Definition: Omega_h_tag.hpp:53
Definition: amr_mpi_test.cpp:6
Definition: Omega_h_adj.hpp:11
Definition: Omega_h_adj.hpp:30
Definition: Omega_h_mesh.hpp:21
directed graph (as defined by graph theory) in compressed row format
Definition: Omega_h_graph.hpp:22
Definition: Omega_h_adj.hpp:22
Definition: Omega_h_remotes.hpp:9
Definition: Omega_h_remotes.hpp:23