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>
183 if (initialized ()) {
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;
201 if (map.isDistributed ()) {
202 if (map.isUniform ()) {
203 dir = new ::Tpetra::Details::ContiguousUniformDirectory<LO, GO, NT> (map);
205 else if (map.isContiguous ()) {
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
230 if (! initialized ()) {
234 const_cast<Directory<LO, GO, NT>*
> (
this)->
initialize (map);
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
248 if (! initialized ()) {
252 const_cast<Directory<LO, GO, NT>*
> (
this)->
initialize (map);
254 const bool computeLIDs =
true;
255 return impl_->getEntries (map, globalIDs, nodeIDs, localIDs, computeLIDs);
258 template<
class LO,
class GO,
class NT>
260 if (! initialized ()) {
264 const_cast<Directory<LO, GO, NT>*
> (
this)->
initialize (map);
266 return impl_->isOneToOne (* (map.getComm ()));
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