rheolef  6.3
distributor.h
Go to the documentation of this file.
1 #ifndef _RHEO_DISTRIBUTOR_H
2 #define _RHEO_DISTRIBUTOR_H
3 
4 # include "rheolef/distributed.h"
5 # include "rheolef/dis_macros.h"
6 # include "rheolef/Vector.h"
7 
8 namespace rheolef {
9 
19 class distributor : public Vector<std::allocator<int>::size_type> {
20 public:
21 
22 
27  typedef int tag_type;
28  typedef communicator communicator_type;
29 
30 
31  static const size_type decide = size_type(-1);
32 
33 // allocators/deallocators:
34 
36  size_type dis_size = 0,
38  size_type loc_size = decide);
39 
40  distributor(const distributor&);
41  ~distributor();
42 
43  void resize(
44  size_type dis_size = 0,
46  size_type loc_size = decide);
47 
48 
49  const communicator_type& comm() const;
50 
52  size_type dis_size () const;
53 
55  size_type process () const;
56 
58  size_type n_process () const;
59 
61  size_type find_owner (size_type dis_i) const;
62 
64  size_type first_index (size_type ip) const;
65  size_type last_index (size_type ip) const;
66  size_type size (size_type ip) const;
67 
69  size_type first_index () const;
70  size_type last_index () const;
71  size_type size () const;
72 
74  bool is_owned (size_type dis_i, size_type ip) const;
75 
76  bool is_owned (size_type dis_i) const;
77 
78 
80  static tag_type get_new_tag();
81 
82 
83  bool operator== (const distributor&) const;
84  bool operator!= (const distributor&) const;
85 protected:
87 };
88 @endcode
89 
90 inline
93 {
94  return _comm;
95 }
96 inline
99 {
100  return at(j);
101 }
102 inline
105 {
106  return at(j+1);
107 }
108 inline
111 {
112  return last_index(j) - first_index(j);
113 }
114 inline
117 {
118 #ifdef _RHEOLEF_HAVE_MPI
119  return _comm.size();
120 #else // _RHEOLEF_HAVE_MPI
121  return 1;
122 #endif // _RHEOLEF_HAVE_MPI
123 }
124 inline
127 {
128 #ifdef _RHEOLEF_HAVE_MPI
129  return _comm.rank();
130 #else // _RHEOLEF_HAVE_MPI
131  return 0;
132 #endif // _RHEOLEF_HAVE_MPI
133 }
134 inline
137 {
138  return first_index(process());
139 }
140 inline
143 {
144  return last_index(process());
145 }
146 inline
149 {
150  return size(process());
151 }
152 inline
155 {
156  return at(n_process());
157 }
158 inline
159 bool
161 {
162  return dis_i >= first_index(ip) && dis_i < last_index(ip);
163 }
164 inline
165 bool
167 {
168  return is_owned (dis_i, process());
169 }
170 inline
171 bool
173 {
174  return !operator==(x);
175 }
176 inline
177 bool
179 {
180  return (x.n_process() == n_process()) && (x.size() == size()) && (x.dis_size() == dis_size());
181 }
182 
183 } // namespace rheolef
184 #endif // _RHEO_DISTRIBUTOR_H
185