OpenFPM_pdata  1.1.0
Project that contain the implementation of distributed structures
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Pages
Ghost.hpp
1 /*
2  * Ghost.hpp
3  *
4  * Created on: Apr 28, 2015
5  * Author: Pietro Incardona
6  */
7 
8 #ifndef GHOST_HPP_
9 #define GHOST_HPP_
10 
11 #include "SpaceBox.hpp"
12 
13 #define INVALID_GHOST 9223372036854775807
14 
38 template<unsigned int dim, typename T>
39 class Ghost : public Box<dim,T>
40 {
41 public:
42 
48  template <typename S> inline Ghost(const Ghost<dim,S> & g)
49  {
50  for (size_t i = 0 ; i < dim ; i++)
51  {
52  this->setLow(i,g.getLow(i));
53  this->setHigh(i,g.getHigh(i));
54  }
55  }
56 
57  // construct a ghost based on interaction radius
58  inline Ghost(T r)
59  {
60  for (size_t i = 0 ; i < dim ; i++)
61  {
62  this->setLow(i,-r);
63  this->setHigh(i,r);
64  }
65  }
66 
67  // Basic constructor
68  inline Ghost()
69  {
70  for (size_t i = 0 ; i < dim ; i++)
71  {
72  this->setLow(i,0);
73  this->setHigh(i,0);
74  }
75  }
76 
84  inline Ghost<dim,T> & operator/=(const Point<dim,T> & p)
85  {
87 
88  return *this;
89  }
90 
96  inline bool isInvalidGhost()
97  {
98  for (size_t i = 0 ; i < dim ; i++)
99  {
100  if (this->getLow(i) == -INVALID_GHOST) return true;
101  if (this->getHigh(i) == INVALID_GHOST) return true;
102  }
103 
104  return false;
105  }
106 
107 };
108 
116 template<unsigned int dim>
117 class Padding : public Ghost<dim,long int>
118 {
119 public:
126  Padding(std::initializer_list<long int> p1, std::initializer_list<long int> p2)
127  {
128  Box<dim,long int>::set(p1,p2);
129  }
130 };
131 
132 #endif /* GHOST_HPP_ */
T getLow(int i) const
get the i-coordinate of the low bound interval of the box
Definition: Box.hpp:479
Ghost(const Ghost< dim, S > &g)
Definition: Ghost.hpp:48
T getHigh(int i) const
get the high interval of the box
Definition: Box.hpp:490
Class that contain Padding information on each direction positive and Negative direction.
Definition: Ghost.hpp:117
void setHigh(int i, T val)
set the high interval of the box
Definition: Box.hpp:467
This class implement the point shape in an N-dimensional space.
Definition: Point.hpp:22
Ghost< dim, T > & operator/=(const Point< dim, T > &p)
Divide component wise the ghost box with a point.
Definition: Ghost.hpp:84
Definition: Ghost.hpp:39
static const unsigned int p1
Low point.
Definition: Box.hpp:69
void setLow(int i, T val)
set the low interval of the box
Definition: Box.hpp:456
This class represent an N-dimensional box.
Definition: Box.hpp:56
static const unsigned int p2
High point.
Definition: Box.hpp:71
Box< dim, T > & operator/=(const Point< dim, T > &p)
Divide component wise each box points with a point.
Definition: Box.hpp:391
Padding(std::initializer_list< long int > p1, std::initializer_list< long int > p2)
Constructor from initializer list.
Definition: Ghost.hpp:126
void set(std::initializer_list< T > p1, std::initializer_list< T > p2)
Constructor from initializer list.
Definition: Box.hpp:429
bool isInvalidGhost()
check if the Ghost is valid
Definition: Ghost.hpp:96