omega_h
Reliable mesh adaptation
Omega_h_mixedMesh.hpp
1 #ifndef OMEGA_H_MIXEDMESH_HPP
2 #define OMEGA_H_MIXEDMESH_HPP
3 
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>
9 #include <array>
10 #include <map>
11 #include <set>
12 #include <string>
13 #include <vector>
14 
15 namespace Omega_h {
16 
17 class MixedMesh {
18  public:
19  MixedMesh();
20  MixedMesh(Library* library);
21  void set_library(Library* library);
22  void set_comm(CommPtr const& new_comm);
23  void set_dim(Int dim_in);
24  void set_verts(LO nverts_in);
25  void set_ents(Int ent_dim, Adj down);
26  Library* library() const;
27  CommPtr comm() const;
28  inline Int dim() const {
29  OMEGA_H_CHECK(0 <= dim_ && dim_ <= 3);
30  return dim_;
31  }
32  inline Omega_h_Family family() const { return family_; }
33 
34  void set_verts_type(LO nverts_in);
35  void set_ents(Topo_type high_type, Topo_type low_type, Adj h2l);
36  LO nents(Topo_type ent_type) const;
37  Int ent_dim(Topo_type ent_type) const;
38 
39  LO npyrams() const;
40  LO nwedges() const;
41  LO nhexs() const;
42  LO ntets() const;
43  LO nquads() const;
44  LO ntris() const;
45  LO nregions_mix() const;
46  LO nfaces_mix() const;
47  LO nedges_mix() const;
48  LO nverts_mix() const;
49 
50  template <typename T>
51  void add_tag(Topo_type ent_type, std::string const& name, Int ncomps);
52  template <typename T>
53  void add_tag(Topo_type ent_type, std::string const& name, Int ncomps,
54  Read<T> array, bool internal = false);
55  template <typename T>
56  void set_tag(Topo_type ent_type, std::string const& name, Read<T> array,
57  bool internal = false);
58  TagBase const* get_tagbase(Topo_type ent_type, std::string const& name) const;
59  template <typename T>
60  Tag<T> const* get_tag(Topo_type ent_type, std::string const& name) const;
61  template <typename T>
62  Read<T> get_array(Topo_type ent_type, std::string const& name) const;
63  void remove_tag(Topo_type ent_type, std::string const& name);
64  bool has_tag(Topo_type ent_type, std::string const& name) const;
65  [[nodiscard]] Int ntags(Topo_type ent_type) const;
66  TagBase const* get_tag(Topo_type ent_type, Int i) const;
67  bool has_ents(Topo_type ent_type) const;
68  bool has_adj(Topo_type from_type, Topo_type to_type) const;
69  Adj get_adj(Topo_type from_type, Topo_type to_type) const;
70  Adj ask_down(Topo_type from_type, Topo_type to_type);
71  LOs ask_verts_of(Topo_type ent_type);
72  Adj ask_up(Topo_type from_type, Topo_type to_type);
73 
74  typedef std::shared_ptr<const TagBase> TagPtr;
75  typedef std::shared_ptr<const Adj> AdjPtr;
76 
77  private:
78  typedef std::vector<TagPtr> TagVector;
79  typedef TagVector::iterator TagIter;
80  typedef TagVector::const_iterator TagCIter;
81  TagIter tag_iter(Topo_type ent_type, std::string const& name);
82  TagCIter tag_iter(Topo_type ent_type, std::string const& name) const;
83  void check_type(Topo_type ent_type) const;
84  void check_type2(Topo_type ent_type) const;
85  void add_adj(Topo_type from_type, Topo_type to_type, Adj adj);
86  Adj derive_adj(Topo_type from_type, Topo_type to_type);
87  Adj ask_adj(Topo_type from_type, Topo_type to_type);
88  void react_to_set_tag(Topo_type ent_type, std::string const& name);
89  Library* library_;
90  Omega_h_Family family_;
91  Int dim_;
92  CommPtr comm_;
93  LO nents_[DIMS];
94  TagVector tags_[DIMS];
95  LO nents_type_[TOPO_TYPES];
96  TagVector tags_type_[TOPO_TYPES];
97  AdjPtr adjs_type_[TOPO_TYPES][TOPO_TYPES];
98 
99  public:
100  void add_coords_mix(Reals array);
101  Reals coords_mix() const;
102 };
103 
104 using TagSet = std::array<std::set<std::string>, DIMS>;
105 
106 void get_all_type_tags(MixedMesh* mesh, Int dim, Topo_type ent_type, TagSet* tags);
107 
108 #define OMEGA_H_EXPL_INST_DECL(T) \
109  extern template Read<T> MixedMesh::get_array<T>( \
110  Topo_type ent_type, std::string const& name) const; \
111  extern template void MixedMesh::add_tag<T>( \
112  Topo_type ent_type, std::string const& name, Int ncomps); \
113  extern template void MixedMesh::add_tag<T>(Topo_type ent_type, \
114  std::string const& name, Int ncomps, Read<T> array, bool internal); \
115  extern template void MixedMesh::set_tag(Topo_type ent_type, \
116  std::string const& name, Read<T> array, bool internal);
117 OMEGA_H_EXPL_INST_DECL(I8)
118 OMEGA_H_EXPL_INST_DECL(I32)
119 OMEGA_H_EXPL_INST_DECL(I64)
120 OMEGA_H_EXPL_INST_DECL(Real)
121 #undef OMEGA_H_EXPL_INST_DECL
122 
123 } // namespace Omega_h
124 
125 #endif
Definition: Omega_h_library.hpp:10
Definition: Omega_h_mixedMesh.hpp:17
Definition: Omega_h_array.hpp:89
Definition: Omega_h_tag.hpp:31
Definition: Omega_h_tag.hpp:53
Definition: amr_mpi_test.cpp:6
Definition: Omega_h_adj.hpp:11