2 #include <Tpetra_Core.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>
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;
41 Galeri::Xpetra::Parameters<gno_t> params(tclp, xdim, ydim, zdim, problemType);
43 if (comm->getRank() == 0) cout <<
"BUILD MAP" << endl;
45 rcp(
new Tpetra::Map<lno_t, gno_t>(
46 params.GetNumGlobalElements(), 0, comm));
48 if (comm->getRank() == 0) cout <<
"BUILD MATRIX" << endl;
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 Tpetra::ScopeGuard mpiSession(&narg, &arg);
84 if (comm->getRank() == 0) cout <<
"TESTING WITH scalar_t == DOUBLE" << endl;
85 ierr = buildCrsMatrix<int, long, double>(10, 10, 10, std::string(
"Laplace3D"), comm);
86 if (comm->getRank() == 0 && !ierr)
87 cout <<
"SUCCESS for scalar_t == DOUBLE" << endl << endl << endl;
89 if (comm->getRank() == 0) cout <<
"TESTING WITH scalar_t == FLOAT" << endl;
90 jerr = buildCrsMatrix<int, long, float>(10, 10, 10, std::string(
"Laplace3D"), comm);
91 if (comm->getRank() == 0 && !jerr)
92 cout <<
"SUCCESS for scalar_t == FLOAT" << endl << endl << endl;
95 cout <<
"FAIL: M_ was NULL for scalar_t == DOUBLE " << endl;
97 cout <<
"FAIL: M_ was NULL for scalar_t == FLOAT " << endl;
99 cout <<
"PASS" << endl;
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
bool is_null(const RCP< T > &p)
int buildCrsMatrix(int xdim, int ydim, int zdim, std::string problemType, RCP< const Teuchos::Comm< int > > &comm)
int main(int argc, char *argv[])