OpenFPM_pdata  1.1.0
Project that contain the implementation of distributed structures
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Pages
grid_dist_id_iterator_util.hpp
1 /*
2  * grid_dist_id_iterator_util.hpp
3  *
4  * Created on: Jan 6, 2017
5  * Author: i-bird
6  */
7 
8 #ifndef SRC_GRID_ITERATORS_GRID_DIST_ID_ITERATOR_UTIL_HPP_
9 #define SRC_GRID_ITERATORS_GRID_DIST_ID_ITERATOR_UTIL_HPP_
10 
11 
23 template<typename Decomposition> static inline bool compute_subset(const openfpm::vector<GBoxes<Decomposition::dims>> & gdb_ext, size_t g_c, grid_key_dx<Decomposition::dims> & start, grid_key_dx<Decomposition::dims> & stop, grid_key_dx<Decomposition::dims> & start_c, grid_key_dx<Decomposition::dims> & stop_c)
24 {
25  // Intersect the grid keys
26 
27  for (size_t i = 0 ; i < Decomposition::dims ; i++)
28  {
29  long int start_p = gdb_ext.get(g_c).Dbox.getP1().get(i) + gdb_ext.get(g_c).origin.get(i);
30  long int stop_p = gdb_ext.get(g_c).Dbox.getP2().get(i) + gdb_ext.get(g_c).origin.get(i);
31  if (start.get(i) <= start_p)
32  start_c.set_d(i,gdb_ext.get(g_c).Dbox.getP1().get(i));
33  else if (start.get(i) <= stop_p)
34  start_c.set_d(i,start.get(i) - gdb_ext.get(g_c).origin.get(i));
35  else
36  return false;
37 
38  if (stop.get(i) >= stop_p)
39  stop_c.set_d(i,gdb_ext.get(g_c).Dbox.getP2().get(i));
40  else if (stop.get(i) >= start_p)
41  stop_c.set_d(i,stop.get(i) - gdb_ext.get(g_c).origin.get(i));
42  else
43  return false;
44  }
45 
46  return true;
47 }
48 
49 
50 
51 #endif /* SRC_GRID_ITERATORS_GRID_DIST_ID_ITERATOR_UTIL_HPP_ */
mem_id get(size_t i) const
Get the i index.
Definition: grid_key.hpp:394
This structure store the Box that define the domain inside the Ghost + domain box.
Definition: GBoxes.hpp:39
void set_d(size_t i, mem_id id)
Set the i index.
Definition: grid_key.hpp:407
Implementation of 1-D std::vector like structure.
Definition: map_vector.hpp:61