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;
148 const RCP<const map_t> &smap = from.getRowMap();
149 gno_t numGlobalRows = smap->getGlobalNumElements();
150 gno_t base = smap->getMinAllGlobalIndex();
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);
175 from.importAndFillComplete(M, importer, tmap, tmap);
211 #if defined(HAVE_ZOLTAN2_EPETRA) && defined(HAVE_XPETRA_EPETRA)
214 struct XpetraTraits<Epetra_CrsMatrix>
216 typedef InputTraits<Epetra_CrsMatrix>::scalar_t scalar_t;
217 typedef InputTraits<Epetra_CrsMatrix>::lno_t
lno_t;
218 typedef InputTraits<Epetra_CrsMatrix>::gno_t
gno_t;
219 typedef InputTraits<Epetra_CrsMatrix>::node_t node_t;
221 static inline RCP<Xpetra::CrsMatrix<scalar_t,lno_t,gno_t,node_t> >
224 RCP<Xpetra::EpetraCrsMatrixT<gno_t, node_t> > xa;
226 xa = rcp(
new Xpetra::EpetraCrsMatrixT<gno_t, node_t>(a));
228 catch (std::exception &e) {
229 if (std::is_same<node_t, Xpetra::EpetraNode>::value)
230 throw std::runtime_error(std::string(
"Cannot convert from "
231 "Epetra_CrsMatrix to "
232 "Xpetra::EpetraCrsMatrixT\n")
235 throw std::runtime_error(std::string(
"Cannot convert from "
236 "Epetra_CrsMatrix to "
237 "Xpetra::EpetraCrsMatrixT\n"
238 "Use node_t that is supported by "
239 "Xpetra with Epetra classes\n")
246 static RCP<Epetra_CrsMatrix>
doMigration(
const Epetra_CrsMatrix &from,
247 size_t numLocalRows,
const gno_t *myNewRows)
250 const Epetra_Map &smap = from.RowMap();
251 gno_t numGlobalRows = smap.NumGlobalElements();
252 int base = smap.MinAllGID();
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;
423 const RCP<const map_t> &smap = from.getRowMap();
424 int oldNumElts = smap->getNodeNumElements();
425 gno_t numGlobalRows = smap->getGlobalNumElements();
426 gno_t base = smap->getMinAllGlobalIndex();
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(
new map_t(numGlobalRows, rowList, base, comm));
434 Tpetra::Import<lno_t, gno_t, node_t> importer(smap, tmap);
437 typedef Tpetra::Vector<gno_t, lno_t, gno_t, node_t> vector_t;
438 vector_t numOld(smap);
439 vector_t numNew(tmap);
440 for (
int lid=0; lid < oldNumElts; lid++){
441 numOld.replaceGlobalValue(smap->getGlobalElement(lid),
442 from.getNumEntriesInLocalRow(lid));
444 numNew.doImport(numOld, importer, Tpetra::INSERT);
446 size_t numElts = tmap->getNodeNumElements();
447 ArrayRCP<const gno_t> nnz;
449 nnz = numNew.getData(0);
451 ArrayRCP<const size_t> nnz_size_t;
453 if (numElts &&
sizeof(
gno_t) !=
sizeof(
size_t)){
454 size_t *
vals =
new size_t [numElts];
455 nnz_size_t = arcp(vals, 0, numElts,
true);
456 for (
size_t i=0; i < numElts; i++){
457 vals[i] =
static_cast<size_t>(nnz[i]);
461 nnz_size_t = arcp_reinterpret_cast<
const size_t>(nnz);
465 RCP<tgraph_t> G = rcp(
new tgraph_t(tmap, nnz_size_t(), Tpetra::StaticProfile));
467 G->doImport(from, importer, Tpetra::INSERT);
476 #if defined(HAVE_ZOLTAN2_EPETRA) && defined(HAVE_XPETRA_EPETRA)
479 struct XpetraTraits<Epetra_CrsGraph>
481 typedef InputTraits<Epetra_CrsGraph>::lno_t
lno_t;
482 typedef InputTraits<Epetra_CrsGraph>::gno_t
gno_t;
483 typedef InputTraits<Epetra_CrsGraph>::node_t node_t;
484 static inline RCP<Xpetra::CrsGraph<lno_t,gno_t,node_t> >
487 RCP<Xpetra::EpetraCrsGraphT<gno_t, node_t> > xa;
489 xa = rcp(
new Xpetra::EpetraCrsGraphT<gno_t, node_t>(a));
491 catch (std::exception &e) {
492 if (std::is_same<node_t, Xpetra::EpetraNode>::value)
493 throw std::runtime_error(std::string(
"Cannot convert from "
494 "Epetra_CrsGraph to "
495 "Xpetra::EpetraCrsGraphT\n")
498 throw std::runtime_error(std::string(
"Cannot convert from "
499 "Epetra_CrsGraph to "
500 "Xpetra::EpetraCrsGraphT\n"
501 "Use node_t that is supported by "
502 "Xpetra with Epetra classes\n")
508 static RCP<Epetra_CrsGraph>
doMigration(
const Epetra_CrsGraph &from,
509 size_t numLocalRows,
const gno_t *myNewRows)
512 const Epetra_BlockMap &smap = from.RowMap();
513 gno_t numGlobalRows = smap.NumGlobalElements();
514 lno_t oldNumElts = smap.NumMyElements();
515 int base = smap.MinAllGID();
518 const Epetra_Comm &comm = from.Comm();
519 Epetra_BlockMap tmap(numGlobalRows, numLocalRows, myNewRows, 1, base, comm);
520 lno_t newNumElts = tmap.NumMyElements();
523 Epetra_Import importer(tmap, smap);
526 Epetra_Vector numOld(smap);
527 Epetra_Vector numNew(tmap);
529 for (
int lid=0; lid < oldNumElts; lid++){
530 numOld[lid] = from.NumMyIndices(lid);
532 numNew.Import(numOld, importer, Insert);
534 Array<int> nnz(newNumElts);
535 for (
int lid=0; lid < newNumElts; lid++){
536 nnz[lid] =
static_cast<int>(numNew[lid]);
540 RCP<Epetra_CrsGraph> G = rcp(
new Epetra_CrsGraph(::Copy, tmap, nnz.getRawPtr(),
true));
541 G->Import(from, importer, Insert);
554 template <
typename lno_t,
557 struct XpetraTraits<Xpetra::CrsGraph<lno_t, gno_t, node_t> >
559 typedef Xpetra::CrsGraph<lno_t, gno_t, node_t> x_graph_t;
560 typedef Xpetra::TpetraCrsGraph<lno_t, gno_t, node_t> xt_graph_t;
561 typedef Tpetra::CrsGraph<lno_t,gno_t,node_t> t_graph_t;
568 static RCP<x_graph_t>
doMigration(
const x_graph_t &from,
569 size_t numLocalRows,
const gno_t *myNewRows)
571 Xpetra::UnderlyingLib lib = from.getRowMap()->lib();
573 if (lib == Xpetra::UseEpetra){
574 throw std::logic_error(
"compiler should have used specialization");
577 const xt_graph_t *xtg =
dynamic_cast<const xt_graph_t *
>(&from);
578 RCP<const t_graph_t> tg = xtg->getTpetra_CrsGraph();
581 *tg, numLocalRows, myNewRows);
592 template <
typename node_t>
593 struct XpetraTraits<Xpetra::CrsGraph<int, int, node_t> >
597 typedef Xpetra::CrsGraph<lno_t, gno_t, node_t> x_graph_t;
598 typedef Xpetra::TpetraCrsGraph<lno_t, gno_t, node_t> xt_graph_t;
599 typedef Tpetra::CrsGraph<lno_t,gno_t,node_t> t_graph_t;
606 static RCP<x_graph_t>
doMigration(
const x_graph_t &from,
607 size_t numLocalRows,
const gno_t *myNewRows)
609 Xpetra::UnderlyingLib lib = from.getRowMap()->lib();
611 if (lib == Xpetra::UseEpetra){
612 #if defined(HAVE_ZOLTAN2_EPETRA) && defined(HAVE_XPETRA_EPETRA)
613 typedef Xpetra::EpetraCrsGraphT<gno_t,node_t> xe_graph_t;
614 typedef Epetra_CrsGraph e_graph_t;
616 const xe_graph_t *xeg =
dynamic_cast<const xe_graph_t *
>(&from);
617 RCP<const e_graph_t> eg = xeg->getEpetra_CrsGraph();
620 *eg, numLocalRows, myNewRows);
626 throw std::runtime_error(
"Xpetra with Epetra requested, but "
627 "Trilinos is not built with Epetra");
631 const xt_graph_t *xtg =
dynamic_cast<const xt_graph_t *
>(&from);
632 RCP<const t_graph_t> tg = xtg->getTpetra_CrsGraph();
635 *tg, numLocalRows, myNewRows);
646 template <
typename scalar_t,
650 struct XpetraTraits<Tpetra::
Vector<scalar_t, lno_t, gno_t, node_t> >
652 typedef Tpetra::Vector<scalar_t, lno_t, gno_t, node_t> t_vector_t;
653 typedef Xpetra::TpetraVector<scalar_t, lno_t, gno_t, node_t> xt_vector_t;
654 typedef Xpetra::Vector<scalar_t, lno_t, gno_t, node_t> x_vector_t;
656 static inline RCP<x_vector_t>
convertToXpetra(
const RCP<t_vector_t> &a)
658 return rcp(
new xt_vector_t(a));
661 static RCP<t_vector_t>
doMigration(
const t_vector_t &from,
662 size_t numLocalElts,
const gno_t *myNewElts)
664 typedef Tpetra::Map<lno_t, gno_t, node_t> map_t;
667 const RCP<const map_t> &smap = from.getMap();
668 gno_t numGlobalElts = smap->getGlobalNumElements();
669 gno_t base = smap->getMinAllGlobalIndex();
672 ArrayView<const gno_t> eltList(myNewElts, numLocalElts);
673 const RCP<const Teuchos::Comm<int> > comm = from.getMap()->getComm();
674 RCP<const map_t> tmap = rcp(
new map_t(numGlobalElts, eltList, base, comm));
677 Tpetra::Import<lno_t, gno_t, node_t> importer(smap, tmap);
681 Tpetra::createVector<scalar_t,lno_t,gno_t,node_t>(tmap);
682 V->doImport(from, importer, Tpetra::INSERT);
689 #if defined(HAVE_ZOLTAN2_EPETRA) && defined(HAVE_XPETRA_EPETRA)
692 struct XpetraTraits<Epetra_Vector>
694 typedef InputTraits<Epetra_Vector>::lno_t
lno_t;
695 typedef InputTraits<Epetra_Vector>::gno_t
gno_t;
696 typedef InputTraits<Epetra_Vector>::node_t node_t;
697 typedef InputTraits<Epetra_Vector>::scalar_t scalar_t;
699 typedef Xpetra::Vector<scalar_t, lno_t, gno_t, node_t> x_vector_t;
701 static inline RCP<x_vector_t>
convertToXpetra(
const RCP<Epetra_Vector> &a)
703 RCP<Xpetra::EpetraVectorT<gno_t, node_t> > xev;
705 xev = rcp(
new Xpetra::EpetraVectorT<gno_t,node_t>(a));
707 catch (std::exception &e) {
708 if (std::is_same<node_t, Xpetra::EpetraNode>::value)
709 throw std::runtime_error(std::string(
"Cannot convert from "
711 "Xpetra::EpetraVectorT\n")
714 throw std::runtime_error(std::string(
"Cannot convert from "
716 "Xpetra::EpetraVectorT\n"
717 "Use node_t that is supported by "
718 "Xpetra with Epetra classes\n")
721 return rcp_implicit_cast<x_vector_t>(xev);
724 static RCP<Epetra_Vector>
doMigration(
const Epetra_Vector &from,
725 size_t numLocalElts,
const gno_t *myNewElts)
728 const Epetra_BlockMap &smap = from.Map();
729 gno_t numGlobalElts = smap.NumGlobalElements();
730 int base = smap.MinAllGID();
733 const Epetra_Comm &comm = from.Comm();
734 const Epetra_BlockMap tmap(numGlobalElts, numLocalElts, myNewElts,
738 Epetra_Import importer(tmap, smap);
741 RCP<Epetra_Vector> V = rcp(
new Epetra_Vector(tmap,
true));
742 Epetra_CombineMode c = Insert;
743 V->Import(from, importer, c);
752 template <
typename scalar_t,
756 struct XpetraTraits<Xpetra::
Vector<scalar_t, lno_t, gno_t, node_t> >
758 typedef Xpetra::Vector<scalar_t, lno_t, gno_t, node_t> x_vector_t;
759 typedef Xpetra::TpetraVector<scalar_t, lno_t, gno_t, node_t> xt_vector_t;
760 typedef Tpetra::Vector<scalar_t, lno_t, gno_t, node_t> t_vector_t;
762 static inline RCP<x_vector_t>
convertToXpetra(
const RCP<x_vector_t> &a)
767 static RCP<x_vector_t>
doMigration(
const x_vector_t &from,
768 size_t numLocalRows,
const gno_t *myNewRows)
770 Xpetra::UnderlyingLib lib = from.getMap()->lib();
772 if (lib == Xpetra::UseEpetra){
773 throw std::logic_error(
"compiler should have used specialization");
776 const xt_vector_t *xtv =
dynamic_cast<const xt_vector_t *
>(&from);
777 RCP<const t_vector_t> tv = xtv->getTpetra_Vector();
780 *tv, numLocalRows, myNewRows);
791 template <
typename node_t>
792 struct XpetraTraits<Xpetra::
Vector<double, int, int, node_t> >
794 typedef double scalar_t;
797 typedef Xpetra::Vector<scalar_t, lno_t, gno_t, node_t> x_vector_t;
798 typedef Xpetra::TpetraVector<scalar_t, lno_t, gno_t, node_t> xt_vector_t;
799 typedef Tpetra::Vector<scalar_t, lno_t, gno_t, node_t> t_vector_t;
801 static inline RCP<x_vector_t>
convertToXpetra(
const RCP<x_vector_t> &a)
806 static RCP<x_vector_t>
doMigration(
const x_vector_t &from,
807 size_t numLocalRows,
const gno_t *myNewRows)
809 Xpetra::UnderlyingLib lib = from.getMap()->lib();
811 if (lib == Xpetra::UseEpetra){
812 #if defined(HAVE_ZOLTAN2_EPETRA) && defined(HAVE_XPETRA_EPETRA)
813 typedef Epetra_Vector e_vector_t;
814 typedef Xpetra::EpetraVectorT<gno_t,node_t> xe_vector_t;
816 const xe_vector_t *xev =
dynamic_cast<const xe_vector_t *
>(&from);
817 RCP<const e_vector_t> ev = rcp(xev->getEpetra_Vector());
820 *ev, numLocalRows, myNewRows);
826 throw std::runtime_error(
"Xpetra with Epetra requested, but "
827 "Trilinos is not built with Epetra");
831 const xt_vector_t *xtv =
dynamic_cast<const xt_vector_t *
>(&from);
832 RCP<t_vector_t> tv = xtv->getTpetra_Vector();
835 *tv, numLocalRows, myNewRows);
846 template <
typename scalar_t,
850 struct XpetraTraits<Tpetra::MultiVector<scalar_t, lno_t, gno_t, node_t> >
852 typedef Tpetra::MultiVector<scalar_t, lno_t, gno_t, node_t> t_vector_t;
853 typedef Xpetra::TpetraMultiVector<scalar_t, lno_t, gno_t, node_t> xt_vector_t;
854 typedef Xpetra::MultiVector<scalar_t, lno_t, gno_t, node_t> x_vector_t;
856 static inline RCP<x_vector_t>
convertToXpetra(
const RCP<t_vector_t> &a)
858 return rcp(
new xt_vector_t(a));
861 static RCP<t_vector_t>
doMigration(
const t_vector_t &from,
862 size_t numLocalElts,
const gno_t *myNewElts)
864 typedef Tpetra::Map<lno_t, gno_t, node_t> map_t;
867 const RCP<const map_t> &smap = from.getMap();
868 gno_t numGlobalElts = smap->getGlobalNumElements();
869 gno_t base = smap->getMinAllGlobalIndex();
872 ArrayView<const gno_t> eltList(myNewElts, numLocalElts);
873 const RCP<const Teuchos::Comm<int> > comm = from.getMap()->getComm();
874 RCP<const map_t> tmap = rcp(
new map_t(numGlobalElts, eltList, base, comm));
877 Tpetra::Import<lno_t, gno_t, node_t> importer(smap, tmap);
880 RCP<t_vector_t> MV = rcp(
881 new t_vector_t(tmap, from.getNumVectors(),
true));
882 MV->doImport(from, importer, Tpetra::INSERT);
889 #if defined(HAVE_ZOLTAN2_EPETRA) && defined(HAVE_XPETRA_EPETRA)
892 struct XpetraTraits<Epetra_MultiVector>
894 typedef InputTraits<Epetra_MultiVector>::lno_t
lno_t;
895 typedef InputTraits<Epetra_MultiVector>::gno_t
gno_t;
896 typedef InputTraits<Epetra_MultiVector>::node_t node_t;
897 typedef InputTraits<Epetra_MultiVector>::scalar_t scalar_t;
898 typedef Xpetra::MultiVector<scalar_t, lno_t, gno_t, node_t> x_mvector_t;
901 const RCP<Epetra_MultiVector> &a)
903 RCP<Xpetra::EpetraMultiVectorT<gno_t, node_t> > xemv;
905 xemv = rcp(
new Xpetra::EpetraMultiVectorT<gno_t,node_t>(a));
907 catch (std::exception &e) {
908 if (std::is_same<node_t, Xpetra::EpetraNode>::value)
909 throw std::runtime_error(std::string(
"Cannot convert from "
910 "Epetra_MultiVector to "
911 "Xpetra::EpetraMultiVectorT\n")
914 throw std::runtime_error(std::string(
"Cannot convert from "
915 "Epetra_MultiVector to "
916 "Xpetra::EpetraMultiVectorT\n"
917 "Use node_t that is supported by "
918 "Xpetra with Epetra classes\n")
921 return rcp_implicit_cast<x_mvector_t>(xemv);
924 static RCP<Epetra_MultiVector>
doMigration(
const Epetra_MultiVector &from,
925 size_t numLocalElts,
const gno_t *myNewElts)
928 const Epetra_BlockMap &smap = from.Map();
929 gno_t numGlobalElts = smap.NumGlobalElements();
930 int base = smap.MinAllGID();
933 const Epetra_Comm &comm = from.Comm();
934 const Epetra_BlockMap tmap(numGlobalElts, numLocalElts, myNewElts,
938 Epetra_Import importer(tmap, smap);
941 RCP<Epetra_MultiVector> MV = rcp(
942 new Epetra_MultiVector(tmap, from.NumVectors(),
true));
943 Epetra_CombineMode c = Insert;
944 MV->Import(from, importer, c);
953 template <
typename scalar_t,
957 struct XpetraTraits<Xpetra::MultiVector<scalar_t, lno_t, gno_t, node_t> >
959 typedef Xpetra::MultiVector<scalar_t, lno_t, gno_t, node_t> x_mvector_t;
960 typedef Xpetra::TpetraMultiVector<scalar_t, lno_t, gno_t, node_t> xt_mvector_t;
961 typedef Tpetra::MultiVector<scalar_t, lno_t, gno_t, node_t> t_mvector_t;
963 static inline RCP<x_mvector_t>
convertToXpetra(
const RCP<x_mvector_t> &a)
968 static RCP<x_mvector_t>
doMigration(
const x_mvector_t &from,
969 size_t numLocalRows,
const gno_t *myNewRows)
971 Xpetra::UnderlyingLib lib = from.getMap()->lib();
973 if (lib == Xpetra::UseEpetra){
974 throw std::logic_error(
"compiler should have used specialization");
977 const xt_mvector_t *xtv =
dynamic_cast<const xt_mvector_t *
>(&from);
978 RCP<t_mvector_t> tv = xtv->getTpetra_MultiVector();
981 *tv, numLocalRows, myNewRows);
992 template <
typename node_t>
993 struct XpetraTraits<Xpetra::MultiVector<double, int, int, node_t> >
995 typedef double scalar_t;
998 typedef Xpetra::MultiVector<scalar_t, lno_t, gno_t, node_t> x_mvector_t;
999 typedef Xpetra::TpetraMultiVector<scalar_t, lno_t, gno_t, node_t> xt_mvector_t;
1000 typedef Tpetra::MultiVector<scalar_t, lno_t, gno_t, node_t> t_mvector_t;
1002 static inline RCP<x_mvector_t>
convertToXpetra(
const RCP<x_mvector_t> &a)
1007 static RCP<x_mvector_t>
doMigration(
const x_mvector_t &from,
1008 size_t numLocalRows,
const gno_t *myNewRows)
1010 Xpetra::UnderlyingLib lib = from.getMap()->lib();
1012 if (lib == Xpetra::UseEpetra){
1013 #if defined(HAVE_ZOLTAN2_EPETRA) && defined(HAVE_XPETRA_EPETRA)
1014 typedef Epetra_MultiVector e_mvector_t;
1015 typedef Xpetra::EpetraMultiVectorT<gno_t,node_t> xe_mvector_t;
1017 const xe_mvector_t *xev =
dynamic_cast<const xe_mvector_t *
>(&from);
1018 RCP<e_mvector_t> ev = xev->getEpetra_MultiVector();
1021 *ev, numLocalRows, myNewRows);
1027 throw std::runtime_error(
"Xpetra with Epetra requested, but "
1028 "Trilinos is not built with Epetra");
1032 const xt_mvector_t *xtv =
dynamic_cast<const xt_mvector_t *
>(&from);
1033 RCP<t_mvector_t> tv = xtv->getTpetra_MultiVector();
1036 *tv, numLocalRows, myNewRows);
1045 #endif // DOXYGEN_SHOULD_SKIP_THIS
1049 #endif // _ZOLTAN2_XPETRATRAITS_HPP_
Defines the traits required for Tpetra, Eptra and Xpetra objects.
Tpetra::Vector< z2TestScalar, z2TestLO, z2TestGO > Vector
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...
::Tpetra::Details::DefaultTypes::global_ordinal_type default_gno_t
::Tpetra::Details::DefaultTypes::local_ordinal_type default_lno_t
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.
Gathering definitions used in software development.