Zoltan 2 Version 0.5
XpetraTraits.cpp
Go to the documentation of this file.
00001 // @HEADER
00002 //
00003 // ***********************************************************************
00004 //
00005 //   Zoltan2: A package of combinatorial algorithms for scientific computing
00006 //                  Copyright 2012 Sandia Corporation
00007 //
00008 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00009 // the U.S. Government retains certain rights in this software.
00010 //
00011 // Redistribution and use in source and binary forms, with or without
00012 // modification, are permitted provided that the following conditions are
00013 // met:
00014 //
00015 // 1. Redistributions of source code must retain the above copyright
00016 // notice, this list of conditions and the following disclaimer.
00017 //
00018 // 2. Redistributions in binary form must reproduce the above copyright
00019 // notice, this list of conditions and the following disclaimer in the
00020 // documentation and/or other materials provided with the distribution.
00021 //
00022 // 3. Neither the name of the Corporation nor the names of the
00023 // contributors may be used to endorse or promote products derived from
00024 // this software without specific prior written permission.
00025 //
00026 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00027 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00029 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00030 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00031 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00032 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00033 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00034 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00035 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00036 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00037 //
00038 // Questions? Contact Karen Devine      (kddevin@sandia.gov)
00039 //                    Erik Boman        (egboman@sandia.gov)
00040 //                    Siva Rajamanickam (srajama@sandia.gov)
00041 //
00042 // ***********************************************************************
00043 //
00044 // @HEADER
00045 //
00046 // Basic test of the XpetraTraits definitions.
00047 //
00048 // TODO - a real test would figure out if the migrated objects are
00049 // the same as the original, here we just look at them on stdout.
00050 // TODO look at number of diagonals and max number of entries in
00051 //   Tpetra and Xpetra migrated graphs.  They're garbage.
00052 
00053 #include <Zoltan2_XpetraTraits.hpp>
00054 #include <Zoltan2_TestHelpers.hpp>
00055 
00056 #include <string>
00057 #include <Teuchos_GlobalMPISession.hpp>
00058 #include <Teuchos_DefaultComm.hpp>
00059 #include <Teuchos_RCP.hpp>
00060 #include <Teuchos_Array.hpp>
00061 #include <Teuchos_ArrayRCP.hpp>
00062 #include <Teuchos_Comm.hpp>
00063 #include <Teuchos_VerboseObject.hpp>
00064 #include <Tpetra_CrsMatrix.hpp>
00065 #include <Tpetra_Vector.hpp>
00066 
00067 #include <Xpetra_EpetraUtils.hpp>
00068 #ifdef HAVE_ZOLTAN2_MPI
00069 #include <Epetra_MpiComm.h>
00070 #else
00071 #include <Epetra_SerialComm.h>
00072 #endif
00073 
00074 using namespace std;
00075 using std::string;
00076 using Teuchos::RCP;
00077 using Teuchos::ArrayRCP;
00078 using Teuchos::ArrayView;
00079 using Teuchos::Array;
00080 using Teuchos::rcp;
00081 using Teuchos::Comm;
00082 
00083 ArrayRCP<gno_t> roundRobinMap(
00084     const RCP<const Xpetra::Map<lno_t, gno_t, node_t> > &m)
00085 {
00086   const RCP<const Comm<int> > &comm = m->getComm();
00087   int proc = comm->getRank();
00088   int nprocs = comm->getSize();
00089   gno_t base = m->getMinAllGlobalIndex();
00090   gno_t max = m->getMaxAllGlobalIndex();
00091   size_t globalrows = m->getGlobalNumElements();
00092   if (globalrows != size_t(max - base + 1)){
00093     TEST_FAIL_AND_EXIT(*comm, 0, 
00094       string("Map is invalid for test - fix test"), 1);
00095   }
00096   RCP<Array<gno_t> > mygids = rcp(new Array<gno_t>);
00097   gno_t firstgno_t = proc; 
00098   if (firstgno_t < base){
00099     gno_t n = base % proc;
00100     if (n>0)
00101       firstgno_t = base - n + proc;
00102     else
00103       firstgno_t = base;
00104   }
00105   for (gno_t gid=firstgno_t; gid <= max; gid+=nprocs){
00106     (*mygids).append(gid);
00107   }
00108 
00109   ArrayRCP<gno_t> newIdArcp = Teuchos::arcp(mygids);
00110 
00111   return newIdArcp;
00112 }
00113 
00114 int main(int argc, char *argv[])
00115 {
00116   Teuchos::GlobalMPISession session(&argc, &argv);
00117   RCP<const Comm<int> > comm = Teuchos::DefaultComm<int>::getComm();
00118   int rank = comm->getRank();
00119 
00120   Teuchos::RCP<Teuchos::FancyOStream> outStream = 
00121     Teuchos::VerboseObjectBase::getDefaultOStream();
00122   Teuchos::EVerbosityLevel v=Teuchos::VERB_EXTREME;
00123 
00124   typedef UserInputForTests uinput_t;
00125   typedef Tpetra::CrsMatrix<scalar_t,lno_t,gno_t,node_t> tmatrix_t;
00126   typedef Tpetra::CrsGraph<lno_t,gno_t,node_t> tgraph_t;
00127   typedef Tpetra::Vector<scalar_t,lno_t,gno_t,node_t> tvector_t;
00128   typedef Tpetra::MultiVector<scalar_t,lno_t,gno_t,node_t> tmvector_t;
00129   typedef Xpetra::CrsMatrix<scalar_t,lno_t,gno_t,node_t> xmatrix_t;
00130   typedef Xpetra::CrsGraph<lno_t,gno_t,node_t> xgraph_t;
00131   typedef Xpetra::Vector<scalar_t,lno_t,gno_t,node_t> xvector_t;
00132   typedef Xpetra::MultiVector<scalar_t,lno_t,gno_t,node_t> xmvector_t;
00133   typedef Xpetra::TpetraMap<lno_t,gno_t,node_t> xtmap_t;
00134 
00135   // Create object that can give us test Tpetra and Xpetra input.
00136 
00137   RCP<uinput_t> uinput;
00138 
00139   try{
00140     uinput = 
00141       rcp(new uinput_t(testDataFilePath,std::string("simple"), comm, true));
00142   }
00143   catch(std::exception &e){
00144     TEST_FAIL_AND_EXIT(*comm, 0, string("input ")+e.what(), 1);
00145   }
00146 
00148   //   Tpetra::CrsMatrix
00149   //   Tpetra::CrsGraph
00150   //   Tpetra::Vector
00151   //   Tpetra::MultiVector
00153 
00154   // XpetraTraits<Tpetra::CrsMatrix<scalar_t, lno_t, gno_t, node_t> > 
00155   {
00156     RCP<tmatrix_t> M;
00157   
00158     try{
00159       M = uinput->getTpetraCrsMatrix();
00160     }
00161     catch(std::exception &e){
00162       TEST_FAIL_AND_EXIT(*comm, 0, 
00163         string("getTpetraCrsMatrix ")+e.what(), 1);
00164     }
00165   
00166     if (rank== 0)
00167       std::cout << "Original Tpetra matrix " << M->getGlobalNumRows()
00168         << " x " << M->getGlobalNumCols() << std::endl;
00169 
00170     M->describe(*outStream,v);
00171 
00172     RCP<const xtmap_t> xmap(new xtmap_t(M->getRowMap()));
00173 
00174     ArrayRCP<gno_t> newRowIds = roundRobinMap(xmap);
00175   
00176     gno_t localNumRows = newRowIds.size();
00177   
00178     RCP<const tmatrix_t> newM;
00179     try{
00180       newM = Zoltan2::XpetraTraits<tmatrix_t>::doMigration(
00181         rcp_const_cast<const tmatrix_t>(M),
00182         localNumRows, newRowIds.getRawPtr());
00183     }
00184     catch(std::exception &e){
00185       TEST_FAIL_AND_EXIT(*comm, 0, 
00186         string(" Zoltan2::XpetraTraits<tmatrix_t>::doMigration ")+e.what(), 1);
00187     }
00188 
00189     if (rank== 0)
00190       std::cout << "Migrated Tpetra matrix" << std::endl;
00191   
00192     newM->describe(*outStream,v);
00193   }
00194 
00195   // XpetraTraits<Tpetra::CrsGraph<scalar_t, lno_t, gno_t, node_t> > 
00196   {
00197     RCP<tgraph_t> G;
00198   
00199     try{
00200       G = uinput->getTpetraCrsGraph();
00201     }
00202     catch(std::exception &e){
00203       TEST_FAIL_AND_EXIT(*comm, 0, 
00204         string("getTpetraCrsGraph ")+e.what(), 1);
00205     }
00206   
00207     if (rank== 0)
00208       std::cout << "Original Tpetra graph" << std::endl;
00209   
00210     Teuchos::RCP<Teuchos::FancyOStream>
00211       outStream = Teuchos::VerboseObjectBase::getDefaultOStream();
00212     Teuchos::EVerbosityLevel v=Teuchos::VERB_EXTREME;
00213     G->describe(*outStream,v);
00214   
00215     RCP<const xtmap_t> xmap(new xtmap_t(G->getRowMap()));
00216     ArrayRCP<gno_t> newRowIds = roundRobinMap(xmap);
00217   
00218     gno_t localNumRows = newRowIds.size();
00219   
00220     RCP<const tgraph_t> newG;
00221     try{
00222       newG = Zoltan2::XpetraTraits<tgraph_t>::doMigration(
00223         rcp_const_cast<const tgraph_t>(G),
00224         localNumRows, newRowIds.getRawPtr());
00225     }
00226     catch(std::exception &e){
00227       TEST_FAIL_AND_EXIT(*comm, 0, 
00228         string(" Zoltan2::XpetraTraits<tgraph_t>::doMigration ")+e.what(), 1);
00229     }
00230   
00231     if (rank== 0)
00232       std::cout << "Migrated Tpetra graph" << std::endl;
00233   
00234     newG->describe(*outStream,v);
00235   }
00236 
00237   // XpetraTraits<Tpetra::Vector<scalar_t, lno_t, gno_t, node_t>> 
00238   {
00239     RCP<tvector_t> V;
00240   
00241     try{
00242       V = uinput->getTpetraVector();
00243     }
00244     catch(std::exception &e){
00245       TEST_FAIL_AND_EXIT(*comm, 0, 
00246         string("getTpetraVector")+e.what(), 1);
00247     }
00248   
00249     if (rank== 0)
00250       std::cout << "Original Tpetra vector" << std::endl;
00251   
00252     V->describe(*outStream,v);
00253   
00254     RCP<const xtmap_t> xmap(new xtmap_t(V->getMap()));
00255     ArrayRCP<gno_t> newRowIds = roundRobinMap(xmap);
00256   
00257     gno_t localNumRows = newRowIds.size();
00258   
00259     RCP<const tvector_t> newV;
00260     try{
00261       newV = Zoltan2::XpetraTraits<tvector_t>::doMigration(
00262         rcp_const_cast<const tvector_t>(V),
00263         localNumRows, newRowIds.getRawPtr());
00264     }
00265     catch(std::exception &e){
00266       TEST_FAIL_AND_EXIT(*comm, 0, 
00267         string(" Zoltan2::XpetraTraits<tvector_t>::doMigration ")+e.what(), 1);
00268     }
00269   
00270     if (rank== 0)
00271       std::cout << "Migrated Tpetra vector" << std::endl;
00272   
00273     newV->describe(*outStream,v);
00274   }
00275 
00276   // XpetraTraits<Tpetra::MultiVector<scalar_t, lno_t, gno_t, node_t>> 
00277   {
00278     RCP<tmvector_t> MV;
00279   
00280     try{
00281       MV = uinput->getTpetraMultiVector(3);
00282     }
00283     catch(std::exception &e){
00284       TEST_FAIL_AND_EXIT(*comm, 0, 
00285         string("getTpetraMultiVector")+e.what(), 1);
00286     }
00287   
00288     if (rank== 0)
00289       std::cout << "Original Tpetra multivector" << std::endl;
00290   
00291     MV->describe(*outStream,v);
00292   
00293     RCP<const xtmap_t> xmap(new xtmap_t(MV->getMap()));
00294     ArrayRCP<gno_t> newRowIds = roundRobinMap(xmap);
00295   
00296     gno_t localNumRows = newRowIds.size();
00297   
00298     RCP<const tmvector_t> newMV;
00299     try{
00300       newMV = Zoltan2::XpetraTraits<tmvector_t>::doMigration(
00301         rcp_const_cast<const tmvector_t>(MV),
00302         localNumRows, newRowIds.getRawPtr());
00303     }
00304     catch(std::exception &e){
00305       TEST_FAIL_AND_EXIT(*comm, 0, 
00306         string(" Zoltan2::XpetraTraits<tmvector_t>::doMigration ")+e.what(), 1);
00307     }
00308   
00309     if (rank== 0)
00310       std::cout << "Migrated Tpetra multivector" << std::endl;
00311   
00312     newMV->describe(*outStream,v);
00313   }
00314 
00316   //   Xpetra::CrsMatrix
00317   //   Xpetra::CrsGraph
00318   //   Xpetra::Vector
00319   //   Xpetra::MultiVector
00321 
00322   // XpetraTraits<Xpetra::CrsMatrix<scalar_t, lno_t, gno_t, node_t> > 
00323   {
00324     RCP<xmatrix_t> M;
00325   
00326     try{
00327       M = uinput->getXpetraCrsMatrix();
00328     }
00329     catch(std::exception &e){
00330       TEST_FAIL_AND_EXIT(*comm, 0, 
00331         string("getXpetraCrsMatrix ")+e.what(), 1);
00332     }
00333   
00334     if (rank== 0)
00335       std::cout << "Original Xpetra matrix" << std::endl;
00336   
00337     M->describe(*outStream,v);
00338   
00339     ArrayRCP<gno_t> newRowIds = roundRobinMap(M->getRowMap());
00340   
00341     gno_t localNumRows = newRowIds.size();
00342   
00343     RCP<const xmatrix_t> newM;
00344     try{
00345       newM = Zoltan2::XpetraTraits<xmatrix_t>::doMigration(
00346         rcp_const_cast<const xmatrix_t>(M),
00347         localNumRows, newRowIds.getRawPtr());
00348     }
00349     catch(std::exception &e){
00350       TEST_FAIL_AND_EXIT(*comm, 0, 
00351         string(" Zoltan2::XpetraTraits<xmatrix_t>::doMigration ")+e.what(), 1);
00352     }
00353 
00354     if (rank== 0)
00355       std::cout << "Migrated Xpetra matrix" << std::endl;
00356   
00357     newM->describe(*outStream,v);
00358   }
00359 
00360   // XpetraTraits<Xpetra::CrsGraph<scalar_t, lno_t, gno_t, node_t> > 
00361   {
00362     RCP<xgraph_t> G;
00363   
00364     try{
00365       G = uinput->getXpetraCrsGraph();
00366     }
00367     catch(std::exception &e){
00368       TEST_FAIL_AND_EXIT(*comm, 0, 
00369         string("getXpetraCrsGraph ")+e.what(), 1);
00370     }
00371   
00372     if (rank== 0)
00373       std::cout << "Original Xpetra graph" << std::endl;
00374   
00375     Teuchos::RCP<Teuchos::FancyOStream>
00376       outStream = Teuchos::VerboseObjectBase::getDefaultOStream();
00377     Teuchos::EVerbosityLevel v=Teuchos::VERB_EXTREME;
00378     G->describe(*outStream,v);
00379   
00380     ArrayRCP<gno_t> newRowIds = roundRobinMap(G->getRowMap());
00381   
00382     gno_t localNumRows = newRowIds.size();
00383   
00384     RCP<const xgraph_t> newG;
00385     try{
00386       newG = Zoltan2::XpetraTraits<xgraph_t>::doMigration(
00387         rcp_const_cast<const xgraph_t>(G),
00388         localNumRows, newRowIds.getRawPtr());
00389     }
00390     catch(std::exception &e){
00391       TEST_FAIL_AND_EXIT(*comm, 0, 
00392         string(" Zoltan2::XpetraTraits<xgraph_t>::doMigration ")+e.what(), 1);
00393     }
00394   
00395     if (rank== 0)
00396       std::cout << "Migrated Xpetra graph" << std::endl;
00397   
00398     newG->describe(*outStream,v);
00399   }
00400 
00401   // XpetraTraits<Xpetra::Vector<scalar_t, lno_t, gno_t, node_t>> 
00402   {
00403     RCP<xvector_t> V;
00404   
00405     try{
00406       V = uinput->getXpetraVector();
00407     }
00408     catch(std::exception &e){
00409       TEST_FAIL_AND_EXIT(*comm, 0, 
00410         string("getXpetraVector")+e.what(), 1);
00411     }
00412   
00413     if (rank== 0)
00414       std::cout << "Original Xpetra vector" << std::endl;
00415   
00416     V->describe(*outStream,v);
00417   
00418     ArrayRCP<gno_t> newRowIds = roundRobinMap(V->getMap());
00419   
00420     gno_t localNumRows = newRowIds.size();
00421   
00422     RCP<const xvector_t> newV;
00423     try{
00424       newV = Zoltan2::XpetraTraits<xvector_t>::doMigration(
00425         rcp_const_cast<const xvector_t>(V),
00426         localNumRows, newRowIds.getRawPtr());
00427     }
00428     catch(std::exception &e){
00429       TEST_FAIL_AND_EXIT(*comm, 0, 
00430         string(" Zoltan2::XpetraTraits<xvector_t>::doMigration ")+e.what(), 1);
00431     }
00432   
00433     if (rank== 0)
00434       std::cout << "Migrated Xpetra vector" << std::endl;
00435   
00436     newV->describe(*outStream,v);
00437   }
00438 
00439   // XpetraTraits<Xpetra::MultiVector<scalar_t, lno_t, gno_t, node_t>> 
00440   {
00441     RCP<xmvector_t> MV;
00442   
00443     try{
00444       MV = uinput->getXpetraMultiVector(3);
00445     }
00446     catch(std::exception &e){
00447       TEST_FAIL_AND_EXIT(*comm, 0, 
00448         string("getXpetraMultiVector")+e.what(), 1);
00449     }
00450   
00451     if (rank== 0)
00452       std::cout << "Original Xpetra multivector" << std::endl;
00453   
00454     MV->describe(*outStream,v);
00455   
00456     ArrayRCP<gno_t> newRowIds = roundRobinMap(MV->getMap());
00457   
00458     gno_t localNumRows = newRowIds.size();
00459   
00460     RCP<const xmvector_t> newMV;
00461     try{
00462       newMV = Zoltan2::XpetraTraits<xmvector_t>::doMigration(
00463         rcp_const_cast<const xmvector_t>(MV),
00464         localNumRows, newRowIds.getRawPtr());
00465     }
00466     catch(std::exception &e){
00467       TEST_FAIL_AND_EXIT(*comm, 0, 
00468         string(" Zoltan2::XpetraTraits<xmvector_t>::doMigration ")+e.what(), 1);
00469     }
00470   
00471     if (rank== 0)
00472       std::cout << "Migrated Xpetra multivector" << std::endl;
00473   
00474     newMV->describe(*outStream,v);
00475   }
00476 
00477 #ifdef HAVE_EPETRA_DATA_TYPES
00478 
00479   //   Epetra_CrsMatrix
00480   //   Epetra_CrsGraph
00481   //   Epetra_Vector
00482   //   Epetra_MultiVector
00484 
00485   typedef Epetra_CrsMatrix ematrix_t;
00486   typedef Epetra_CrsGraph egraph_t;
00487   typedef Epetra_Vector evector_t;
00488   typedef Epetra_MultiVector emvector_t;
00489   typedef Xpetra::EpetraMap xemap_t;
00490   typedef Epetra_BlockMap emap_t;
00491 
00492   // Create object that can give us test Epetra input.
00493 
00494   RCP<uinput_t> euinput;
00495 
00496   try{
00497     euinput = 
00498       rcp(new uinput_t(testDataFilePath,std::string("simple"), comm, true));
00499   }
00500   catch(std::exception &e){
00501     TEST_FAIL_AND_EXIT(*comm, 0, string("epetra input ")+e.what(), 1);
00502   }
00503 
00504   // XpetraTraits<Epetra_CrsMatrix> 
00505   {
00506     RCP<ematrix_t> M;
00507   
00508     try{
00509       M = euinput->getEpetraCrsMatrix();
00510     }
00511     catch(std::exception &e){
00512       TEST_FAIL_AND_EXIT(*comm, 0, 
00513         string("getEpetraCrsMatrix ")+e.what(), 1);
00514     }
00515 
00516     if (rank== 0)
00517       std::cout << "Original Epetra matrix" << std::endl;
00518   
00519     M->Print(std::cout);
00520   
00521     RCP<const emap_t> emap = Teuchos::rcpFromRef(M->RowMap());
00522     RCP<const xemap_t> xmap(new xemap_t(emap));
00523 
00524     ArrayRCP<gno_t> newRowIds = roundRobinMap(xmap);
00525   
00526     gno_t localNumRows = newRowIds.size();
00527   
00528     RCP<const ematrix_t> newM;
00529     try{
00530       newM = Zoltan2::XpetraTraits<ematrix_t>::doMigration(
00531         rcp_const_cast<const ematrix_t>(M),
00532         localNumRows, newRowIds.getRawPtr());
00533     }
00534     catch(std::exception &e){
00535       TEST_FAIL_AND_EXIT(*comm, 0, 
00536         string(" Zoltan2::XpetraTraits<ematrix_t>::doMigration ")+e.what(), 1);
00537     }
00538 
00539     if (rank== 0)
00540       std::cout << "Migrated Epetra matrix" << std::endl;
00541   
00542     newM->Print(std::cout);
00543   }
00544 
00545   // XpetraTraits<Epetra_CrsGraph> 
00546   {
00547     RCP<egraph_t> G;
00548   
00549     try{
00550       G = euinput->getEpetraCrsGraph();
00551     }
00552     catch(std::exception &e){
00553       TEST_FAIL_AND_EXIT(*comm, 0, 
00554         string("getEpetraCrsGraph ")+e.what(), 1);
00555     }
00556   
00557     if (rank== 0)
00558       std::cout << "Original Epetra graph" << std::endl;
00559   
00560     G->Print(std::cout);
00561   
00562     RCP<const emap_t> emap = Teuchos::rcpFromRef(G->RowMap());
00563     RCP<const xemap_t> xmap(new xemap_t(emap));
00564     ArrayRCP<gno_t> newRowIds = roundRobinMap(xmap);
00565   
00566     gno_t localNumRows = newRowIds.size();
00567   
00568     RCP<const egraph_t> newG;
00569     try{
00570       newG = Zoltan2::XpetraTraits<egraph_t>::doMigration(
00571         rcp_const_cast<const egraph_t>(G),
00572         localNumRows, newRowIds.getRawPtr());
00573     }
00574     catch(std::exception &e){
00575       TEST_FAIL_AND_EXIT(*comm, 0, 
00576         string(" Zoltan2::XpetraTraits<egraph_t>::doMigration ")+e.what(), 1);
00577     }
00578   
00579     if (rank== 0)
00580       std::cout << "Migrated Epetra graph" << std::endl;
00581   
00582     newG->Print(std::cout);
00583   }
00584 
00585   // XpetraTraits<Epetra_Vector>
00586   {
00587     RCP<evector_t> V;
00588   
00589     try{
00590       V = euinput->getEpetraVector();
00591     }
00592     catch(std::exception &e){
00593       TEST_FAIL_AND_EXIT(*comm, 0, 
00594         string("getEpetraVector")+e.what(), 1);
00595     }
00596   
00597     if (rank== 0)
00598       std::cout << "Original Epetra vector" << std::endl;
00599   
00600     V->Print(std::cout);
00601   
00602     RCP<const emap_t> emap = Teuchos::rcpFromRef(V->Map());
00603     RCP<const xemap_t> xmap(new xemap_t(emap));
00604     ArrayRCP<gno_t> newRowIds = roundRobinMap(xmap);
00605   
00606     gno_t localNumRows = newRowIds.size();
00607   
00608     RCP<const evector_t> newV;
00609     try{
00610       newV = Zoltan2::XpetraTraits<evector_t>::doMigration(
00611         rcp_const_cast<const evector_t>(V),
00612         localNumRows, newRowIds.getRawPtr());
00613     }
00614     catch(std::exception &e){
00615       TEST_FAIL_AND_EXIT(*comm, 0, 
00616         string(" Zoltan2::XpetraTraits<evector_t>::doMigration ")+e.what(), 1);
00617     }
00618   
00619     if (rank== 0)
00620       std::cout << "Migrated Epetra vector" << std::endl;
00621   
00622     newV->Print(std::cout);
00623   }
00624 
00625   // XpetraTraits<Epetra_MultiVector>
00626   {
00627     RCP<emvector_t> MV;
00628   
00629     try{
00630       MV = euinput->getEpetraMultiVector(3);
00631     }
00632     catch(std::exception &e){
00633       TEST_FAIL_AND_EXIT(*comm, 0, 
00634         string("getEpetraMultiVector")+e.what(), 1);
00635     }
00636   
00637     if (rank== 0)
00638       std::cout << "Original Epetra multivector" << std::endl;
00639   
00640     MV->Print(std::cout);
00641   
00642     RCP<const emap_t> emap = Teuchos::rcpFromRef(MV->Map());
00643     RCP<const xemap_t> xmap(new xemap_t(emap));
00644     ArrayRCP<gno_t> newRowIds = roundRobinMap(xmap);
00645   
00646     gno_t localNumRows = newRowIds.size();
00647   
00648     RCP<const emvector_t> newMV;
00649     try{
00650       newMV = Zoltan2::XpetraTraits<emvector_t>::doMigration(
00651         rcp_const_cast<const emvector_t>(MV),
00652         localNumRows, newRowIds.getRawPtr());
00653     }
00654     catch(std::exception &e){
00655       TEST_FAIL_AND_EXIT(*comm, 0, 
00656         string(" Zoltan2::XpetraTraits<emvector_t>::doMigration ")+e.what(), 1);
00657     }
00658   
00659     if (rank== 0)
00660       std::cout << "Migrated Epetra multivector" << std::endl;
00661   
00662     newMV->Print(std::cout);
00663   }
00664 #endif   // have epetra data types (int, int, double)
00665 
00667   // DONE
00669 
00670   if (rank==0)
00671     std::cout << "PASS" << std::endl;
00672 }
00673