15 #include <Teuchos_RCP.hpp>
16 #include <Teuchos_DefaultComm.hpp>
17 #include <Teuchos_Comm.hpp>
19 #include <Tpetra_Core.hpp>
20 #include <Tpetra_Map.hpp>
21 #include <Epetra_Map.h>
22 #include <Xpetra_EpetraCrsMatrix.hpp>
23 #include <Xpetra_EpetraUtils.hpp>
26 int main(
int narg,
char **arg)
30 Tpetra::ScopeGuard tscope(&narg, &arg);
31 Teuchos::RCP<const Teuchos::Comm<int> > tcomm = Tpetra::getDefaultComm();
32 Teuchos::RCP<const Epetra_Comm> ecomm = Xpetra::toEpetra(tcomm);
37 const int nGlobRows = 50;
38 const Epetra_Map emap(nGlobRows, 0, *ecomm);
39 Epetra_CrsMatrix emat(Copy, emap, 1,
true);
40 const double one = 1.;
41 for (
int i = 0; i < emat.NumMyRows(); i++) {
42 int gid = emat.GCID(i);
43 emat.InsertGlobalValues(gid, 1, &one, &gid);
51 std::cout <<
"Building Xpetra::EpetraCrsMatrixT from Epetra_CrsMatrix: "
54 Teuchos::RCP<Epetra_CrsMatrix> ematrcp = Teuchos::rcpFromRef(emat);
55 typedef Xpetra::EpetraCrsMatrixT<int, Tpetra::Map<>::node_type> xemat_t;
56 Teuchos::RCP<const xemat_t> xmat;
60 xmat = rcp(
new xemat_t(ematrcp));
62 catch (std::exception &e) {
63 std::cout <<
"Xpetra::EpetraCrsMatrixT threw an error "
64 << e.what() << std::endl;
69 std::cout <<
"Building Xpetra::EpetraCrsMatrixT from Epetra_CrsMatrix: "
70 <<
"DONE with no errors caught " << std::endl;
75 std::cout <<
"Building Xpetra::EpetraMapT from Epetra_Map: "
78 Teuchos::RCP<const Epetra_BlockMap> emaprcp = Teuchos::rcpFromRef(emap);
79 typedef Xpetra::EpetraMapT<int, Tpetra::Map<>::node_type> xemap_t;
80 Teuchos::RCP<const xemap_t> xmap;
84 xmap = rcp(
new xemap_t(emaprcp));
86 catch (std::exception &e) {
87 std::cout <<
"Xpetra::EpetraMapT threw an error "
88 << e.what() << std::endl;
93 std::cout <<
"Building Xpetra::EpetraMapT from Epetra_Map: "
94 <<
"DONE with no errors caught " << std::endl;
99 std::cout <<
"Teuchos: Hello from "
100 << tcomm->getRank() <<
" of "
101 << tcomm->getSize() << std::endl;
102 std::cout <<
"Epetra_CrsMatrix: Hello from "
103 << ematrcp->Comm().MyPID() <<
" of "
104 << ematrcp->Comm().NumProc() << std::endl;
105 std::cout <<
"Epetra_Map: Hello from "
106 << emaprcp->Comm().MyPID() <<
" of "
107 << emaprcp->Comm().NumProc() << std::endl;
109 std::cout <<
"Xpetra::EpetraCrsMatrixT: Hello from "
110 << xmat->getRowMap()->getComm()->getRank() <<
" of "
111 << xmat->getRowMap()->getComm()->getSize() << std::endl;
113 std::cout <<
"Xpetra::EpetraMapT: Hello from "
114 << xmap->getComm()->getRank() <<
" of "
115 << xmap->getComm()->getSize() << std::endl;
int main(int narg, char **arg)