Interface Documentation
Version: invalid
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 "../utility_types.hh"
25 
26 namespace flecsi {
27 namespace topo {
28 
29 using ntree_entity_base_t = entity_base<0>;
30 
31 /*----------------------------------------------------------------------------*
32  * class tree_entity
33  *----------------------------------------------------------------------------*/
34 
35 //-----------------------------------------------------------------//
42 //-----------------------------------------------------------------//
43 
44 template<size_t DIM, class KEY>
46 {
47 public:
48  enum LOCALITY : int { LOCAL = 0, NON_LOCAL = 1, SHARED = 2 };
49 
50  static constexpr size_t dimension = DIM;
52  using id_t = util::id_t;
53  using key_t = KEY;
54 
55  ntree_entity() : locality_(LOCAL) {}
56  ~ntree_entity() {}
57 
58  ntree_entity(const point_t & coordinates) : coordinates_(coordinates) {}
59 
60  // Setters
61  void set_coordinates(const point_t & coordinates) {
62  coordinates_ = coordinates;
63  }
64  void set_global_id(id_t id) {
65  id_ = id;
66  }
67  void set_key(const key_t & key) {
68  key_ = key;
69  }
70 
71  // Getters
72  key_t key() {
73  return key_;
74  }
75  id_t global_id() {
76  return id_;
77  }
78  point_t coordinates() {
79  return coordinates_;
80  }
81  LOCALITY locality() {
82  return locality_;
83  }
84  size_t owner() {
85  return owner_;
86  }
87  double mass() {
88  return mass_;
89  }
90  double radius() {
91  return radius_;
92  }
93 
94  template<size_t A, class B>
95  friend std::ostream & operator<<(std::ostream & os,
96  const ntree_entity<A, B> & dt);
97 
98 private:
99  point_t coordinates_;
100  double mass_;
101  double radius_;
102  key_t key_;
103  size_t owner_;
104  id_t id_;
105 
106  LOCALITY locality_;
107 
108 }; // class tree_entity
109 
110 template<size_t DIM, class KEY>
111 std::ostream &
112 operator<<(std::ostream & os, const ntree_entity<DIM, KEY> & e) {
113  os << "Entity: p: " << e.coordinates_ << " m: " << e.mass_;
114  os << " id: " << e.id_.entity() << " key: " << e.key_;
115  return os;
116 }
117 
118 //-----------------------------------------------------------------//
125 //-----------------------------------------------------------------//
126 
127 template<size_t DIM, class KEY>
129 {
130 public:
131  static constexpr size_t dimension = DIM;
133  using id_t = util::id_t;
134  using key_t = KEY;
135 
137  ~ntree_entity_holder() {}
138 
139  ntree_entity_holder(const point_t & p) : coordinates_(p) {}
140 
141 private:
142  point_t coordinates_;
143  double mass_;
144  double radius_;
145  key_t key_;
146  int owner_;
147 }; // class tree_entity
148 
149 /*----------------------------------------------------------------------------*
150  * class tree_node_t
151  *----------------------------------------------------------------------------*/
152 
153 //----------------------------------------------------------------------------//
162 //----------------------------------------------------------------------------//
163 
164 template<size_t DIM, class TREE_ENTITY_TYPE, class KEY>
166 {
167 public:
168  enum LOCALITY : int { LOCAL = 0, NON_LOCAL = 1, SHARED = 2 };
169 
170  static constexpr size_t dimension = DIM;
171  using entity_id_t = typename TREE_ENTITY_TYPE::id_t;
172  using id_t = util::id_t;
174  using key_t = KEY;
175 
176  ntree_node() : size_(0), is_leaf_(true) {}
177  ntree_node(const key_t & key) : size_(0), is_leaf_(true) {
178  key_ = key;
179  }
180  ~ntree_node() {}
181 
182  // Setter
183  void set_leaf(const bool & is_leaf) {
184  is_leaf_ = is_leaf;
185  }
186  void set_bit_child(const char & bit_child) {
187  bit_child_ = bit_child;
188  }
189  void set_coordinates(const point_t & coordinates) {
190  coordinates_ = coordinates;
191  }
192  void set_bmin(const point_t & bmin) {
193  bmin_ = bmin;
194  }
195  void set_bmax(const point_t & bmax) {
196  bmax_ = bmax;
197  }
198  void set_mass(const double & mass) {
199  mass_ = mass;
200  }
201  void set_sub_entities(const size_t & sub_entities) {
202  sub_entities_ = sub_entities;
203  }
204 
205  // Getter
206  key_t key() {
207  return key_;
208  }
209  uint32_t size() {
210  return size_;
211  }
212  size_t owner() {
213  return owner_;
214  }
215  size_t sub_entities() {
216  return sub_entities_;
217  }
218  bool requested() {
219  return requested_;
220  }
221  bool ghosts_local() {
222  return ghosts_local_;
223  }
224  LOCALITY locality() {
225  return locality_;
226  }
227  double mass() {
228  return mass_;
229  }
230  point_t coordinates() {
231  return coordinates_;
232  }
233  point_t bmin() {
234  return bmin_;
235  }
236  point_t bmax() {
237  return bmax_;
238  }
239  char bit_child() {
240  return bit_child_;
241  }
242 
243  // Check
244  bool is_leaf() {
245  return is_leaf_;
246  }
247 
251  void insert(const entity_id_t & id) {
252  entities_[size_++] = id;
253  }
254 
255  entity_id_t * begin() {
256  return entities_;
257  }
258  entity_id_t * end() {
259  return entities_ + size_;
260  }
261 
262  void clear() {
263  size_ = 0;
264  }
265  void add_bit_child(char bit) {
266  bit_child_ = bit_child_ | (1 << bit);
267  }
268  bool as_child(int bit) {
269  return bit_child_ & (1 << bit);
270  }
271 
272 private:
273  entity_id_t entities_[1 << dimension];
274  point_t coordinates_;
275  double mass_;
276  point_t bmin_;
277  point_t bmax_;
278  key_t key_;
279  bool is_leaf_;
280  uint32_t size_;
281  char bit_child_;
282  size_t sub_entities_;
283  size_t owner_;
284 
285  bool requested_;
286  bool ghosts_local_;
287 
288  LOCALITY locality_;
289 }; // class ntree_node
290 
291 } // namespace topo
292 } // namespace flecsi
Definition: id.hh:36
void insert(const entity_id_t &id)
Definition: types.hh:251
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
Definition: types.hh:165
Definition: dimensioned_array.hh:58
Definition: types.hh:45
Definition: types.hh:128
Definition: control.hh:31