61 int me = comm.
MyPID();
68 const int nGlobalEntries = 8 * np;
69 const double tgtScalar = 100. * (me+1);
70 const double srcScalar = 2.;
74 map_t defaultMap(nGlobalEntries, 0, comm);
76 std::cout << me <<
" DEFAULT MAP" << std::endl;
77 defaultMap.Print(std::cout);
81 vector_t defaultVecTgt(defaultMap);
82 defaultVecTgt.PutScalar(tgtScalar);
84 vector_t defaultVecSrc(defaultMap);
85 defaultVecSrc.PutScalar(srcScalar);
90 defaultVecTgt.Export(defaultVecSrc, defaultToDefault,
Add);
92 std::cout << me <<
" DEFAULT TO DEFAULT " << std::endl;
93 defaultVecTgt.Print(std::cout);
96 for (
int i = 0; i < defaultVecTgt.MyLength(); i++)
97 if (defaultVecTgt[i] != srcScalar) ierr++;
100 std::cout <<
"TEST FAILED: DEFAULT-TO-DEFAULT-EPETRA TEST HAD " << ierr
101 <<
" FAILURES ON RANK " << me << std::endl;
104 comm.
SumAll(&ierr, &gerr, 1);
112 int me = comm.
MyPID();
119 const int nGlobalEntries = 8 * np;
120 const double tgtScalar = 100. * (me+1);
121 const double srcScalar = 2.;
122 std::vector<int> myEntries(nGlobalEntries);
126 map_t defaultMap(nGlobalEntries, 0, comm);
128 std::cout << me <<
" DEFAULT MAP" << std::endl;
129 defaultMap.Print(std::cout);
134 for (
int i = 0; i < nGlobalEntries; i++) {
136 myEntries[nMyEntries++] = i;
141 map_t cyclicMap(dummy, nMyEntries, &myEntries[0], 0, comm);
143 std::cout << me <<
" CYCLIC MAP" << std::endl;
144 cyclicMap.Print(std::cout);
148 vector_t defaultVecTgt(defaultMap);
149 defaultVecTgt.PutScalar(tgtScalar);
151 vector_t cyclicVecSrc(cyclicMap);
152 cyclicVecSrc.PutScalar(srcScalar);
157 defaultVecTgt.Export(cyclicVecSrc, cyclicToDefault,
Add);
159 std::cout << me <<
" CYCLIC TO DEFAULT " << std::endl;
160 defaultVecTgt.Print(std::cout);
163 for (
int i = 0; i < defaultVecTgt.MyLength(); i++) {
164 if (cyclicMap.LID(defaultMap.GID(i)) != -1) {
167 if (defaultVecTgt[i] != srcScalar) ierr++;
172 if (defaultVecTgt[i] != tgtScalar + srcScalar) ierr++;
176 std::cout <<
"TEST FAILED: CYCLIC-TO-DEFAULT-EPETRA TEST HAD " << ierr
177 <<
" FAILURES ON RANK " << me << std::endl;
180 comm.
SumAll(&ierr, &gerr, 1);
188 int me = comm.
MyPID();
197 const int nGlobalEntries = 8 * np;
198 const double tgtScalar = 100. * (me+1);
199 const double srcScalar = 2.;
200 std::vector<int> myEntries(nGlobalEntries);
204 map_t defaultMap(nGlobalEntries, 0, comm);
206 std::cout << me <<
" DEFAULT MAP" << std::endl;
207 defaultMap.Print(std::cout);
211 for (
int i = 0; i < defaultMap.NumMyElements()/2; i++) {
212 myEntries[nMyEntries++] = defaultMap.GID(i);
214 for (
int i = 0; i < defaultMap.NumMyElements(); i++) {
215 myEntries[nMyEntries++] =
216 (defaultMap.MaxMyGID() + 1 + i) % nGlobalEntries;
220 map_t overlapMap(dummy, nMyEntries, &myEntries[0], 0, comm);
222 std::cout << me <<
" OVERLAP MAP" << std::endl;
223 overlapMap.Print(std::cout);
227 vector_t defaultVecTgt(defaultMap);
228 defaultVecTgt.PutScalar(tgtScalar);
230 vector_t overlapVecSrc(overlapMap);
231 overlapVecSrc.PutScalar(srcScalar);
236 defaultVecTgt.Export(overlapVecSrc, overlapToDefault,
Add);
238 std::cout << me <<
" OVERLAP TO DEFAULT " << std::endl;
239 defaultVecTgt.Print(std::cout);
241 for (
int i = 0; i < defaultVecTgt.MyLength()/2; i++)
242 if (defaultVecTgt[i] != srcScalar + srcScalar) ierr++;
243 for (
int i = defaultVecTgt.MyLength()/2;
244 i < defaultVecTgt.MyLength(); i++)
245 if (defaultVecTgt[i] != tgtScalar + srcScalar) ierr++;
247 std::cout <<
"TEST FAILED: OVERLAP-TO-DEFAULT-EPETRA TEST HAD " << ierr
248 <<
" FAILURES ON RANK " << me << std::endl;
252 comm.
SumAll(&ierr, &gerr, 1);
270 int me = comm.
MyPID();
277 const int nGlobalEntries = 8 * np;
278 const double tgtScalar = 100. * (me+1);
279 const double srcScalar = 2.;
280 std::vector<int> myEntries(nGlobalEntries);
284 for (
int i = 0; i < nGlobalEntries; i++) {
285 if (
int(i % 2) == (me % 2)) {
286 myEntries[nMyEntries++] = i;
291 map_t oddEvenMap(dummy, nMyEntries, &myEntries[0], 0, comm);
293 std::cout << me <<
" ODDEVEN MAP" << std::endl;
294 oddEvenMap.Print(std::cout);
299 int nSerialEntries = (me == 0 ? nGlobalEntries : 0);
300 map_t serialMap(dummy, nSerialEntries, 0, comm);
302 std::cout << me <<
" SERIAL MAP" << std::endl;
303 serialMap.Print(std::cout);
307 vector_t oddEvenVecSrc(oddEvenMap);
308 oddEvenVecSrc.PutScalar(srcScalar);
310 vector_t serialVecTgt(serialMap);
311 serialVecTgt.PutScalar(tgtScalar);
316 serialVecTgt.Export(oddEvenVecSrc, oddEvenToSerial,
Add);
318 std::cout << me <<
" ODDEVEN TO SERIAL " << std::endl;
319 serialVecTgt.Print(std::cout);
323 for (
int i = 0; i < serialVecTgt.MyLength(); i++) {
324 double nCopies = double(((np+1) / 2) - ((i % 2 == 1) && (np % 2 == 1)));
325 if (serialVecTgt[i] != (i%2 ? tgtScalar : 0.) + srcScalar * nCopies)
329 std::cout <<
"TEST FAILED: ODDEVEN-TO-SERIAL TEST HAD " << ierr
330 <<
" FAILURES ON RANK " << me << std::endl;
333 comm.
SumAll(&ierr, &gerr, 1);
341 int me = comm.
MyPID();
350 const int nGlobalEntries = 8 * np;
351 const double tgtScalar = 100. * (me+1);
352 const double srcScalar = 2.;
353 std::vector<int> myEntries(nGlobalEntries);
357 map_t defaultMap(nGlobalEntries, 0, comm);
359 std::cout << me <<
" DEFAULT MAP" << std::endl;
360 defaultMap.Print(std::cout);
364 for (
int i = 0; i < defaultMap.NumMyElements(); i++) {
365 myEntries[nMyEntries++] = defaultMap.GID(i);
367 for (
int i = 0; i < defaultMap.NumMyElements()/2; i++) {
368 myEntries[nMyEntries++] =
369 (defaultMap.MaxMyGID() + 1 + i) % nGlobalEntries;
373 map_t supersetMap(dummy, nMyEntries, &myEntries[0], 0, comm);
375 std::cout << me <<
" SUPERSET MAP" << std::endl;
376 supersetMap.Print(std::cout);
380 vector_t defaultVecTgt(defaultMap);
381 defaultVecTgt.PutScalar(tgtScalar);
383 vector_t supersetVecSrc(supersetMap);
384 supersetVecSrc.PutScalar(srcScalar);
389 defaultVecTgt.Export(supersetVecSrc, supersetToDefault,
Add);
391 std::cout << me <<
" SUPERSET TO DEFAULT " << std::endl;
392 defaultVecTgt.Print(std::cout);
394 for (
int i = 0; i < defaultVecTgt.MyLength()/2; i++)
395 if (defaultVecTgt[i] != 2 * srcScalar) ierr++;
396 for (
int i = defaultVecTgt.MyLength()/2;
397 i < defaultVecTgt.MyLength(); i++)
398 if (defaultVecTgt[i] != srcScalar) ierr++;
400 std::cout <<
"TEST FAILED: SUPERSET-TO-DEFAULT-EPETRA TEST HAD " << ierr
401 <<
" FAILURES ON RANK " << me << std::endl;
405 comm.
SumAll(&ierr, &gerr, 1);
418 int me = comm.
MyPID();
426 const int nGlobalEntries = 8 * np;
427 const double tgtScalar = 100. * (me+1);
428 const double srcScalar = 2.;
429 std::vector<int> myEntries(nGlobalEntries);
433 map_t defaultMap(nGlobalEntries, 0, comm);
435 std::cout << me <<
" DEFAULT MAP" << std::endl;
436 defaultMap.Print(std::cout);
440 for (
int i = 0; i < defaultMap.NumMyElements(); i++) {
441 myEntries[nMyEntries++] =
442 (defaultMap.MaxMyGID() + 1 + i) % nGlobalEntries;
446 map_t noSamesMap(dummy, nMyEntries, &myEntries[0], 0, comm);
448 std::cout << me <<
" NOSAMES MAP" << std::endl;
449 noSamesMap.Print(std::cout);
453 vector_t defaultVecTgt(defaultMap);
454 defaultVecTgt.PutScalar(tgtScalar);
456 vector_t noSamesVecSrc(noSamesMap);
457 noSamesVecSrc.PutScalar(srcScalar);
462 defaultVecTgt.Export(noSamesVecSrc, noSamesToDefault,
Add);
464 std::cout << me <<
" NOSAMES TO DEFAULT " << std::endl;
465 defaultVecTgt.Print(std::cout);
467 for (
int i = 0; i < defaultVecTgt.MyLength(); i++)
468 if (defaultVecTgt[i] != tgtScalar + srcScalar) ierr++;
470 std::cout <<
"TEST FAILED: NOSAMES-TO-DEFAULT TEST HAD " << ierr
471 <<
" FAILURES ON RANK " << me << std::endl;
475 comm.
SumAll(&ierr, &gerr, 1);
481 int main(
int argc,
char **argv)
485 MPI_Init(&argc,&argv);
500 if (Comm.
MyPID() == 0) {
501 if (gerr > 0) std::cout <<
"TEST FAILED" << std::endl;
502 else std::cout <<
"TEST PASSED" << std::endl;
int OverlapToDefaultEpetra(const Epetra_Comm &comm)
Epetra_Map: A class for partitioning vectors and matrices.
Epetra_Export: This class builds an export object for efficient exporting of off-processor elements...
Epetra_Vector: A class for constructing and using dense vectors on a parallel computer.
int MyPID() const
Return my process ID.
Epetra_MpiComm: The Epetra MPI Communication Class.
virtual int MyPID() const =0
Return my process ID.
int DefaultToDefaultEpetra(const Epetra_Comm &comm)
virtual int SumAll(double *PartialSums, double *GlobalSums, int Count) const =0
Epetra_Comm Global Sum function.
Epetra_Comm: The Epetra Communication Abstract Base Class.
Epetra_SerialComm: The Epetra Serial Communication Class.
virtual int NumProc() const =0
Returns total number of processes.
int main(int argc, char *argv[])
int CyclicToDefaultEpetra(const Epetra_Comm &comm)
int SupersetToDefaultEpetra(const Epetra_Comm &comm)
int NoSamesToDefaultEpetra(const Epetra_Comm &comm)
int OddEvenToSerialEpetra(const Epetra_Comm &comm)