Rheolef  7.2
an efficient C++ finite element environment
 
Loading...
Searching...
No Matches
distributor.h
Go to the documentation of this file.
1#ifndef _RHEO_DISTRIBUTOR_H
2#define _RHEO_DISTRIBUTOR_H
3//
4// This file is part of Rheolef.
5//
6// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
7//
8// Rheolef is free software; you can redistribute it and/or modify
9// it under the terms of the GNU General Public License as published by
10// the Free Software Foundation; either version 2 of the License, or
11// (at your option) any later version.
12//
13// Rheolef is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17//
18// You should have received a copy of the GNU General Public License
19// along with Rheolef; if not, write to the Free Software
20// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21//
22// =========================================================================
23// AUTHOR: Pierre.Saramito@imag.fr
24// DATE: 27 november 1998
25
26namespace rheolef {
60} // namespace rheolef
61
62# include "rheolef/communicator.h"
63# include "rheolef/dis_macros.h"
64# include "rheolef/Vector.h"
65
66namespace rheolef {
67
68// [verbatim_distributor]
69class distributor : public Vector<std::allocator<int>::size_type> {
70public:
71
72// typedefs:
73
74 typedef std::allocator<int>::size_type size_type;
76 typedef _base::iterator iterator;
77 typedef _base::const_iterator const_iterator;
78 typedef int tag_type;
79 typedef communicator communicator_type;
80
81// constants:
82
83 static const size_type decide = size_type(-1);
84
85// allocators/deallocators:
86
90 size_type loc_size = decide);
91
94
95 void resize(
98 size_type loc_size = decide);
99
100// accessors:
101
102 const communicator_type& comm() const;
103
105 size_type dis_size () const;
106
108 size_type process () const;
109
111 size_type n_process () const;
112
114 size_type find_owner (size_type dis_i) const;
115
117 size_type first_index (size_type iproc) const;
118 size_type last_index (size_type iproc) const;
119 size_type size (size_type iproc) const;
120
122 size_type first_index () const;
123 size_type last_index () const;
124 size_type size () const;
125
127 bool is_owned (size_type dis_i, size_type iproc) const;
128
129 // the same with ip=current process
130 bool is_owned (size_type dis_i) const;
131
132
134 static tag_type get_new_tag();
135
136// comparators:
137
138 bool operator== (const distributor&) const;
139 bool operator!= (const distributor&) const;
140// [verbatim_distributor]
141
142// data:
143protected:
145// [verbatim_distributor_cont]
146};
147// [verbatim_distributor_cont]
148
149// inline'd
150inline
153{
154 return _comm;
155}
156inline
159{
160 return at(j);
161}
162inline
165{
166 return at(j+1);
167}
168inline
171{
172 return last_index(j) - first_index(j);
173}
174inline
177{
178#ifdef _RHEOLEF_HAVE_MPI
179 return _comm.size();
180#else // _RHEOLEF_HAVE_MPI
181 return 1;
182#endif // _RHEOLEF_HAVE_MPI
183}
184inline
187{
188#ifdef _RHEOLEF_HAVE_MPI
189 return _comm.rank();
190#else // _RHEOLEF_HAVE_MPI
191 return 0;
192#endif // _RHEOLEF_HAVE_MPI
193}
194inline
197{
198 return first_index(process());
199}
200inline
203{
204 return last_index(process());
205}
206inline
209{
210 return size(process());
211}
212inline
215{
216 return at(n_process());
217}
218inline
219bool
221{
222 return dis_i >= first_index(ip) && dis_i < last_index(ip);
223}
224inline
225bool
227{
228 return is_owned (dis_i, process());
229}
230inline
231bool
233{
234 return !operator==(x);
235}
236inline
237bool
239{
240 return (x.n_process() == n_process()) && (x.size() == size()) && (x.dis_size() == dis_size());
241}
242
243} // namespace rheolef
244#endif // _RHEO_DISTRIBUTOR_H
see the distributor page for the full documentation
Definition distributor.h:69
size_type last_index() const
size_type n_process() const
number of processes
Vector< size_type > _base
Definition distributor.h:75
size_type find_owner(size_type dis_i) const
find iproc associated to a global index dis_i: CPU=log(nproc)
void resize(size_type dis_size=0, const communicator_type &c=communicator_type(), size_type loc_size=decide)
size_type dis_size() const
global and local sizes
communicator communicator_type
Definition distributor.h:79
size_type size(size_type iproc) const
static tag_type get_new_tag()
returns a new tag
_base::iterator iterator
Definition distributor.h:76
size_type process() const
current process id
bool operator!=(const distributor &) const
size_type first_index() const
global index range and local size owned by current process
bool operator==(const distributor &) const
_base::const_iterator const_iterator
Definition distributor.h:77
communicator_type _comm
size_type size() const
bool is_owned(size_type dis_i, size_type iproc) const
true when dis_i in [first_index(iproc):last_index(iproc)[
static const size_type decide
Definition distributor.h:83
std::allocator< int >::size_type size_type
Definition distributor.h:74
const communicator_type & comm() const
This file is part of Rheolef.
const_reference at(size_type n) const
Definition Vector.h:283