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)
62  : import_(Teuchos::rcp(new Tpetra::Import<LocalOrdinal, GlobalOrdinal, Node>(toTpetra(source), toTpetra(target)))) {}
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)
66  : import_(Teuchos::rcp(new Tpetra::Import<LocalOrdinal, GlobalOrdinal, Node>(toTpetra(source), toTpetra(target), plist))) {}
67 
68 template <class LocalOrdinal, class GlobalOrdinal, class Node>
70  : import_(Teuchos::rcp(new Tpetra::Import<LocalOrdinal, GlobalOrdinal, Node>(toTpetra(import)))) {}
71 
72 template <class LocalOrdinal, class GlobalOrdinal, class Node>
74 
75 template <class LocalOrdinal, class GlobalOrdinal, class Node>
76 Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> >
77 TpetraImport<LocalOrdinal, GlobalOrdinal, Node>::createRemoteOnlyImport(const Teuchos::RCP<const map_type> &remoteTarget) const {
78  Teuchos::RCP<const Tpetra::Import<LocalOrdinal, GlobalOrdinal, Node> > newImport = import_->createRemoteOnlyImport(toTpetra(remoteTarget));
79  return Teuchos::rcp(new TpetraImport<LocalOrdinal, GlobalOrdinal, Node>(newImport));
80 }
81 
82 template <class LocalOrdinal, class GlobalOrdinal, class Node>
84  XPETRA_MONITOR("TpetraImport::getNumSameIDs");
85  return import_->getNumSameIDs();
86 }
87 
88 template <class LocalOrdinal, class GlobalOrdinal, class Node>
90  XPETRA_MONITOR("TpetraImport::getNumPermuteIDs");
91  return import_->getNumPermuteIDs();
92 }
93 
94 template <class LocalOrdinal, class GlobalOrdinal, class Node>
96  XPETRA_MONITOR("TpetraImport::getPermuteFromLIDs");
97  return import_->getPermuteFromLIDs();
98 }
99 
100 template <class LocalOrdinal, class GlobalOrdinal, class Node>
102  XPETRA_MONITOR("TpetraImport::getPermuteToLIDs");
103  return import_->getPermuteToLIDs();
104 }
105 
106 template <class LocalOrdinal, class GlobalOrdinal, class Node>
108  XPETRA_MONITOR("TpetraImport::getNumRemoteIDs");
109  return import_->getNumRemoteIDs();
110 }
111 
112 template <class LocalOrdinal, class GlobalOrdinal, class Node>
113 void TpetraImport<LocalOrdinal, GlobalOrdinal, Node>::setDistributorParameters(const Teuchos::RCP<Teuchos::ParameterList> params) const {
114  XPETRA_MONITOR("TpetraImport::setDistributorParameters");
115  import_->getDistributor().setParameterList(params);
116  auto revDistor = import_->getDistributor().getReverse(false);
117  if (!revDistor.is_null())
118  revDistor->setParameterList(params);
119 }
120 
121 template <class LocalOrdinal, class GlobalOrdinal, class Node>
123  XPETRA_MONITOR("TpetraImport::getRemoteLIDs");
124  return import_->getRemoteLIDs();
125 }
126 
127 template <class LocalOrdinal, class GlobalOrdinal, class Node>
129  XPETRA_MONITOR("TpetraImport::getNumExportIDs");
130  return import_->getNumExportIDs();
131 }
132 
133 template <class LocalOrdinal, class GlobalOrdinal, class Node>
135  XPETRA_MONITOR("TpetraImport::getExportLIDs");
136  return import_->getExportLIDs();
137 }
138 
139 template <class LocalOrdinal, class GlobalOrdinal, class Node>
141  XPETRA_MONITOR("TpetraImport::getExportPIDs");
142  return import_->getExportPIDs();
143 }
144 
145 template <class LocalOrdinal, class GlobalOrdinal, class Node>
146 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > TpetraImport<LocalOrdinal, GlobalOrdinal, Node>::getSourceMap() const {
147  XPETRA_MONITOR("TpetraImport::getSourceMap");
148  return toXpetra(import_->getSourceMap());
149 }
150 
151 template <class LocalOrdinal, class GlobalOrdinal, class Node>
152 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > TpetraImport<LocalOrdinal, GlobalOrdinal, Node>::getTargetMap() const {
153  XPETRA_MONITOR("TpetraImport::getTargetMap");
154  return toXpetra(import_->getTargetMap());
155 }
156 
157 template <class LocalOrdinal, class GlobalOrdinal, class Node>
159  XPETRA_MONITOR("TpetraImport::print");
160  import_->print(os);
161 }
162 
163 template <class LocalOrdinal, class GlobalOrdinal, class Node>
164 TpetraImport<LocalOrdinal, GlobalOrdinal, Node>::TpetraImport(const RCP<const Tpetra::Import<LocalOrdinal, GlobalOrdinal, Node> > &import)
165  : import_(import) {}
166 
167 template <class LocalOrdinal, class GlobalOrdinal, class Node>
168 RCP<const Tpetra::Import<LocalOrdinal, GlobalOrdinal, Node> > TpetraImport<LocalOrdinal, GlobalOrdinal, Node>::getTpetra_Import() const { return import_; }
169 
170 #ifdef HAVE_XPETRA_EPETRA
171 
172 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
173  (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
174 
175 // stub implementation for GO=int and NO=EpetraNode
176 template <>
177 class TpetraImport<int, int, EpetraNode> : public Import<int, int, EpetraNode> {
178  public:
179  typedef int LocalOrdinal;
180  typedef int GlobalOrdinal;
181  typedef EpetraNode Node;
182 
185 
187 
188 
190  TpetraImport(const Teuchos::RCP<const map_type> &source, const Teuchos::RCP<const map_type> &target) {
192  }
193 
195  TpetraImport(const Teuchos::RCP<const map_type> &source, const Teuchos::RCP<const map_type> &target, const Teuchos::RCP<Teuchos::ParameterList> &plist) {
197  }
198 
202  }
203 
206 
208  Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> >
209  createRemoteOnlyImport(const Teuchos::RCP<const map_type> &remoteTarget) const {
210  return Teuchos::null;
211  }
212 
214 
216 
217 
219  size_t getNumSameIDs() const { return 0; }
220 
222  size_t getNumPermuteIDs() const { return 0; }
223 
225  ArrayView<const LocalOrdinal> getPermuteFromLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
226 
228  ArrayView<const LocalOrdinal> getPermuteToLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
229 
231  size_t getNumRemoteIDs() const { return 0; }
232 
234  ArrayView<const LocalOrdinal> getRemoteLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
235 
237  size_t getNumExportIDs() const { return 0; }
238 
240  ArrayView<const LocalOrdinal> getExportLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
241 
243  ArrayView<const int> getExportPIDs() const { return Teuchos::ArrayView<const int>(); }
244 
246  Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > getSourceMap() const { return Teuchos::null; }
247 
249  Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > getTargetMap() const { return Teuchos::null; }
250 
252  void setDistributorParameters(const Teuchos::RCP<Teuchos::ParameterList> params) const {}
253 
255 
257 
258 
260  void print(std::ostream &os) const { /* noop */
261  }
262 
264 
266 
267 
269  TpetraImport(const RCP<const Tpetra::Import<LocalOrdinal, GlobalOrdinal, Node> > &import) {
271  }
272 
273  RCP<const Tpetra::Import<LocalOrdinal, GlobalOrdinal, Node> > getTpetra_Import() const { return Teuchos::null; }
274 
276 
277 }; // TpetraImport class (stub implementation for GO=int, NO=EpetraNode)
278 #endif
279 
280 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_LONG_LONG))) || \
281  (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
282 
283 // stub implementation for GO=long long and NO=EpetraNode
284 template <>
285 class TpetraImport<int, long long, EpetraNode> : public Import<int, long long, EpetraNode> {
286  public:
287  typedef int LocalOrdinal;
288  typedef long long GlobalOrdinal;
289  typedef EpetraNode Node;
290 
293 
295 
296 
298  TpetraImport(const Teuchos::RCP<const map_type> &source, const Teuchos::RCP<const map_type> &target) {
300  }
301 
303  TpetraImport(const Teuchos::RCP<const map_type> &source, const Teuchos::RCP<const map_type> &target, const Teuchos::RCP<Teuchos::ParameterList> &plist) {
305  }
306 
310  }
311 
314 
316  Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> >
317  createRemoteOnlyImport(const Teuchos::RCP<const map_type> &remoteTarget) const {
318  return Teuchos::null;
319  }
320 
322 
324 
325 
327  size_t getNumSameIDs() const { return 0; }
328 
330  size_t getNumPermuteIDs() const { return 0; }
331 
333  ArrayView<const LocalOrdinal> getPermuteFromLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
334 
336  ArrayView<const LocalOrdinal> getPermuteToLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
337 
339  size_t getNumRemoteIDs() const { return 0; }
340 
342  ArrayView<const LocalOrdinal> getRemoteLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
343 
345  size_t getNumExportIDs() const { return 0; }
346 
348  ArrayView<const LocalOrdinal> getExportLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
349 
351  ArrayView<const int> getExportPIDs() const { return Teuchos::ArrayView<const int>(); }
352 
354  Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > getSourceMap() const { return Teuchos::null; }
355 
357  Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > getTargetMap() const { return Teuchos::null; }
358 
360  void setDistributorParameters(const Teuchos::RCP<Teuchos::ParameterList> params) const {}
361 
363 
365 
366 
368  void print(std::ostream &os) const { /* noop */
369  }
370 
372 
374 
375 
377  TpetraImport(const RCP<const Tpetra::Import<LocalOrdinal, GlobalOrdinal, Node> > &import) {
379  }
380 
381  RCP<const Tpetra::Import<LocalOrdinal, GlobalOrdinal, Node> > getTpetra_Import() const { return Teuchos::null; }
382 
384 
385 }; // TpetraImport class (stub implementation for GO=long long, NO=EpetraNode)
386 #endif
387 
388 #endif // HAVE_XPETRA_EPETRA
389 
390 } // namespace Xpetra
391 
392 #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.