14 #ifndef _ZOLTAN2_XPETRATRAITS_HPP_
15 #define _ZOLTAN2_XPETRATRAITS_HPP_
20 #include <Xpetra_TpetraCrsGraph.hpp>
21 #include <Xpetra_TpetraCrsMatrix.hpp>
22 #include <Xpetra_TpetraVector.hpp>
23 #include <Tpetra_Vector.hpp>
25 #if defined(HAVE_ZOLTAN2_EPETRA) && defined(HAVE_XPETRA_EPETRA)
26 #include <Xpetra_EpetraCrsMatrix.hpp>
27 #include <Xpetra_EpetraVector.hpp>
28 #include <Xpetra_EpetraUtils.hpp>
58 template <
typename User>
82 size_t numLocalRows,
const gno_t *myNewRows)
88 #ifndef DOXYGEN_SHOULD_SKIP_THIS
92 template <
typename scalar_t,
96 struct XpetraTraits<Tpetra::CrsMatrix<scalar_t, lno_t, gno_t, node_t> >
98 typedef typename Xpetra::CrsMatrix<scalar_t,lno_t,gno_t,node_t>
xmatrix_t;
99 typedef typename Xpetra::TpetraCrsMatrix<scalar_t,lno_t,gno_t,node_t> xtmatrix_t;
100 typedef typename Tpetra::CrsMatrix<scalar_t,lno_t,gno_t,node_t>
tmatrix_t;
104 return rcp(
new xtmatrix_t(a));
108 size_t numLocalRows,
const gno_t *myNewRows)
110 typedef Tpetra::Map<lno_t, gno_t, node_t>
map_t;
113 const RCP<const map_t> &smap = from.getRowMap();
114 gno_t numGlobalRows = smap->getGlobalNumElements();
115 gno_t base = smap->getMinAllGlobalIndex();
118 ArrayView<const gno_t> rowList(myNewRows, numLocalRows);
119 const RCP<const Teuchos::Comm<int> > &comm = from.getComm();
120 RCP<const map_t> tmap = rcp(
new map_t(numGlobalRows, rowList, base, comm));
123 Tpetra::Import<lno_t, gno_t, node_t> importer(smap, tmap);
140 from.importAndFillComplete(M, importer, tmap, tmap);
176 #if defined(HAVE_ZOLTAN2_EPETRA) && defined(HAVE_XPETRA_EPETRA)
179 struct XpetraTraits<Epetra_CrsMatrix>
181 typedef InputTraits<Epetra_CrsMatrix>::scalar_t scalar_t;
186 static inline RCP<Xpetra::CrsMatrix<scalar_t,lno_t,gno_t,node_t> >
189 RCP<Xpetra::EpetraCrsMatrixT<gno_t, node_t> > xa;
191 xa = rcp(
new Xpetra::EpetraCrsMatrixT<gno_t, node_t>(a));
193 catch (std::exception &e) {
194 if (std::is_same<node_t, Xpetra::EpetraNode>::value)
195 throw std::runtime_error(std::string(
"Cannot convert from "
196 "Epetra_CrsMatrix to "
197 "Xpetra::EpetraCrsMatrixT\n")
200 throw std::runtime_error(std::string(
"Cannot convert from "
201 "Epetra_CrsMatrix to "
202 "Xpetra::EpetraCrsMatrixT\n"
203 "Use node_t that is supported by "
204 "Xpetra with Epetra classes\n")
211 static RCP<Epetra_CrsMatrix>
doMigration(
const Epetra_CrsMatrix &from,
212 size_t numLocalRows,
const gno_t *myNewRows)
215 const Epetra_Map &smap = from.RowMap();
216 gno_t numGlobalRows = smap.NumGlobalElements();
217 int base = smap.MinAllGID();
220 const Epetra_Comm &comm = from.Comm();
221 Epetra_Map tmap(numGlobalRows, numLocalRows, myNewRows, base, comm);
224 Epetra_Import importer(tmap, smap);
236 RCP<Epetra_CrsMatrix> M = rcp(
new Epetra_CrsMatrix(from, importer,
272 template <
typename scalar_t,
276 struct XpetraTraits<Xpetra::CrsMatrix<scalar_t, lno_t, gno_t, node_t> >
278 typedef Xpetra::CrsMatrix<scalar_t, lno_t, gno_t, node_t> x_matrix_t;
279 typedef Xpetra::TpetraCrsMatrix<scalar_t, lno_t, gno_t, node_t> xt_matrix_t;
280 typedef Tpetra::CrsMatrix<scalar_t,lno_t,gno_t,node_t> t_matrix_t;
282 static inline RCP<x_matrix_t>
convertToXpetra(
const RCP<x_matrix_t > &a)
287 static RCP<x_matrix_t>
doMigration(
const x_matrix_t &from,
288 size_t numLocalRows,
const gno_t *myNewRows)
290 Xpetra::UnderlyingLib lib = from.getRowMap()->lib();
292 if (lib == Xpetra::UseEpetra){
293 throw std::logic_error(
"compiler should have used specialization");
296 const xt_matrix_t *xtm =
dynamic_cast<const xt_matrix_t *
>(&from);
297 RCP<const t_matrix_t> tm = xtm->getTpetra_CrsMatrix();
300 *tm, numLocalRows, myNewRows);
312 template <
typename node_t>
313 struct XpetraTraits<Xpetra::CrsMatrix<double, int, int, node_t> >
315 typedef double scalar_t;
318 typedef Xpetra::CrsMatrix<scalar_t, lno_t, gno_t, node_t> x_matrix_t;
319 typedef Xpetra::TpetraCrsMatrix<scalar_t, lno_t, gno_t, node_t> xt_matrix_t;
320 typedef Tpetra::CrsMatrix<scalar_t,lno_t,gno_t,node_t> t_matrix_t;
322 static inline RCP<x_matrix_t>
convertToXpetra(
const RCP<x_matrix_t > &a)
327 static RCP<x_matrix_t>
doMigration(
const x_matrix_t &from,
328 size_t numLocalRows,
const gno_t *myNewRows)
330 Xpetra::UnderlyingLib lib = from.getRowMap()->lib();
332 if (lib == Xpetra::UseEpetra){
333 #if defined(HAVE_ZOLTAN2_EPETRA) && defined(HAVE_XPETRA_EPETRA)
334 typedef Epetra_CrsMatrix e_matrix_t;
335 typedef Xpetra::EpetraCrsMatrixT<gno_t,node_t> xe_matrix_t;
337 const xe_matrix_t *xem =
dynamic_cast<const xe_matrix_t *
>(&from);
338 RCP<const e_matrix_t> em = xem->getEpetra_CrsMatrix();
341 *em, numLocalRows, myNewRows);
347 throw std::runtime_error(
"Xpetra with Epetra requested, but "
348 "Trilinos is not built with Epetra");
352 const xt_matrix_t *xtm =
dynamic_cast<const xt_matrix_t *
>(&from);
353 RCP<const t_matrix_t> tm = xtm->getTpetra_CrsMatrix();
356 *tm, numLocalRows, myNewRows);
368 template <
typename lno_t,
371 struct XpetraTraits<Tpetra::CrsGraph<lno_t, gno_t, node_t> >
373 typedef typename Xpetra::CrsGraph<lno_t, gno_t, node_t>
xgraph_t;
374 typedef typename Xpetra::TpetraCrsGraph<lno_t, gno_t, node_t> xtgraph_t;
375 typedef typename Tpetra::CrsGraph<lno_t, gno_t, node_t>
tgraph_t;
379 return rcp(
new xtgraph_t(a));
383 size_t numLocalRows,
const gno_t *myNewRows)
385 typedef Tpetra::Map<lno_t, gno_t, node_t>
map_t;
388 const RCP<const map_t> &smap = from.getRowMap();
389 int oldNumElts = smap->getLocalNumElements();
390 gno_t numGlobalRows = smap->getGlobalNumElements();
391 gno_t base = smap->getMinAllGlobalIndex();
394 ArrayView<const gno_t> rowList(myNewRows, numLocalRows);
395 const RCP<const Teuchos::Comm<int> > &comm = from.getComm();
396 RCP<const map_t> tmap = rcp(
new map_t(numGlobalRows, rowList, base, comm));
399 Tpetra::Import<lno_t, gno_t, node_t> importer(smap, tmap);
402 typedef Tpetra::Vector<gno_t, lno_t, gno_t, node_t> vector_t;
403 vector_t numOld(smap);
404 vector_t numNew(tmap);
405 for (
int lid=0; lid < oldNumElts; lid++){
406 numOld.replaceGlobalValue(smap->getGlobalElement(lid),
407 from.getNumEntriesInLocalRow(lid));
409 numNew.doImport(numOld, importer, Tpetra::INSERT);
411 size_t numElts = tmap->getLocalNumElements();
412 ArrayRCP<const gno_t> nnz;
414 nnz = numNew.getData(0);
416 ArrayRCP<const size_t> nnz_size_t;
418 if (numElts &&
sizeof(
gno_t) !=
sizeof(
size_t)){
419 size_t *vals =
new size_t [numElts];
420 nnz_size_t = arcp(vals, 0, numElts,
true);
421 for (
size_t i=0; i < numElts; i++){
422 vals[i] =
static_cast<size_t>(nnz[i]);
426 nnz_size_t = arcp_reinterpret_cast<
const size_t>(nnz);
430 RCP<tgraph_t> G = rcp(
new tgraph_t(tmap, nnz_size_t()));
432 G->doImport(from, importer, Tpetra::INSERT);
441 #if defined(HAVE_ZOLTAN2_EPETRA) && defined(HAVE_XPETRA_EPETRA)
444 struct XpetraTraits<Epetra_CrsGraph>
449 static inline RCP<Xpetra::CrsGraph<lno_t,gno_t,node_t> >
452 RCP<Xpetra::EpetraCrsGraphT<gno_t, node_t> > xa;
454 xa = rcp(
new Xpetra::EpetraCrsGraphT<gno_t, node_t>(a));
456 catch (std::exception &e) {
457 if (std::is_same<node_t, Xpetra::EpetraNode>::value)
458 throw std::runtime_error(std::string(
"Cannot convert from "
459 "Epetra_CrsGraph to "
460 "Xpetra::EpetraCrsGraphT\n")
463 throw std::runtime_error(std::string(
"Cannot convert from "
464 "Epetra_CrsGraph to "
465 "Xpetra::EpetraCrsGraphT\n"
466 "Use node_t that is supported by "
467 "Xpetra with Epetra classes\n")
473 static RCP<Epetra_CrsGraph>
doMigration(
const Epetra_CrsGraph &from,
474 size_t numLocalRows,
const gno_t *myNewRows)
477 const Epetra_BlockMap &smap = from.RowMap();
478 gno_t numGlobalRows = smap.NumGlobalElements();
479 lno_t oldNumElts = smap.NumMyElements();
480 int base = smap.MinAllGID();
483 const Epetra_Comm &comm = from.Comm();
484 Epetra_BlockMap tmap(numGlobalRows, numLocalRows, myNewRows, 1, base, comm);
485 lno_t newNumElts = tmap.NumMyElements();
488 Epetra_Import importer(tmap, smap);
491 Epetra_Vector numOld(smap);
492 Epetra_Vector numNew(tmap);
494 for (
int lid=0; lid < oldNumElts; lid++){
495 numOld[lid] = from.NumMyIndices(lid);
497 numNew.Import(numOld, importer, Insert);
499 Array<int> nnz(newNumElts);
500 for (
int lid=0; lid < newNumElts; lid++){
501 nnz[lid] =
static_cast<int>(numNew[lid]);
505 RCP<Epetra_CrsGraph> G = rcp(
new Epetra_CrsGraph(::Copy, tmap, nnz.getRawPtr(),
true));
506 G->Import(from, importer, Insert);
519 template <
typename lno_t,
522 struct XpetraTraits<Xpetra::CrsGraph<lno_t, gno_t, node_t> >
524 typedef Xpetra::CrsGraph<lno_t, gno_t, node_t> x_graph_t;
525 typedef Xpetra::TpetraCrsGraph<lno_t, gno_t, node_t> xt_graph_t;
526 typedef Tpetra::CrsGraph<lno_t,gno_t,node_t> t_graph_t;
533 static RCP<x_graph_t>
doMigration(
const x_graph_t &from,
534 size_t numLocalRows,
const gno_t *myNewRows)
536 Xpetra::UnderlyingLib lib = from.getRowMap()->lib();
538 if (lib == Xpetra::UseEpetra){
539 throw std::logic_error(
"compiler should have used specialization");
542 const xt_graph_t *xtg =
dynamic_cast<const xt_graph_t *
>(&from);
543 RCP<const t_graph_t> tg = xtg->getTpetra_CrsGraph();
546 *tg, numLocalRows, myNewRows);
557 template <
typename node_t>
558 struct XpetraTraits<Xpetra::CrsGraph<int, int, 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 #if defined(HAVE_ZOLTAN2_EPETRA) && defined(HAVE_XPETRA_EPETRA)
578 typedef Xpetra::EpetraCrsGraphT<gno_t,node_t> xe_graph_t;
579 typedef Epetra_CrsGraph e_graph_t;
581 const xe_graph_t *xeg =
dynamic_cast<const xe_graph_t *
>(&from);
582 RCP<const e_graph_t> eg = xeg->getEpetra_CrsGraph();
585 *eg, numLocalRows, myNewRows);
591 throw std::runtime_error(
"Xpetra with Epetra requested, but "
592 "Trilinos is not built with Epetra");
596 const xt_graph_t *xtg =
dynamic_cast<const xt_graph_t *
>(&from);
597 RCP<const t_graph_t> tg = xtg->getTpetra_CrsGraph();
600 *tg, numLocalRows, myNewRows);
611 template <
typename scalar_t,
615 struct XpetraTraits<Tpetra::
Vector<scalar_t, lno_t, gno_t, node_t> >
617 typedef Tpetra::Vector<scalar_t, lno_t, gno_t, node_t> t_vector_t;
618 typedef Xpetra::TpetraVector<scalar_t, lno_t, gno_t, node_t> xt_vector_t;
619 typedef Xpetra::Vector<scalar_t, lno_t, gno_t, node_t> x_vector_t;
621 static inline RCP<x_vector_t>
convertToXpetra(
const RCP<t_vector_t> &a)
623 return rcp(
new xt_vector_t(a));
626 static RCP<t_vector_t>
doMigration(
const t_vector_t &from,
627 size_t numLocalElts,
const gno_t *myNewElts)
629 typedef Tpetra::Map<lno_t, gno_t, node_t>
map_t;
632 const RCP<const map_t> &smap = from.getMap();
633 gno_t numGlobalElts = smap->getGlobalNumElements();
634 gno_t base = smap->getMinAllGlobalIndex();
637 ArrayView<const gno_t> eltList(myNewElts, numLocalElts);
638 const RCP<const Teuchos::Comm<int> > comm = from.getMap()->getComm();
639 RCP<const map_t> tmap = rcp(
new map_t(numGlobalElts, eltList, base, comm));
642 Tpetra::Import<lno_t, gno_t, node_t> importer(smap, tmap);
646 Tpetra::createVector<scalar_t,lno_t,gno_t,node_t>(tmap);
647 V->doImport(from, importer, Tpetra::INSERT);
654 #if defined(HAVE_ZOLTAN2_EPETRA) && defined(HAVE_XPETRA_EPETRA)
657 struct XpetraTraits<Epetra_Vector>
662 typedef InputTraits<Epetra_Vector>::scalar_t scalar_t;
664 typedef Xpetra::Vector<scalar_t, lno_t, gno_t, node_t> x_vector_t;
666 static inline RCP<x_vector_t>
convertToXpetra(
const RCP<Epetra_Vector> &a)
668 RCP<Xpetra::EpetraVectorT<gno_t, node_t> > xev;
670 xev = rcp(
new Xpetra::EpetraVectorT<gno_t,node_t>(a));
672 catch (std::exception &e) {
673 if (std::is_same<node_t, Xpetra::EpetraNode>::value)
674 throw std::runtime_error(std::string(
"Cannot convert from "
676 "Xpetra::EpetraVectorT\n")
679 throw std::runtime_error(std::string(
"Cannot convert from "
681 "Xpetra::EpetraVectorT\n"
682 "Use node_t that is supported by "
683 "Xpetra with Epetra classes\n")
686 return rcp_implicit_cast<x_vector_t>(xev);
689 static RCP<Epetra_Vector>
doMigration(
const Epetra_Vector &from,
690 size_t numLocalElts,
const gno_t *myNewElts)
693 const Epetra_BlockMap &smap = from.Map();
694 gno_t numGlobalElts = smap.NumGlobalElements();
695 int base = smap.MinAllGID();
698 const Epetra_Comm &comm = from.Comm();
699 const Epetra_BlockMap tmap(numGlobalElts, numLocalElts, myNewElts,
703 Epetra_Import importer(tmap, smap);
706 RCP<Epetra_Vector> V = rcp(
new Epetra_Vector(tmap,
true));
707 Epetra_CombineMode c = Insert;
708 V->Import(from, importer, c);
717 template <
typename scalar_t,
721 struct XpetraTraits<Xpetra::
Vector<scalar_t, lno_t, gno_t, node_t> >
723 typedef Xpetra::Vector<scalar_t, lno_t, gno_t, node_t> x_vector_t;
724 typedef Xpetra::TpetraVector<scalar_t, lno_t, gno_t, node_t> xt_vector_t;
725 typedef Tpetra::Vector<scalar_t, lno_t, gno_t, node_t> t_vector_t;
727 static inline RCP<x_vector_t>
convertToXpetra(
const RCP<x_vector_t> &a)
732 static RCP<x_vector_t>
doMigration(
const x_vector_t &from,
733 size_t numLocalRows,
const gno_t *myNewRows)
735 Xpetra::UnderlyingLib lib = from.getMap()->lib();
737 if (lib == Xpetra::UseEpetra){
738 throw std::logic_error(
"compiler should have used specialization");
741 const xt_vector_t *xtv =
dynamic_cast<const xt_vector_t *
>(&from);
742 RCP<const t_vector_t> tv = xtv->getTpetra_Vector();
745 *tv, numLocalRows, myNewRows);
756 template <
typename node_t>
757 struct XpetraTraits<Xpetra::
Vector<double, int, int, node_t> >
759 typedef double scalar_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 #if defined(HAVE_ZOLTAN2_EPETRA) && defined(HAVE_XPETRA_EPETRA)
778 typedef Epetra_Vector e_vector_t;
779 typedef Xpetra::EpetraVectorT<gno_t,node_t> xe_vector_t;
781 const xe_vector_t *xev =
dynamic_cast<const xe_vector_t *
>(&from);
782 RCP<const e_vector_t> ev = rcp(xev->getEpetra_Vector());
785 *ev, numLocalRows, myNewRows);
791 throw std::runtime_error(
"Xpetra with Epetra requested, but "
792 "Trilinos is not built with Epetra");
796 const xt_vector_t *xtv =
dynamic_cast<const xt_vector_t *
>(&from);
797 RCP<t_vector_t> tv = xtv->getTpetra_Vector();
800 *tv, numLocalRows, myNewRows);
811 template <
typename scalar_t,
815 struct XpetraTraits<Tpetra::MultiVector<scalar_t, lno_t, gno_t, node_t> >
817 typedef Tpetra::MultiVector<scalar_t, lno_t, gno_t, node_t> t_vector_t;
818 typedef Xpetra::TpetraMultiVector<scalar_t, lno_t, gno_t, node_t> xt_vector_t;
819 typedef Xpetra::MultiVector<scalar_t, lno_t, gno_t, node_t> x_vector_t;
821 static inline RCP<x_vector_t>
convertToXpetra(
const RCP<t_vector_t> &a)
823 return rcp(
new xt_vector_t(a));
826 static RCP<t_vector_t>
doMigration(
const t_vector_t &from,
827 size_t numLocalElts,
const gno_t *myNewElts)
829 typedef Tpetra::Map<lno_t, gno_t, node_t>
map_t;
832 const RCP<const map_t> &smap = from.getMap();
833 gno_t numGlobalElts = smap->getGlobalNumElements();
834 gno_t base = smap->getMinAllGlobalIndex();
837 ArrayView<const gno_t> eltList(myNewElts, numLocalElts);
838 const RCP<const Teuchos::Comm<int> > comm = from.getMap()->getComm();
839 RCP<const map_t> tmap = rcp(
new map_t(numGlobalElts, eltList, base, comm));
842 Tpetra::Import<lno_t, gno_t, node_t> importer(smap, tmap);
845 RCP<t_vector_t> MV = rcp(
846 new t_vector_t(tmap, from.getNumVectors(),
true));
847 MV->doImport(from, importer, Tpetra::INSERT);
854 #if defined(HAVE_ZOLTAN2_EPETRA) && defined(HAVE_XPETRA_EPETRA)
857 struct XpetraTraits<Epetra_MultiVector>
862 typedef InputTraits<Epetra_MultiVector>::scalar_t scalar_t;
863 typedef Xpetra::MultiVector<scalar_t, lno_t, gno_t, node_t> x_mvector_t;
866 const RCP<Epetra_MultiVector> &a)
868 RCP<Xpetra::EpetraMultiVectorT<gno_t, node_t> > xemv;
870 xemv = rcp(
new Xpetra::EpetraMultiVectorT<gno_t,node_t>(a));
872 catch (std::exception &e) {
873 if (std::is_same<node_t, Xpetra::EpetraNode>::value)
874 throw std::runtime_error(std::string(
"Cannot convert from "
875 "Epetra_MultiVector to "
876 "Xpetra::EpetraMultiVectorT\n")
879 throw std::runtime_error(std::string(
"Cannot convert from "
880 "Epetra_MultiVector to "
881 "Xpetra::EpetraMultiVectorT\n"
882 "Use node_t that is supported by "
883 "Xpetra with Epetra classes\n")
886 return rcp_implicit_cast<x_mvector_t>(xemv);
889 static RCP<Epetra_MultiVector>
doMigration(
const Epetra_MultiVector &from,
890 size_t numLocalElts,
const gno_t *myNewElts)
893 const Epetra_BlockMap &smap = from.Map();
894 gno_t numGlobalElts = smap.NumGlobalElements();
895 int base = smap.MinAllGID();
898 const Epetra_Comm &comm = from.Comm();
899 const Epetra_BlockMap tmap(numGlobalElts, numLocalElts, myNewElts,
903 Epetra_Import importer(tmap, smap);
906 RCP<Epetra_MultiVector> MV = rcp(
907 new Epetra_MultiVector(tmap, from.NumVectors(),
true));
908 Epetra_CombineMode c = Insert;
909 MV->Import(from, importer, c);
918 template <
typename scalar_t,
922 struct XpetraTraits<Xpetra::MultiVector<scalar_t, lno_t, gno_t, node_t> >
924 typedef Xpetra::MultiVector<scalar_t, lno_t, gno_t, node_t> x_mvector_t;
925 typedef Xpetra::TpetraMultiVector<scalar_t, lno_t, gno_t, node_t> xt_mvector_t;
926 typedef Tpetra::MultiVector<scalar_t, lno_t, gno_t, node_t> t_mvector_t;
928 static inline RCP<x_mvector_t>
convertToXpetra(
const RCP<x_mvector_t> &a)
933 static RCP<x_mvector_t>
doMigration(
const x_mvector_t &from,
934 size_t numLocalRows,
const gno_t *myNewRows)
936 Xpetra::UnderlyingLib lib = from.getMap()->lib();
938 if (lib == Xpetra::UseEpetra){
939 throw std::logic_error(
"compiler should have used specialization");
942 const xt_mvector_t *xtv =
dynamic_cast<const xt_mvector_t *
>(&from);
943 RCP<t_mvector_t> tv = xtv->getTpetra_MultiVector();
946 *tv, numLocalRows, myNewRows);
957 template <
typename node_t>
958 struct XpetraTraits<Xpetra::MultiVector<double, int, int, node_t> >
960 typedef double scalar_t;
963 typedef Xpetra::MultiVector<scalar_t, lno_t, gno_t, node_t> x_mvector_t;
964 typedef Xpetra::TpetraMultiVector<scalar_t, lno_t, gno_t, node_t> xt_mvector_t;
965 typedef Tpetra::MultiVector<scalar_t, lno_t, gno_t, node_t> t_mvector_t;
967 static inline RCP<x_mvector_t>
convertToXpetra(
const RCP<x_mvector_t> &a)
972 static RCP<x_mvector_t>
doMigration(
const x_mvector_t &from,
973 size_t numLocalRows,
const gno_t *myNewRows)
975 Xpetra::UnderlyingLib lib = from.getMap()->lib();
977 if (lib == Xpetra::UseEpetra){
978 #if defined(HAVE_ZOLTAN2_EPETRA) && defined(HAVE_XPETRA_EPETRA)
979 typedef Epetra_MultiVector e_mvector_t;
980 typedef Xpetra::EpetraMultiVectorT<gno_t,node_t> xe_mvector_t;
982 const xe_mvector_t *xev =
dynamic_cast<const xe_mvector_t *
>(&from);
983 RCP<e_mvector_t> ev = xev->getEpetra_MultiVector();
986 *ev, numLocalRows, myNewRows);
992 throw std::runtime_error(
"Xpetra with Epetra requested, but "
993 "Trilinos is not built with Epetra");
997 const xt_mvector_t *xtv =
dynamic_cast<const xt_mvector_t *
>(&from);
998 RCP<t_mvector_t> tv = xtv->getTpetra_MultiVector();
1001 *tv, numLocalRows, myNewRows);
1010 #endif // DOXYGEN_SHOULD_SKIP_THIS
1014 #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.
map_t::global_ordinal_type gno_t
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
Tpetra::Vector< z2TestScalar, z2TestLO, z2TestGO > Vector
static RCP< User > convertToXpetra(const RCP< User > &a)
Convert the object to its Xpetra wrapped version.
map_t::local_ordinal_type lno_t
default_lno_t lno_t
The objects local ordinal data type.
Gathering definitions used in software development.