50 #ifndef _ZOLTAN2_XPETRATRAITS_HPP_ 51 #define _ZOLTAN2_XPETRATRAITS_HPP_ 56 #include <Xpetra_TpetraCrsMatrix.hpp> 57 #include <Xpetra_TpetraVector.hpp> 58 #include <Tpetra_Vector.hpp> 60 #if defined(HAVE_ZOLTAN2_EPETRA) && defined(HAVE_XPETRA_EPETRA) 61 #include <Xpetra_EpetraCrsMatrix.hpp> 62 #include <Xpetra_EpetraVector.hpp> 63 #include <Xpetra_EpetraUtils.hpp> 93 template <
typename User>
117 size_t numLocalRows,
const gno_t *myNewRows)
119 return Teuchos::null;
123 #ifndef DOXYGEN_SHOULD_SKIP_THIS 127 template <
typename scalar_t,
131 struct XpetraTraits<Tpetra::CrsMatrix<scalar_t, lno_t, gno_t, node_t> >
133 typedef typename Xpetra::CrsMatrix<scalar_t,lno_t,gno_t,node_t>
xmatrix_t;
134 typedef typename Xpetra::TpetraCrsMatrix<scalar_t,lno_t,gno_t,node_t> xtmatrix_t;
135 typedef typename Tpetra::CrsMatrix<scalar_t,lno_t,gno_t,node_t>
tmatrix_t;
139 return rcp(
new xtmatrix_t(a));
143 size_t numLocalRows,
const gno_t *myNewRows)
145 typedef Tpetra::Map<lno_t, gno_t, node_t> map_t;
149 const RCP<const map_t> &smap = from.getRowMap();
150 gno_t numGlobalRows = smap->getGlobalNumElements();
153 ArrayView<const gno_t> rowList(myNewRows, numLocalRows);
154 const RCP<const Teuchos::Comm<int> > &comm = from.getComm();
155 RCP<const map_t> tmap = rcp(
new map_t(numGlobalRows, rowList, base, comm));
158 Tpetra::Import<lno_t, gno_t, node_t> importer(smap, tmap);
178 int oldNumElts = smap->getNodeNumElements();
179 int newNumElts = numLocalRows;
182 typedef Tpetra::Vector<scalar_t, lno_t, gno_t, node_t> vector_t;
183 vector_t numOld(smap);
184 vector_t numNew(tmap);
185 for (
int lid=0; lid < oldNumElts; lid++){
186 numOld.replaceGlobalValue(smap->getGlobalElement(lid),
187 scalar_t(from.getNumEntriesInLocalRow(lid)));
189 numNew.doImport(numOld, importer, Tpetra::INSERT);
192 ArrayRCP<size_t> nnz(newNumElts);
194 ArrayRCP<scalar_t> ptr = numNew.getDataNonConst(0);
195 for (
int lid=0; lid < newNumElts; lid++){
196 nnz[lid] =
static_cast<size_t>(ptr[lid]);
200 RCP<tmatrix_t> M = rcp(
new tmatrix_t(tmap, nnz, Tpetra::StaticProfile));
201 M->doImport(from, importer, Tpetra::INSERT);
210 #if defined(HAVE_ZOLTAN2_EPETRA) && defined(HAVE_XPETRA_EPETRA) 213 struct XpetraTraits<Epetra_CrsMatrix>
220 static inline RCP<Xpetra::CrsMatrix<scalar_t,lno_t,gno_t,node_t> >
223 RCP<Xpetra::EpetraCrsMatrixT<gno_t, node_t> > xa;
225 xa = rcp(
new Xpetra::EpetraCrsMatrixT<gno_t, node_t>(a));
227 catch (std::exception &e) {
228 if (std::is_same<node_t, Xpetra::EpetraNode>::value)
229 throw std::runtime_error(std::string(
"Cannot convert from " 230 "Epetra_CrsMatrix to " 231 "Xpetra::EpetraCrsMatrixT\n")
234 throw std::runtime_error(std::string(
"Cannot convert from " 235 "Epetra_CrsMatrix to " 236 "Xpetra::EpetraCrsMatrixT\n" 237 "Use node_t that is supported by " 238 "Xpetra with Epetra classes\n")
245 static RCP<Epetra_CrsMatrix>
doMigration(
const Epetra_CrsMatrix &from,
246 size_t numLocalRows,
const gno_t *myNewRows)
251 const Epetra_Map &smap = from.RowMap();
252 gno_t numGlobalRows = smap.NumGlobalElements();
255 const Epetra_Comm &comm = from.Comm();
256 Epetra_Map tmap(numGlobalRows, numLocalRows, myNewRows, base, comm);
259 Epetra_Import importer(tmap, smap);
271 RCP<Epetra_CrsMatrix> M = rcp(
new Epetra_CrsMatrix(from, importer,
307 template <
typename scalar_t,
311 struct XpetraTraits<Xpetra::CrsMatrix<scalar_t, lno_t, gno_t, node_t> >
313 typedef Xpetra::CrsMatrix<scalar_t, lno_t, gno_t, node_t> x_matrix_t;
314 typedef Xpetra::TpetraCrsMatrix<scalar_t, lno_t, gno_t, node_t> xt_matrix_t;
315 typedef Tpetra::CrsMatrix<scalar_t,lno_t,gno_t,node_t> t_matrix_t;
317 static inline RCP<x_matrix_t>
convertToXpetra(
const RCP<x_matrix_t > &a)
322 static RCP<x_matrix_t>
doMigration(
const x_matrix_t &from,
323 size_t numLocalRows,
const gno_t *myNewRows)
325 Xpetra::UnderlyingLib lib = from.getRowMap()->lib();
327 if (lib == Xpetra::UseEpetra){
328 throw std::logic_error(
"compiler should have used specialization");
331 const xt_matrix_t *xtm =
dynamic_cast<const xt_matrix_t *
>(&from);
332 RCP<const t_matrix_t> tm = xtm->getTpetra_CrsMatrix();
335 *tm, numLocalRows, myNewRows);
347 template <
typename node_t>
348 struct XpetraTraits<Xpetra::CrsMatrix<double, int, int, node_t> >
350 typedef double scalar_t;
353 typedef Xpetra::CrsMatrix<scalar_t, lno_t, gno_t, node_t> x_matrix_t;
354 typedef Xpetra::TpetraCrsMatrix<scalar_t, lno_t, gno_t, node_t> xt_matrix_t;
355 typedef Tpetra::CrsMatrix<scalar_t,lno_t,gno_t,node_t> t_matrix_t;
357 static inline RCP<x_matrix_t>
convertToXpetra(
const RCP<x_matrix_t > &a)
362 static RCP<x_matrix_t>
doMigration(
const x_matrix_t &from,
363 size_t numLocalRows,
const gno_t *myNewRows)
365 Xpetra::UnderlyingLib lib = from.getRowMap()->lib();
367 if (lib == Xpetra::UseEpetra){
368 #if defined(HAVE_ZOLTAN2_EPETRA) && defined(HAVE_XPETRA_EPETRA) 369 typedef Epetra_CrsMatrix e_matrix_t;
370 typedef Xpetra::EpetraCrsMatrixT<gno_t,node_t> xe_matrix_t;
372 const xe_matrix_t *xem =
dynamic_cast<const xe_matrix_t *
>(&from);
373 RCP<const e_matrix_t> em = xem->getEpetra_CrsMatrix();
376 *em, numLocalRows, myNewRows);
382 throw std::runtime_error(
"Xpetra with Epetra requested, but " 383 "Trilinos is not built with Epetra");
387 const xt_matrix_t *xtm =
dynamic_cast<const xt_matrix_t *
>(&from);
388 RCP<const t_matrix_t> tm = xtm->getTpetra_CrsMatrix();
391 *tm, numLocalRows, myNewRows);
403 template <
typename lno_t,
406 struct XpetraTraits<Tpetra::CrsGraph<lno_t, gno_t, node_t> >
408 typedef typename Xpetra::CrsGraph<lno_t, gno_t, node_t>
xgraph_t;
409 typedef typename Xpetra::TpetraCrsGraph<lno_t, gno_t, node_t> xtgraph_t;
410 typedef typename Tpetra::CrsGraph<lno_t, gno_t, node_t>
tgraph_t;
414 return rcp(
new xtgraph_t(a));
418 size_t numLocalRows,
const gno_t *myNewRows)
420 typedef Tpetra::Map<lno_t, gno_t, node_t> map_t;
424 const RCP<const map_t> &smap = from.getRowMap();
425 int oldNumElts = smap->getNodeNumElements();
426 gno_t numGlobalRows = smap->getGlobalNumElements();
429 ArrayView<const gno_t> rowList(myNewRows, numLocalRows);
430 const RCP<const Teuchos::Comm<int> > &comm = from.getComm();
431 RCP<const map_t> tmap = rcp(
432 new map_t(numGlobalRows, rowList, base, comm));
435 Tpetra::Import<lno_t, gno_t, node_t> importer(smap, tmap);
438 typedef Tpetra::Vector<gno_t, lno_t, gno_t, node_t> vector_t;
439 vector_t numOld(smap);
440 vector_t numNew(tmap);
441 for (
int lid=0; lid < oldNumElts; lid++){
442 numOld.replaceGlobalValue(smap->getGlobalElement(lid),
443 from.getNumEntriesInLocalRow(lid));
445 numNew.doImport(numOld, importer, Tpetra::INSERT);
447 size_t numElts = tmap->getNodeNumElements();
448 ArrayRCP<const gno_t> nnz;
450 nnz = numNew.getData(0);
452 ArrayRCP<const size_t> nnz_size_t;
454 if (numElts &&
sizeof(
gno_t) !=
sizeof(
size_t)){
455 size_t *
vals =
new size_t [numElts];
456 nnz_size_t = arcp(
vals, 0, numElts,
true);
457 for (
size_t i=0; i < numElts; i++){
458 vals[i] =
static_cast<size_t>(nnz[i]);
462 nnz_size_t = arcp_reinterpret_cast<
const size_t>(nnz);
466 RCP<tgraph_t> G = rcp(
new tgraph_t(tmap, nnz_size_t, Tpetra::StaticProfile));
468 G->doImport(from, importer, Tpetra::INSERT);
477 #if defined(HAVE_ZOLTAN2_EPETRA) && defined(HAVE_XPETRA_EPETRA) 480 struct XpetraTraits<Epetra_CrsGraph>
485 static inline RCP<Xpetra::CrsGraph<lno_t,gno_t,node_t> >
488 RCP<Xpetra::EpetraCrsGraphT<gno_t, node_t> > xa;
490 xa = rcp(
new Xpetra::EpetraCrsGraphT<gno_t, node_t>(a));
492 catch (std::exception &e) {
493 if (std::is_same<node_t, Xpetra::EpetraNode>::value)
494 throw std::runtime_error(std::string(
"Cannot convert from " 495 "Epetra_CrsGraph to " 496 "Xpetra::EpetraCrsGraphT\n")
499 throw std::runtime_error(std::string(
"Cannot convert from " 500 "Epetra_CrsGraph to " 501 "Xpetra::EpetraCrsGraphT\n" 502 "Use node_t that is supported by " 503 "Xpetra with Epetra classes\n")
509 static RCP<Epetra_CrsGraph>
doMigration(
const Epetra_CrsGraph &from,
510 size_t numLocalRows,
const gno_t *myNewRows)
515 const Epetra_BlockMap &smap = from.RowMap();
516 gno_t numGlobalRows = smap.NumGlobalElements();
517 lno_t oldNumElts = smap.NumMyElements();
520 const Epetra_Comm &comm = from.Comm();
521 Epetra_BlockMap tmap(numGlobalRows, numLocalRows,
522 myNewRows, 1, base, comm);
523 lno_t newNumElts = tmap.NumMyElements();
526 Epetra_Import importer(tmap, smap);
529 Epetra_Vector numOld(smap);
530 Epetra_Vector numNew(tmap);
532 for (
int lid=0; lid < oldNumElts; lid++){
533 numOld[lid] = from.NumMyIndices(lid);
535 numNew.Import(numOld, importer, Insert);
537 Array<int> nnz(newNumElts);
538 for (
int lid=0; lid < newNumElts; lid++){
539 nnz[lid] =
static_cast<int>(numNew[lid]);
543 RCP<Epetra_CrsGraph> G = rcp(
new Epetra_CrsGraph(::Copy, tmap, nnz.getRawPtr(),
true));
544 G->Import(from, importer, Insert);
557 template <
typename lno_t,
560 struct XpetraTraits<Xpetra::CrsGraph<lno_t, gno_t, node_t> >
562 typedef Xpetra::CrsGraph<lno_t, gno_t, node_t> x_graph_t;
563 typedef Xpetra::TpetraCrsGraph<lno_t, gno_t, node_t> xt_graph_t;
564 typedef Tpetra::CrsGraph<lno_t,gno_t,node_t> t_graph_t;
571 static RCP<x_graph_t>
doMigration(
const x_graph_t &from,
572 size_t numLocalRows,
const gno_t *myNewRows)
574 Xpetra::UnderlyingLib lib = from.getRowMap()->lib();
576 if (lib == Xpetra::UseEpetra){
577 throw std::logic_error(
"compiler should have used specialization");
580 const xt_graph_t *xtg =
dynamic_cast<const xt_graph_t *
>(&from);
581 RCP<const t_graph_t> tg = xtg->getTpetra_CrsGraph();
584 *tg, numLocalRows, myNewRows);
595 template <
typename node_t>
596 struct XpetraTraits<Xpetra::CrsGraph<int, int, node_t> >
600 typedef Xpetra::CrsGraph<lno_t, gno_t, node_t> x_graph_t;
601 typedef Xpetra::TpetraCrsGraph<lno_t, gno_t, node_t> xt_graph_t;
602 typedef Tpetra::CrsGraph<lno_t,gno_t,node_t> t_graph_t;
609 static RCP<x_graph_t>
doMigration(
const x_graph_t &from,
610 size_t numLocalRows,
const gno_t *myNewRows)
612 Xpetra::UnderlyingLib lib = from.getRowMap()->lib();
614 if (lib == Xpetra::UseEpetra){
615 #if defined(HAVE_ZOLTAN2_EPETRA) && defined(HAVE_XPETRA_EPETRA) 616 typedef Xpetra::EpetraCrsGraphT<gno_t,node_t> xe_graph_t;
617 typedef Epetra_CrsGraph e_graph_t;
619 const xe_graph_t *xeg =
dynamic_cast<const xe_graph_t *
>(&from);
620 RCP<const e_graph_t> eg = xeg->getEpetra_CrsGraph();
623 *eg, numLocalRows, myNewRows);
629 throw std::runtime_error(
"Xpetra with Epetra requested, but " 630 "Trilinos is not built with Epetra");
634 const xt_graph_t *xtg =
dynamic_cast<const xt_graph_t *
>(&from);
635 RCP<const t_graph_t> tg = xtg->getTpetra_CrsGraph();
638 *tg, numLocalRows, myNewRows);
649 template <
typename scalar_t,
653 struct XpetraTraits<Tpetra::
Vector<scalar_t, lno_t, gno_t, node_t> >
655 typedef Tpetra::Vector<scalar_t, lno_t, gno_t, node_t> t_vector_t;
656 typedef Xpetra::TpetraVector<scalar_t, lno_t, gno_t, node_t> xt_vector_t;
657 typedef Xpetra::Vector<scalar_t, lno_t, gno_t, node_t> x_vector_t;
659 static inline RCP<x_vector_t>
convertToXpetra(
const RCP<t_vector_t> &a)
661 return rcp(
new xt_vector_t(a));
664 static RCP<t_vector_t>
doMigration(
const t_vector_t &from,
665 size_t numLocalElts,
const gno_t *myNewElts)
668 typedef Tpetra::Map<lno_t, gno_t, node_t> map_t;
671 const RCP<const map_t> &smap = from.getMap();
672 gno_t numGlobalElts = smap->getGlobalNumElements();
675 ArrayView<const gno_t> eltList(myNewElts, numLocalElts);
676 const RCP<const Teuchos::Comm<int> > comm = from.getMap()->getComm();
677 RCP<const map_t> tmap = rcp(
678 new map_t(numGlobalElts, eltList, base, comm));
681 Tpetra::Import<lno_t, gno_t, node_t> importer(smap, tmap);
685 Tpetra::createVector<scalar_t,lno_t,gno_t,node_t>(tmap);
686 V->doImport(from, importer, Tpetra::INSERT);
693 #if defined(HAVE_ZOLTAN2_EPETRA) && defined(HAVE_XPETRA_EPETRA) 696 struct XpetraTraits<Epetra_Vector>
703 typedef Xpetra::Vector<scalar_t, lno_t, gno_t, node_t> x_vector_t;
705 static inline RCP<x_vector_t>
convertToXpetra(
const RCP<Epetra_Vector> &a)
707 RCP<Xpetra::EpetraVectorT<gno_t, node_t> > xev;
709 xev = rcp(
new Xpetra::EpetraVectorT<gno_t,node_t>(a));
711 catch (std::exception &e) {
712 if (std::is_same<node_t, Xpetra::EpetraNode>::value)
713 throw std::runtime_error(std::string(
"Cannot convert from " 715 "Xpetra::EpetraVectorT\n")
718 throw std::runtime_error(std::string(
"Cannot convert from " 720 "Xpetra::EpetraVectorT\n" 721 "Use node_t that is supported by " 722 "Xpetra with Epetra classes\n")
725 return rcp_implicit_cast<x_vector_t>(xev);
728 static RCP<Epetra_Vector>
doMigration(
const Epetra_Vector &from,
729 size_t numLocalElts,
const gno_t *myNewElts)
733 const Epetra_BlockMap &smap = from.Map();
734 gno_t numGlobalElts = smap.NumGlobalElements();
737 const Epetra_Comm &comm = from.Comm();
738 const Epetra_BlockMap tmap(numGlobalElts, numLocalElts, myNewElts,
742 Epetra_Import importer(tmap, smap);
745 RCP<Epetra_Vector> V = rcp(
new Epetra_Vector(tmap,
true));
746 Epetra_CombineMode c = Insert;
747 V->Import(from, importer, c);
756 template <
typename scalar_t,
760 struct XpetraTraits<Xpetra::
Vector<scalar_t, lno_t, gno_t, node_t> >
762 typedef Xpetra::Vector<scalar_t, lno_t, gno_t, node_t> x_vector_t;
763 typedef Xpetra::TpetraVector<scalar_t, lno_t, gno_t, node_t> xt_vector_t;
764 typedef Tpetra::Vector<scalar_t, lno_t, gno_t, node_t> t_vector_t;
766 static inline RCP<x_vector_t>
convertToXpetra(
const RCP<x_vector_t> &a)
771 static RCP<x_vector_t>
doMigration(
const x_vector_t &from,
772 size_t numLocalRows,
const gno_t *myNewRows)
774 Xpetra::UnderlyingLib lib = from.getMap()->lib();
776 if (lib == Xpetra::UseEpetra){
777 throw std::logic_error(
"compiler should have used specialization");
780 const xt_vector_t *xtv =
dynamic_cast<const xt_vector_t *
>(&from);
781 RCP<const t_vector_t> tv = xtv->getTpetra_Vector();
784 *tv, numLocalRows, myNewRows);
795 template <
typename node_t>
796 struct XpetraTraits<Xpetra::
Vector<double, int, int, node_t> >
798 typedef double scalar_t;
801 typedef Xpetra::Vector<scalar_t, lno_t, gno_t, node_t> x_vector_t;
802 typedef Xpetra::TpetraVector<scalar_t, lno_t, gno_t, node_t> xt_vector_t;
803 typedef Tpetra::Vector<scalar_t, lno_t, gno_t, node_t> t_vector_t;
805 static inline RCP<x_vector_t>
convertToXpetra(
const RCP<x_vector_t> &a)
810 static RCP<x_vector_t>
doMigration(
const x_vector_t &from,
811 size_t numLocalRows,
const gno_t *myNewRows)
813 Xpetra::UnderlyingLib lib = from.getMap()->lib();
815 if (lib == Xpetra::UseEpetra){
816 #if defined(HAVE_ZOLTAN2_EPETRA) && defined(HAVE_XPETRA_EPETRA) 817 typedef Epetra_Vector e_vector_t;
818 typedef Xpetra::EpetraVectorT<gno_t,node_t> xe_vector_t;
820 const xe_vector_t *xev =
dynamic_cast<const xe_vector_t *
>(&from);
821 RCP<const e_vector_t> ev = rcp(xev->getEpetra_Vector());
824 *ev, numLocalRows, myNewRows);
830 throw std::runtime_error(
"Xpetra with Epetra requested, but " 831 "Trilinos is not built with Epetra");
835 const xt_vector_t *xtv =
dynamic_cast<const xt_vector_t *
>(&from);
836 RCP<t_vector_t> tv = xtv->getTpetra_Vector();
839 *tv, numLocalRows, myNewRows);
850 template <
typename scalar_t,
854 struct XpetraTraits<Tpetra::MultiVector<scalar_t, lno_t, gno_t, node_t> >
856 typedef Tpetra::MultiVector<scalar_t, lno_t, gno_t, node_t> t_vector_t;
857 typedef Xpetra::TpetraMultiVector<scalar_t, lno_t, gno_t, node_t> xt_vector_t;
858 typedef Xpetra::MultiVector<scalar_t, lno_t, gno_t, node_t> x_vector_t;
860 static inline RCP<x_vector_t>
convertToXpetra(
const RCP<t_vector_t> &a)
862 return rcp(
new xt_vector_t(a));
865 static RCP<t_vector_t>
doMigration(
const t_vector_t &from,
866 size_t numLocalElts,
const gno_t *myNewElts)
868 typedef Tpetra::Map<lno_t, gno_t, node_t> map_t;
872 const RCP<const map_t> &smap = from.getMap();
873 gno_t numGlobalElts = smap->getGlobalNumElements();
876 ArrayView<const gno_t> eltList(myNewElts, numLocalElts);
877 const RCP<const Teuchos::Comm<int> > comm = from.getMap()->getComm();
878 RCP<const map_t> tmap = rcp(
879 new map_t(numGlobalElts, eltList, base, comm));
882 Tpetra::Import<lno_t, gno_t, node_t> importer(smap, tmap);
885 RCP<t_vector_t> MV = rcp(
886 new t_vector_t(tmap, from.getNumVectors(),
true));
887 MV->doImport(from, importer, Tpetra::INSERT);
894 #if defined(HAVE_ZOLTAN2_EPETRA) && defined(HAVE_XPETRA_EPETRA) 897 struct XpetraTraits<Epetra_MultiVector>
903 typedef Xpetra::MultiVector<scalar_t, lno_t, gno_t, node_t> x_mvector_t;
906 const RCP<Epetra_MultiVector> &a)
908 RCP<Xpetra::EpetraMultiVectorT<gno_t, node_t> > xemv;
910 xemv = rcp(
new Xpetra::EpetraMultiVectorT<gno_t,node_t>(a));
912 catch (std::exception &e) {
913 if (std::is_same<node_t, Xpetra::EpetraNode>::value)
914 throw std::runtime_error(std::string(
"Cannot convert from " 915 "Epetra_MultiVector to " 916 "Xpetra::EpetraMultiVectorT\n")
919 throw std::runtime_error(std::string(
"Cannot convert from " 920 "Epetra_MultiVector to " 921 "Xpetra::EpetraMultiVectorT\n" 922 "Use node_t that is supported by " 923 "Xpetra with Epetra classes\n")
926 return rcp_implicit_cast<x_mvector_t>(xemv);
929 static RCP<Epetra_MultiVector>
doMigration(
const Epetra_MultiVector &from,
930 size_t numLocalElts,
const gno_t *myNewElts)
934 const Epetra_BlockMap &smap = from.Map();
935 gno_t numGlobalElts = smap.NumGlobalElements();
938 const Epetra_Comm &comm = from.Comm();
939 const Epetra_BlockMap tmap(numGlobalElts, numLocalElts, myNewElts,
943 Epetra_Import importer(tmap, smap);
946 RCP<Epetra_MultiVector> MV = rcp(
947 new Epetra_MultiVector(tmap, from.NumVectors(),
true));
948 Epetra_CombineMode c = Insert;
949 MV->Import(from, importer, c);
958 template <
typename scalar_t,
962 struct XpetraTraits<Xpetra::MultiVector<scalar_t, lno_t, gno_t, node_t> >
964 typedef Xpetra::MultiVector<scalar_t, lno_t, gno_t, node_t> x_mvector_t;
965 typedef Xpetra::TpetraMultiVector<scalar_t, lno_t, gno_t, node_t> xt_mvector_t;
966 typedef Tpetra::MultiVector<scalar_t, lno_t, gno_t, node_t> t_mvector_t;
968 static inline RCP<x_mvector_t>
convertToXpetra(
const RCP<x_mvector_t> &a)
973 static RCP<x_mvector_t>
doMigration(
const x_mvector_t &from,
974 size_t numLocalRows,
const gno_t *myNewRows)
976 Xpetra::UnderlyingLib lib = from.getMap()->lib();
978 if (lib == Xpetra::UseEpetra){
979 throw std::logic_error(
"compiler should have used specialization");
982 const xt_mvector_t *xtv =
dynamic_cast<const xt_mvector_t *
>(&from);
983 RCP<t_mvector_t> tv = xtv->getTpetra_MultiVector();
986 *tv, numLocalRows, myNewRows);
997 template <
typename node_t>
998 struct XpetraTraits<Xpetra::MultiVector<double, int, int, node_t> >
1000 typedef double scalar_t;
1003 typedef Xpetra::MultiVector<scalar_t, lno_t, gno_t, node_t> x_mvector_t;
1004 typedef Xpetra::TpetraMultiVector<scalar_t, lno_t, gno_t, node_t> xt_mvector_t;
1005 typedef Tpetra::MultiVector<scalar_t, lno_t, gno_t, node_t> t_mvector_t;
1007 static inline RCP<x_mvector_t>
convertToXpetra(
const RCP<x_mvector_t> &a)
1012 static RCP<x_mvector_t>
doMigration(
const x_mvector_t &from,
1013 size_t numLocalRows,
const gno_t *myNewRows)
1015 Xpetra::UnderlyingLib lib = from.getMap()->lib();
1017 if (lib == Xpetra::UseEpetra){
1018 #if defined(HAVE_ZOLTAN2_EPETRA) && defined(HAVE_XPETRA_EPETRA) 1019 typedef Epetra_MultiVector e_mvector_t;
1020 typedef Xpetra::EpetraMultiVectorT<gno_t,node_t> xe_mvector_t;
1022 const xe_mvector_t *xev =
dynamic_cast<const xe_mvector_t *
>(&from);
1023 RCP<e_mvector_t> ev = xev->getEpetra_MultiVector();
1026 *ev, numLocalRows, myNewRows);
1032 throw std::runtime_error(
"Xpetra with Epetra requested, but " 1033 "Trilinos is not built with Epetra");
1037 const xt_mvector_t *xtv =
dynamic_cast<const xt_mvector_t *
>(&from);
1038 RCP<t_mvector_t> tv = xtv->getTpetra_MultiVector();
1041 *tv, numLocalRows, myNewRows);
1050 #endif // DOXYGEN_SHOULD_SKIP_THIS 1054 #endif // _ZOLTAN2_XPETRATRAITS_HPP_ Defines the traits required for Tpetra, Eptra and Xpetra objects.
default_gno_t gno_t
The objects global ordinal data type.
static RCP< User > doMigration(const User &from, size_t numLocalRows, const gno_t *myNewRows)
Migrate the object Given a user object and a new row distribution, create and return a new user objec...
static RCP< User > convertToXpetra(const RCP< User > &a)
Convert the object to its Xpetra wrapped version.
default_lno_t lno_t
The objects local ordinal data type.
Tpetra::Vector< z2TestScalar, z2TestLO, z2TestGO > Vector
Gathering definitions used in software development.