10 #ifndef PACKAGES_XPETRA_IMPORT_UTILS_HPP_
11 #define PACKAGES_XPETRA_IMPORT_UTILS_HPP_
15 #include "Xpetra_Map.hpp"
17 #include "Teuchos_Array.hpp"
18 #include "Teuchos_ArrayView.hpp"
22 #ifdef HAVE_XPETRA_EPETRA
23 #include "Epetra_Util.h"
27 #ifdef HAVE_XPETRA_TPETRA
28 #include "Xpetra_TpetraImport.hpp"
29 #include "Tpetra_Import_Util.hpp"
41 template <
class LocalOrdinal,
43 class Node = Tpetra::KokkosClassic::DefaultNode::DefaultNodeType>
45 #undef XPETRA_IMPORTUTILS_SHORT
56 Teuchos::Array<std::pair<int, GlobalOrdinal> >& gpids,
57 bool use_minus_one_for_local) {
60 #if defined(HAVE_XPETRA_EPETRA)
61 throw(
Xpetra::Exceptions::RuntimeError(
"Xpetra::ImportUtils only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)"));
62 #endif // HAVE_XPETRA_EPETRA
64 #ifdef HAVE_XPETRA_TPETRA
65 Tpetra::Import_Util::getPidGidPairs(
Xpetra::toTpetra(Importer), gpids, use_minus_one_for_local);
66 #endif // HAVE_XPETRA_TPETRA
73 Teuchos::Array<int>& pids,
74 bool use_minus_one_for_local) {
77 #if defined(HAVE_XPETRA_EPETRA)
78 throw(
Xpetra::Exceptions::RuntimeError(
"Xpetra::ImportUtils only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)"));
79 #endif // HAVE_XPETRA_EPETRA
81 #ifdef HAVE_XPETRA_TPETRA
82 Tpetra::Import_Util::getPids(
Xpetra::toTpetra(Importer), pids, use_minus_one_for_local);
83 #endif // HAVE_XPETRA_TPETRA
91 Teuchos::ArrayView<int>& pids,
92 bool use_minus_one_for_local) {
95 #if defined(HAVE_XPETRA_EPETRA)
96 throw(
Xpetra::Exceptions::RuntimeError(
"Xpetra::ImportUtils only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)"));
97 #endif // HAVE_XPETRA_EPETRA
99 #ifdef HAVE_XPETRA_TPETRA
100 Tpetra::Import_Util::getPids(
Xpetra::toTpetra(Importer), pids, use_minus_one_for_local);
101 #endif // HAVE_XPETRA_TPETRA
109 Teuchos::Array<int>& RemotePIDs) {
112 #if defined(HAVE_XPETRA_EPETRA)
113 throw(
Xpetra::Exceptions::RuntimeError(
"Xpetra::ImportUtils only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)"));
114 #endif // HAVE_XPETRA_EPETRA
116 #ifdef HAVE_XPETRA_TPETRA
118 #endif // HAVE_XPETRA_TPETRA
124 #ifdef HAVE_XPETRA_EPETRA
131 #undef XPETRA_IMPORTUTILS_SHORT
136 Teuchos::Array<std::pair<int, GlobalOrdinal> >& gpids,
137 bool use_minus_one_for_local) {
141 std::vector<std::pair<int, GlobalOrdinal> > gpids_v(gpids.size());
142 Epetra_Util::GetPidGidPairs(*e_Importer, gpids_v, use_minus_one_for_local);
143 std::copy(gpids_v.begin(), gpids_v.end(), gpids.begin());
145 #ifdef HAVE_XPETRA_TPETRA
146 Tpetra::Import_Util::getPidGidPairs(
Xpetra::toTpetra(Importer), gpids, use_minus_one_for_local);
147 #endif // HAVE_XPETRA_TPETRA
154 Teuchos::Array<int>& pids,
155 bool use_minus_one_for_local) {
159 std::vector<int> pids_v(pids.size());
160 Epetra_Util::GetPids(*e_Importer, pids_v, use_minus_one_for_local);
161 std::copy(pids_v.begin(), pids_v.end(), pids.begin());
163 #ifdef HAVE_XPETRA_TPETRA
164 Tpetra::Import_Util::getPids(
Xpetra::toTpetra(Importer), pids, use_minus_one_for_local);
165 #endif // HAVE_XPETRA_TPETRA
173 Teuchos::ArrayView<int>& pids,
174 bool use_minus_one_for_local) {
178 std::vector<int> pids_v(pids.begin(), pids.end());
179 Epetra_Util::GetPids(*e_Importer, pids_v, use_minus_one_for_local);
181 #ifdef HAVE_XPETRA_TPETRA
182 Tpetra::Import_Util::getPids(
Xpetra::toTpetra(Importer), pids, use_minus_one_for_local);
183 #endif // HAVE_XPETRA_TPETRA
191 Teuchos::Array<int>& RemotePIDs) {
195 std::vector<int> pids_v(RemotePIDs.size());
196 Epetra_Util::GetRemotePIDs(*e_Importer, pids_v);
197 std::copy(pids_v.begin(), pids_v.end(), RemotePIDs.begin());
199 #ifdef HAVE_XPETRA_TPETRA
201 #endif // HAVE_XPETRA_TPETRA
213 #undef XPETRA_IMPORTUTILS_SHORT
218 Teuchos::Array<std::pair<int, GlobalOrdinal> >& gpids,
219 bool use_minus_one_for_local) {
223 std::vector<std::pair<int, GlobalOrdinal> > gpids_v(gpids.size());
224 Epetra_Util::GetPidGidPairs(*e_Importer, gpids_v, use_minus_one_for_local);
225 std::copy(gpids_v.begin(), gpids_v.end(), gpids.begin());
228 #ifdef HAVE_XPETRA_TPETRA
229 Tpetra::Import_Util::getPidGidPairs(
Xpetra::toTpetra(Importer), gpids, use_minus_one_for_local);
230 #endif // HAVE_XPETRA_TPETRA
237 Teuchos::Array<int>& pids,
238 bool use_minus_one_for_local) {
242 std::vector<int> pids_v(pids.size());
243 Epetra_Util::GetPids(*e_Importer, pids_v, use_minus_one_for_local);
244 std::copy(pids_v.begin(), pids_v.end(), pids.begin());
246 #ifdef HAVE_XPETRA_TPETRA
247 Tpetra::Import_Util::getPids(
Xpetra::toTpetra(Importer), pids, use_minus_one_for_local);
248 #endif // HAVE_XPETRA_TPETRA
256 Teuchos::ArrayView<int>& pids,
257 bool use_minus_one_for_local) {
261 std::vector<int> pids_v(pids.size());
262 Epetra_Util::GetPids(*e_Importer, pids_v, use_minus_one_for_local);
263 std::copy(pids_v.begin(), pids_v.end(), pids.begin());
265 #ifdef HAVE_XPETRA_TPETRA
266 Tpetra::Import_Util::getPids(
Xpetra::toTpetra(Importer), pids, use_minus_one_for_local);
267 #endif // HAVE_XPETRA_TPETRA
275 Teuchos::Array<int>& RemotePIDs) {
279 std::vector<int> pids_v(RemotePIDs.size());
280 Epetra_Util::GetRemotePIDs(*e_Importer, pids_v);
281 std::copy(pids_v.begin(), pids_v.end(), RemotePIDs.begin());
283 #ifdef HAVE_XPETRA_TPETRA
285 #endif // HAVE_XPETRA_TPETRA
290 #endif // HAVE_XPETRA_EPETRA for Epetra scpecialization
294 #define XPETRA_IMPORTUTILS_SHORT
296 #endif // PACKAGES_XPETRA_IMPORT_UTILS_HPP_
void getPidGidPairs(const Import< LocalOrdinal, GlobalOrdinal, Node > &Importer, Teuchos::Array< std::pair< int, GlobalOrdinal > > &gpids, bool use_minus_one_for_local)
For each GID in the TargetMap, find who owns the GID in the SourceMap.
void getPidGidPairs(const Import< LocalOrdinal, GlobalOrdinal, Node > &Importer, Teuchos::Array< std::pair< int, GlobalOrdinal > > &gpids, bool use_minus_one_for_local)
void getRemotePIDs(const Import< LocalOrdinal, GlobalOrdinal, Node > &Importer, Teuchos::Array< int > &RemotePIDs)
Get a list of remote PIDs from an importer in the order corresponding to the remote LIDs...
void getPids(const Import< LocalOrdinal, GlobalOrdinal, Node > &Importer, Teuchos::Array< int > &pids, bool use_minus_one_for_local)
Like getPidGidPairs, but just gets the PIDs, ordered by the column Map.
Exception throws to report errors in the internal logical of the program.
void getPids(const Import< LocalOrdinal, GlobalOrdinal, Node > &Importer, Teuchos::ArrayView< int > &pids, bool use_minus_one_for_local)
Like getPidGidPairs, but just gets the PIDs, ordered by the column Map.
void getPids(const Import< LocalOrdinal, GlobalOrdinal, Node > &Importer, Teuchos::ArrayView< int > &pids, bool use_minus_one_for_local)
Like getPidGidPairs, but just gets the PIDs, ordered by the column Map.
void getRemotePIDs(const Import< LocalOrdinal, GlobalOrdinal, Node > &Importer, Teuchos::Array< int > &RemotePIDs)
Get a list of remote PIDs from an importer in the order corresponding to the remote LIDs...
void getPids(const Import< LocalOrdinal, GlobalOrdinal, Node > &Importer, Teuchos::Array< int > &pids, bool use_minus_one_for_local)
Like getPidGidPairs, but just gets the PIDs, ordered by the column Map.
RCP< const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > toTpetra(const RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &graph)
void getPids(const Import< LocalOrdinal, GlobalOrdinal, Node > &Importer, Teuchos::ArrayView< int > &pids, bool use_minus_one_for_local)
Like getPidGidPairs, but just gets the PIDs, ordered by the column Map.
Tpetra::KokkosCompat::KokkosSerialWrapperNode EpetraNode
void getRemotePIDs(const Import< LocalOrdinal, GlobalOrdinal, Node > &Importer, Teuchos::Array< int > &RemotePIDs)
Get a list of remote PIDs from an importer in the order corresponding to the remote LIDs...
virtual Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getSourceMap() const =0
The Source Map used to construct this Import object.
Xpetra utility class for Import-related routines.
void getPids(const Import< LocalOrdinal, GlobalOrdinal, Node > &Importer, Teuchos::Array< int > &pids, bool use_minus_one_for_local)
Like getPidGidPairs, but just gets the PIDs, ordered by the column Map.
void getPidGidPairs(const Import< LocalOrdinal, GlobalOrdinal, Node > &Importer, Teuchos::Array< std::pair< int, GlobalOrdinal > > &gpids, bool use_minus_one_for_local)