42 #ifndef TPETRA_DETAILS_TRANSFER_DEF_HPP
43 #define TPETRA_DETAILS_TRANSFER_DEF_HPP
45 #include "Tpetra_Details_gathervPrint.hpp"
46 #include "Tpetra_Distributor.hpp"
47 #include "Tpetra_Map.hpp"
48 #include "Teuchos_CommHelpers.hpp"
49 #include "Teuchos_TypeNameTraits.hpp"
56 template <
class LO,
class GO,
class NT>
60 const Teuchos::EVerbosityLevel verbLevel)
const
62 this->describeImpl (out,
"Tpetra::Details::Transfer", verbLevel);
65 template<
class LO,
class GO,
class NT>
69 const std::string& className,
70 const Teuchos::EVerbosityLevel verbLevel)
const
72 using Teuchos::TypeNameTraits;
73 using Teuchos::VERB_DEFAULT;
74 using Teuchos::VERB_NONE;
75 using Teuchos::VERB_LOW;
77 const Teuchos::EVerbosityLevel vl =
78 (verbLevel == VERB_DEFAULT) ? VERB_LOW : verbLevel;
80 if (vl == VERB_NONE) {
87 auto srcMap = this->getSourceMap ();
88 if (srcMap.is_null ()) {
91 auto comm = srcMap->getComm ();
92 if (comm.is_null ()) {
95 if (this->getTargetMap ().is_null () ||
96 this->getTargetMap ()->getComm ().is_null ()) {
100 const int myRank = comm->getRank ();
101 const int numProcs = comm->getSize ();
108 Teuchos::RCP<Teuchos::OSTab> tab0, tab1;
114 tab0 = Teuchos::rcp (
new Teuchos::OSTab (out));
116 out <<
"\"" << className <<
"\":" << endl;
117 tab1 = Teuchos::rcp (
new Teuchos::OSTab (out));
120 out <<
"Template parameters:" << endl;
121 Teuchos::OSTab tab2 (out);
122 out <<
"LocalOrdinal: " << TypeNameTraits<LO>::name () << endl
123 <<
"GlobalOrdinal: " << TypeNameTraits<GO>::name () << endl
124 <<
"Node: " << TypeNameTraits<NT>::name () << endl;
127 const std::string label = this->getObjectLabel ();
129 out <<
"Label: " << label << endl;
131 out <<
"Number of processes: " << numProcs << endl;
138 this->globalDescribe (out, vl);
150 out <<
"Source Map:" << endl;
153 this->getSourceMap ()->describe (out, vl);
156 out <<
"Target Map:" << endl;
159 this->getTargetMap ()->describe (out, vl);
162 out <<
"Distributor:" << endl;
164 this->getDistributor ().describe (out, vl);
167 template<
class LO,
class GO,
class NT>
171 const Teuchos::EVerbosityLevel vl)
const
174 using Teuchos::OSTab;
176 using Teuchos::toString;
183 auto srcMap = this->getSourceMap ();
184 if (srcMap.is_null ()) {
187 RCP<const Teuchos::Comm<int> > comm = srcMap->getComm ();
188 if (comm.is_null ()) {
192 const std::string myStr = localDescribeToString (vl);
193 ::Tpetra::Details::gathervPrint (out, myStr, *comm);
196 template<
class LO,
class GO,
class NT>
198 Transfer<LO, GO, NT>::
199 localDescribeToString (
const Teuchos::EVerbosityLevel vl)
const
201 using Teuchos::OSTab;
205 RCP<std::ostringstream> outString (
new std::ostringstream);
206 RCP<Teuchos::FancyOStream> outp = Teuchos::getFancyOStream (outString);
207 Teuchos::FancyOStream& out = *outp;
209 RCP<const Teuchos::Comm<int> > comm = this->getSourceMap ()->getComm ();
210 if (this->getSourceMap ().is_null () ||
211 this->getSourceMap ()->getComm ().is_null ()) {
216 return std::string (
"");
219 const int myRank = comm->getRank ();
220 const int numProcs = comm->getSize ();
222 out <<
"Process " << myRank <<
" of " << numProcs <<
":" << endl;
225 out <<
"numSameIDs: " << getNumSameIDs () << endl;
226 out <<
"numPermuteIDs: " << getNumPermuteIDs () << endl;
227 out <<
"numRemoteIDs: " << getNumRemoteIDs () << endl;
228 out <<
"numExportIDs: " << getNumExportIDs () << endl;
232 if (vl <= Teuchos::VERB_MEDIUM) {
233 out <<
"permuteFromLIDs count: " << getPermuteFromLIDs ().size () << endl
234 <<
"permuteToLIDs count: " << getPermuteToLIDs ().size () << endl
235 <<
"remoteLIDs count: " << getRemoteLIDs ().size () << endl
236 <<
"exportLIDs count: " << getExportLIDs ().size () << endl
237 <<
"exportPIDs count: " << getExportPIDs () << endl;
241 RCP<const Map<LO,GO,NT> > tmap = getTargetMap();
242 RCP<const Map<LO,GO,NT> > smap = getSourceMap();
243 Teuchos::Array<GO> RemoteGIDs(getRemoteLIDs().size());
244 Teuchos::Array<int> RemotePIDs(getRemoteLIDs().size());
245 for(
size_t i=0; i<(size_t)getRemoteLIDs().size(); i++)
246 RemoteGIDs[i] = tmap->getGlobalElement(getRemoteLIDs()[i]);
248 Teuchos::Array<int> ExportGIDs(getExportLIDs().size());
249 for(
size_t i=0; i<(size_t)getExportLIDs().size(); i++)
250 ExportGIDs[i] = smap->getGlobalElement(getExportLIDs()[i]);
255 Teuchos::ArrayView<const int> ProcsFrom = D.
getProcsFrom();
256 Teuchos::ArrayView<const size_t> LengthsFrom = D.
getLengthsFrom();
257 for (
size_t i = 0, j = 0; i < NumReceives; ++i) {
258 const int pid = ProcsFrom[i];
259 for (
size_t k = 0; k < LengthsFrom[i]; ++k) {
265 out <<
"distor.NumRecvs : "<<NumReceives<<endl
266 <<
"distor.ProcsFrom : "<<toString(ProcsFrom)<<endl
267 <<
"distor.LengthsFrom: "<<toString(LengthsFrom)<<endl;
270 <<
"distor.ProcsTo : "<<toString(D.
getProcsTo())<<endl
271 <<
"distor.LengthsTo : "<<toString(D.
getLengthsTo())<<endl;
275 out <<
"permuteFromLIDs: " << toString (getPermuteFromLIDs ()) << endl
276 <<
"permuteToLIDs: " << toString (getPermuteToLIDs ()) << endl
277 <<
"remoteLIDs: " << toString (getRemoteLIDs ()) << endl
278 <<
"remoteGIDs: " << toString (RemoteGIDs ()) << endl
279 <<
"remotePIDs: " << toString (RemotePIDs ()) << endl
280 <<
"exportLIDs: " << toString (getExportLIDs ()) << endl
281 <<
"exportGIDs: " << toString (ExportGIDs ()) << endl
282 <<
"exportPIDs: " << toString (getExportPIDs ()) << endl;
286 return outString->str ();
294 #endif // TPETRA_DETAILS_TRANSFER_DEF_HPP