Xpetra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Xpetra_TpetraImport_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_TPETRAIMPORT_DEF_HPP
47 #define XPETRA_TPETRAIMPORT_DEF_HPP
49 
50 #include "Xpetra_Import.hpp"
52 #include "Xpetra_Exceptions.hpp"
53 
54 #include "Xpetra_TpetraMap.hpp"
55 #include "Tpetra_Import.hpp"
56 #include "Tpetra_Distributor.hpp"
57 
58 namespace Xpetra {
59 
60 template<class LocalOrdinal, class GlobalOrdinal, class Node>
61 TpetraImport<LocalOrdinal,GlobalOrdinal,Node>::TpetraImport(const Teuchos::RCP< const map_type > &source, const Teuchos::RCP< const map_type > &target):import_(Teuchos::rcp(new Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node >(toTpetra(source), toTpetra(target))))
62 { }
63 
64 template<class LocalOrdinal, class GlobalOrdinal, class Node>
65 TpetraImport<LocalOrdinal,GlobalOrdinal,Node>::TpetraImport(const Teuchos::RCP< const map_type > &source, const Teuchos::RCP< const map_type > &target, const Teuchos::RCP< Teuchos::ParameterList > &plist):import_(Teuchos::rcp(new Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node >(toTpetra(source), toTpetra(target), plist)))
66 { }
67 
68 template<class LocalOrdinal, class GlobalOrdinal, class Node>
69 TpetraImport<LocalOrdinal,GlobalOrdinal,Node>::TpetraImport(const Import< LocalOrdinal, GlobalOrdinal, Node > &import):import_(Teuchos::rcp(new Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node >(toTpetra(import))))
70 { }
71 
72 template<class LocalOrdinal, class GlobalOrdinal, class Node>
74 { }
75 
76 template<class LocalOrdinal, class GlobalOrdinal, class Node>
78 { XPETRA_MONITOR("TpetraImport::getNumSameIDs"); return import_->getNumSameIDs(); }
79 
80 template<class LocalOrdinal, class GlobalOrdinal, class Node>
82 { XPETRA_MONITOR("TpetraImport::getNumPermuteIDs"); return import_->getNumPermuteIDs(); }
83 
84 template<class LocalOrdinal, class GlobalOrdinal, class Node>
86 { XPETRA_MONITOR("TpetraImport::getPermuteFromLIDs"); return import_->getPermuteFromLIDs(); }
87 
88 template<class LocalOrdinal, class GlobalOrdinal, class Node>
90 { XPETRA_MONITOR("TpetraImport::getPermuteToLIDs"); return import_->getPermuteToLIDs(); }
91 
92 template<class LocalOrdinal, class GlobalOrdinal, class Node>
94 { XPETRA_MONITOR("TpetraImport::getNumRemoteIDs"); return import_->getNumRemoteIDs(); }
95 
96 template<class LocalOrdinal, class GlobalOrdinal, class Node>
97 void TpetraImport<LocalOrdinal,GlobalOrdinal,Node>::setDistributorParameters(const Teuchos::RCP<Teuchos::ParameterList> params) const{
98  XPETRA_MONITOR("TpetraImport::setDistributorParameters");
99  import_->getDistributor().setParameterList(params);
100  auto revDistor = import_->getDistributor().getReverse(false);
101  if (!revDistor.is_null())
102  revDistor->setParameterList(params);
103 }
104 
105 template<class LocalOrdinal, class GlobalOrdinal, class Node>
107 { XPETRA_MONITOR("TpetraImport::getRemoteLIDs"); return import_->getRemoteLIDs(); }
108 
109 template<class LocalOrdinal, class GlobalOrdinal, class Node>
111 { XPETRA_MONITOR("TpetraImport::getNumExportIDs"); return import_->getNumExportIDs(); }
112 
113 template<class LocalOrdinal, class GlobalOrdinal, class Node>
115 { XPETRA_MONITOR("TpetraImport::getExportLIDs"); return import_->getExportLIDs(); }
116 
117 template<class LocalOrdinal, class GlobalOrdinal, class Node>
119 { XPETRA_MONITOR("TpetraImport::getExportPIDs"); return import_->getExportPIDs(); }
120 
121 template<class LocalOrdinal, class GlobalOrdinal, class Node>
122 Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > TpetraImport<LocalOrdinal,GlobalOrdinal,Node>::getSourceMap() const
123 { XPETRA_MONITOR("TpetraImport::getSourceMap"); return toXpetra(import_->getSourceMap()); }
124 
125 template<class LocalOrdinal, class GlobalOrdinal, class Node>
126 Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > TpetraImport<LocalOrdinal,GlobalOrdinal,Node>::getTargetMap() const
127 { XPETRA_MONITOR("TpetraImport::getTargetMap"); return toXpetra(import_->getTargetMap()); }
128 
129 template<class LocalOrdinal, class GlobalOrdinal, class Node>
131 { XPETRA_MONITOR("TpetraImport::print"); import_->print(os); }
132 
133 template<class LocalOrdinal, class GlobalOrdinal, class Node>
134 TpetraImport<LocalOrdinal,GlobalOrdinal,Node>::TpetraImport(const RCP<const Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node > > &import) : import_(import)
135 { }
136 
137 template<class LocalOrdinal, class GlobalOrdinal, class Node>
138 RCP< const Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node > > TpetraImport<LocalOrdinal,GlobalOrdinal,Node>::getTpetra_Import() const
139 { return import_; }
140 
141 
142 #ifdef HAVE_XPETRA_EPETRA
143 
144 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
145  (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
146 
147  // stub implementation for GO=int and NO=EpetraNode
148  template <>
149  class TpetraImport<int, int, EpetraNode> : public Import<int, int, EpetraNode>
150  {
151 
152  public:
153  typedef int LocalOrdinal;
154  typedef int GlobalOrdinal;
155  typedef EpetraNode Node;
156 
159 
161 
162 
164  TpetraImport(const Teuchos::RCP< const map_type > &source, const Teuchos::RCP< const map_type > &target) {
166  }
167 
169  TpetraImport(const Teuchos::RCP< const map_type > &source, const Teuchos::RCP< const map_type > &target, const Teuchos::RCP< Teuchos::ParameterList > &plist) {
171  }
172 
176  }
177 
180 
182 
184 
185 
187  size_t getNumSameIDs() const { return 0; }
188 
190  size_t getNumPermuteIDs() const { return 0; }
191 
193  ArrayView< const LocalOrdinal > getPermuteFromLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
194 
196  ArrayView< const LocalOrdinal > getPermuteToLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
197 
199  size_t getNumRemoteIDs() const { return 0; }
200 
202  ArrayView< const LocalOrdinal > getRemoteLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
203 
205  size_t getNumExportIDs() const { return 0; }
206 
208  ArrayView< const LocalOrdinal > getExportLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
209 
211  ArrayView< const int > getExportPIDs() const { return Teuchos::ArrayView<const int>(); }
212 
214  Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getSourceMap() const { return Teuchos::null; }
215 
217  Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getTargetMap() const { return Teuchos::null; }
218 
220  void setDistributorParameters(const Teuchos::RCP<Teuchos::ParameterList> params) const { }
221 
223 
225 
226 
228  void print(std::ostream &os) const { /* noop */ }
229 
231 
233 
234 
236  TpetraImport(const RCP<const Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node > > &import) {
238  }
239 
240  RCP< const Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node > > getTpetra_Import() const { return Teuchos::null; }
241 
243 
244  }; // TpetraImport class (stub implementation for GO=int, NO=EpetraNode)
245 #endif
246 
247 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_LONG_LONG))) || \
248  (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
249 
250  // stub implementation for GO=long long and NO=EpetraNode
251  template <>
252  class TpetraImport<int, long long, EpetraNode> : public Import<int, long long, EpetraNode>
253  {
254 
255  public:
256  typedef int LocalOrdinal;
257  typedef long long GlobalOrdinal;
258  typedef EpetraNode Node;
259 
262 
264 
265 
267  TpetraImport(const Teuchos::RCP< const map_type > &source, const Teuchos::RCP< const map_type > &target) {
269  }
270 
272  TpetraImport(const Teuchos::RCP< const map_type > &source, const Teuchos::RCP< const map_type > &target, const Teuchos::RCP< Teuchos::ParameterList > &plist) {
274  }
275 
279  }
280 
283 
285 
287 
288 
290  size_t getNumSameIDs() const { return 0; }
291 
293  size_t getNumPermuteIDs() const { return 0; }
294 
296  ArrayView< const LocalOrdinal > getPermuteFromLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
297 
299  ArrayView< const LocalOrdinal > getPermuteToLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
300 
302  size_t getNumRemoteIDs() const { return 0; }
303 
305  ArrayView< const LocalOrdinal > getRemoteLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
306 
308  size_t getNumExportIDs() const { return 0; }
309 
311  ArrayView< const LocalOrdinal > getExportLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
312 
314  ArrayView< const int > getExportPIDs() const { return Teuchos::ArrayView<const int>(); }
315 
317  Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getSourceMap() const { return Teuchos::null; }
318 
320  Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getTargetMap() const { return Teuchos::null; }
321 
323  void setDistributorParameters(const Teuchos::RCP<Teuchos::ParameterList> params) const { }
324 
326 
328 
329 
331  void print(std::ostream &os) const { /* noop */ }
332 
334 
336 
337 
339  TpetraImport(const RCP<const Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node > > &import) {
341  }
342 
343  RCP< const Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node > > getTpetra_Import() const { return Teuchos::null; }
344 
346 
347  }; // TpetraImport class (stub implementation for GO=long long, NO=EpetraNode)
348 #endif
349 
350 #endif // HAVE_XPETRA_EPETRA
351 
352 } // Xpetra namespace
353 
354 #endif
void print(std::ostream &os) const
Print the Import&#39;s data to the given output stream.
TpetraImport(const Import< LocalOrdinal, GlobalOrdinal, Node > &import)
Copy constructor.
size_t getNumSameIDs() const
Number of initial identical IDs.
RCP< const Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node > > getTpetra_Import() const
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 Import object.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getTargetMap() const
The Target Map used to construct this Import object.
size_t getNumPermuteIDs() const
Number of IDs to permute but not to communicate.
ArrayView< const LocalOrdinal > getPermuteToLIDs() const
List of local IDs in the target Map that are permuted.
RCP< const Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node > > getTpetra_Import() const
ArrayView< const LocalOrdinal > getExportLIDs() const
List of entries in the source Map that will be sent 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.
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.
#define XPETRA_TPETRA_ETI_EXCEPTION(cl, obj, go, node)
ArrayView< const LocalOrdinal > getExportLIDs() const
List of entries in the source Map that will be sent to other processes.
TpetraImport(const Import< LocalOrdinal, GlobalOrdinal, Node > &import)
Copy constructor.
void print(std::ostream &os) const
Print the Import&#39;s data to the given output stream.
size_t getNumExportIDs() const
Number of entries that must be sent by the calling process to other processes.
size_t getNumPermuteIDs() const
Number of IDs to permute but not to communicate.
TpetraImport(const Teuchos::RCP< const map_type > &source, const Teuchos::RCP< const map_type > &target)
Construct an Import from the source and target Maps.
ArrayView< const int > getExportPIDs() const
List of processes to which entries will be sent.
void setDistributorParameters(const Teuchos::RCP< Teuchos::ParameterList > params) const
Set parameters on the underlying object.
TpetraImport(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).
TpetraImport(const Teuchos::RCP< const map_type > &source, const Teuchos::RCP< const map_type > &target)
Construct an Import from the source and target Maps.
TpetraImport(const RCP< const Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node > > &import)
TpetraImport constructor to wrap a Tpetra::Import object.
size_t getNumSameIDs() const
Number of initial identical IDs.
ArrayView< const LocalOrdinal > getRemoteLIDs() const
List of entries in the target Map to receive from other processes.
RCP< const Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node > > getTpetra_Import() const
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.
Map< LocalOrdinal, GlobalOrdinal, Node > map_type
The specialization of Map used by this class.
RCP< const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > toTpetra(const RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &graph)
ArrayView< const LocalOrdinal > getRemoteLIDs() const
List of entries in the target Map to receive from other processes.
RCP< const CrsGraph< int, GlobalOrdinal, Node > > toXpetra(const Epetra_CrsGraph &g)
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getTargetMap() const
The Target Map used to construct this Import object.
TpetraImport(const RCP< const Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node > > &import)
TpetraImport constructor to wrap a Tpetra::Import object.
Map< LocalOrdinal, GlobalOrdinal, Node > map_type
The specialization of Map used by this class.
TpetraImport(const Teuchos::RCP< const map_type > &source, const Teuchos::RCP< const map_type > &target)
Construct an Import from the source and target Maps.
void setDistributorParameters(const Teuchos::RCP< Teuchos::ParameterList > params) const
Set parameters on distributor.
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 Import object.
#define XPETRA_MONITOR(funcName)
ArrayView< const LocalOrdinal > getPermuteFromLIDs() const
List of local IDs in the source Map that are permuted.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getSourceMap() const
The Source Map used to construct this Import object.
size_t getNumRemoteIDs() const
Number of entries not on the calling process.
void setDistributorParameters(const Teuchos::RCP< Teuchos::ParameterList > params) const
Set parameters on the underlying object.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getSourceMap() const
The Source Map used to construct this Import object.
void print(std::ostream &os) const
Print the Import&#39;s data to the given output stream.
size_t getNumExportIDs() const
Number of entries that must be sent by the calling process to other processes.
ArrayView< const LocalOrdinal > getPermuteToLIDs() const
List of local IDs in the target Map that are permuted.
size_t getNumRemoteIDs() const
Number of entries not on the calling process.
TpetraImport(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).
ArrayView< const int > getExportPIDs() const
List of processes to which entries will be sent.
size_t getNumSameIDs() const
Number of initial identical IDs.
ArrayView< const LocalOrdinal > getPermuteToLIDs() const
List of local IDs in the target Map that are permuted.