44 #include "Stokhos_Ensemble_Sizes.hpp"
52 #include "Tpetra_Core.hpp"
53 #include "Tpetra_Map.hpp"
54 #include "Tpetra_MultiVector.hpp"
55 #include "Tpetra_Vector.hpp"
56 #include "Tpetra_CrsGraph.hpp"
57 #include "Tpetra_CrsMatrix.hpp"
61 #ifdef HAVE_STOKHOS_BELOS
63 #include "BelosLinearProblem.hpp"
64 #include "BelosPseudoBlockGmresSolMgr.hpp"
65 #include "BelosPseudoBlockCGSolMgr.hpp"
69 #ifdef HAVE_STOKHOS_IFPACK2
71 #include "Ifpack2_Factory.hpp"
75 #ifdef HAVE_STOKHOS_MUELU
77 #include "MueLu_CreateTpetraPreconditioner.hpp"
81 #ifdef HAVE_STOKHOS_AMESOS2
83 #include "Amesos2_Factory.hpp"
86 template <
typename scalar,
typename ordinal>
90 const ordinal iColFEM,
91 const ordinal iStoch )
93 const scalar X_fem = 100.0 + scalar(iColFEM) / scalar(nFEM);
94 const scalar X_stoch = 1.0 + scalar(iStoch) / scalar(nStoch);
95 return X_fem + X_stoch;
99 template <
typename scalar,
typename ordinal>
103 const ordinal nStoch,
104 const ordinal iColFEM,
106 const ordinal iStoch)
108 const scalar X_fem = 100.0 + scalar(iColFEM) / scalar(nFEM);
109 const scalar X_stoch = 1.0 + scalar(iStoch) / scalar(nStoch);
110 const scalar X_col = 0.01 + scalar(iVec) / scalar(nVec);
111 return X_fem + X_stoch + X_col;
137 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
138 typedef Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_Vector;
141 if ( !Kokkos::is_initialized() )
142 Kokkos::initialize();
145 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
149 RCP<const Tpetra_Map> map =
150 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
152 ArrayView<const GlobalOrdinal> myGIDs = map->getNodeElementList();
153 const size_t num_my_row = myGIDs.size();
156 RCP<Tpetra_Vector> x1 = Tpetra::createVector<Scalar>(map);
157 RCP<Tpetra_Vector> x2 = Tpetra::createVector<Scalar>(map);
158 ArrayRCP<Scalar> x1_view = x1->get1dViewNonConst();
159 ArrayRCP<Scalar> x2_view = x2->get1dViewNonConst();
161 for (
size_t i=0; i<num_my_row; ++i) {
164 val1.fastAccessCoeff(
j) = generate_vector_coefficient<BaseScalar,size_t>(nrow,
VectorSize, row,
j);
165 val2.fastAccessCoeff(
j) = 0.12345 * generate_vector_coefficient<BaseScalar,size_t>(nrow,
VectorSize, row,
j);
176 RCP<Tpetra_Vector> y = Tpetra::createVector<Scalar>(map);
177 y->update(alpha, *x1, beta, *x2,
Scalar(0.0));
183 ArrayRCP<Scalar> y_view = y->get1dViewNonConst();
185 BaseScalar tol = 1.0e-14;
186 for (
size_t i=0; i<num_my_row; ++i) {
189 BaseScalar v = generate_vector_coefficient<BaseScalar,size_t>(
191 val.fastAccessCoeff(
j) = alpha.coeff(
j)*v + 0.12345*beta.coeff(
j)*v;
215 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
216 typedef Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_Vector;
217 typedef typename Tpetra_Vector::dot_type dot_type;
220 if ( !Kokkos::is_initialized() )
221 Kokkos::initialize();
224 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
228 RCP<const Tpetra_Map> map =
229 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
231 ArrayView<const GlobalOrdinal> myGIDs = map->getNodeElementList();
232 const size_t num_my_row = myGIDs.size();
235 RCP<Tpetra_Vector> x1 = Tpetra::createVector<Scalar>(map);
236 RCP<Tpetra_Vector> x2 = Tpetra::createVector<Scalar>(map);
237 ArrayRCP<Scalar> x1_view = x1->get1dViewNonConst();
238 ArrayRCP<Scalar> x2_view = x2->get1dViewNonConst();
240 for (
size_t i=0; i<num_my_row; ++i) {
243 val1.fastAccessCoeff(
j) = generate_vector_coefficient<BaseScalar,size_t>(nrow,
VectorSize, row,
j);
244 val2.fastAccessCoeff(
j) = 0.12345 * generate_vector_coefficient<BaseScalar,size_t>(nrow,
VectorSize, row,
j);
253 dot_type
dot = x1->dot(*x2);
257 #ifdef HAVE_STOKHOS_ENSEMBLE_REDUCT
260 dot_type local_val(0);
261 for (
size_t i=0; i<num_my_row; ++i) {
264 BaseScalar v = generate_vector_coefficient<BaseScalar,size_t>(
266 local_val += 0.12345 * v * v;
273 Teuchos::outArg(val));
279 for (
size_t i=0; i<num_my_row; ++i) {
282 BaseScalar v = generate_vector_coefficient<BaseScalar,size_t>(
284 local_val.fastAccessCoeff(
j) += 0.12345 * v * v;
291 Teuchos::outArg(val));
295 out <<
"dot = " << dot <<
" expected = " << val << std::endl;
297 BaseScalar tol = 1.0e-14;
317 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
318 typedef Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_MultiVector;
321 if ( !Kokkos::is_initialized() )
322 Kokkos::initialize();
325 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
329 RCP<const Tpetra_Map> map =
330 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
332 ArrayView<const GlobalOrdinal> myGIDs = map->getNodeElementList();
333 const size_t num_my_row = myGIDs.size();
337 RCP<Tpetra_MultiVector> x1 = Tpetra::createMultiVector<Scalar>(map, ncol);
338 RCP<Tpetra_MultiVector> x2 = Tpetra::createMultiVector<Scalar>(map, ncol);
339 ArrayRCP< ArrayRCP<Scalar> > x1_view = x1->get2dViewNonConst();
340 ArrayRCP< ArrayRCP<Scalar> > x2_view = x2->get2dViewNonConst();
342 for (
size_t i=0; i<num_my_row; ++i) {
344 for (
size_t j=0;
j<ncol; ++
j) {
347 generate_multi_vector_coefficient<BaseScalar,size_t>(
349 val1.fastAccessCoeff(k) = v;
350 val2.fastAccessCoeff(k) = 0.12345 * v;
352 x1_view[
j][i] = val1;
353 x2_view[
j][i] = val2;
362 RCP<Tpetra_MultiVector> y = Tpetra::createMultiVector<Scalar>(map, ncol);
363 y->update(alpha, *x1, beta, *x2,
Scalar(0.0));
369 ArrayRCP< ArrayRCP<Scalar> > y_view = y->get2dViewNonConst();
371 BaseScalar tol = 1.0e-14;
372 for (
size_t i=0; i<num_my_row; ++i) {
374 for (
size_t j=0;
j<ncol; ++
j) {
376 BaseScalar v = generate_multi_vector_coefficient<BaseScalar,size_t>(
378 val.fastAccessCoeff(k) = alpha.coeff(k)*v + 0.12345*beta.coeff(k)*v;
383 val.fastAccessCoeff(k), tol );
404 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
405 typedef Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_MultiVector;
406 typedef typename Tpetra_MultiVector::dot_type dot_type;
409 if ( !Kokkos::is_initialized() )
410 Kokkos::initialize();
413 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
417 RCP<const Tpetra_Map> map =
418 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
420 ArrayView<const GlobalOrdinal> myGIDs = map->getNodeElementList();
421 const size_t num_my_row = myGIDs.size();
425 RCP<Tpetra_MultiVector> x1 = Tpetra::createMultiVector<Scalar>(map, ncol);
426 RCP<Tpetra_MultiVector> x2 = Tpetra::createMultiVector<Scalar>(map, ncol);
427 ArrayRCP< ArrayRCP<Scalar> > x1_view = x1->get2dViewNonConst();
428 ArrayRCP< ArrayRCP<Scalar> > x2_view = x2->get2dViewNonConst();
430 for (
size_t i=0; i<num_my_row; ++i) {
432 for (
size_t j=0;
j<ncol; ++
j) {
435 generate_multi_vector_coefficient<BaseScalar,size_t>(
437 val1.fastAccessCoeff(k) = v;
438 val2.fastAccessCoeff(k) = 0.12345 * v;
440 x1_view[
j][i] = val1;
441 x2_view[
j][i] = val2;
448 Array<dot_type> dots(ncol);
449 x1->dot(*x2, dots());
453 #ifdef HAVE_STOKHOS_ENSEMBLE_REDUCT
456 Array<dot_type> local_vals(ncol, dot_type(0));
457 for (
size_t i=0; i<num_my_row; ++i) {
459 for (
size_t j=0;
j<ncol; ++
j) {
461 BaseScalar v = generate_multi_vector_coefficient<BaseScalar,size_t>(
463 local_vals[
j] += 0.12345 * v * v;
469 Array<dot_type> vals(ncol, dot_type(0));
471 local_vals.getRawPtr(), vals.getRawPtr());
476 Array<dot_type> local_vals(ncol, dot_type(
VectorSize, 0.0));
477 for (
size_t i=0; i<num_my_row; ++i) {
479 for (
size_t j=0;
j<ncol; ++
j) {
481 BaseScalar v = generate_multi_vector_coefficient<BaseScalar,size_t>(
483 local_vals[
j].fastAccessCoeff(k) += 0.12345 * v * v;
489 Array<dot_type> vals(ncol, dot_type(
VectorSize, 0.0));
491 local_vals.getRawPtr(), vals.getRawPtr());
495 BaseScalar tol = 1.0e-14;
496 for (
size_t j=0;
j<ncol; ++
j) {
497 out <<
"dots(" <<
j <<
") = " << dots[
j]
498 <<
" expected(" <<
j <<
") = " << vals[
j] << std::endl;
519 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
520 typedef Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_MultiVector;
521 typedef typename Tpetra_MultiVector::dot_type dot_type;
524 if ( !Kokkos::is_initialized() )
525 Kokkos::initialize();
528 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
532 RCP<const Tpetra_Map> map =
533 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
535 ArrayView<const GlobalOrdinal> myGIDs = map->getNodeElementList();
536 const size_t num_my_row = myGIDs.size();
540 RCP<Tpetra_MultiVector> x1 = Tpetra::createMultiVector<Scalar>(map, ncol);
541 RCP<Tpetra_MultiVector> x2 = Tpetra::createMultiVector<Scalar>(map, ncol);
542 ArrayRCP< ArrayRCP<Scalar> > x1_view = x1->get2dViewNonConst();
543 ArrayRCP< ArrayRCP<Scalar> > x2_view = x2->get2dViewNonConst();
545 for (
size_t i=0; i<num_my_row; ++i) {
547 for (
size_t j=0;
j<ncol; ++
j) {
550 generate_multi_vector_coefficient<BaseScalar,size_t>(
552 val1.fastAccessCoeff(k) = v;
553 val2.fastAccessCoeff(k) = 0.12345 * v;
555 x1_view[
j][i] = val1;
556 x2_view[
j][i] = val2;
565 cols[0] = 4; cols[1] = 2;
566 RCP<const Tpetra_MultiVector> x1_sub = x1->subView(cols());
567 RCP<const Tpetra_MultiVector> x2_sub = x2->subView(cols());
570 Array<dot_type> dots(ncol_sub);
571 x1_sub->dot(*x2_sub, dots());
575 #ifdef HAVE_STOKHOS_ENSEMBLE_REDUCT
578 Array<dot_type> local_vals(ncol_sub, dot_type(0));
579 for (
size_t i=0; i<num_my_row; ++i) {
581 for (
size_t j=0;
j<ncol_sub; ++
j) {
583 BaseScalar v = generate_multi_vector_coefficient<BaseScalar,size_t>(
585 local_vals[
j] += 0.12345 * v * v;
591 Array<dot_type> vals(ncol_sub, dot_type(0));
593 Teuchos::as<int>(ncol_sub), local_vals.getRawPtr(),
599 Array<dot_type> local_vals(ncol_sub, dot_type(
VectorSize, 0.0));
600 for (
size_t i=0; i<num_my_row; ++i) {
602 for (
size_t j=0;
j<ncol_sub; ++
j) {
604 BaseScalar v = generate_multi_vector_coefficient<BaseScalar,size_t>(
606 local_vals[
j].fastAccessCoeff(k) += 0.12345 * v * v;
612 Array<dot_type> vals(ncol_sub, dot_type(
VectorSize, 0.0));
614 Teuchos::as<int>(ncol_sub), local_vals.getRawPtr(),
619 BaseScalar tol = 1.0e-14;
620 for (
size_t j=0;
j<ncol_sub; ++
j) {
621 out <<
"dots(" <<
j <<
") = " << dots[
j]
622 <<
" expected(" <<
j <<
") = " << vals[
j] << std::endl;
643 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
644 typedef Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_Vector;
645 typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsMatrix;
646 typedef Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsGraph;
649 if ( !Kokkos::is_initialized() )
650 Kokkos::initialize();
654 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
655 RCP<const Tpetra_Map> map =
656 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
658 RCP<Tpetra_CrsGraph> graph =
659 rcp(
new Tpetra_CrsGraph(map,
size_t(2), Tpetra::StaticProfile));
660 Array<GlobalOrdinal> columnIndices(2);
661 ArrayView<const GlobalOrdinal> myGIDs = map->getNodeElementList();
662 const size_t num_my_row = myGIDs.size();
663 for (
size_t i=0; i<num_my_row; ++i) {
665 columnIndices[0] = row;
668 columnIndices[1] = row+1;
671 graph->insertGlobalIndices(row, columnIndices(0,ncol));
673 graph->fillComplete();
674 RCP<Tpetra_CrsMatrix> matrix =
rcp(
new Tpetra_CrsMatrix(graph));
677 Array<Scalar> vals(2);
679 for (
size_t i=0; i<num_my_row; ++i) {
681 columnIndices[0] = row;
683 val.fastAccessCoeff(
j) = generate_vector_coefficient<BaseScalar,size_t>(
689 columnIndices[1] = row+1;
691 val.fastAccessCoeff(
j) = generate_vector_coefficient<BaseScalar,size_t>(
696 matrix->replaceGlobalValues(row, columnIndices(0,ncol), vals(0,ncol));
698 matrix->fillComplete();
701 RCP<Tpetra_Vector> x = Tpetra::createVector<Scalar>(map);
702 ArrayRCP<Scalar> x_view = x->get1dViewNonConst();
703 for (
size_t i=0; i<num_my_row; ++i) {
706 val.fastAccessCoeff(
j) = generate_vector_coefficient<BaseScalar,size_t>(
719 RCP<Tpetra_Vector> y = Tpetra::createVector<Scalar>(map);
720 matrix->apply(*x, *y);
726 ArrayRCP<Scalar> y_view = y->get1dViewNonConst();
727 BaseScalar tol = 1.0e-14;
728 for (
size_t i=0; i<num_my_row; ++i) {
731 BaseScalar v = generate_vector_coefficient<BaseScalar,size_t>(
733 val.fastAccessCoeff(
j) = v*v;
737 BaseScalar v = generate_vector_coefficient<BaseScalar,size_t>(
739 val.fastAccessCoeff(
j) += v*v;
764 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
765 typedef Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_MultiVector;
766 typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsMatrix;
767 typedef Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsGraph;
770 if ( !Kokkos::is_initialized() )
771 Kokkos::initialize();
775 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
776 RCP<const Tpetra_Map> map =
777 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
779 RCP<Tpetra_CrsGraph> graph =
780 rcp(
new Tpetra_CrsGraph(map,
size_t(2), Tpetra::StaticProfile));
781 Array<GlobalOrdinal> columnIndices(2);
782 ArrayView<const GlobalOrdinal> myGIDs = map->getNodeElementList();
783 const size_t num_my_row = myGIDs.size();
784 for (
size_t i=0; i<num_my_row; ++i) {
786 columnIndices[0] = row;
789 columnIndices[1] = row+1;
792 graph->insertGlobalIndices(row, columnIndices(0,ncol));
794 graph->fillComplete();
795 RCP<Tpetra_CrsMatrix> matrix =
rcp(
new Tpetra_CrsMatrix(graph));
798 Array<Scalar> vals(2);
800 for (
size_t i=0; i<num_my_row; ++i) {
802 columnIndices[0] = row;
804 val.fastAccessCoeff(
j) = generate_vector_coefficient<BaseScalar,size_t>(
810 columnIndices[1] = row+1;
812 val.fastAccessCoeff(
j) = generate_vector_coefficient<BaseScalar,size_t>(
817 matrix->replaceGlobalValues(row, columnIndices(0,ncol), vals(0,ncol));
819 matrix->fillComplete();
823 RCP<Tpetra_MultiVector> x = Tpetra::createMultiVector<Scalar>(map, ncol);
824 ArrayRCP< ArrayRCP<Scalar> > x_view = x->get2dViewNonConst();
825 for (
size_t i=0; i<num_my_row; ++i) {
827 for (
size_t j=0;
j<ncol; ++
j) {
830 generate_multi_vector_coefficient<BaseScalar,size_t>(
832 val.fastAccessCoeff(k) = v;
846 RCP<Tpetra_MultiVector> y = Tpetra::createMultiVector<Scalar>(map, ncol);
847 matrix->apply(*x, *y);
853 ArrayRCP< ArrayRCP<Scalar> > y_view = y->get2dViewNonConst();
854 BaseScalar tol = 1.0e-14;
855 for (
size_t i=0; i<num_my_row; ++i) {
857 for (
size_t j=0;
j<ncol; ++
j) {
859 BaseScalar v1 = generate_vector_coefficient<BaseScalar,size_t>(
861 BaseScalar v2 = generate_multi_vector_coefficient<BaseScalar,size_t>(
863 val.fastAccessCoeff(k) = v1*v2;
867 BaseScalar v1 = generate_vector_coefficient<BaseScalar,size_t>(
869 BaseScalar v2 = generate_multi_vector_coefficient<BaseScalar,size_t>(
871 val.fastAccessCoeff(k) += v1*v2;
877 val.fastAccessCoeff(k), tol );
898 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
899 typedef Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_Vector;
900 typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsMatrix;
901 typedef Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsGraph;
903 typedef Tpetra::Vector<BaseScalar,LocalOrdinal,GlobalOrdinal,Node> Flat_Tpetra_Vector;
904 typedef Tpetra::CrsMatrix<BaseScalar,LocalOrdinal,GlobalOrdinal,Node> Flat_Tpetra_CrsMatrix;
907 if ( !Kokkos::is_initialized() )
908 Kokkos::initialize();
912 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
913 RCP<const Tpetra_Map> map =
914 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
916 RCP<Tpetra_CrsGraph> graph =
917 rcp(
new Tpetra_CrsGraph(map,
size_t(2), Tpetra::StaticProfile));
918 Array<GlobalOrdinal> columnIndices(2);
919 ArrayView<const GlobalOrdinal> myGIDs = map->getNodeElementList();
920 const size_t num_my_row = myGIDs.size();
921 for (
size_t i=0; i<num_my_row; ++i) {
923 columnIndices[0] = row;
926 columnIndices[1] = row+1;
929 graph->insertGlobalIndices(row, columnIndices(0,ncol));
931 graph->fillComplete();
932 RCP<Tpetra_CrsMatrix> matrix =
rcp(
new Tpetra_CrsMatrix(graph));
935 Array<Scalar> vals(2);
937 for (
size_t i=0; i<num_my_row; ++i) {
939 columnIndices[0] = row;
941 val.fastAccessCoeff(
j) = generate_vector_coefficient<BaseScalar,size_t>(
947 columnIndices[1] = row+1;
949 val.fastAccessCoeff(
j) = generate_vector_coefficient<BaseScalar,size_t>(
954 matrix->replaceGlobalValues(row, columnIndices(0,ncol), vals(0,ncol));
956 matrix->fillComplete();
959 RCP<Tpetra_Vector> x = Tpetra::createVector<Scalar>(map);
960 ArrayRCP<Scalar> x_view = x->get1dViewNonConst();
961 for (
size_t i=0; i<num_my_row; ++i) {
964 val.fastAccessCoeff(
j) = generate_vector_coefficient<BaseScalar,size_t>(
970 RCP<Tpetra_Vector> y = Tpetra::createVector<Scalar>(map);
971 matrix->apply(*x, *y);
974 RCP<const Tpetra_Map> flat_x_map, flat_y_map;
975 RCP<const Tpetra_CrsGraph> flat_graph =
977 RCP<Flat_Tpetra_CrsMatrix> flat_matrix =
981 RCP<Tpetra_Vector> y2 = Tpetra::createVector<Scalar>(map);
982 RCP<Flat_Tpetra_Vector> flat_x =
984 RCP<Flat_Tpetra_Vector> flat_y =
986 flat_matrix->apply(*flat_x, *flat_y);
992 BaseScalar tol = 1.0e-14;
993 ArrayRCP<Scalar> y_view = y->get1dViewNonConst();
994 ArrayRCP<Scalar> y2_view = y2->get1dViewNonConst();
995 for (
size_t i=0; i<num_my_row; ++i) {
1021 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
1022 typedef Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_Vector;
1023 typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsMatrix;
1024 typedef Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsGraph;
1027 if ( !Kokkos::is_initialized() )
1028 Kokkos::initialize();
1032 BaseScalar h = 1.0 /
static_cast<BaseScalar
>(nrow-1);
1033 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
1034 RCP<const Tpetra_Map> map =
1035 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
1037 RCP<Tpetra_CrsGraph> graph =
1038 rcp(
new Tpetra_CrsGraph(map,
size_t(3), Tpetra::StaticProfile));
1039 Array<GlobalOrdinal> columnIndices(3);
1040 ArrayView<const GlobalOrdinal> myGIDs = map->getNodeElementList();
1041 const size_t num_my_row = myGIDs.size();
1042 for (
size_t i=0; i<num_my_row; ++i) {
1044 if (row == 0 || row == nrow-1) {
1045 columnIndices[0] = row;
1046 graph->insertGlobalIndices(row, columnIndices(0,1));
1049 columnIndices[0] = row-1;
1050 columnIndices[1] = row;
1051 columnIndices[2] = row+1;
1052 graph->insertGlobalIndices(row, columnIndices(0,3));
1055 graph->fillComplete();
1056 RCP<Tpetra_CrsMatrix> matrix =
rcp(
new Tpetra_CrsMatrix(graph));
1059 Array<Scalar> vals(3);
1062 a_val.fastAccessCoeff(
j) =
1063 BaseScalar(1.0) + BaseScalar(
j) / BaseScalar(VectorSize);
1065 for (
size_t i=0; i<num_my_row; ++i) {
1067 if (row == 0 || row == nrow-1) {
1068 columnIndices[0] = row;
1070 matrix->replaceGlobalValues(row, columnIndices(0,1), vals(0,1));
1073 columnIndices[0] = row-1;
1074 columnIndices[1] = row;
1075 columnIndices[2] = row+1;
1076 vals[0] =
Scalar(-1.0) * a_val;
1077 vals[1] =
Scalar(2.0) * a_val;
1078 vals[2] =
Scalar(-1.0) * a_val;
1079 matrix->replaceGlobalValues(row, columnIndices(0,3), vals(0,3));
1082 matrix->fillComplete();
1084 matrix->describe(*(Teuchos::fancyOStream(
rcp(&std::cout,
false))),
1088 RCP<Tpetra_Vector> b = Tpetra::createVector<Scalar>(map);
1089 ArrayRCP<Scalar> b_view = b->get1dViewNonConst();
1090 Scalar b_val(VectorSize, BaseScalar(0.0));
1092 b_val.fastAccessCoeff(
j) =
1093 BaseScalar(-1.0) + BaseScalar(
j) / BaseScalar(VectorSize);
1095 for (
size_t i=0; i<num_my_row; ++i) {
1097 if (row == 0 || row == nrow-1)
1100 b_view[i] = -
Scalar(b_val * h * h);
1104 RCP<Tpetra_Vector> x = Tpetra::createVector<Scalar>(map);
1105 typedef Kokkos::Details::ArithTraits<BaseScalar> BST;
1106 typedef typename BST::mag_type base_mag_type;
1107 typedef typename Tpetra_Vector::mag_type mag_type;
1108 base_mag_type btol = 1e-9;
1109 mag_type tol = btol;
1112 out.getOStream().get());
1120 ArrayRCP<Scalar> x_view = x->get1dViewNonConst();
1121 Scalar
val(VectorSize, BaseScalar(0.0));
1122 for (
size_t i=0; i<num_my_row; ++i) {
1124 BaseScalar xx = row * h;
1126 val.fastAccessCoeff(
j) =
1127 BaseScalar(0.5) * (b_val.coeff(
j)/a_val.coeff(
j)) * xx * (xx - BaseScalar(1.0));
1132 Scalar v = x_view[i];
1135 v.fastAccessCoeff(
j) = BaseScalar(0.0);
1137 val.fastAccessCoeff(
j) = BaseScalar(0.0);
1146 #if defined(HAVE_STOKHOS_MUELU) && defined(HAVE_STOKHOS_AMESOS2) && defined(HAVE_STOKHOS_IFPACK2)
1160 using Teuchos::getParametersFromXmlFile;
1166 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
1167 typedef Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_Vector;
1168 typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsMatrix;
1169 typedef Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsGraph;
1172 if ( !Kokkos::is_initialized() )
1173 Kokkos::initialize();
1177 BaseScalar h = 1.0 /
static_cast<BaseScalar
>(nrow-1);
1178 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
1179 RCP<const Tpetra_Map> map =
1180 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
1182 RCP<Tpetra_CrsGraph> graph =
1183 rcp(
new Tpetra_CrsGraph(map,
size_t(3), Tpetra::StaticProfile));
1184 Array<GlobalOrdinal> columnIndices(3);
1185 ArrayView<const GlobalOrdinal> myGIDs = map->getNodeElementList();
1186 const size_t num_my_row = myGIDs.size();
1187 for (
size_t i=0; i<num_my_row; ++i) {
1189 if (row == 0 || row == nrow-1) {
1190 columnIndices[0] = row;
1191 graph->insertGlobalIndices(row, columnIndices(0,1));
1194 columnIndices[0] = row-1;
1195 columnIndices[1] = row;
1196 columnIndices[2] = row+1;
1197 graph->insertGlobalIndices(row, columnIndices(0,3));
1200 graph->fillComplete();
1201 RCP<Tpetra_CrsMatrix> matrix =
rcp(
new Tpetra_CrsMatrix(graph));
1204 Array<Scalar> vals(3);
1207 a_val.fastAccessCoeff(
j) =
1208 BaseScalar(1.0) + BaseScalar(
j) / BaseScalar(VectorSize);
1210 for (
size_t i=0; i<num_my_row; ++i) {
1212 if (row == 0 || row == nrow-1) {
1213 columnIndices[0] = row;
1215 matrix->replaceGlobalValues(row, columnIndices(0,1), vals(0,1));
1218 columnIndices[0] = row-1;
1219 columnIndices[1] = row;
1220 columnIndices[2] = row+1;
1221 vals[0] =
Scalar(-1.0) * a_val;
1222 vals[1] =
Scalar(2.0) * a_val;
1223 vals[2] =
Scalar(-1.0) * a_val;
1224 matrix->replaceGlobalValues(row, columnIndices(0,3), vals(0,3));
1227 matrix->fillComplete();
1230 RCP<Tpetra_Vector> b = Tpetra::createVector<Scalar>(map);
1231 ArrayRCP<Scalar> b_view = b->get1dViewNonConst();
1232 Scalar b_val(VectorSize, BaseScalar(0.0));
1234 b_val.fastAccessCoeff(
j) =
1235 BaseScalar(-1.0) + BaseScalar(
j) / BaseScalar(VectorSize);
1237 for (
size_t i=0; i<num_my_row; ++i) {
1239 if (row == 0 || row == nrow-1)
1242 b_view[i] = -
Scalar(b_val * h * h);
1246 typedef Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> OP;
1247 RCP<OP> matrix_op = matrix;
1248 RCP<ParameterList> muelu_params =
1249 getParametersFromXmlFile(
"muelu_cheby.xml");
1251 MueLu::CreateTpetraPreconditioner<Scalar,LocalOrdinal,GlobalOrdinal,Node>(matrix_op, *muelu_params);
1254 RCP<Tpetra_Vector> x = Tpetra::createVector<Scalar>(map);
1255 typedef Kokkos::Details::ArithTraits<BaseScalar> BST;
1256 typedef typename BST::mag_type base_mag_type;
1257 typedef typename Tpetra_Vector::mag_type mag_type;
1258 base_mag_type btol = 1e-9;
1259 mag_type tol = btol;
1262 out.getOStream().get());
1270 ArrayRCP<Scalar> x_view = x->get1dViewNonConst();
1271 Scalar
val(VectorSize, BaseScalar(0.0));
1272 for (
size_t i=0; i<num_my_row; ++i) {
1274 BaseScalar xx = row * h;
1276 val.fastAccessCoeff(
j) =
1277 BaseScalar(0.5) * (b_val.coeff(
j)/a_val.coeff(
j)) * xx * (xx - BaseScalar(1.0));
1282 Scalar v = x_view[i];
1284 if (BST::magnitude(v.coeff(
j)) < btol)
1285 v.fastAccessCoeff(
j) = BaseScalar(0.0);
1286 if (BST::magnitude(
val.coeff(
j)) < btol)
1287 val.fastAccessCoeff(
j) = BaseScalar(0.0);
1303 #if defined(HAVE_STOKHOS_BELOS)
1322 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
1323 typedef Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_Vector;
1324 typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsMatrix;
1325 typedef Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsGraph;
1328 if ( !Kokkos::is_initialized() )
1329 Kokkos::initialize();
1333 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
1334 RCP<const Tpetra_Map> map =
1335 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
1337 RCP<Tpetra_CrsGraph> graph =
1338 rcp(
new Tpetra_CrsGraph(map,
size_t(2), Tpetra::StaticProfile));
1339 Array<GlobalOrdinal> columnIndices(2);
1340 ArrayView<const GlobalOrdinal> myGIDs = map->getNodeElementList();
1341 const size_t num_my_row = myGIDs.size();
1342 for (
size_t i=0; i<num_my_row; ++i) {
1344 columnIndices[0] = row;
1346 if (row != nrow-1) {
1347 columnIndices[1] = row+1;
1350 graph->insertGlobalIndices(row, columnIndices(0,ncol));
1352 graph->fillComplete();
1353 RCP<Tpetra_CrsMatrix> matrix =
rcp(
new Tpetra_CrsMatrix(graph));
1356 Array<Scalar> vals(2);
1357 Scalar
val(VectorSize, BaseScalar(0.0));
1358 for (
size_t i=0; i<num_my_row; ++i) {
1360 columnIndices[0] = row;
1362 val.fastAccessCoeff(
j) =
j+1;
1366 if (row != nrow-1) {
1367 columnIndices[1] = row+1;
1369 val.fastAccessCoeff(
j) =
j+1;
1373 matrix->replaceGlobalValues(row, columnIndices(0,ncol), vals(0,ncol));
1375 matrix->fillComplete();
1378 RCP<Tpetra_Vector> b = Tpetra::createVector<Scalar>(map);
1379 ArrayRCP<Scalar> b_view = b->get1dViewNonConst();
1380 for (
size_t i=0; i<num_my_row; ++i) {
1386 #ifdef HAVE_STOKHOS_ENSEMBLE_REDUCT
1387 typedef BaseScalar BelosScalar;
1389 typedef Scalar BelosScalar;
1391 typedef Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> MV;
1392 typedef Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> OP;
1393 typedef Belos::LinearProblem<BelosScalar,MV,OP> BLinProb;
1394 RCP<Tpetra_Vector> x = Tpetra::createVector<Scalar>(map);
1395 RCP< BLinProb > problem =
rcp(
new BLinProb(matrix, x, b));
1396 RCP<ParameterList> belosParams =
rcp(
new ParameterList);
1397 typename ST::magnitudeType tol = 1e-9;
1398 belosParams->set(
"Flexible Gmres",
false);
1399 belosParams->set(
"Num Blocks", 100);
1400 belosParams->set(
"Convergence Tolerance", BelosScalar(tol));
1401 belosParams->set(
"Maximum Iterations", 100);
1402 belosParams->set(
"Verbosity", 33);
1403 belosParams->set(
"Output Style", 1);
1404 belosParams->set(
"Output Frequency", 1);
1405 belosParams->set(
"Output Stream", out.getOStream());
1406 RCP<Belos::SolverManager<BelosScalar,MV,OP> > solver =
1407 rcp(
new Belos::PseudoBlockGmresSolMgr<BelosScalar,MV,OP>(problem, belosParams));
1408 problem->setProblem();
1409 Belos::ReturnType ret = solver->solve();
1422 ArrayRCP<Scalar> x_view = x->get1dViewNonConst();
1423 for (
size_t i=0; i<num_my_row; ++i) {
1427 val.fastAccessCoeff(
j) = BaseScalar(1.0) / BaseScalar(
j+1);
1431 val =
Scalar(VectorSize, BaseScalar(0.0));
1435 Scalar v = x_view[i];
1437 if (ST::magnitude(v.coeff(
j)) < tol)
1438 v.fastAccessCoeff(
j) = BaseScalar(0.0);
1454 using Teuchos::tuple;
1464 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
1465 typedef Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_Vector;
1466 typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsMatrix;
1467 typedef Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsGraph;
1470 if ( !Kokkos::is_initialized() )
1471 Kokkos::initialize();
1475 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
1476 RCP<const Tpetra_Map> map =
1477 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
1479 RCP<Tpetra_CrsGraph> graph =
1480 rcp(
new Tpetra_CrsGraph(map,
size_t(1), Tpetra::StaticProfile));
1481 Array<GlobalOrdinal> columnIndices(1);
1482 ArrayView<const GlobalOrdinal> myGIDs = map->getNodeElementList();
1483 const size_t num_my_row = myGIDs.size();
1484 for (
size_t i=0; i<num_my_row; ++i) {
1486 columnIndices[0] = row;
1488 graph->insertGlobalIndices(row, columnIndices(0,ncol));
1490 graph->fillComplete();
1491 RCP<Tpetra_CrsMatrix> matrix =
rcp(
new Tpetra_CrsMatrix(graph));
1493 Array<Scalar> vals(1);
1494 for (
size_t i=0; i<num_my_row; ++i) {
1496 columnIndices[0] = row;
1498 matrix->replaceGlobalValues(row, columnIndices(0,1), vals(0,1));
1500 matrix->fillComplete();
1509 RCP<Tpetra_Vector> b = Tpetra::createVector<Scalar>(map);
1510 ArrayRCP<Scalar> b_view = b->get1dViewNonConst();
1511 for (
size_t i=0; i<num_my_row; ++i) {
1515 if (
int(
j+2+row-VectorSize) > 0)
1516 b_view[i].fastAccessCoeff(
j) = BaseScalar(row+1);
1521 #ifdef HAVE_STOKHOS_ENSEMBLE_REDUCT
1522 typedef BaseScalar BelosScalar;
1524 typedef Scalar BelosScalar;
1526 typedef Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> MV;
1527 typedef Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> OP;
1528 typedef Belos::LinearProblem<BelosScalar,MV,OP> BLinProb;
1529 RCP<Tpetra_Vector> x = Tpetra::createVector<Scalar>(map);
1530 RCP< BLinProb > problem =
rcp(
new BLinProb(matrix, x, b));
1531 RCP<ParameterList> belosParams =
rcp(
new ParameterList);
1532 typename ST::magnitudeType tol = 1e-9;
1533 belosParams->set(
"Flexible Gmres",
false);
1534 belosParams->set(
"Num Blocks", 100);
1535 belosParams->set(
"Convergence Tolerance", BelosScalar(tol));
1536 belosParams->set(
"Maximum Iterations", 100);
1537 belosParams->set(
"Verbosity", 33);
1538 belosParams->set(
"Output Style", 1);
1539 belosParams->set(
"Output Frequency", 1);
1540 belosParams->set(
"Output Stream", out.getOStream());
1541 belosParams->set(
"Orthogonalization",
"DGKS");
1542 RCP<Belos::PseudoBlockGmresSolMgr<BelosScalar,MV,OP> > solver =
1543 rcp(
new Belos::PseudoBlockGmresSolMgr<BelosScalar,MV,OP>(problem, belosParams));
1544 problem->setProblem();
1545 Belos::ReturnType ret = solver->solve();
1548 #ifndef HAVE_STOKHOS_ENSEMBLE_REDUCT
1549 int numItersExpected = nrow;
1550 int numIters = solver->getNumIters();
1551 out <<
"numIters = " << numIters << std::endl;
1555 std::vector<int> ensemble_iterations =
1557 out <<
"Ensemble iterations = ";
1558 for (
auto ensemble_iteration : ensemble_iterations)
1559 out << ensemble_iteration <<
" ";
1563 if (
int(
j+1+nrow-VectorSize) > 0) {
1579 ArrayRCP<Scalar> x_view = x->get1dViewNonConst();
1580 for (
size_t i=0; i<num_my_row; ++i) {
1582 Scalar v = x_view[i];
1585 if (ST::magnitude(v.coeff(
j)) < tol)
1586 v.fastAccessCoeff(
j) = BaseScalar(0.0);
1592 if (
j+2+row-VectorSize > 0)
1593 val.fastAccessCoeff(
j) = BaseScalar(1.0);
1608 using Teuchos::tuple;
1618 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
1619 typedef Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_Vector;
1620 typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsMatrix;
1621 typedef Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsGraph;
1624 if ( !Kokkos::is_initialized() )
1625 Kokkos::initialize();
1629 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
1630 RCP<const Tpetra_Map> map =
1631 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
1633 RCP<Tpetra_CrsGraph> graph =
1634 rcp(
new Tpetra_CrsGraph(map,
size_t(1), Tpetra::StaticProfile));
1635 Array<GlobalOrdinal> columnIndices(1);
1636 ArrayView<const GlobalOrdinal> myGIDs = map->getNodeElementList();
1637 const size_t num_my_row = myGIDs.size();
1638 for (
size_t i=0; i<num_my_row; ++i) {
1640 columnIndices[0] = row;
1642 graph->insertGlobalIndices(row, columnIndices(0,ncol));
1644 graph->fillComplete();
1645 RCP<Tpetra_CrsMatrix> matrix =
rcp(
new Tpetra_CrsMatrix(graph));
1647 Array<Scalar> vals(1);
1648 for (
size_t i=0; i<num_my_row; ++i) {
1650 columnIndices[0] = row;
1652 matrix->replaceGlobalValues(row, columnIndices(0,1), vals(0,1));
1654 matrix->fillComplete();
1663 RCP<Tpetra_Vector> b = Tpetra::createVector<Scalar>(map);
1664 ArrayRCP<Scalar> b_view = b->get1dViewNonConst();
1665 for (
size_t i=0; i<num_my_row; ++i) {
1669 if (
int(
j+2+row-VectorSize) > 0)
1670 b_view[i].fastAccessCoeff(
j) = BaseScalar(row+1);
1675 #ifdef HAVE_STOKHOS_ENSEMBLE_REDUCT
1676 typedef BaseScalar BelosScalar;
1678 typedef Scalar BelosScalar;
1680 typedef Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> MV;
1681 typedef Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> OP;
1682 typedef Belos::LinearProblem<BelosScalar,MV,OP> BLinProb;
1683 RCP<Tpetra_Vector> x = Tpetra::createVector<Scalar>(map);
1684 RCP< BLinProb > problem =
rcp(
new BLinProb(matrix, x, b));
1685 RCP<ParameterList> belosParams =
rcp(
new ParameterList);
1686 typename ST::magnitudeType tol = 1e-9;
1687 belosParams->set(
"Flexible Gmres",
false);
1688 belosParams->set(
"Num Blocks", 100);
1689 belosParams->set(
"Convergence Tolerance", BelosScalar(tol));
1690 belosParams->set(
"Maximum Iterations", 100);
1691 belosParams->set(
"Verbosity", 33);
1692 belosParams->set(
"Output Style", 1);
1693 belosParams->set(
"Output Frequency", 1);
1694 belosParams->set(
"Output Stream", out.getOStream());
1695 belosParams->set(
"Orthogonalization",
"ICGS");
1696 RCP<Belos::PseudoBlockGmresSolMgr<BelosScalar,MV,OP> > solver =
1697 rcp(
new Belos::PseudoBlockGmresSolMgr<BelosScalar,MV,OP>(problem, belosParams));
1698 problem->setProblem();
1699 Belos::ReturnType ret = solver->solve();
1702 #ifndef HAVE_STOKHOS_ENSEMBLE_REDUCT
1703 int numItersExpected = nrow;
1704 int numIters = solver->getNumIters();
1705 out <<
"numIters = " << numIters << std::endl;
1709 std::vector<int> ensemble_iterations =
1711 out <<
"Ensemble iterations = ";
1712 for (
auto ensemble_iteration : ensemble_iterations)
1713 out << ensemble_iteration <<
" ";
1717 if (
int(
j+1+nrow-VectorSize) > 0) {
1733 ArrayRCP<Scalar> x_view = x->get1dViewNonConst();
1734 for (
size_t i=0; i<num_my_row; ++i) {
1736 Scalar v = x_view[i];
1739 if (ST::magnitude(v.coeff(
j)) < tol)
1740 v.fastAccessCoeff(
j) = BaseScalar(0.0);
1743 Scalar val =
Scalar(0.0);
1746 if (
j+2+row-VectorSize > 0)
1747 val.fastAccessCoeff(
j) = BaseScalar(1.0);
1762 using Teuchos::tuple;
1772 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
1773 typedef Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_Vector;
1774 typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsMatrix;
1775 typedef Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsGraph;
1778 if ( !Kokkos::is_initialized() )
1779 Kokkos::initialize();
1783 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
1784 RCP<const Tpetra_Map> map =
1785 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
1787 RCP<Tpetra_CrsGraph> graph =
1788 rcp(
new Tpetra_CrsGraph(map,
size_t(1), Tpetra::StaticProfile));
1789 Array<GlobalOrdinal> columnIndices(1);
1790 ArrayView<const GlobalOrdinal> myGIDs = map->getNodeElementList();
1791 const size_t num_my_row = myGIDs.size();
1792 for (
size_t i=0; i<num_my_row; ++i) {
1794 columnIndices[0] = row;
1796 graph->insertGlobalIndices(row, columnIndices(0,ncol));
1798 graph->fillComplete();
1799 RCP<Tpetra_CrsMatrix> matrix =
rcp(
new Tpetra_CrsMatrix(graph));
1801 Array<Scalar> vals(1);
1802 for (
size_t i=0; i<num_my_row; ++i) {
1804 columnIndices[0] = row;
1806 matrix->replaceGlobalValues(row, columnIndices(0,1), vals(0,1));
1808 matrix->fillComplete();
1817 RCP<Tpetra_Vector> b = Tpetra::createVector<Scalar>(map);
1818 ArrayRCP<Scalar> b_view = b->get1dViewNonConst();
1819 for (
size_t i=0; i<num_my_row; ++i) {
1823 if (
int(
j+2+row-VectorSize) > 0)
1824 b_view[i].fastAccessCoeff(
j) = BaseScalar(row+1);
1829 #ifdef HAVE_STOKHOS_ENSEMBLE_REDUCT
1830 typedef BaseScalar BelosScalar;
1832 typedef Scalar BelosScalar;
1834 typedef Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> MV;
1835 typedef Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> OP;
1836 typedef Belos::LinearProblem<BelosScalar,MV,OP> BLinProb;
1837 RCP<Tpetra_Vector> x = Tpetra::createVector<Scalar>(map);
1838 RCP< BLinProb > problem =
rcp(
new BLinProb(matrix, x, b));
1839 RCP<ParameterList> belosParams =
rcp(
new ParameterList);
1840 typename ST::magnitudeType tol = 1e-9;
1841 belosParams->set(
"Flexible Gmres",
false);
1842 belosParams->set(
"Num Blocks", 100);
1843 belosParams->set(
"Convergence Tolerance", BelosScalar(tol));
1844 belosParams->set(
"Maximum Iterations", 100);
1845 belosParams->set(
"Verbosity", 33);
1846 belosParams->set(
"Output Style", 1);
1847 belosParams->set(
"Output Frequency", 1);
1848 belosParams->set(
"Output Stream", out.getOStream());
1849 belosParams->set(
"Orthogonalization",
"IMGS");
1850 RCP<Belos::PseudoBlockGmresSolMgr<BelosScalar,MV,OP> > solver =
1851 rcp(
new Belos::PseudoBlockGmresSolMgr<BelosScalar,MV,OP>(problem, belosParams));
1852 problem->setProblem();
1853 Belos::ReturnType ret = solver->solve();
1856 #ifndef HAVE_STOKHOS_ENSEMBLE_REDUCT
1857 int numItersExpected = nrow;
1858 int numIters = solver->getNumIters();
1859 out <<
"numIters = " << numIters << std::endl;
1863 std::vector<int> ensemble_iterations =
1865 out <<
"Ensemble iterations = ";
1866 for (
auto ensemble_iteration : ensemble_iterations)
1867 out << ensemble_iteration <<
" ";
1871 if (
int(
j+1+nrow-VectorSize) > 0) {
1887 ArrayRCP<Scalar> x_view = x->get1dViewNonConst();
1888 for (
size_t i=0; i<num_my_row; ++i) {
1890 Scalar v = x_view[i];
1893 if (ST::magnitude(v.coeff(
j)) < tol)
1894 v.fastAccessCoeff(
j) = BaseScalar(0.0);
1897 Scalar val =
Scalar(0.0);
1900 if (
j+2+row-VectorSize > 0)
1901 val.fastAccessCoeff(
j) = BaseScalar(1.0);
1928 #if defined(HAVE_STOKHOS_BELOS) && defined(HAVE_STOKHOS_IFPACK2)
1948 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
1949 typedef Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_Vector;
1950 typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsMatrix;
1951 typedef Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsGraph;
1954 if ( !Kokkos::is_initialized() )
1955 Kokkos::initialize();
1959 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
1960 RCP<const Tpetra_Map> map =
1961 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
1963 RCP<Tpetra_CrsGraph> graph =
1964 rcp(
new Tpetra_CrsGraph(map,
size_t(2), Tpetra::StaticProfile));
1965 Array<GlobalOrdinal> columnIndices(2);
1966 ArrayView<const GlobalOrdinal> myGIDs = map->getNodeElementList();
1967 const size_t num_my_row = myGIDs.size();
1968 for (
size_t i=0; i<num_my_row; ++i) {
1970 columnIndices[0] = row;
1972 if (row != nrow-1) {
1973 columnIndices[1] = row+1;
1976 graph->insertGlobalIndices(row, columnIndices(0,ncol));
1978 graph->fillComplete();
1979 RCP<Tpetra_CrsMatrix> matrix =
rcp(
new Tpetra_CrsMatrix(graph));
1982 Array<Scalar> vals(2);
1983 Scalar
val(VectorSize, BaseScalar(0.0));
1984 for (
size_t i=0; i<num_my_row; ++i) {
1986 columnIndices[0] = row;
1988 val.fastAccessCoeff(
j) =
j+1;
1992 if (row != nrow-1) {
1993 columnIndices[1] = row+1;
1995 val.fastAccessCoeff(
j) =
j+1;
1999 matrix->replaceGlobalValues(row, columnIndices(0,ncol), vals(0,ncol));
2001 matrix->fillComplete();
2004 RCP<Tpetra_Vector> b = Tpetra::createVector<Scalar>(map);
2005 ArrayRCP<Scalar> b_view = b->get1dViewNonConst();
2006 for (
size_t i=0; i<num_my_row; ++i) {
2011 typedef Ifpack2::Preconditioner<Scalar,LocalOrdinal,GlobalOrdinal,Node> Prec;
2012 Ifpack2::Factory factory;
2013 RCP<Prec> M = factory.create<Tpetra_CrsMatrix>(
"RILUK", matrix);
2019 #ifdef HAVE_STOKHOS_ENSEMBLE_REDUCT
2020 typedef BaseScalar BelosScalar;
2022 typedef Scalar BelosScalar;
2024 typedef Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> MV;
2025 typedef Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> OP;
2026 typedef Belos::LinearProblem<BelosScalar,MV,OP> BLinProb;
2027 RCP<Tpetra_Vector> x = Tpetra::createVector<Scalar>(map);
2028 RCP< BLinProb > problem =
rcp(
new BLinProb(matrix, x, b));
2029 problem->setRightPrec(M);
2030 problem->setProblem();
2031 RCP<ParameterList> belosParams =
rcp(
new ParameterList);
2032 typename ST::magnitudeType tol = 1e-9;
2033 belosParams->set(
"Flexible Gmres",
false);
2034 belosParams->set(
"Num Blocks", 100);
2035 belosParams->set(
"Convergence Tolerance", BelosScalar(tol));
2036 belosParams->set(
"Maximum Iterations", 100);
2037 belosParams->set(
"Verbosity", 33);
2038 belosParams->set(
"Output Style", 1);
2039 belosParams->set(
"Output Frequency", 1);
2040 belosParams->set(
"Output Stream", out.getOStream());
2042 RCP<Belos::SolverManager<BelosScalar,MV,OP> > solver =
2043 rcp(
new Belos::PseudoBlockGmresSolMgr<BelosScalar,MV,OP>(problem, belosParams));
2044 Belos::ReturnType ret = solver->solve();
2057 ArrayRCP<Scalar> x_view = x->get1dViewNonConst();
2058 for (
size_t i=0; i<num_my_row; ++i) {
2062 val.fastAccessCoeff(
j) = BaseScalar(1.0) / BaseScalar(
j+1);
2066 val =
Scalar(VectorSize, BaseScalar(0.0));
2070 Scalar v = x_view[i];
2072 if (ST::magnitude(v.coeff(
j)) < tol)
2073 v.fastAccessCoeff(
j) = BaseScalar(0.0);
2089 #if defined(HAVE_STOKHOS_BELOS) && defined(HAVE_STOKHOS_IFPACK2) && defined(HAVE_STOKHOS_MUELU) && defined(HAVE_STOKHOS_AMESOS2)
2103 using Teuchos::getParametersFromXmlFile;
2109 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
2110 typedef Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_Vector;
2111 typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsMatrix;
2112 typedef Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsGraph;
2115 if ( !Kokkos::is_initialized() )
2116 Kokkos::initialize();
2120 BaseScalar h = 1.0 /
static_cast<BaseScalar
>(nrow-1);
2121 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
2122 RCP<const Tpetra_Map> map =
2123 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
2125 RCP<Tpetra_CrsGraph> graph =
2126 rcp(
new Tpetra_CrsGraph(map,
size_t(3), Tpetra::StaticProfile));
2127 Array<GlobalOrdinal> columnIndices(3);
2128 ArrayView<const GlobalOrdinal> myGIDs = map->getNodeElementList();
2129 const size_t num_my_row = myGIDs.size();
2130 for (
size_t i=0; i<num_my_row; ++i) {
2132 if (row == 0 || row == nrow-1) {
2133 columnIndices[0] = row;
2134 graph->insertGlobalIndices(row, columnIndices(0,1));
2137 columnIndices[0] = row-1;
2138 columnIndices[1] = row;
2139 columnIndices[2] = row+1;
2140 graph->insertGlobalIndices(row, columnIndices(0,3));
2143 graph->fillComplete();
2144 RCP<Tpetra_CrsMatrix> matrix =
rcp(
new Tpetra_CrsMatrix(graph));
2147 Array<Scalar> vals(3);
2148 Scalar a_val(VectorSize, BaseScalar(0.0));
2150 a_val.fastAccessCoeff(
j) =
2151 BaseScalar(1.0) + BaseScalar(
j) / BaseScalar(VectorSize);
2153 for (
size_t i=0; i<num_my_row; ++i) {
2155 if (row == 0 || row == nrow-1) {
2156 columnIndices[0] = row;
2158 matrix->replaceGlobalValues(row, columnIndices(0,1), vals(0,1));
2161 columnIndices[0] = row-1;
2162 columnIndices[1] = row;
2163 columnIndices[2] = row+1;
2164 vals[0] =
Scalar(-1.0) * a_val;
2165 vals[1] =
Scalar(2.0) * a_val;
2166 vals[2] =
Scalar(-1.0) * a_val;
2167 matrix->replaceGlobalValues(row, columnIndices(0,3), vals(0,3));
2170 matrix->fillComplete();
2173 RCP<Tpetra_Vector> b = Tpetra::createVector<Scalar>(map);
2174 ArrayRCP<Scalar> b_view = b->get1dViewNonConst();
2175 Scalar b_val(VectorSize, BaseScalar(0.0));
2177 b_val.fastAccessCoeff(
j) =
2178 BaseScalar(-1.0) + BaseScalar(
j) / BaseScalar(VectorSize);
2180 for (
size_t i=0; i<num_my_row; ++i) {
2182 if (row == 0 || row == nrow-1)
2185 b_view[i] = -
Scalar(b_val * h * h);
2189 typedef Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> OP;
2190 RCP<ParameterList> muelu_params =
2191 getParametersFromXmlFile(
"muelu_cheby.xml");
2192 RCP<OP> matrix_op = matrix;
2194 MueLu::CreateTpetraPreconditioner<Scalar,LocalOrdinal,GlobalOrdinal,Node>(matrix_op, *muelu_params);
2198 #ifdef HAVE_STOKHOS_ENSEMBLE_REDUCT
2199 typedef BaseScalar BelosScalar;
2201 typedef Scalar BelosScalar;
2203 typedef Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> MV;
2204 typedef Belos::LinearProblem<BelosScalar,MV,OP> BLinProb;
2205 RCP<Tpetra_Vector> x = Tpetra::createVector<Scalar>(map);
2206 RCP< BLinProb > problem =
rcp(
new BLinProb(matrix, x, b));
2207 problem->setRightPrec(M);
2208 problem->setProblem();
2209 RCP<ParameterList> belosParams =
rcp(
new ParameterList);
2210 typename ST::magnitudeType tol = 1e-9;
2211 belosParams->set(
"Num Blocks", 100);
2212 belosParams->set(
"Convergence Tolerance", BelosScalar(tol));
2213 belosParams->set(
"Maximum Iterations", 100);
2214 belosParams->set(
"Verbosity", 33);
2215 belosParams->set(
"Output Style", 1);
2216 belosParams->set(
"Output Frequency", 1);
2217 belosParams->set(
"Output Stream", out.getOStream());
2220 belosParams->set(
"Implicit Residual Scaling",
"None");
2222 RCP<Belos::PseudoBlockCGSolMgr<BelosScalar,MV,OP,true> > solver =
2223 rcp(
new Belos::PseudoBlockCGSolMgr<BelosScalar,MV,OP,true>(problem, belosParams));
2224 Belos::ReturnType ret = solver->solve();
2227 #ifndef HAVE_STOKHOS_ENSEMBLE_REDUCT
2229 std::vector<int> ensemble_iterations =
2230 solver->getResidualStatusTest()->getEnsembleIterations();
2231 out <<
"Ensemble iterations = ";
2233 out << ensemble_iterations[i] <<
" ";
2242 ArrayRCP<Scalar> x_view = x->get1dViewNonConst();
2243 Scalar
val(VectorSize, BaseScalar(0.0));
2244 for (
size_t i=0; i<num_my_row; ++i) {
2246 BaseScalar xx = row * h;
2248 val.fastAccessCoeff(
j) =
2249 BaseScalar(0.5) * (b_val.coeff(
j)/a_val.coeff(
j)) * xx * (xx - BaseScalar(1.0));
2254 Scalar v = x_view[i];
2256 if (ST::magnitude(v.coeff(
j)) < tol)
2257 v.fastAccessCoeff(
j) = BaseScalar(0.0);
2258 if (ST::magnitude(val.coeff(
j)) < tol)
2259 val.fastAccessCoeff(
j) = BaseScalar(0.0);
2276 #if defined(HAVE_STOKHOS_AMESOS2)
2295 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
2296 typedef Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_Vector;
2297 typedef Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_MultiVector;
2298 typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsMatrix;
2299 typedef Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsGraph;
2302 if ( !Kokkos::is_initialized() )
2303 Kokkos::initialize();
2307 BaseScalar h = 1.0 /
static_cast<BaseScalar
>(nrow-1);
2308 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
2309 RCP<const Tpetra_Map> map =
2310 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
2312 RCP<Tpetra_CrsGraph> graph = Tpetra::createCrsGraph(map,
size_t(3));
2313 Array<GlobalOrdinal> columnIndices(3);
2314 ArrayView<const GlobalOrdinal> myGIDs = map->getNodeElementList();
2315 const size_t num_my_row = myGIDs.size();
2316 for (
size_t i=0; i<num_my_row; ++i) {
2318 if (row == 0 || row == nrow-1) {
2319 columnIndices[0] = row;
2320 graph->insertGlobalIndices(row, columnIndices(0,1));
2323 columnIndices[0] = row-1;
2324 columnIndices[1] = row;
2325 columnIndices[2] = row+1;
2326 graph->insertGlobalIndices(row, columnIndices(0,3));
2329 graph->fillComplete();
2330 RCP<Tpetra_CrsMatrix> matrix =
rcp(
new Tpetra_CrsMatrix(graph));
2333 Array<Scalar> vals(3);
2334 Scalar a_val(VectorSize, BaseScalar(0.0));
2336 a_val.fastAccessCoeff(
j) =
2337 BaseScalar(1.0) + BaseScalar(
j) / BaseScalar(VectorSize);
2339 for (
size_t i=0; i<num_my_row; ++i) {
2341 if (row == 0 || row == nrow-1) {
2342 columnIndices[0] = row;
2344 matrix->replaceGlobalValues(row, columnIndices(0,1), vals(0,1));
2347 columnIndices[0] = row-1;
2348 columnIndices[1] = row;
2349 columnIndices[2] = row+1;
2350 vals[0] =
Scalar(-1.0) * a_val;
2351 vals[1] =
Scalar(2.0) * a_val;
2352 vals[2] =
Scalar(-1.0) * a_val;
2353 matrix->replaceGlobalValues(row, columnIndices(0,3), vals(0,3));
2356 matrix->fillComplete();
2359 RCP<Tpetra_Vector> b = Tpetra::createVector<Scalar>(map);
2360 ArrayRCP<Scalar> b_view = b->get1dViewNonConst();
2361 Scalar b_val(VectorSize, BaseScalar(0.0));
2363 b_val.fastAccessCoeff(
j) =
2364 BaseScalar(-1.0) + BaseScalar(
j) / BaseScalar(VectorSize);
2366 for (
size_t i=0; i<num_my_row; ++i) {
2368 if (row == 0 || row == nrow-1)
2371 b_view[i] = -
Scalar(b_val * h * h);
2375 typedef Amesos2::Solver<Tpetra_CrsMatrix,Tpetra_MultiVector> Solver;
2376 RCP<Tpetra_Vector> x = Tpetra::createVector<Scalar>(map);
2377 std::string solver_name;
2378 #if defined(HAVE_AMESOS2_BASKER)
2379 solver_name =
"basker";
2380 #elif defined(HAVE_AMESOS2_KLU2)
2381 solver_name =
"klu2";
2382 #elif defined(HAVE_AMESOS2_SUPERLUDIST)
2383 solver_name =
"superlu_dist";
2384 #elif defined(HAVE_AMESOS2_SUPERLUMT)
2385 solver_name =
"superlu_mt";
2386 #elif defined(HAVE_AMESOS2_SUPERLU)
2387 solver_name =
"superlu";
2388 #elif defined(HAVE_AMESOS2_PARDISO_MKL)
2389 solver_name =
"pardisomkl";
2390 #elif defined(HAVE_AMESOS2_LAPACK)
2391 solver_name =
"lapack";
2392 #elif defined(HAVE_AMESOS2_CHOLMOD) && defined (HAVE_AMESOS2_EXPERIMENTAL)
2393 solver_name =
"lapack";
2399 out <<
"Solving linear system with " << solver_name << std::endl;
2400 RCP<Solver> solver = Amesos2::create<Tpetra_CrsMatrix,Tpetra_MultiVector>(
2401 solver_name, matrix, x, b);
2409 typename ST::magnitudeType tol = 1e-9;
2410 ArrayRCP<Scalar> x_view = x->get1dViewNonConst();
2411 Scalar
val(VectorSize, BaseScalar(0.0));
2412 for (
size_t i=0; i<num_my_row; ++i) {
2414 BaseScalar xx = row * h;
2416 val.fastAccessCoeff(
j) =
2417 BaseScalar(0.5) * (b_val.coeff(
j)/a_val.coeff(
j)) * xx * (xx - BaseScalar(1.0));
2422 Scalar v = x_view[i];
2424 if (ST::magnitude(v.coeff(
j)) < tol)
2425 v.fastAccessCoeff(
j) = BaseScalar(0.0);
2426 if (ST::magnitude(val.coeff(
j)) < tol)
2427 val.fastAccessCoeff(
j) = BaseScalar(0.0);
2443 #define CRSMATRIX_MP_VECTOR_TESTS_SLGN(S, LO, GO, N) \
2444 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, VectorAdd, S, LO, GO, N ) \
2445 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, VectorDot, S, LO, GO, N ) \
2446 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, MultiVectorAdd, S, LO, GO, N ) \
2447 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, MultiVectorDot, S, LO, GO, N ) \
2448 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, MultiVectorDotSub, S, LO, GO, N ) \
2449 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, MatrixVectorMultiply, S, LO, GO, N ) \
2450 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, MatrixMultiVectorMultiply, S, LO, GO, N ) \
2451 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, Flatten, S, LO, GO, N ) \
2452 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, SimpleCG, S, LO, GO, N ) \
2453 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, SimplePCG_Muelu, S, LO, GO, N ) \
2454 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, BelosGMRES, S, LO, GO, N ) \
2455 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, BelosGMRES_DGKS, S, LO, GO, N ) \
2456 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, BelosGMRES_ICGS, S, LO, GO, N ) \
2457 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, BelosGMRES_IMGS, S, LO, GO, N ) \
2458 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, BelosGMRES_RILUK, S, LO, GO, N ) \
2459 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, BelosCG_Muelu, S, LO, GO, N ) \
2460 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, Amesos2, S, LO, GO, N )
2462 #define CRSMATRIX_MP_VECTOR_TESTS_N_SFS(N) \
2463 typedef Stokhos::DeviceForNode<N>::type Device; \
2464 typedef Stokhos::StaticFixedStorage<int,double,VectorSize,Device::execution_space> SFS; \
2465 using default_global_ordinal_type = ::Tpetra::Map<>::global_ordinal_type; \
2466 using default_local_ordinal_type = ::Tpetra::Map<>::local_ordinal_type; \
2467 CRSMATRIX_MP_VECTOR_TESTS_SLGN(SFS, default_local_ordinal_type, default_global_ordinal_type, N)
2469 #define CRSMATRIX_MP_VECTOR_TESTS_N(N) \
2470 CRSMATRIX_MP_VECTOR_TESTS_N_SFS(N)
bool CG_Solve(const Matrix &A, Vector &x, const Vector &b, typename Vector::mag_type tol, Ordinal max_its, std::ostream *out=0)
scalar generate_multi_vector_coefficient(const ordinal nFEM, const ordinal nVec, const ordinal nStoch, const ordinal iColFEM, const ordinal iVec, const ordinal iStoch)
TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(Tpetra_CrsMatrix_MP, VectorAdd, Storage, LocalOrdinal, GlobalOrdinal, Node)
Convergence test using the implicit residual norm(s), with an explicit residual norm(s) check for los...
#define TEST_EQUALITY_CONST(v1, v2)
scalar generate_vector_coefficient(const ordinal nFEM, const ordinal nStoch, const ordinal iColFEM, const ordinal iStoch)
std::enable_if< Kokkos::is_view_uq_pce< Kokkos::View< XD, XP...> >::value &&Kokkos::is_view_uq_pce< Kokkos::View< YD, YP...> >::value, typename Kokkos::Details::InnerProductSpaceTraits< typename Kokkos::View< XD, XP...>::non_const_value_type >::dot_type >::type dot(const Kokkos::View< XD, XP...> &x, const Kokkos::View< YD, YP...> &y)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::RCP< const Tpetra::MultiVector< typename Storage::value_type, LocalOrdinal, GlobalOrdinal, Node > > create_flat_vector_view(const Tpetra::MultiVector< Sacado::MP::Vector< Storage >, LocalOrdinal, GlobalOrdinal, Node > &vec_const, const Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > &flat_map)
bool PCG_Solve(const Matrix &A, Vector &x, const Vector &b, const Prec &M, typename Vector::mag_type tol, Ordinal max_its, std::ostream *out=0)
KokkosClassic::DefaultNode::DefaultNodeType Node
KOKKOS_INLINE_FUNCTION PCE< Storage > abs(const PCE< Storage > &a)
Teuchos::RCP< Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > create_flat_mp_graph(const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > &graph, Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > &flat_domain_map, Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > &flat_range_map, const LocalOrdinal block_size)
Teuchos::RCP< Tpetra::CrsMatrix< typename Storage::value_type, LocalOrdinal, GlobalOrdinal, Node > > create_flat_matrix(const Tpetra::CrsMatrix< Sacado::MP::Vector< Storage >, LocalOrdinal, GlobalOrdinal, Node > &mat, const Teuchos::RCP< const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &flat_graph, const LocalOrdinal block_size)
expr1 expr1 expr1 expr2 expr1 expr1 c expr2 expr1 c fastAccessCoeff(j)-expr2.val(j)
#define TEST_FLOATING_EQUALITY(v1, v2, tol)
#define TEST_EQUALITY(v1, v2)
const unsigned VectorSize