2 #include <Tpetra_DefaultPlatform.hpp> 3 #include <Tpetra_MultiVector.hpp> 4 #include <Xpetra_Vector.hpp> 5 #include <Xpetra_CrsMatrix.hpp> 6 #include <Xpetra_CrsGraph.hpp> 8 #include <Galeri_XpetraProblemFactory.hpp> 9 #include <Galeri_XpetraParameters.hpp> 11 #include <Kokkos_DefaultNode.hpp> 16 using Teuchos::rcp_const_cast;
19 template <
typename lno_t,
typename gno_t,
typename scalar_t>
21 RCP<
const Teuchos::Comm<int> > &comm)
23 if (comm->getRank() == 0){
24 cout <<
"Create matrix with " << problemType;
25 cout <<
" (and " << xdim;
27 cout <<
" x " << ydim <<
" x " << zdim <<
" ";
29 cout <<
" x" << ydim <<
" x 1 ";
32 cout <<
" mesh)" << endl;
34 cout <<
"Template Type Sizes: " << endl
35 <<
" sizeof(lno_t) = " <<
sizeof(lno_t) <<
" " << endl
36 <<
" sizeof(gno_t) = " <<
sizeof(gno_t) <<
" " << endl
37 <<
" sizeof(scalar_t) = " <<
sizeof(scalar_t) << endl;
40 Teuchos::CommandLineProcessor tclp;
41 Galeri::Xpetra::Parameters<gno_t> params(tclp, xdim, ydim, zdim, problemType);
43 if (comm->getRank() == 0) cout <<
"BUILD MAP" << endl;
44 RCP<const Tpetra::Map<lno_t, gno_t> > map =
45 rcp(
new Tpetra::Map<lno_t, gno_t>(
46 params.GetNumGlobalElements(), 0, comm));
48 if (comm->getRank() == 0) cout <<
"BUILD MATRIX" << endl;
50 RCP<Tpetra::CrsMatrix<scalar_t, lno_t, gno_t> > M_;
52 RCP<Galeri::Xpetra::Problem<Tpetra::Map<lno_t, gno_t>,
53 Tpetra::CrsMatrix<scalar_t, lno_t, gno_t>,
54 Tpetra::MultiVector<scalar_t, lno_t, gno_t> > > Pr=
55 Galeri::Xpetra::BuildProblem<scalar_t, lno_t, gno_t,
56 Tpetra::Map<lno_t, gno_t>,
57 Tpetra::CrsMatrix<scalar_t, lno_t, gno_t>,
58 Tpetra::MultiVector<scalar_t, lno_t, gno_t> >
59 (params.GetMatrixType(), map, params.GetParameterList());
60 if (comm->getRank() == 0)
61 cout <<
"AFTER GALERI BuildProblem M_=" << M_ << endl;
63 M_ = Pr->BuildMatrix();
64 if (comm->getRank() == 0)
65 cout <<
"AFTER GALERI BuildMatrix M_=" << M_ << endl;
67 catch (std::exception &e) {
68 cout <<
"Error returned from Galeri " << e.what() << endl;
77 int main(
int narg,
char **arg)
81 Teuchos::GlobalMPISession mpiSession(&narg, &arg, NULL);
82 RCP<const Teuchos::Comm<int> > comm =
83 Tpetra::DefaultPlatform::getDefaultPlatform().getComm();
85 if (comm->getRank() == 0) cout <<
"TESTING WITH scalar_t == DOUBLE" << endl;
86 ierr = buildCrsMatrix<int, long, double>(10, 10, 10, std::string(
"Laplace3D"), comm);
87 if (comm->getRank() == 0 && !ierr)
88 cout <<
"SUCCESS for scalar_t == DOUBLE" << endl << endl << endl;
90 if (comm->getRank() == 0) cout <<
"TESTING WITH scalar_t == FLOAT" << endl;
91 jerr = buildCrsMatrix<int, long, float>(10, 10, 10, std::string(
"Laplace3D"), comm);
92 if (comm->getRank() == 0 && !jerr)
93 cout <<
"SUCCESS for scalar_t == FLOAT" << endl << endl << endl;
96 cout <<
"FAIL: M_ was NULL for scalar_t == DOUBLE " << endl;
98 cout <<
"FAIL: M_ was NULL for scalar_t == FLOAT " << endl;
100 cout <<
"PASS" << endl;
int buildCrsMatrix(int xdim, int ydim, int zdim, std::string problemType, RCP< const Teuchos::Comm< int > > &comm)
int main(int narg, char **arg)