Interface Documentation
Version: invalid
utility_types.hh
Go to the documentation of this file.
1 /*
2  @@@@@@@@ @@ @@@@@@ @@@@@@@@ @@
3  /@@///// /@@ @@////@@ @@////// /@@
4  /@@ /@@ @@@@@ @@ // /@@ /@@
5  /@@@@@@@ /@@ @@///@@/@@ /@@@@@@@@@/@@
6  /@@//// /@@/@@@@@@@/@@ ////////@@/@@
7  /@@ /@@/@@//// //@@ @@ /@@/@@
8  /@@ @@@//@@@@@@ //@@@@@@ @@@@@@@@ /@@
9  // /// ////// ////// //////// //
10 
11  Copyright (c) 2016, Triad National Security, LLC
12  All rights reserved.
13  */
14 #pragma once
15 
18 #if !defined(__FLECSI_PRIVATE__)
19 #error Do not include this file directly!
20 #endif
21 
22 #include "flecsi/util/typeify.hh"
23 
24 namespace flecsi {
25 namespace topo {
26 
27 //----------------------------------------------------------------------------//
28 // Type creation utilities to create C++ types from size_t ids.
29 //----------------------------------------------------------------------------//
30 
37 template<size_t TOPOLOGICAL_DIMENSION>
39 
46 template<size_t TOPOLOGICAL_DOMAIN>
48 
55 template<size_t INDEX_SUBSPACE>
57 
58 //----------------------------------------------------------------------------//
59 // Simple Types.
60 //----------------------------------------------------------------------------//
61 
62 using id_vector_t = std::vector<util::id_t>;
63 using connection_vector_t = std::vector<id_vector_t>;
64 
65 // Hash type use for mappings in building topology connectivity
66 
68  size_t operator()(const id_vector_t & v) const {
69  size_t h = 0;
70  for(util::id_t id : v) {
71  h |= static_cast<size_t>(id.local_id());
72  } // for
73 
74  return h;
75  } // operator()
76 
77 }; // struct id_vector_hash_t
78 
79 // Map type used when building the topology connectivities.
80 
81 using id_vector_map_t =
82  std::unordered_map<id_vector_t, util::id_t, id_vector_hash_t>;
83 
84 // The second topology vector holds the offsets into to from dimension
85 
86 using index_vector_t = std::vector<size_t>;
87 //-----------------------------------------------------------------//
93 //-----------------------------------------------------------------//
94 
96 {
97 public:
98  using id_t = util::id_t;
99 };
100 
101 template<size_t NUM_DOMAINS>
102 class entity_base : public entity_base_
103 {
104 public:
105  ~entity_base() {}
106 
107  //-----------------------------------------------------------------//
111  //-----------------------------------------------------------------//
112  template<size_t DOM = 0>
113  id_t global_id() const {
114  return ids_[DOM];
115  } // id
116 
117  id_t global_id(size_t domain) const {
118  return ids_[domain];
119  } // id
120 
121  template<size_t DOM = 0>
122  size_t id() const {
123  return ids_[DOM].entity();
124  } // id
125 
126  size_t id(size_t domain) const {
127  return ids_[domain].entity();
128  } // id
129 
130  template<size_t DOM = 0>
131  uint16_t info() const {
132  return ids_[DOM] >> 48;
133  } // info
134 
135  //-----------------------------------------------------------------//
137  //-----------------------------------------------------------------//
138  template<size_t DOM = 0>
139  void set_global_id(const id_t & id) {
140  ids_[DOM] = id;
141  } // id
142 
146  static constexpr size_t get_dim_(size_t meshDim, size_t dim) {
147  return dim > meshDim ? meshDim : dim;
148  } // get_dim_
149 
150 protected:
151  template<size_t DOM = 0>
152  void set_info(uint16_t info) {
153  ids_[DOM] = (uint64_t(info) << 48) | ids_[DOM];
154  } // set_info
155 
156 private:
157  std::array<id_t, NUM_DOMAINS> ids_;
158 
159 }; // class entity_base
160 
161 //-----------------------------------------------------------------//
165 //-----------------------------------------------------------------//
166 template<size_t NUM_DOMAINS>
167 using entity_vector_t = std::vector<entity_base<NUM_DOMAINS> *>;
168 
169 } // namespace topo
170 } // namespace flecsi
Definition: id.hh:36
id_t global_id() const
Definition: utility_types.hh:113
Definition: utility_types.hh:67
Definition: typeify.hh:31
entity_base defines a base class that stores the raw info that a topology needs, i.e: id and rank data
Definition: utility_types.hh:102
void set_global_id(const id_t &id)
Set the id of this entity.
Definition: utility_types.hh:139
std::vector< entity_base< NUM_DOMAINS > * > entity_vector_t
Definition: utility_types.hh:167
Definition: utility_types.hh:95
Definition: control.hh:31