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" 
   52   template<
class LO, 
class GO, 
class NT>
 
   57   template<
class LO, 
class GO, 
class NT>
 
   65   template<
class LO, 
class GO, 
class NT>
 
   72   template<
class LO, 
class GO, 
class NT>
 
   79       TEUCHOS_TEST_FOR_EXCEPTION(
 
   80         impl_ == NULL, std::logic_error, 
"Tpetra::Directory::initialize: " 
   81         "The Directory claims that it has been initialized, " 
   82         "but its implementation object has not yet been created.  " 
   83         "Please report this bug to the Tpetra developers.");
 
   86       TEUCHOS_TEST_FOR_EXCEPTION(
 
   87         impl_ != NULL, std::logic_error, 
"Tpetra::Directory::initialize: " 
   88         "Directory implementation has already been initialized, " 
   89         "but initialized() returns false.  " 
   90         "Please report this bug to the Tpetra developers.");
 
  114       const ::Tpetra::Details::Directory<LO, GO, NT>* dir = NULL;
 
  115       bool usedTieBreak = 
false;
 
  118           dir = new ::Tpetra::Details::ContiguousUniformDirectory<LO, GO, NT> (map);
 
  121           dir = new ::Tpetra::Details::DistributedContiguousDirectory<LO, GO, NT> (map);
 
  124           dir = new ::Tpetra::Details::DistributedNoncontiguousDirectory<LO, GO, NT> (map, tieBreak);
 
  129         dir = new ::Tpetra::Details::ReplicatedDirectory<LO, GO, NT> (map);
 
  134           const int myRank = map.
getComm ()->getRank ();
 
  139             std::vector<std::pair<int, LO> > pidLidList (1);
 
  142             for (LO locInd = minLocInd; locInd <= maxLocInd; ++locInd) {
 
  143               pidLidList[0] = std::make_pair (myRank, locInd);
 
  161         std::vector<std::pair<int, LO> > pidLidList (1);
 
  164         const int myRank = map.
getComm ()->getRank ();
 
  165         for (LO locInd = minLocInd; locInd <= maxLocInd; ++locInd) {
 
  166           pidLidList[0] = std::make_pair (myRank, locInd);
 
  178   template<
class LO, 
class GO, 
class NT>
 
  182     if (initialized ()) {
 
  183       TEUCHOS_TEST_FOR_EXCEPTION(
 
  184         impl_ == NULL, std::logic_error, 
"Tpetra::Directory::initialize: " 
  185         "The Directory claims that it has been initialized, " 
  186         "but its implementation object has not yet been created.  " 
  187         "Please report this bug to the Tpetra developers.");
 
  190       TEUCHOS_TEST_FOR_EXCEPTION(
 
  191         impl_ != NULL, std::logic_error, 
"Tpetra::Directory::initialize: " 
  192         "Directory implementation has already been initialized, " 
  193         "but initialized() returns false.  " 
  194         "Please report this bug to the Tpetra developers.");
 
  199       const ::Tpetra::Details::Directory<LO, GO, NT>* dir = NULL;
 
  200       if (map.isDistributed ()) {
 
  201         if (map.isUniform ()) {
 
  202           dir = new ::Tpetra::Details::ContiguousUniformDirectory<LO, GO, NT> (map);
 
  204         else if (map.isContiguous ()) {
 
  205           dir = new ::Tpetra::Details::DistributedContiguousDirectory<LO, GO, NT> (map);
 
  208           dir = new ::Tpetra::Details::DistributedNoncontiguousDirectory<LO, GO, NT> (map);
 
  212         dir = new ::Tpetra::Details::ReplicatedDirectory<LO, GO, NT> (map);
 
  214       TEUCHOS_TEST_FOR_EXCEPTION(
 
  215         dir == NULL, std::logic_error, 
"Tpetra::Directory::initialize: " 
  216         "Failed to create Directory implementation.  " 
  217         "Please report this bug to the Tpetra developers.");
 
  222   template<
class LO, 
class GO, 
class NT>
 
  226                        const Teuchos::ArrayView<const GO>& globalIDs,
 
  227                        const Teuchos::ArrayView<int>& nodeIDs)
 const 
  229     if (! initialized ()) {
 
  233       const_cast<Directory<LO, GO, NT>* 
> (
this)->
initialize (map);
 
  235     const bool computeLIDs = 
false;
 
  236     return impl_->getEntries (map, globalIDs, nodeIDs, Teuchos::null, computeLIDs);
 
  239   template<
class LO, 
class GO, 
class NT>
 
  243                        const Teuchos::ArrayView<const GO>& globalIDs,
 
  244                        const Teuchos::ArrayView<int>& nodeIDs,
 
  245                        const Teuchos::ArrayView<LO>& localIDs)
 const 
  247     if (! initialized ()) {
 
  251       const_cast<Directory<LO, GO, NT>* 
> (
this)->
initialize (map);
 
  253     const bool computeLIDs = 
true;
 
  254     return impl_->getEntries (map, globalIDs, nodeIDs, localIDs, computeLIDs);
 
  257   template<
class LO, 
class GO, 
class NT>
 
  259     if (! initialized ()) {
 
  263       const_cast<Directory<LO, GO, NT>* 
> (
this)->
initialize (map);
 
  265     return impl_->isOneToOne (* (map.getComm ()));
 
  268   template<
class LO, 
class GO, 
class NT>
 
  272     using Teuchos::TypeNameTraits;
 
  274     std::ostringstream os;
 
  276        << 
"<" << TypeNameTraits<LO>::name ()
 
  277        << 
", " << TypeNameTraits<GO>::name ()
 
  278        << 
", " << TypeNameTraits<NT>::name () << 
">";
 
  290 #define TPETRA_DIRECTORY_INSTANT(LO,GO,NODE) \ 
  291   template class Directory< LO , GO , NODE >; 
  293 #endif // TPETRA_DIRECTORY_HPP 
Interface for breaking ties in ownership. 
 
void initialize(int *argc, char ***argv)
Initialize Tpetra. 
 
bool isContiguous() const 
True if this Map is distributed contiguously, else false. 
 
LookupStatus
Return status of Map remote index lookup (getRemoteIndexList()). 
 
bool isUniform() const 
Whether the range of global indices is uniform. 
 
bool isDistributed() const 
Whether this Map is globally distributed or locally replicated. 
 
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const 
Accessors for the Teuchos::Comm and Kokkos Node objects. 
 
local_ordinal_type getMinLocalIndex() const 
The minimum local index. 
 
global_ordinal_type getGlobalElement(local_ordinal_type localIndex) const 
The global index corresponding to the given local index. 
 
bool isOneToOne(const map_type &map) const 
Whether the Directory's input Map is (globally) one to one. 
 
local_ordinal_type getMaxLocalIndex() const 
The maximum local index on the calling process. 
 
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. 
 
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. 
 
size_t getNodeNumElements() const 
The number of elements belonging to the calling process. 
 
A parallel distribution of indices over processes. 
 
bool initialized() const 
Whether the Directory is initialized. 
 
void initialize(const map_type &map)
Initialize the Directory with its Map. 
 
Directory()
Default constructor: the only one you should use. 
 
std::string description() const 
A one-line human-readable description of this object. 
 
virtual bool mayHaveSideEffects() const 
Whether selectedIndex() may have side effects.