Debian Codegraph @

packages/isorropia/src/epetra/Isorropia_EpetraRedistributor.hpp

raw
1 //@HEADER
2 //************************************************************************
3 //
4 // Isorropia: Partitioning and Load Balancing Package
5 // Copyright (2006) Sandia Corporation
6 //
7 //Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 //license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 //************************************************************************
38 //@HEADER
39
40 #ifndef _Isorropia_EpetraRedistributor_hpp_
41 #define _Isorropia_EpetraRedistributor_hpp_
42
43 #include <Isorropia_Redistributor.hpp>
44 #include <Isorropia_ConfigDefs.hpp>
45 #include <Teuchos_RCP.hpp>
46 #include <Teuchos_ParameterList.hpp>
47
48 #ifdef HAVE_EPETRA
49 class Epetra_Map;
50 class Epetra_BlockMap;
51 class Epetra_Import;
52 class Epetra_Vector;
53 class Epetra_MultiVector;
54 class Epetra_CrsGraph;
55 class Epetra_CrsMatrix;
56 class Epetra_RowMatrix;
57 class Epetra_LinearProblem;
58 class Epetra_SrcDistObject;
59 class Epetra_DistObject;
60
61 namespace Isorropia {
62
63 namespace Epetra {
64 class Partitioner;
65
66 /** @ingroup partitioning_grp partitioning_rcp_grp partitioning_ptr_grp
67 Class which is constructed with a Partitioner instance, and
68 provides several methods for redistributing Epetra objects
69 given the partitioning computed by the Partitioner object.
70 */
71
72 class Redistributor : public Isorropia::Redistributor {
73 public:
74
75 /** @ingroup partitioning_rcp_grp
76 This constructor calls the Isorropia::Epetra::Partitioner::partition
77 method on the @c partitioner if it has not already been called.
78
79 \param partitioner (in) this input partitioner determines the new partitioning
80 to be created when Isorropia::Epetra::Redistributor::redistribute is called
81 */
82 Redistributor(Teuchos::RCP<Isorropia::Epetra::Partitioner> partitioner);
83
84 /** @ingroup partitioning_rcp_grp
85 This constructor sets the target map for the redistribution.
86
87 \param target_map (in) this input map determines the new matrices/vectors
88 to be created when Isorropia::Epetra::Redistributor::redistribute is
89 called
90 */
91 Redistributor(Teuchos::RCP<Epetra_Map> target_map);
92
93 /** @ingroup partitioning_ptr_grp
94 This constructor calls the Isorropia::Epetra::Partitioner::partition
95 method on the @c partitioner if it has not already been called.
96
97 \param partitioner (in) this input partitioner determines the new partitioning
98 to be created when Isorropia::Epetra::Redistributor::redistribute is called
99 */
100 Redistributor(Isorropia::Epetra::Partitioner *partitioner);
101
102 /** @ingroup partitioning_ptr_grp
103 This constructor sets the target map for the redistribution.
104
105 \param target_map (in) this input map determines the new matrices/vectors
106 to be created when Isorropia::Epetra::Redistributor::redistribute is
107 called
108 */
109 Redistributor(Epetra_Map *target_map);
110
111 /**
112 Destructor
113 */
114 virtual ~Redistributor();
115
116 /** @ingroup partitioning_grp
117 Method to redistribute a Epetra_SrcDistObject into a
118 Epetra_DistObject. The caller is required to have constructed
119 the target object using the correct target map.
120 */
121 void redistribute(const Epetra_SrcDistObject& src,
122 Epetra_DistObject& target);
123
124 /** @ingroup partitioning_rcp_grp
125 Method to accept a Epetra_CrsGraph object, and
126 return a redistributed Epetra_CrsGraph object.
127
128 \param input_graph (in) the graph for which we want a new graph that is distributed
129 according to the partitioner with which this Redistributor was
130 created.
131
132 \param callFillComplete (in) The new graph is FillComplete'd if callFillComplete is @c true.
133 In that case, the range map is set to equal the row map.
134 The domain map will equal the range map, unless the
135 input_graph has different domain and range maps, in which case
136 the original domain map is preserved. By default callFillComplete is @c true.
137
138 \return a reference counted pointer to the new redistributed graph
139 */
140 Teuchos::RCP<Epetra_CrsGraph>
141 redistribute(const Epetra_CrsGraph& input_graph, bool callFillComplete= true);
142
143 /** @ingroup partitioning_ptr_grp
144 Method to accept a Epetra_CrsGraph object, and
145 return a redistributed Epetra_CrsGraph object.
146
147 \param input_graph (in) the graph for which we want a new graph that is distributed
148 according to the partitioner with which this Redistributor was
149 created.
150
151 \param outputGraphPtr (out) pointer to the new redistributed graph
152
153 \param callFillComplete (in) The new graph is FillComplete'd if callFillComplete is @c true.
154 In that case, the range map is set to equal the row map.
155 The domain map will equal the range map, unless the
156 input_graph has different domain and range maps, in which case
157 the original domain map is preserved. By default callFillComplete is @c true.
158
159 */
160 void redistribute(const Epetra_CrsGraph& input_graph, Epetra_CrsGraph * &outputGraphPtr, bool callFillComplete= true);
161
162 /** @ingroup partitioning_rcp_grp
163 Method to accept a Epetra_CrsMatrix object, and
164 return a redistributed Epetra_CrsMatrix object.
165
166 \param input_matrix (in) the matrix for which we want a new matrix that is distributed
167 according to the partitioner with which this Redistributor was
168 created.
169
170 \param callFillComplete (in) The new matrix is FillComplete'd if callFillComplete is @c true.
171 In that case, the range map is set to equal the row map.
172 The domain map will equal the range map, unless the
173 input_matrix has different domain and range maps, in which case
174 the original domain map is preserved. By default callFillComplete is @c true.
175
176 \return a reference counted pointer to the new redistributed matrix
177 */
178 Teuchos::RCP<Epetra_CrsMatrix>
179 redistribute(const Epetra_CrsMatrix& input_matrix, bool callFillComplete= true);
180
181 /** @ingroup partitioning_ptr_grp
182 Method to accept a Epetra_CrsMatrix object, and
183 return a redistributed Epetra_CrsMatrix object.
184
185 \param inputMatrix (in) the matrix for which we want a new matrix that is distributed
186 according to the partitioner with which this Redistributor was
187 created.
188
189 \param outputMatrix (out) pointer to the new redistributed matrix
190
191 \param callFillComplete (in) The new matrix is FillComplete'd if callFillComplete is @c true.
192 In that case, the range map is set to equal the row map.
193 The domain map will equal the range map, unless the
194 input_matrix has different domain and range maps, in which case
195 the original domain map is preserved. By default callFillComplete is @c true.
196 */
197
198 void redistribute(const Epetra_CrsMatrix& inputMatrix, Epetra_CrsMatrix * &outputMatrix, bool callFillComplete= true);
199
200 /** @ingroup partitioning_rcp_grp
201 Method to accept a Epetra_RowMatrix object, and
202 return a redistributed Epetra_CrsMatrix object.
203
204 \param input_matrix (in) the row matrix for which we want a new matrix that is distributed
205 according to the partitioner with which this Redistributor was
206 created.
207
208 \param callFillComplete (in) The new matrix is FillComplete'd if callFillComplete is @c true.
209 In that case, the range map is set to equal the row map.
210 The domain map will equal the range map, unless the
211 input_matrix has different domain and range maps, in which case
212 the original domain map is preserved. By default callFillComplete is @c true.
213
214 \return a reference counted pointer to the new redistributed matrix
215 */
216 Teuchos::RCP<Epetra_CrsMatrix>
217 redistribute(const Epetra_RowMatrix& input_matrix, bool callFillComplete= true);
218
219
220 /** @ingroup partitioning_ptr_grp
221 Method to accept a Epetra_RowMatrix object, and
222 return a redistributed Epetra_CrsMatrix object.
223
224 \param inputMatrix (in) the row matrix for which we want a new matrix that is distributed
225 according to the partitioner with which this Redistributor was
226 created.
227
228 \param outputMatrix (out) pointer to the new redistributed matrix
229
230 \param callFillComplete (in) The new matrix is FillComplete'd if callFillComplete is @c true.
231 In that case, the range map is set to equal the row map.
232 The domain map will equal the range map, unless the
233 input_matrix has different domain and range maps, in which case
234 the original domain map is preserved. By default callFillComplete is @c true.
235 */
236 void
237 redistribute(const Epetra_RowMatrix& inputMatrix, Epetra_CrsMatrix * &outputMatrix, bool callFillComplete= true);
238
239 /** @ingroup partitioning_rcp_grp
240 Method to accept a Epetra_Vector object, and
241 return a redistributed Epetra_Vector object.
242
243 \param input_vector (in) the vector for which we want a new vector that is distributed
244 according to the partitioner with which this Redistributor was
245 created.
246
247 \return a reference counted pointer to the new redistributed vector
248 */
249 Teuchos::RCP<Epetra_Vector>
250 redistribute(const Epetra_Vector& input_vector);
251
252 /** @ingroup partitioning_ptr_grp
253 Method to accept a Epetra_Vector object, and
254 return a redistributed Epetra_Vector object.
255
256 \param inputVector (in) the vector for which we want a new vector that is distributed
257 according to the partitioner with which this Redistributor was
258 created.
259
260 \param outputVector (out) pointer to the new redistributed vector
261 */
262 void
263 redistribute(const Epetra_Vector& inputVector, Epetra_Vector * &outputVector);
264
265 /** @ingroup partitioning_rcp_grp
266 Method to accept a Epetra_MultiVector object, and
267 return a redistributed Epetra_MultiVector object.
268
269 \param input_vector (in) the multi vector for which we want a new multi vector that is distributed
270 according to the partitioner with which this Redistributor was
271 created.
272
273 \return a reference counted pointer to the new redistributed multi vector
274
275 */
276 Teuchos::RCP<Epetra_MultiVector>
277 redistribute(const Epetra_MultiVector& input_vector);
278
279
280 /** @ingroup partitioning_ptr_grp
281 Method to accept a Epetra_MultiVector object, and
282 return a redistributed Epetra_MultiVector object.
283
284 \param inputVector (in) the multi vector for which we want a new multi vector that is distributed
285 according to the partitioner with which this Redistributor was
286 created.
287
288 \param outputVector (out) a reference counted pointer to the new redistributed multi vector
289
290 */
291 void
292 redistribute(const Epetra_MultiVector& inputVector, Epetra_MultiVector * &outputVector);
293
294 /** @ingroup partitioning_grp
295 Reverse redistribute an Epetra_Vector.
296
297 \param input_vector (in) a vector that is distributed according to the partitioner that was used to create this Redistributor
298
299 \param output_vector (out) a copy of the @c input_vector which has been redistributed according
300 to the reverse of the partitioner that was used to create this Redistributor
301
302 */
303 void
304 redistribute_reverse(const Epetra_Vector& input_vector, Epetra_Vector& output_vector);
305
306 /** @ingroup partitioning_grp
307 Reverse redistribute an Epetra_MultiVector.
308
309 \param input_vector (in) a multi vector that is distributed according to the partitioner that was used to create this Redistributor
310
311 \param output_vector (out) a copy of the @c input_vector which has been redistributed according
312 to the reverse of the partitioner that was used to create this Redistributor
313 */
314 void
315 redistribute_reverse(const Epetra_MultiVector& input_vector, Epetra_MultiVector& output_vector);
316
317 Epetra_Import &get_importer() { return *importer_;}
318
319 private:
320 /** @ingroup partitioning_grp
321 Create an importer object to be used in the redistribution
322 \param src_map (in) the map describing the pattern of the import operation
323 */
324 void create_importer(const Epetra_BlockMap& src_map);
325
326 Teuchos::RCP<Isorropia::Epetra::Partitioner> partitioner_;
327 Teuchos::RCP<Epetra_Import> importer_;
328 Teuchos::RCP<Epetra_Map> target_map_;
329
330 }; //class Redistributor
331
332 }//namespace Epetra
333
334 }//namespace Isorropia
335
336 #endif //HAVE_EPETRA
337
338 #endif
339
340
341 #if defined(Isorropia_SHOW_DEPRECATED_WARNINGS)
342 #ifdef __GNUC__
343 #warning "The Isorropia package is deprecated"
344 #endif
345 #endif
346