Xpetra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Xpetra_TpetraExport_def.hpp
Go to the documentation of this file.
1 // @HEADER
2 //
3 // ***********************************************************************
4 //
5 // Xpetra: A linear algebra interface package
6 // Copyright 2012 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact
39 // Jonathan Hu (jhu@sandia.gov)
40 // Andrey Prokopenko (aprokop@sandia.gov)
41 // Ray Tuminaro (rstumin@sandia.gov)
42 //
43 // ***********************************************************************
44 //
45 // @HEADER
46 #ifndef XPETRA_TPETRAEXPORT_DEF_HPP
47 #define XPETRA_TPETRAEXPORT_DEF_HPP
48 
49 
51 #include "Tpetra_Distributor.hpp"
52 
53 namespace Xpetra {
54 
55 template<class LocalOrdinal, class GlobalOrdinal, class Node>
57 TpetraExport(const Teuchos::RCP<const map_type>& source,
58  const Teuchos::RCP<const map_type>& target)
59  : export_(Teuchos::rcp(new Tpetra::Export<LocalOrdinal, GlobalOrdinal, Node>(toTpetra(source), toTpetra(target))))
60 {
61 }
62 
63 
64 template<class LocalOrdinal, class GlobalOrdinal, class Node>
66 TpetraExport(const Teuchos::RCP<const map_type>& source,
67  const Teuchos::RCP<const map_type>& target,
68  const Teuchos::RCP<Teuchos::ParameterList>& plist)
69  : export_(Teuchos::rcp(new Tpetra::Export<LocalOrdinal, GlobalOrdinal, Node>(toTpetra(source), toTpetra(target), plist)))
70 {
71 }
72 
73 
74 template<class LocalOrdinal, class GlobalOrdinal, class Node>
77  : export_(Teuchos::rcp(new Tpetra::Export<LocalOrdinal, GlobalOrdinal, Node>(toTpetra(rhs))))
78 {
79 }
80 
81 
82 template<class LocalOrdinal, class GlobalOrdinal, class Node>
85 {
86 }
87 
88 
89 template<class LocalOrdinal, class GlobalOrdinal, class Node>
90 size_t
93 {
94  XPETRA_MONITOR("TpetraExport::getNumSameIDs");
95  return export_->getNumSameIDs();
96 }
97 
98 
99 template<class LocalOrdinal, class GlobalOrdinal, class Node>
100 size_t
103 {
104  XPETRA_MONITOR("TpetraExport::getNumPermuteIDs");
105  return export_->getNumPermuteIDs();
106 }
107 
108 
109 template<class LocalOrdinal, class GlobalOrdinal, class Node>
110 ArrayView<const LocalOrdinal>
113 {
114  XPETRA_MONITOR("TpetraExport::getPermuteFromLIDs");
115  return export_->getPermuteFromLIDs();
116 }
117 
118 
119 template<class LocalOrdinal, class GlobalOrdinal, class Node>
120 ArrayView<const LocalOrdinal>
123 {
124  XPETRA_MONITOR("TpetraExport::getPermuteToLIDs");
125  return export_->getPermuteToLIDs();
126 }
127 
128 
129 template<class LocalOrdinal, class GlobalOrdinal, class Node>
130 size_t
133 {
134  XPETRA_MONITOR("TpetraExport::getNumRemoteIDs");
135  return export_->getNumRemoteIDs();
136 }
137 
138 
139 template<class LocalOrdinal, class GlobalOrdinal, class Node>
140 ArrayView<const LocalOrdinal>
143 {
144  XPETRA_MONITOR("TpetraExport::getRemoteLIDs");
145  return export_->getRemoteLIDs();
146 }
147 
148 
149 template<class LocalOrdinal, class GlobalOrdinal, class Node>
150 size_t
153 {
154  XPETRA_MONITOR("TpetraExport::getNumExportIDs");
155  return export_->getNumExportIDs();
156 }
157 
158 
159 template<class LocalOrdinal, class GlobalOrdinal, class Node>
160 ArrayView<const LocalOrdinal>
163 {
164  XPETRA_MONITOR("TpetraExport::getExportLIDs");
165  return export_->getExportLIDs();
166 }
167 
168 
169 template<class LocalOrdinal, class GlobalOrdinal, class Node>
170 ArrayView<const int>
173 {
174  XPETRA_MONITOR("TpetraExport::getExportPIDs");
175  return export_->getExportPIDs();
176 }
177 
178 
179 template<class LocalOrdinal, class GlobalOrdinal, class Node>
180 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
183 {
184  XPETRA_MONITOR("TpetraExport::getSourceMap");
185  return toXpetra(export_->getSourceMap());
186 }
187 
188 
189 template<class LocalOrdinal, class GlobalOrdinal, class Node>
190 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
193 {
194  XPETRA_MONITOR("TpetraExport::getTargetMap");
195  return toXpetra(export_->getTargetMap());
196 }
197 
198 template<class LocalOrdinal, class GlobalOrdinal, class Node>
199 void
201 setDistributorParameters(const Teuchos::RCP<Teuchos::ParameterList> params) const {
202  XPETRA_MONITOR("TpetraExport::setDistributorParameters");
203  export_->getDistributor().setParameterList(params);
204  auto revDistor = export_->getDistributor().getReverse(false);
205  if (!revDistor.is_null())
206  revDistor->setParameterList(params);
207 }
208 
209 
210 template<class LocalOrdinal, class GlobalOrdinal, class Node>
211 void
213 print(std::ostream& os) const
214 {
215  XPETRA_MONITOR("TpetraExport::print");
216  export_->print(os);
217 }
218 
219 
220 template<class LocalOrdinal, class GlobalOrdinal, class Node>
223  const RCP<const Tpetra::Export<LocalOrdinal, GlobalOrdinal, Node>>& exp)
224  : export_(exp)
225 {
226 }
227 
228 
229 template<class LocalOrdinal, class GlobalOrdinal, class Node>
230 RCP<const Tpetra::Export<LocalOrdinal, GlobalOrdinal, Node>>
233 {
234  return export_;
235 }
236 
237 
238 
239 #ifdef HAVE_XPETRA_EPETRA
240 
241 #if((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) \
242  || (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
243 
244 // stub implementation for GO=int and NO=EpetraNode
245 template<>
246 class TpetraExport<int, int, EpetraNode>
247  : public Export<int, int, EpetraNode>
248 {
249 
250  public:
251  typedef int LocalOrdinal;
252  typedef int GlobalOrdinal;
253  typedef EpetraNode Node;
254 
257 
259 
260 
262  TpetraExport(const Teuchos::RCP<const map_type>& source, const Teuchos::RCP<const map_type>& target)
263  {
266  "int",
267  typeid(EpetraNode).name());
268  }
269 
270 
272  TpetraExport(const Teuchos::RCP<const map_type>& source,
273  const Teuchos::RCP<const map_type>& target,
274  const Teuchos::RCP<Teuchos::ParameterList>& plist)
275  {
278  "int",
279  typeid(EpetraNode).name());
280  }
281 
282 
285  {
288  "int",
289  typeid(EpetraNode).name());
290  }
291 
292 
295 
296 
298 
300 
301 
302 
304  size_t getNumSameIDs() const { return 0; }
305 
306 
308  size_t getNumPermuteIDs() const { return 0; }
309 
310 
312  ArrayView<const LocalOrdinal> getPermuteFromLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
313 
314 
316  ArrayView<const LocalOrdinal> getPermuteToLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
317 
318 
320  size_t getNumRemoteIDs() const { return 0; }
321 
322 
324  ArrayView<const LocalOrdinal> getRemoteLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
325 
326 
328  size_t getNumExportIDs() const { return 0; }
329 
330 
332  ArrayView<const LocalOrdinal> getExportLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
333 
334 
336  ArrayView<const int> getExportPIDs() const { return Teuchos::ArrayView<const int>(); }
337 
338 
340  Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> getSourceMap() const { return Teuchos::null; }
341 
342 
344  Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> getTargetMap() const { return Teuchos::null; }
345 
347  void setDistributorParameters(const Teuchos::RCP<Teuchos::ParameterList> params) const { };
348 
349 
351 
353 
354 
355 
357  void print(std::ostream& os) const
358  { /* noop */
359  }
360 
361 
363 
364 
366 
367 
368 
370  TpetraExport(const RCP<const Tpetra::Export<LocalOrdinal, GlobalOrdinal, Node>>& exp)
371  {
374  "int",
375  typeid(EpetraNode).name());
376  }
377 
378 
379  RCP<const Tpetra::Export<LocalOrdinal, GlobalOrdinal, Node>> getTpetra_Export() const { return Teuchos::null; }
380 
382 
383 }; // TpetraExport class (specialization for LO=GO=int)
384 #endif // #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT)))
385 
386 
387 
388 #if((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_LONG_LONG))) \
389  || (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
390 
391 // stub implementation for GO=long long and NO=EpetraNode
392 template<>
393 class TpetraExport<int, long long, EpetraNode>
394  : public Export<int, long long, EpetraNode>
395 {
396 
397  public:
398  typedef int LocalOrdinal;
399  typedef long long GlobalOrdinal;
400  typedef EpetraNode Node;
401 
404 
406 
407 
408 
410  TpetraExport(const Teuchos::RCP<const map_type>& source, const Teuchos::RCP<const map_type>& target)
411  {
414  "long long",
415  typeid(EpetraNode).name());
416  }
417 
418 
420  TpetraExport(const Teuchos::RCP<const map_type>& source,
421  const Teuchos::RCP<const map_type>& target,
422  const Teuchos::RCP<Teuchos::ParameterList>& plist)
423  {
426  "long long",
427  typeid(EpetraNode).name());
428  }
429 
430 
433  {
436  "long long",
437  typeid(EpetraNode).name());
438  }
439 
440 
443 
444 
446 
448 
449 
450 
452  size_t getNumSameIDs() const { return 0; }
453 
454 
456  size_t getNumPermuteIDs() const { return 0; }
457 
458 
460  ArrayView<const LocalOrdinal> getPermuteFromLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
461 
462 
464  ArrayView<const LocalOrdinal> getPermuteToLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
465 
466 
468  size_t getNumRemoteIDs() const { return 0; }
469 
470 
472  ArrayView<const LocalOrdinal> getRemoteLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
473 
474 
476  size_t getNumExportIDs() const { return 0; }
477 
478 
480  ArrayView<const LocalOrdinal> getExportLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
481 
482 
484  ArrayView<const int> getExportPIDs() const { return Teuchos::ArrayView<const int>(); }
485 
486 
488  Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> getSourceMap() const { return Teuchos::null; }
489 
490 
492  Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> getTargetMap() const { return Teuchos::null; }
493 
495  void setDistributorParameters(const Teuchos::RCP<Teuchos::ParameterList> params) const { };
496 
498 
500 
501 
502 
504  void print(std::ostream& os) const
505  { /* noop */
506  }
507 
508 
510 
512 
513 
514 
516  TpetraExport(const RCP<const Tpetra::Export<LocalOrdinal, GlobalOrdinal, Node>>& exp)
517  {
520  "long long",
521  typeid(EpetraNode).name());
522  }
523 
524 
525  RCP<const Tpetra::Export<LocalOrdinal, GlobalOrdinal, Node>> getTpetra_Export() const { return Teuchos::null; }
526 
527 
529 
530 }; // TpetraExport class (specialization for GO=long long, NO=EpetraNode)
531 #endif // #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_LONG_LONG)))
532 
533 
534 #endif // HAVE_XPETRA_EPETRA
535 
536 
537 } // namespace Xpetra
538 
539 
540 #endif // XPETRA_TPETRAEXPORT_DEF_HPP
541 
542 
size_t getNumSameIDs() const
Number of initial identical IDs.
TpetraExport(const Export< LocalOrdinal, GlobalOrdinal, Node > &rhs)
Copy constructor.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getSourceMap() const
The source Map used to construct this Export.
ArrayView< const LocalOrdinal > getPermuteFromLIDs() const
List of local IDs in the source Map that are permuted.
ArrayView< const LocalOrdinal > getExportLIDs() const
List of entries in the source Map that will be sent to other processes.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getTargetMap() const
The target Map used to construct this Export.
TpetraExport(const RCP< const Tpetra::Export< LocalOrdinal, GlobalOrdinal, Node >> &exp)
TpetraExport constructor to wrap a Tpetra::Export object.
TpetraExport(const Teuchos::RCP< const map_type > &source, const Teuchos::RCP< const map_type > &target, const Teuchos::RCP< Teuchos::ParameterList > &plist)
Constructor (with list of parameters).
RCP< const Tpetra::Export< LocalOrdinal, GlobalOrdinal, Node > > getTpetra_Export() const
Map< LocalOrdinal, GlobalOrdinal, Node > map_type
The specialization of Map used by this class.
TpetraExport(const Export< LocalOrdinal, GlobalOrdinal, Node > &rhs)
Copy constructor.
size_t getNumExportIDs() const
Number of entries that must be sent by the calling process to other processes.
size_t getNumRemoteIDs() const
Number of entries not on the calling process.
ArrayView< const LocalOrdinal > getRemoteLIDs() const
List of entries in the target Map to receive from other processes.
RCP< const Tpetra::Export< LocalOrdinal, GlobalOrdinal, Node > > getTpetra_Export() const
#define XPETRA_TPETRA_ETI_EXCEPTION(cl, obj, go, node)
ArrayView< const LocalOrdinal > getRemoteLIDs() const
List of entries in the target Map to receive from other processes.
size_t getNumRemoteIDs() const
Number of entries not on the calling process.
void print(std::ostream &os) const
Print the Export&#39;s data to the given output stream.
TpetraExport(const Teuchos::RCP< const map_type > &source, const Teuchos::RCP< const map_type > &target)
Construct a Export object from the source and target Map.
size_t getNumSameIDs() const
Number of initial identical IDs.
size_t getNumPermuteIDs() const
Number of IDs to permute but not to communicate.
size_t getNumExportIDs() const
Number of entries that must be sent by the calling process to other processes.
size_t getNumSameIDs() const
Number of initial identical IDs.
TpetraExport(const Teuchos::RCP< const map_type > &source, const Teuchos::RCP< const map_type > &target, const Teuchos::RCP< Teuchos::ParameterList > &plist)
Constructor (with list of parameters).
Map< LocalOrdinal, GlobalOrdinal, Node > map_type
The specialization of Map used by this class.
size_t getNumPermuteIDs() const
Number of IDs to permute but not to communicate.
ArrayView< const int > getExportPIDs() const
List of processes to which entries will be sent.
size_t getNumExportIDs() const
Number of entries that must be sent by the calling process to other processes.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getTargetMap() const
The target Map used to construct this Export.
ArrayView< const LocalOrdinal > getPermuteToLIDs() const
List of local IDs in the target Map that are permuted.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getSourceMap() const
The source Map used to construct this Export.
TpetraExport(const RCP< const Tpetra::Export< LocalOrdinal, GlobalOrdinal, Node >> &exp)
TpetraExport constructor to wrap a Tpetra::Export object.
void setDistributorParameters(const Teuchos::RCP< Teuchos::ParameterList > params) const
Set parameters on the underlying object.
void setDistributorParameters(const Teuchos::RCP< Teuchos::ParameterList > params) const
Set parameters on the underlying object.
RCP< const Tpetra::Export< LocalOrdinal, GlobalOrdinal, Node > > getTpetra_Export() const
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getTargetMap() const
The target Map used to construct this Export.
RCP< const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > toTpetra(const RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &graph)
ArrayView< const LocalOrdinal > getExportLIDs() const
List of entries in the source Map that will be sent to other processes.
RCP< const CrsGraph< int, GlobalOrdinal, Node > > toXpetra(const Epetra_CrsGraph &g)
void print(std::ostream &os) const
Print the Export&#39;s data to the given output stream.
TpetraExport(const Teuchos::RCP< const map_type > &source, const Teuchos::RCP< const map_type > &target)
Construct a Export object from the source and target Map.
void setDistributorParameters(const Teuchos::RCP< Teuchos::ParameterList > params) const
Set distributor parameters.
#define XPETRA_MONITOR(funcName)
size_t getNumRemoteIDs() const
Number of entries not on the calling process.
size_t getNumPermuteIDs() const
Number of IDs to permute but not to communicate.
ArrayView< const LocalOrdinal > getPermuteFromLIDs() const
List of local IDs in the source Map that are permuted.
TpetraExport(const Teuchos::RCP< const map_type > &source, const Teuchos::RCP< const map_type > &target)
Construct a Export object from the source and target Map.
ArrayView< const int > getExportPIDs() const
List of processes to which entries will be sent.
ArrayView< const LocalOrdinal > getPermuteToLIDs() const
List of local IDs in the target Map that are permuted.
ArrayView< const LocalOrdinal > getPermuteToLIDs() const
List of local IDs in the target Map that are permuted.
ArrayView< const LocalOrdinal > getRemoteLIDs() const
List of entries in the target Map to receive from other processes.
ArrayView< const LocalOrdinal > getExportLIDs() const
List of entries in the source Map that will be sent to other processes.
ArrayView< const int > getExportPIDs() const
List of processes to which entries will be sent.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getSourceMap() const
The source Map used to construct this Export.
void print(std::ostream &os) const
Print the Export&#39;s data to the given output stream.
ArrayView< const LocalOrdinal > getPermuteFromLIDs() const
List of local IDs in the source Map that are permuted.