Xpetra Version of the Day
Loading...
Searching...
No Matches
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
58namespace Xpetra {
59
60template<class LocalOrdinal, class GlobalOrdinal, class Node>
61TpetraImport<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
64template<class LocalOrdinal, class GlobalOrdinal, class Node>
65TpetraImport<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
68template<class LocalOrdinal, class GlobalOrdinal, class Node>
69TpetraImport<LocalOrdinal,GlobalOrdinal,Node>::TpetraImport(const Import< LocalOrdinal, GlobalOrdinal, Node > &import):import_(Teuchos::rcp(new Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node >(toTpetra(import))))
70{ }
71
72template<class LocalOrdinal, class GlobalOrdinal, class Node>
75
76template<class LocalOrdinal, class GlobalOrdinal, class Node>
82
83
84
85template<class LocalOrdinal, class GlobalOrdinal, class Node>
87{ XPETRA_MONITOR("TpetraImport::getNumSameIDs"); return import_->getNumSameIDs(); }
88
89template<class LocalOrdinal, class GlobalOrdinal, class Node>
91{ XPETRA_MONITOR("TpetraImport::getNumPermuteIDs"); return import_->getNumPermuteIDs(); }
92
93template<class LocalOrdinal, class GlobalOrdinal, class Node>
95{ XPETRA_MONITOR("TpetraImport::getPermuteFromLIDs"); return import_->getPermuteFromLIDs(); }
96
97template<class LocalOrdinal, class GlobalOrdinal, class Node>
99{ XPETRA_MONITOR("TpetraImport::getPermuteToLIDs"); return import_->getPermuteToLIDs(); }
100
101template<class LocalOrdinal, class GlobalOrdinal, class Node>
103{ XPETRA_MONITOR("TpetraImport::getNumRemoteIDs"); return import_->getNumRemoteIDs(); }
104
105template<class LocalOrdinal, class GlobalOrdinal, class Node>
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
114template<class LocalOrdinal, class GlobalOrdinal, class Node>
116{ XPETRA_MONITOR("TpetraImport::getRemoteLIDs"); return import_->getRemoteLIDs(); }
117
118template<class LocalOrdinal, class GlobalOrdinal, class Node>
120{ XPETRA_MONITOR("TpetraImport::getNumExportIDs"); return import_->getNumExportIDs(); }
121
122template<class LocalOrdinal, class GlobalOrdinal, class Node>
124{ XPETRA_MONITOR("TpetraImport::getExportLIDs"); return import_->getExportLIDs(); }
125
126template<class LocalOrdinal, class GlobalOrdinal, class Node>
128{ XPETRA_MONITOR("TpetraImport::getExportPIDs"); return import_->getExportPIDs(); }
129
130template<class LocalOrdinal, class GlobalOrdinal, class Node>
133
134template<class LocalOrdinal, class GlobalOrdinal, class Node>
137
138template<class LocalOrdinal, class GlobalOrdinal, class Node>
140{ XPETRA_MONITOR("TpetraImport::print"); import_->print(os); }
141
142template<class LocalOrdinal, class GlobalOrdinal, class Node>
143TpetraImport<LocalOrdinal,GlobalOrdinal,Node>::TpetraImport(const RCP<const Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node > > &import) : import_(import)
144{ }
145
146template<class LocalOrdinal, class GlobalOrdinal, class Node>
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;
165
168
170
171
176
181
186
189
190
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
210
213
215 size_t getNumRemoteIDs() const { return 0; }
216
219
221 size_t getNumExportIDs() const { return 0; }
222
225
228
231
234
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
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;
275
278
280
281
286
291
296
299
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
319
322
324 size_t getNumRemoteIDs() const { return 0; }
325
328
330 size_t getNumExportIDs() const { return 0; }
331
334
337
340
343
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
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
#define XPETRA_MONITOR(funcName)
#define XPETRA_TPETRA_ETI_EXCEPTION(cl, obj, go, node)
void setDistributorParameters(const Teuchos::RCP< Teuchos::ParameterList > params) const
Set parameters on the underlying object.
size_t getNumRemoteIDs() const
Number of entries not on the calling process.
size_t getNumSameIDs() const
Number of initial identical IDs.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getTargetMap() const
The Target Map used to construct this Import object.
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.
ArrayView< const LocalOrdinal > getExportLIDs() const
List of entries in the source Map that will be sent to other processes.
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.
void print(std::ostream &os) const
Print the Import's data to the given output stream.
RCP< const Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node > > getTpetra_Import() const
Teuchos::RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > createRemoteOnlyImport(const Teuchos::RCP< const map_type > &remoteTarget) const
Special "constructor".
TpetraImport(const Teuchos::RCP< const map_type > &source, const Teuchos::RCP< const map_type > &target)
Construct an Import from the source and target Maps.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getSourceMap() const
The Source 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.
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 > getRemoteLIDs() const
List of entries in the target Map to receive from other processes.
TpetraImport(const RCP< const Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node > > &import)
TpetraImport constructor to wrap a Tpetra::Import object.
ArrayView< const int > getExportPIDs() const
List of processes to which entries will be sent.
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.
TpetraImport(const Import< LocalOrdinal, GlobalOrdinal, Node > &import)
Copy constructor.
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).
Map< LocalOrdinal, GlobalOrdinal, Node > map_type
The specialization of Map used by this class.
void print(std::ostream &os) const
Print the Import's data to the given output stream.
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 "constructor".
ArrayView< const LocalOrdinal > getPermuteFromLIDs() const
List of local IDs in the source Map that are permuted.
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)
Construct an Import from the source and target Maps.
ArrayView< const LocalOrdinal > getExportLIDs() const
List of entries in the source Map that will be sent to other processes.
ArrayView< const LocalOrdinal > getPermuteToLIDs() const
List of local IDs in the target Map that are permuted.
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.
RCP< const Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node > > getTpetra_Import() const
ArrayView< const int > getExportPIDs() const
List of processes to which entries will be sent.
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.
void setDistributorParameters(const Teuchos::RCP< Teuchos::ParameterList > params) const
Set parameters on distributor.
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
ArrayView< const LocalOrdinal > getPermuteToLIDs() const
List of local IDs in the target Map that are permuted.
size_t getNumSameIDs() const
Number of initial identical IDs.
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 "constructor".
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 print(std::ostream &os) const
Print the Import's data to the given output stream.
ArrayView< const LocalOrdinal > getPermuteFromLIDs() const
List of local IDs in the source Map that are permuted.
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.
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.
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.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Xpetra namespace
RCP< const CrsGraph< int, GlobalOrdinal, Node > > toXpetra(const Epetra_CrsGraph &g)
RCP< const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > toTpetra(const RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &graph)