42 #ifndef TPETRA_DIRECTORY_HPP 43 #define TPETRA_DIRECTORY_HPP 45 #include "Tpetra_Distributor.hpp" 46 #include "Tpetra_Map.hpp" 47 #include "Tpetra_DirectoryImpl.hpp" 48 #include "Tpetra_Directory_decl.hpp" 53 template<
class LO,
class GO,
class NT>
58 template<
class LO,
class GO,
class NT>
66 template<
class LO,
class GO,
class NT>
73 template<
class LO,
class GO,
class NT>
80 TEUCHOS_TEST_FOR_EXCEPTION(
81 impl_ == NULL, std::logic_error,
"Tpetra::Directory::initialize: " 82 "The Directory claims that it has been initialized, " 83 "but its implementation object has not yet been created. " 84 "Please report this bug to the Tpetra developers.");
87 TEUCHOS_TEST_FOR_EXCEPTION(
88 impl_ != NULL, std::logic_error,
"Tpetra::Directory::initialize: " 89 "Directory implementation has already been initialized, " 90 "but initialized() returns false. " 91 "Please report this bug to the Tpetra developers.");
115 const ::Tpetra::Details::Directory<LO, GO, NT>* dir = NULL;
116 bool usedTieBreak =
false;
119 dir = new ::Tpetra::Details::ContiguousUniformDirectory<LO, GO, NT> (map);
122 dir = new ::Tpetra::Details::DistributedContiguousDirectory<LO, GO, NT> (map);
125 dir = new ::Tpetra::Details::DistributedNoncontiguousDirectory<LO, GO, NT> (map, tieBreak);
130 dir = new ::Tpetra::Details::ReplicatedDirectory<LO, GO, NT> (map);
135 const int myRank = map.
getComm ()->getRank ();
140 std::vector<std::pair<int, LO> > pidLidList (1);
143 for (LO locInd = minLocInd; locInd <= maxLocInd; ++locInd) {
144 pidLidList[0] = std::make_pair (myRank, locInd);
162 std::vector<std::pair<int, LO> > pidLidList (1);
165 const int myRank = map.
getComm ()->getRank ();
166 for (LO locInd = minLocInd; locInd <= maxLocInd; ++locInd) {
167 pidLidList[0] = std::make_pair (myRank, locInd);
179 template<
class LO,
class GO,
class NT>
184 TEUCHOS_TEST_FOR_EXCEPTION(
185 impl_ == NULL, std::logic_error,
"Tpetra::Directory::initialize: " 186 "The Directory claims that it has been initialized, " 187 "but its implementation object has not yet been created. " 188 "Please report this bug to the Tpetra developers.");
191 TEUCHOS_TEST_FOR_EXCEPTION(
192 impl_ != NULL, std::logic_error,
"Tpetra::Directory::initialize: " 193 "Directory implementation has already been initialized, " 194 "but initialized() returns false. " 195 "Please report this bug to the Tpetra developers.");
200 const ::Tpetra::Details::Directory<LO, GO, NT>* dir = NULL;
203 dir = new ::Tpetra::Details::ContiguousUniformDirectory<LO, GO, NT> (map);
206 dir = new ::Tpetra::Details::DistributedContiguousDirectory<LO, GO, NT> (map);
209 dir = new ::Tpetra::Details::DistributedNoncontiguousDirectory<LO, GO, NT> (map);
213 dir = new ::Tpetra::Details::ReplicatedDirectory<LO, GO, NT> (map);
215 TEUCHOS_TEST_FOR_EXCEPTION(
216 dir == NULL, std::logic_error,
"Tpetra::Directory::initialize: " 217 "Failed to create Directory implementation. " 218 "Please report this bug to the Tpetra developers.");
223 template<
class LO,
class GO,
class NT>
227 const Teuchos::ArrayView<const GO>& globalIDs,
228 const Teuchos::ArrayView<int>& nodeIDs)
const 236 const bool computeLIDs =
false;
237 return impl_->
getEntries (map, globalIDs, nodeIDs, Teuchos::null, computeLIDs);
240 template<
class LO,
class GO,
class NT>
244 const Teuchos::ArrayView<const GO>& globalIDs,
245 const Teuchos::ArrayView<int>& nodeIDs,
246 const Teuchos::ArrayView<LO>& localIDs)
const 254 const bool computeLIDs =
true;
255 return impl_->
getEntries (map, globalIDs, nodeIDs, localIDs, computeLIDs);
258 template<
class LO,
class GO,
class NT>
269 template<
class LO,
class GO,
class NT>
273 using Teuchos::TypeNameTraits;
275 std::ostringstream os;
277 <<
"<" << TypeNameTraits<LO>::name ()
278 <<
", " << TypeNameTraits<GO>::name ()
279 <<
", " << TypeNameTraits<NT>::name () <<
">";
292 #define TPETRA_DIRECTORY_INSTANT(LO,GO,NODE) \ 294 namespace Classes { \ 295 template class Directory< LO , GO , NODE >; \ 298 #endif // TPETRA_DIRECTORY_HPP Namespace Tpetra contains the class and methods constituting the Tpetra library.
bool initialized() const
Whether the Directory is initialized.
LocalOrdinal getMinLocalIndex() const
The minimum local index.
LookupStatus
Return status of Map remote index lookup (getRemoteIndexList()).
LocalOrdinal getMaxLocalIndex() const
The maximum local index on the calling process.
GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const
The global index corresponding to the given local index.
size_t getNodeNumElements() const
The number of elements belonging to the calling process.
virtual std::size_t selectedIndex(GlobalOrdinal GID, const std::vector< std::pair< int, LocalOrdinal > > &pid_and_lid) const =0
Break any ties in ownership of the given global index GID.
void initialize(const map_type &map)
Initialize the Directory with its Map.
bool isOneToOne(const map_type &map) const
Whether the Directory's input Map is (globally) one to one.
bool isContiguous() const
True if this Map is distributed contiguously, else false.
Directory()
Default constructor: the only one you should use.
LookupStatus getDirectoryEntries(const map_type &map, const Teuchos::ArrayView< const GlobalOrdinal > &globalIDs, const Teuchos::ArrayView< int > &nodeIDs) const
Given a global ID list, return the list of their owning process IDs.
Implement mapping from global ID to process ID and local ID.
std::string description() const
A one-line human-readable description of this object.
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Accessors for the Teuchos::Comm and Kokkos Node objects.
bool isDistributed() const
Whether this Map is globally distributed or locally replicated.
virtual bool isOneToOne(const Teuchos::Comm< int > &comm) const =0
Whether the Directory's input Map is (globally) one to one.
virtual bool mayHaveSideEffects() const
Whether selectedIndex() may have side effects.
LookupStatus getEntries(const map_type &map, const Teuchos::ArrayView< const GlobalOrdinal > &globalIDs, const Teuchos::ArrayView< int > &nodeIDs, const Teuchos::ArrayView< LocalOrdinal > &localIDs, const bool computeLIDs) const
Interface for breaking ties in ownership.
bool isUniform() const
Whether the range of global indices is uniform.