Xpetra  Version of the Day
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>
77 Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> >
78 TpetraImport<LocalOrdinal,GlobalOrdinal,Node>::createRemoteOnlyImport (const Teuchos::RCP<const map_type>& remoteTarget) const {
79  Teuchos::RCP<const Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node> > newImport = import_->createRemoteOnlyImport(toTpetra(remoteTarget));
80  return Teuchos::rcp(new TpetraImport<LocalOrdinal,GlobalOrdinal,Node>(newImport));
81 }
82 
83 
84 
85 template<class LocalOrdinal, class GlobalOrdinal, class Node>
87 { XPETRA_MONITOR("TpetraImport::getNumSameIDs"); return import_->getNumSameIDs(); }
88 
89 template<class LocalOrdinal, class GlobalOrdinal, class Node>
91 { XPETRA_MONITOR("TpetraImport::getNumPermuteIDs"); return import_->getNumPermuteIDs(); }
92 
93 template<class LocalOrdinal, class GlobalOrdinal, class Node>
95 { XPETRA_MONITOR("TpetraImport::getPermuteFromLIDs"); return import_->getPermuteFromLIDs(); }
96 
97 template<class LocalOrdinal, class GlobalOrdinal, class Node>
99 { XPETRA_MONITOR("TpetraImport::getPermuteToLIDs"); return import_->getPermuteToLIDs(); }
100 
101 template<class LocalOrdinal, class GlobalOrdinal, class Node>
103 { XPETRA_MONITOR("TpetraImport::getNumRemoteIDs"); return import_->getNumRemoteIDs(); }
104 
105 template<class LocalOrdinal, class GlobalOrdinal, class Node>
106 void TpetraImport<LocalOrdinal,GlobalOrdinal,Node>::setDistributorParameters(const Teuchos::RCP<Teuchos::ParameterList> params) const{
107  XPETRA_MONITOR("TpetraImport::setDistributorParameters");
108  import_->getDistributor().setParameterList(params);
109  auto revDistor = import_->getDistributor().getReverse(false);
110  if (!revDistor.is_null())
111  revDistor->setParameterList(params);
112 }
113 
114 template<class LocalOrdinal, class GlobalOrdinal, class Node>
116 { XPETRA_MONITOR("TpetraImport::getRemoteLIDs"); return import_->getRemoteLIDs(); }
117 
118 template<class LocalOrdinal, class GlobalOrdinal, class Node>
120 { XPETRA_MONITOR("TpetraImport::getNumExportIDs"); return import_->getNumExportIDs(); }
121 
122 template<class LocalOrdinal, class GlobalOrdinal, class Node>
124 { XPETRA_MONITOR("TpetraImport::getExportLIDs"); return import_->getExportLIDs(); }
125 
126 template<class LocalOrdinal, class GlobalOrdinal, class Node>
128 { XPETRA_MONITOR("TpetraImport::getExportPIDs"); return import_->getExportPIDs(); }
129 
130 template<class LocalOrdinal, class GlobalOrdinal, class Node>
131 Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > TpetraImport<LocalOrdinal,GlobalOrdinal,Node>::getSourceMap() const
132 { XPETRA_MONITOR("TpetraImport::getSourceMap"); return toXpetra(import_->getSourceMap()); }
133 
134 template<class LocalOrdinal, class GlobalOrdinal, class Node>
135 Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > TpetraImport<LocalOrdinal,GlobalOrdinal,Node>::getTargetMap() const
136 { XPETRA_MONITOR("TpetraImport::getTargetMap"); return toXpetra(import_->getTargetMap()); }
137 
138 template<class LocalOrdinal, class GlobalOrdinal, class Node>
140 { XPETRA_MONITOR("TpetraImport::print"); import_->print(os); }
141 
142 template<class LocalOrdinal, class GlobalOrdinal, class Node>
143 TpetraImport<LocalOrdinal,GlobalOrdinal,Node>::TpetraImport(const RCP<const Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node > > &import) : import_(import)
144 { }
145 
146 template<class LocalOrdinal, class GlobalOrdinal, class Node>
147 RCP< const Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node > > TpetraImport<LocalOrdinal,GlobalOrdinal,Node>::getTpetra_Import() const
148 { return import_; }
149 
150 
151 #ifdef HAVE_XPETRA_EPETRA
152 
153 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
154  (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
155 
156  // stub implementation for GO=int and NO=EpetraNode
157  template <>
158  class TpetraImport<int, int, EpetraNode> : public Import<int, int, EpetraNode>
159  {
160 
161  public:
162  typedef int LocalOrdinal;
163  typedef int GlobalOrdinal;
164  typedef EpetraNode Node;
165 
168 
170 
171 
173  TpetraImport(const Teuchos::RCP< const map_type > &source, const Teuchos::RCP< const map_type > &target) {
175  }
176 
178  TpetraImport(const Teuchos::RCP< const map_type > &source, const Teuchos::RCP< const map_type > &target, const Teuchos::RCP< Teuchos::ParameterList > &plist) {
180  }
181 
185  }
186 
189 
190 
192  Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> >
193  createRemoteOnlyImport (const Teuchos::RCP<const map_type>& remoteTarget) const {
194  return Teuchos::null;
195  }
196 
198 
200 
201 
203  size_t getNumSameIDs() const { return 0; }
204 
206  size_t getNumPermuteIDs() const { return 0; }
207 
209  ArrayView< const LocalOrdinal > getPermuteFromLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
210 
212  ArrayView< const LocalOrdinal > getPermuteToLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
213 
215  size_t getNumRemoteIDs() const { return 0; }
216 
218  ArrayView< const LocalOrdinal > getRemoteLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
219 
221  size_t getNumExportIDs() const { return 0; }
222 
224  ArrayView< const LocalOrdinal > getExportLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
225 
227  ArrayView< const int > getExportPIDs() const { return Teuchos::ArrayView<const int>(); }
228 
230  Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getSourceMap() const { return Teuchos::null; }
231 
233  Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getTargetMap() const { return Teuchos::null; }
234 
236  void setDistributorParameters(const Teuchos::RCP<Teuchos::ParameterList> params) const { }
237 
239 
241 
242 
244  void print(std::ostream &os) const { /* noop */ }
245 
247 
249 
250 
252  TpetraImport(const RCP<const Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node > > &import) {
254  }
255 
256  RCP< const Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node > > getTpetra_Import() const { return Teuchos::null; }
257 
259 
260  }; // TpetraImport class (stub implementation for GO=int, NO=EpetraNode)
261 #endif
262 
263 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_LONG_LONG))) || \
264  (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
265 
266  // stub implementation for GO=long long and NO=EpetraNode
267  template <>
268  class TpetraImport<int, long long, EpetraNode> : public Import<int, long long, EpetraNode>
269  {
270 
271  public:
272  typedef int LocalOrdinal;
273  typedef long long GlobalOrdinal;
274  typedef EpetraNode Node;
275 
278 
280 
281 
283  TpetraImport(const Teuchos::RCP< const map_type > &source, const Teuchos::RCP< const map_type > &target) {
285  }
286 
288  TpetraImport(const Teuchos::RCP< const map_type > &source, const Teuchos::RCP< const map_type > &target, const Teuchos::RCP< Teuchos::ParameterList > &plist) {
290  }
291 
295  }
296 
299 
301  Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> >
302  createRemoteOnlyImport (const Teuchos::RCP<const map_type>& remoteTarget) const {
303  return Teuchos::null;
304  }
305 
307 
309 
310 
312  size_t getNumSameIDs() const { return 0; }
313 
315  size_t getNumPermuteIDs() const { return 0; }
316 
318  ArrayView< const LocalOrdinal > getPermuteFromLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
319 
321  ArrayView< const LocalOrdinal > getPermuteToLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
322 
324  size_t getNumRemoteIDs() const { return 0; }
325 
327  ArrayView< const LocalOrdinal > getRemoteLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
328 
330  size_t getNumExportIDs() const { return 0; }
331 
333  ArrayView< const LocalOrdinal > getExportLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
334 
336  ArrayView< const int > getExportPIDs() const { return Teuchos::ArrayView<const int>(); }
337 
339  Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getSourceMap() const { return Teuchos::null; }
340 
342  Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getTargetMap() const { return Teuchos::null; }
343 
345  void setDistributorParameters(const Teuchos::RCP<Teuchos::ParameterList> params) const { }
346 
348 
350 
351 
353  void print(std::ostream &os) const { /* noop */ }
354 
356 
358 
359 
361  TpetraImport(const RCP<const Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node > > &import) {
363  }
364 
365  RCP< const Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node > > getTpetra_Import() const { return Teuchos::null; }
366 
368 
369  }; // TpetraImport class (stub implementation for GO=long long, NO=EpetraNode)
370 #endif
371 
372 #endif // HAVE_XPETRA_EPETRA
373 
374 } // Xpetra namespace
375 
376 #endif
TpetraImport(const Import< LocalOrdinal, GlobalOrdinal, Node > &import)
Copy constructor.
void setDistributorParameters(const Teuchos::RCP< Teuchos::ParameterList > params) const
Set parameters on distributor.
Teuchos::RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > createRemoteOnlyImport(const Teuchos::RCP< const map_type > &remoteTarget) const
Special "constructor".
size_t getNumPermuteIDs() const
Number of IDs to permute but not to communicate.
RCP< const Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node > > getTpetra_Import() const
size_t getNumRemoteIDs() const
Number of entries not on the calling process.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getTargetMap() const
The Target Map used to construct this Import object.
size_t getNumRemoteIDs() const
Number of entries not on the calling process.
ArrayView< const LocalOrdinal > getPermuteFromLIDs() const
List of local IDs in the source Map that are permuted.
size_t getNumSameIDs() const
Number of initial identical IDs.
Teuchos::RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > createRemoteOnlyImport(const Teuchos::RCP< const map_type > &remoteTarget) const
Special "constructor".
Xpetra namespace
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.
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 Import object.
#define XPETRA_TPETRA_ETI_EXCEPTION(cl, obj, go, node)
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
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getSourceMap() const
The Source Map used to construct this Import object.
ArrayView< const int > getExportPIDs() const
List of processes to which entries will be sent.
void print(std::ostream &os) const
Print the Import&#39;s data to the given output stream.
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.
void print(std::ostream &os) const
Print the Import&#39;s data to the given output stream.
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 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 LocalOrdinal > getExportLIDs() const
List of entries in the source Map that will be sent to other processes.
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.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getTargetMap() const
The Target Map used to construct this Import object.
RCP< const Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node > > getTpetra_Import() const
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getSourceMap() const
The Source Map used to construct this Import object.
size_t getNumPermuteIDs() const
Number of IDs to permute but not to communicate.
void setDistributorParameters(const Teuchos::RCP< Teuchos::ParameterList > params) const
Set parameters on the underlying object.
Teuchos::RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > createRemoteOnlyImport(const Teuchos::RCP< const map_type > &remoteTarget) const
Special "constructor".
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.
ArrayView< const LocalOrdinal > getPermuteToLIDs() const
List of local IDs in the target Map that are permuted.
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)
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 getNumRemoteIDs() const
Number of entries not on the calling process.
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.
size_t getNumExportIDs() const
Number of entries that must be sent by the calling process to other processes.
#define XPETRA_MONITOR(funcName)
ArrayView< const LocalOrdinal > getRemoteLIDs() const
List of entries in the target Map to receive from other processes.
size_t getNumSameIDs() const
Number of initial identical IDs.
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.
void setDistributorParameters(const Teuchos::RCP< Teuchos::ParameterList > params) const
Set parameters on the underlying object.
ArrayView< const LocalOrdinal > getExportLIDs() const
List of entries in the source Map that will be sent to other processes.
size_t getNumExportIDs() const
Number of entries that must be sent by the calling process to other processes.
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.