6 #include <Teuchos_RCP.hpp>
7 #include <Teuchos_DefaultComm.hpp>
8 #include <Teuchos_Comm.hpp>
10 #include <Tpetra_Core.hpp>
11 #include <Tpetra_Map.hpp>
12 #include <Epetra_Map.h>
13 #include <Xpetra_EpetraCrsMatrix.hpp>
14 #include <Xpetra_EpetraUtils.hpp>
17 int main(
int narg,
char **arg)
21 Tpetra::ScopeGuard tscope(&narg, &arg);
22 Teuchos::RCP<const Teuchos::Comm<int> > tcomm = Tpetra::getDefaultComm();
23 Teuchos::RCP<const Epetra_Comm> ecomm = Xpetra::toEpetra(tcomm);
28 const int nGlobRows = 50;
29 const Epetra_Map emap(nGlobRows, 0, *ecomm);
30 Epetra_CrsMatrix emat(Copy, emap, 1,
true);
31 const double one = 1.;
32 for (
int i = 0; i < emat.NumMyRows(); i++) {
33 int gid = emat.GCID(i);
34 emat.InsertGlobalValues(gid, 1, &one, &gid);
42 std::cout <<
"Building Xpetra::EpetraCrsMatrixT from Epetra_CrsMatrix: "
45 Teuchos::RCP<Epetra_CrsMatrix> ematrcp = Teuchos::rcpFromRef(emat);
46 typedef Xpetra::EpetraCrsMatrixT<int, Tpetra::Map<>::node_type> xemat_t;
47 Teuchos::RCP<const xemat_t> xmat;
51 xmat = rcp(
new xemat_t(ematrcp));
53 catch (std::exception &e) {
54 std::cout <<
"Xpetra::EpetraCrsMatrixT threw an error "
55 << e.what() << std::endl;
60 std::cout <<
"Building Xpetra::EpetraCrsMatrixT from Epetra_CrsMatrix: "
61 <<
"DONE with no errors caught " << std::endl;
66 std::cout <<
"Building Xpetra::EpetraMapT from Epetra_Map: "
69 Teuchos::RCP<const Epetra_BlockMap> emaprcp = Teuchos::rcpFromRef(emap);
70 typedef Xpetra::EpetraMapT<int, Tpetra::Map<>::node_type> xemap_t;
71 Teuchos::RCP<const xemap_t> xmap;
75 xmap = rcp(
new xemap_t(emaprcp));
77 catch (std::exception &e) {
78 std::cout <<
"Xpetra::EpetraMapT threw an error "
79 << e.what() << std::endl;
84 std::cout <<
"Building Xpetra::EpetraMapT from Epetra_Map: "
85 <<
"DONE with no errors caught " << std::endl;
90 std::cout <<
"Teuchos: Hello from "
91 << tcomm->getRank() <<
" of "
92 << tcomm->getSize() << std::endl;
93 std::cout <<
"Epetra_CrsMatrix: Hello from "
94 << ematrcp->Comm().MyPID() <<
" of "
95 << ematrcp->Comm().NumProc() << std::endl;
96 std::cout <<
"Epetra_Map: Hello from "
97 << emaprcp->Comm().MyPID() <<
" of "
98 << emaprcp->Comm().NumProc() << std::endl;
100 std::cout <<
"Xpetra::EpetraCrsMatrixT: Hello from "
101 << xmat->getRowMap()->getComm()->getRank() <<
" of "
102 << xmat->getRowMap()->getComm()->getSize() << std::endl;
104 std::cout <<
"Xpetra::EpetraMapT: Hello from "
105 << xmap->getComm()->getRank() <<
" of "
106 << xmap->getComm()->getSize() << std::endl;
int main(int narg, char **arg)