MueLu Version of the Day
Loading...
Searching...
No Matches
MueLu_ImportUtils.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 PACKAGES_MUELU_IMPORT_UTILS_HPP_
11#define PACKAGES_MUELU_IMPORT_UTILS_HPP_
12
13#include "Xpetra_ConfigDefs.hpp"
14#include "Xpetra_Exceptions.hpp"
15#include "Xpetra_Map.hpp" // definition of UnderlyingLib
16#include "Xpetra_Import.hpp"
17#include "Teuchos_Array.hpp"
18#include "Teuchos_ArrayView.hpp"
19
20#include <utility>
21
22#include "Xpetra_TpetraImport.hpp"
23#include "Tpetra_Import_Util.hpp"
24
25namespace MueLu {
26
34template <class LocalOrdinal,
35 class GlobalOrdinal,
36 class Node = Tpetra::KokkosClassic::DefaultNode::DefaultNodeType>
38#undef MUELU_IMPORTUTILS_SHORT
39
40 public:
47 void
48 getPidGidPairs(const Xpetra::Import<LocalOrdinal, GlobalOrdinal, Node>& Importer,
49 Teuchos::Array<std::pair<int, GlobalOrdinal> >& gpids,
50 bool use_minus_one_for_local) {
51 Xpetra::UnderlyingLib lib = Importer.getSourceMap()->lib();
52 if (lib == Xpetra::UseTpetra) {
53 Tpetra::Import_Util::getPidGidPairs(Xpetra::toTpetra(Importer), gpids, use_minus_one_for_local);
54 }
55 }
56
58 void
59 getPids(const Xpetra::Import<LocalOrdinal, GlobalOrdinal, Node>& Importer,
60 Teuchos::Array<int>& pids,
61 bool use_minus_one_for_local) {
62 Xpetra::UnderlyingLib lib = Importer.getSourceMap()->lib();
63 if (lib == Xpetra::UseTpetra) {
64 Tpetra::Import_Util::getPids(Xpetra::toTpetra(Importer), pids, use_minus_one_for_local);
65 }
66 }
67
69 // Like the above, but without the resize
70 void
71 getPids(const Xpetra::Import<LocalOrdinal, GlobalOrdinal, Node>& Importer,
72 Teuchos::ArrayView<int>& pids,
73 bool use_minus_one_for_local) {
74 Xpetra::UnderlyingLib lib = Importer.getSourceMap()->lib();
75 if (lib == Xpetra::UseTpetra) {
76 Tpetra::Import_Util::getPids(Xpetra::toTpetra(Importer), pids, use_minus_one_for_local);
77 }
78 }
79
82 void
83 getRemotePIDs(const Xpetra::Import<LocalOrdinal, GlobalOrdinal, Node>& Importer,
84 Teuchos::Array<int>& RemotePIDs) {
85 Xpetra::UnderlyingLib lib = Importer.getSourceMap()->lib();
86 if (lib == Xpetra::UseTpetra) {
87 Tpetra::Import_Util::getRemotePIDs(Xpetra::toTpetra(Importer), RemotePIDs);
88 }
89 }
90
91}; // end class ImportUtils
92
93} // namespace MueLu
94
95#define MUELU_IMPORTUTILS_SHORT
96
97#endif // PACKAGES_MUELU_IMPORT_UTILS_HPP_
MueLu::DefaultLocalOrdinal LocalOrdinal
MueLu::DefaultGlobalOrdinal GlobalOrdinal
MueLu::DefaultNode Node
MueLu utility class for Import-related routines.
void getRemotePIDs(const Xpetra::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 Xpetra::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 getPidGidPairs(const Xpetra::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 getPids(const Xpetra::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.
Namespace for MueLu classes and methods.