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 // Xpetra: A linear algebra interface package
4 //
5 // Copyright 2012 NTESS and the Xpetra contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef XPETRA_TPETRAIMPORT_DEF_HPP
11 #define XPETRA_TPETRAIMPORT_DEF_HPP
13 
14 #include "Xpetra_Import.hpp"
16 #include "Xpetra_Exceptions.hpp"
17 
18 #include "Xpetra_TpetraMap.hpp"
19 #include "Tpetra_Import.hpp"
20 #include "Tpetra_Distributor.hpp"
21 
22 namespace Xpetra {
23 
24 template <class LocalOrdinal, class GlobalOrdinal, class Node>
25 TpetraImport<LocalOrdinal, GlobalOrdinal, Node>::TpetraImport(const Teuchos::RCP<const map_type> &source, const Teuchos::RCP<const map_type> &target)
26  : import_(Teuchos::rcp(new Tpetra::Import<LocalOrdinal, GlobalOrdinal, Node>(toTpetra(source), toTpetra(target)))) {}
27 
28 template <class LocalOrdinal, class GlobalOrdinal, class Node>
29 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)
30  : import_(Teuchos::rcp(new Tpetra::Import<LocalOrdinal, GlobalOrdinal, Node>(toTpetra(source), toTpetra(target), plist))) {}
31 
32 template <class LocalOrdinal, class GlobalOrdinal, class Node>
34  : import_(Teuchos::rcp(new Tpetra::Import<LocalOrdinal, GlobalOrdinal, Node>(toTpetra(import)))) {}
35 
36 template <class LocalOrdinal, class GlobalOrdinal, class Node>
38 
39 template <class LocalOrdinal, class GlobalOrdinal, class Node>
40 Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> >
41 TpetraImport<LocalOrdinal, GlobalOrdinal, Node>::createRemoteOnlyImport(const Teuchos::RCP<const map_type> &remoteTarget) const {
42  Teuchos::RCP<const Tpetra::Import<LocalOrdinal, GlobalOrdinal, Node> > newImport = import_->createRemoteOnlyImport(toTpetra(remoteTarget));
43  return Teuchos::rcp(new TpetraImport<LocalOrdinal, GlobalOrdinal, Node>(newImport));
44 }
45 
46 template <class LocalOrdinal, class GlobalOrdinal, class Node>
48  XPETRA_MONITOR("TpetraImport::getNumSameIDs");
49  return import_->getNumSameIDs();
50 }
51 
52 template <class LocalOrdinal, class GlobalOrdinal, class Node>
54  XPETRA_MONITOR("TpetraImport::getNumPermuteIDs");
55  return import_->getNumPermuteIDs();
56 }
57 
58 template <class LocalOrdinal, class GlobalOrdinal, class Node>
60  XPETRA_MONITOR("TpetraImport::getPermuteFromLIDs");
61  return import_->getPermuteFromLIDs();
62 }
63 
64 template <class LocalOrdinal, class GlobalOrdinal, class Node>
66  XPETRA_MONITOR("TpetraImport::getPermuteToLIDs");
67  return import_->getPermuteToLIDs();
68 }
69 
70 template <class LocalOrdinal, class GlobalOrdinal, class Node>
72  XPETRA_MONITOR("TpetraImport::getNumRemoteIDs");
73  return import_->getNumRemoteIDs();
74 }
75 
76 template <class LocalOrdinal, class GlobalOrdinal, class Node>
77 void TpetraImport<LocalOrdinal, GlobalOrdinal, Node>::setDistributorParameters(const Teuchos::RCP<Teuchos::ParameterList> params) const {
78  XPETRA_MONITOR("TpetraImport::setDistributorParameters");
79  import_->getDistributor().setParameterList(params);
80  auto revDistor = import_->getDistributor().getReverse(false);
81  if (!revDistor.is_null())
82  revDistor->setParameterList(params);
83 }
84 
85 template <class LocalOrdinal, class GlobalOrdinal, class Node>
87  XPETRA_MONITOR("TpetraImport::getRemoteLIDs");
88  return import_->getRemoteLIDs();
89 }
90 
91 template <class LocalOrdinal, class GlobalOrdinal, class Node>
93  XPETRA_MONITOR("TpetraImport::getNumExportIDs");
94  return import_->getNumExportIDs();
95 }
96 
97 template <class LocalOrdinal, class GlobalOrdinal, class Node>
99  XPETRA_MONITOR("TpetraImport::getExportLIDs");
100  return import_->getExportLIDs();
101 }
102 
103 template <class LocalOrdinal, class GlobalOrdinal, class Node>
105  XPETRA_MONITOR("TpetraImport::getExportPIDs");
106  return import_->getExportPIDs();
107 }
108 
109 template <class LocalOrdinal, class GlobalOrdinal, class Node>
110 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > TpetraImport<LocalOrdinal, GlobalOrdinal, Node>::getSourceMap() const {
111  XPETRA_MONITOR("TpetraImport::getSourceMap");
112  return toXpetra(import_->getSourceMap());
113 }
114 
115 template <class LocalOrdinal, class GlobalOrdinal, class Node>
116 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > TpetraImport<LocalOrdinal, GlobalOrdinal, Node>::getTargetMap() const {
117  XPETRA_MONITOR("TpetraImport::getTargetMap");
118  return toXpetra(import_->getTargetMap());
119 }
120 
121 template <class LocalOrdinal, class GlobalOrdinal, class Node>
123  XPETRA_MONITOR("TpetraImport::print");
124  import_->print(os);
125 }
126 
127 template <class LocalOrdinal, class GlobalOrdinal, class Node>
128 TpetraImport<LocalOrdinal, GlobalOrdinal, Node>::TpetraImport(const RCP<const Tpetra::Import<LocalOrdinal, GlobalOrdinal, Node> > &import)
129  : import_(import) {}
130 
131 template <class LocalOrdinal, class GlobalOrdinal, class Node>
132 RCP<const Tpetra::Import<LocalOrdinal, GlobalOrdinal, Node> > TpetraImport<LocalOrdinal, GlobalOrdinal, Node>::getTpetra_Import() const { return import_; }
133 
134 #ifdef HAVE_XPETRA_EPETRA
135 
136 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
137  (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
138 
139 // stub implementation for GO=int and NO=EpetraNode
140 template <>
141 class TpetraImport<int, int, EpetraNode> : public Import<int, int, EpetraNode> {
142  public:
143  typedef int LocalOrdinal;
144  typedef int GlobalOrdinal;
145  typedef EpetraNode Node;
146 
149 
151 
152 
154  TpetraImport(const Teuchos::RCP<const map_type> &source, const Teuchos::RCP<const map_type> &target) {
156  }
157 
159  TpetraImport(const Teuchos::RCP<const map_type> &source, const Teuchos::RCP<const map_type> &target, const Teuchos::RCP<Teuchos::ParameterList> &plist) {
161  }
162 
166  }
167 
170 
172  Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> >
173  createRemoteOnlyImport(const Teuchos::RCP<const map_type> &remoteTarget) const {
174  return Teuchos::null;
175  }
176 
178 
180 
181 
183  size_t getNumSameIDs() const { return 0; }
184 
186  size_t getNumPermuteIDs() const { return 0; }
187 
189  ArrayView<const LocalOrdinal> getPermuteFromLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
190 
192  ArrayView<const LocalOrdinal> getPermuteToLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
193 
195  size_t getNumRemoteIDs() const { return 0; }
196 
198  ArrayView<const LocalOrdinal> getRemoteLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
199 
201  size_t getNumExportIDs() const { return 0; }
202 
204  ArrayView<const LocalOrdinal> getExportLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
205 
207  ArrayView<const int> getExportPIDs() const { return Teuchos::ArrayView<const int>(); }
208 
210  Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > getSourceMap() const { return Teuchos::null; }
211 
213  Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > getTargetMap() const { return Teuchos::null; }
214 
216  void setDistributorParameters(const Teuchos::RCP<Teuchos::ParameterList> params) const {}
217 
219 
221 
222 
224  void print(std::ostream &os) const { /* noop */
225  }
226 
228 
230 
231 
233  TpetraImport(const RCP<const Tpetra::Import<LocalOrdinal, GlobalOrdinal, Node> > &import) {
235  }
236 
237  RCP<const Tpetra::Import<LocalOrdinal, GlobalOrdinal, Node> > getTpetra_Import() const { return Teuchos::null; }
238 
240 
241 }; // TpetraImport class (stub implementation for GO=int, NO=EpetraNode)
242 #endif
243 
244 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_LONG_LONG))) || \
245  (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
246 
247 // stub implementation for GO=long long and NO=EpetraNode
248 template <>
249 class TpetraImport<int, long long, EpetraNode> : public Import<int, long long, EpetraNode> {
250  public:
251  typedef int LocalOrdinal;
252  typedef long long GlobalOrdinal;
253  typedef EpetraNode Node;
254 
257 
259 
260 
262  TpetraImport(const Teuchos::RCP<const map_type> &source, const Teuchos::RCP<const map_type> &target) {
264  }
265 
267  TpetraImport(const Teuchos::RCP<const map_type> &source, const Teuchos::RCP<const map_type> &target, const Teuchos::RCP<Teuchos::ParameterList> &plist) {
269  }
270 
274  }
275 
278 
280  Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> >
281  createRemoteOnlyImport(const Teuchos::RCP<const map_type> &remoteTarget) const {
282  return Teuchos::null;
283  }
284 
286 
288 
289 
291  size_t getNumSameIDs() const { return 0; }
292 
294  size_t getNumPermuteIDs() const { return 0; }
295 
297  ArrayView<const LocalOrdinal> getPermuteFromLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
298 
300  ArrayView<const LocalOrdinal> getPermuteToLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
301 
303  size_t getNumRemoteIDs() const { return 0; }
304 
306  ArrayView<const LocalOrdinal> getRemoteLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
307 
309  size_t getNumExportIDs() const { return 0; }
310 
312  ArrayView<const LocalOrdinal> getExportLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
313 
315  ArrayView<const int> getExportPIDs() const { return Teuchos::ArrayView<const int>(); }
316 
318  Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > getSourceMap() const { return Teuchos::null; }
319 
321  Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > getTargetMap() const { return Teuchos::null; }
322 
324  void setDistributorParameters(const Teuchos::RCP<Teuchos::ParameterList> params) const {}
325 
327 
329 
330 
332  void print(std::ostream &os) const { /* noop */
333  }
334 
336 
338 
339 
341  TpetraImport(const RCP<const Tpetra::Import<LocalOrdinal, GlobalOrdinal, Node> > &import) {
343  }
344 
345  RCP<const Tpetra::Import<LocalOrdinal, GlobalOrdinal, Node> > getTpetra_Import() const { return Teuchos::null; }
346 
348 
349 }; // TpetraImport class (stub implementation for GO=long long, NO=EpetraNode)
350 #endif
351 
352 #endif // HAVE_XPETRA_EPETRA
353 
354 } // namespace Xpetra
355 
356 #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.
size_t getNumExportIDs() const
Number of entries that must be sent by the calling process to other processes.
Map< LocalOrdinal, GlobalOrdinal, Node > map_type
The specialization of Map used by this class.
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 int > getExportPIDs() const
List of processes to which entries will be sent.
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 int > getExportPIDs() const
List of processes to which entries will be sent.
size_t getNumPermuteIDs() const
Number of IDs to permute but not to communicate.
#define XPETRA_TPETRA_ETI_EXCEPTION(cl, obj, go, node)
ArrayView< const LocalOrdinal > getPermuteToLIDs() const
List of local IDs in the target Map that are permuted.
TpetraImport(const Import< LocalOrdinal, GlobalOrdinal, Node > &import)
Copy constructor.
ArrayView< const LocalOrdinal > getPermuteFromLIDs() const
List of local IDs in the source Map that are permuted.
Map< LocalOrdinal, GlobalOrdinal, Node > map_type
The specialization of Map used by this class.
void print(std::ostream &os) const
Print the Import&#39;s data to the given output stream.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getTargetMap() const
The Target Map used to construct this Import object.
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.
ArrayView< const LocalOrdinal > getExportLIDs() const
List of entries in the source Map that will be sent to other processes.
Teuchos::RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > createRemoteOnlyImport(const Teuchos::RCP< const map_type > &remoteTarget) const
Special &quot;constructor&quot;.
RCP< const Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node > > getTpetra_Import() const
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 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.
RCP< const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > toTpetra(const RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &graph)
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getTargetMap() const
The Target Map used to construct this Import object.
ArrayView< const LocalOrdinal > getRemoteLIDs() const
List of entries in the target Map to receive from other processes.
Teuchos::RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > createRemoteOnlyImport(const Teuchos::RCP< const map_type > &remoteTarget) const
Special &quot;constructor&quot;.
ArrayView< const LocalOrdinal > getRemoteLIDs() const
List of entries in the target Map to receive from other processes.
Tpetra::KokkosCompat::KokkosSerialWrapperNode EpetraNode
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getSourceMap() const
The Source Map used to construct this Import object.
Teuchos::RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > createRemoteOnlyImport(const Teuchos::RCP< const map_type > &remoteTarget) const
Special &quot;constructor&quot;.
TpetraImport(const RCP< const Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node > > &import)
TpetraImport constructor to wrap a Tpetra::Import object.
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 LocalOrdinal > getRemoteLIDs() const
List of entries in the target Map to receive from 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 Import object.
#define XPETRA_MONITOR(funcName)
ArrayView< const LocalOrdinal > getPermuteFromLIDs() const
List of local IDs in the source Map that are permuted.
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.
RCP< const Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node > > getTpetra_Import() const
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).
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getSourceMap() const
The Source Map used to construct this Import object.
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.
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)
ArrayView< const LocalOrdinal > getPermuteFromLIDs() const
List of local IDs in the source Map that are permuted.