12 #include "Stokhos_Ensemble_Sizes.hpp"
20 #include "Tpetra_Core.hpp"
21 #include "Tpetra_Map.hpp"
22 #include "Tpetra_MultiVector.hpp"
23 #include "Tpetra_Vector.hpp"
24 #include "Tpetra_CrsGraph.hpp"
25 #include "Tpetra_CrsMatrix.hpp"
26 #include "Tpetra_Details_WrappedDualView.hpp"
30 #ifdef HAVE_STOKHOS_BELOS
32 #include "BelosLinearProblem.hpp"
33 #include "BelosPseudoBlockGmresSolMgr.hpp"
34 #include "BelosPseudoBlockCGSolMgr.hpp"
38 #ifdef HAVE_STOKHOS_IFPACK2
40 #include "Ifpack2_Factory.hpp"
44 #ifdef HAVE_STOKHOS_MUELU
46 #include "MueLu_CreateTpetraPreconditioner.hpp"
50 #ifdef HAVE_STOKHOS_AMESOS2
52 #include "Amesos2_Factory.hpp"
55 template <
typename scalar,
typename ordinal>
59 const ordinal iColFEM,
60 const ordinal iStoch )
62 const scalar X_fem = 100.0 + scalar(iColFEM) / scalar(nFEM);
63 const scalar X_stoch = 1.0 + scalar(iStoch) / scalar(nStoch);
64 return X_fem + X_stoch;
68 template <
typename scalar,
typename ordinal>
73 const ordinal iColFEM,
77 const scalar X_fem = 100.0 + scalar(iColFEM) / scalar(nFEM);
78 const scalar X_stoch = 1.0 + scalar(iStoch) / scalar(nStoch);
79 const scalar X_col = 0.01 + scalar(iVec) / scalar(nVec);
80 return X_fem + X_stoch + X_col;
106 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
107 typedef Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_Vector;
110 if ( !Kokkos::is_initialized() )
111 Kokkos::initialize();
114 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
118 RCP<const Tpetra_Map> map =
119 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
121 ArrayView<const GlobalOrdinal> myGIDs = map->getLocalElementList();
122 const size_t num_my_row = myGIDs.size();
125 RCP<Tpetra_Vector> x1 = Tpetra::createVector<Scalar>(map);
126 RCP<Tpetra_Vector> x2 = Tpetra::createVector<Scalar>(map);
128 auto x1_view = x1->getLocalViewHost(Tpetra::Access::OverwriteAll);
129 auto x2_view = x2->getLocalViewHost(Tpetra::Access::OverwriteAll);
131 for (
size_t i=0; i<num_my_row; ++i) {
134 val1.fastAccessCoeff(
j) = generate_vector_coefficient<BaseScalar,size_t>(nrow,
VectorSize, row,
j);
135 val2.fastAccessCoeff(
j) = 0.12345 * generate_vector_coefficient<BaseScalar,size_t>(nrow,
VectorSize, row,
j);
145 RCP<Tpetra_Vector> y = Tpetra::createVector<Scalar>(map);
146 y->update(alpha, *x1, beta, *x2,
Scalar(0.0));
152 auto y_view = y->getLocalViewHost(Tpetra::Access::ReadOnly);
154 BaseScalar tol = 1.0e-14;
155 for (
size_t i=0; i<num_my_row; ++i) {
158 BaseScalar v = generate_vector_coefficient<BaseScalar,size_t>(
160 val.fastAccessCoeff(
j) = alpha.coeff(
j)*v + 0.12345*beta.coeff(
j)*v;
184 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
185 typedef Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_Vector;
186 typedef typename Tpetra_Vector::dot_type dot_type;
189 if ( !Kokkos::is_initialized() )
190 Kokkos::initialize();
193 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
197 RCP<const Tpetra_Map> map =
198 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
200 ArrayView<const GlobalOrdinal> myGIDs = map->getLocalElementList();
201 const size_t num_my_row = myGIDs.size();
204 RCP<Tpetra_Vector> x1 = Tpetra::createVector<Scalar>(map);
205 RCP<Tpetra_Vector> x2 = Tpetra::createVector<Scalar>(map);
207 auto x1_view = x1->getLocalViewHost(Tpetra::Access::OverwriteAll);
208 auto x2_view = x2->getLocalViewHost(Tpetra::Access::OverwriteAll);
210 for (
size_t i=0; i<num_my_row; ++i) {
213 val1.fastAccessCoeff(
j) = generate_vector_coefficient<BaseScalar,size_t>(nrow,
VectorSize, row,
j);
214 val2.fastAccessCoeff(
j) = 0.12345 * generate_vector_coefficient<BaseScalar,size_t>(nrow,
VectorSize, row,
j);
222 dot_type
dot = x1->dot(*x2);
226 #ifdef HAVE_STOKHOS_ENSEMBLE_REDUCT
229 dot_type local_val(0);
230 for (
size_t i=0; i<num_my_row; ++i) {
233 BaseScalar v = generate_vector_coefficient<BaseScalar,size_t>(
235 local_val += 0.12345 * v * v;
242 Teuchos::outArg(val));
248 for (
size_t i=0; i<num_my_row; ++i) {
251 BaseScalar v = generate_vector_coefficient<BaseScalar,size_t>(
253 local_val.fastAccessCoeff(
j) += 0.12345 * v * v;
260 Teuchos::outArg(val));
264 out <<
"dot = " << dot <<
" expected = " << val << std::endl;
266 BaseScalar tol = 1.0e-14;
286 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
287 typedef Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_MultiVector;
290 if ( !Kokkos::is_initialized() )
291 Kokkos::initialize();
294 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
298 RCP<const Tpetra_Map> map =
299 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
301 ArrayView<const GlobalOrdinal> myGIDs = map->getLocalElementList();
302 const size_t num_my_row = myGIDs.size();
306 RCP<Tpetra_MultiVector> x1 = Tpetra::createMultiVector<Scalar>(map, ncol);
307 RCP<Tpetra_MultiVector> x2 = Tpetra::createMultiVector<Scalar>(map, ncol);
309 auto x1_view = x1->getLocalViewHost(Tpetra::Access::OverwriteAll);
310 auto x2_view = x2->getLocalViewHost(Tpetra::Access::OverwriteAll);
312 for (
size_t i=0; i<num_my_row; ++i) {
314 for (
size_t j=0;
j<ncol; ++
j) {
317 generate_multi_vector_coefficient<BaseScalar,size_t>(
319 val1.fastAccessCoeff(k) = v;
320 val2.fastAccessCoeff(k) = 0.12345 * v;
331 RCP<Tpetra_MultiVector> y = Tpetra::createMultiVector<Scalar>(map, ncol);
332 y->update(alpha, *x1, beta, *x2,
Scalar(0.0));
338 auto y_view = y->getLocalViewHost(Tpetra::Access::ReadOnly);
340 BaseScalar tol = 1.0e-14;
341 for (
size_t i=0; i<num_my_row; ++i) {
343 for (
size_t j=0;
j<ncol; ++
j) {
345 BaseScalar v = generate_multi_vector_coefficient<BaseScalar,size_t>(
347 val.fastAccessCoeff(k) = alpha.coeff(k)*v + 0.12345*beta.coeff(k)*v;
352 val.fastAccessCoeff(k), tol );
373 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
374 typedef Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_MultiVector;
375 typedef typename Tpetra_MultiVector::dot_type dot_type;
378 if ( !Kokkos::is_initialized() )
379 Kokkos::initialize();
382 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
386 RCP<const Tpetra_Map> map =
387 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
389 ArrayView<const GlobalOrdinal> myGIDs = map->getLocalElementList();
390 const size_t num_my_row = myGIDs.size();
394 RCP<Tpetra_MultiVector> x1 = Tpetra::createMultiVector<Scalar>(map, ncol);
395 RCP<Tpetra_MultiVector> x2 = Tpetra::createMultiVector<Scalar>(map, ncol);
397 auto x1_view = x1->getLocalViewHost(Tpetra::Access::OverwriteAll);
398 auto x2_view = x2->getLocalViewHost(Tpetra::Access::OverwriteAll);
400 for (
size_t i=0; i<num_my_row; ++i) {
402 for (
size_t j=0;
j<ncol; ++
j) {
405 generate_multi_vector_coefficient<BaseScalar,size_t>(
407 val1.fastAccessCoeff(k) = v;
408 val2.fastAccessCoeff(k) = 0.12345 * v;
417 Array<dot_type> dots(ncol);
418 x1->dot(*x2, dots());
422 #ifdef HAVE_STOKHOS_ENSEMBLE_REDUCT
425 Array<dot_type> local_vals(ncol, dot_type(0));
426 for (
size_t i=0; i<num_my_row; ++i) {
428 for (
size_t j=0;
j<ncol; ++
j) {
430 BaseScalar v = generate_multi_vector_coefficient<BaseScalar,size_t>(
432 local_vals[
j] += 0.12345 * v * v;
438 Array<dot_type> vals(ncol, dot_type(0));
440 local_vals.getRawPtr(), vals.getRawPtr());
445 Array<dot_type> local_vals(ncol, dot_type(
VectorSize, 0.0));
446 for (
size_t i=0; i<num_my_row; ++i) {
448 for (
size_t j=0;
j<ncol; ++
j) {
450 BaseScalar v = generate_multi_vector_coefficient<BaseScalar,size_t>(
452 local_vals[
j].fastAccessCoeff(k) += 0.12345 * v * v;
458 Array<dot_type> vals(ncol, dot_type(
VectorSize, 0.0));
460 local_vals.getRawPtr(), vals.getRawPtr());
464 BaseScalar tol = 1.0e-14;
465 for (
size_t j=0;
j<ncol; ++
j) {
466 out <<
"dots(" <<
j <<
") = " << dots[
j]
467 <<
" expected(" <<
j <<
") = " << vals[
j] << std::endl;
488 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
489 typedef Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_MultiVector;
490 typedef typename Tpetra_MultiVector::dot_type dot_type;
493 if ( !Kokkos::is_initialized() )
494 Kokkos::initialize();
497 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
501 RCP<const Tpetra_Map> map =
502 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
504 ArrayView<const GlobalOrdinal> myGIDs = map->getLocalElementList();
505 const size_t num_my_row = myGIDs.size();
509 RCP<Tpetra_MultiVector> x1 = Tpetra::createMultiVector<Scalar>(map, ncol);
510 RCP<Tpetra_MultiVector> x2 = Tpetra::createMultiVector<Scalar>(map, ncol);
512 auto x1_view = x1->getLocalViewHost(Tpetra::Access::OverwriteAll);
513 auto x2_view = x2->getLocalViewHost(Tpetra::Access::OverwriteAll);
515 for (
size_t i=0; i<num_my_row; ++i) {
517 for (
size_t j=0;
j<ncol; ++
j) {
520 generate_multi_vector_coefficient<BaseScalar,size_t>(
522 val1.fastAccessCoeff(k) = v;
523 val2.fastAccessCoeff(k) = 0.12345 * v;
534 cols[0] = 4; cols[1] = 2;
535 RCP<const Tpetra_MultiVector> x1_sub = x1->subView(cols());
536 RCP<const Tpetra_MultiVector> x2_sub = x2->subView(cols());
539 Array<dot_type> dots(ncol_sub);
540 x1_sub->dot(*x2_sub, dots());
544 #ifdef HAVE_STOKHOS_ENSEMBLE_REDUCT
547 Array<dot_type> local_vals(ncol_sub, dot_type(0));
548 for (
size_t i=0; i<num_my_row; ++i) {
550 for (
size_t j=0;
j<ncol_sub; ++
j) {
552 BaseScalar v = generate_multi_vector_coefficient<BaseScalar,size_t>(
554 local_vals[
j] += 0.12345 * v * v;
560 Array<dot_type> vals(ncol_sub, dot_type(0));
562 Teuchos::as<int>(ncol_sub), local_vals.getRawPtr(),
568 Array<dot_type> local_vals(ncol_sub, dot_type(
VectorSize, 0.0));
569 for (
size_t i=0; i<num_my_row; ++i) {
571 for (
size_t j=0;
j<ncol_sub; ++
j) {
573 BaseScalar v = generate_multi_vector_coefficient<BaseScalar,size_t>(
575 local_vals[
j].fastAccessCoeff(k) += 0.12345 * v * v;
581 Array<dot_type> vals(ncol_sub, dot_type(
VectorSize, 0.0));
583 Teuchos::as<int>(ncol_sub), local_vals.getRawPtr(),
588 BaseScalar tol = 1.0e-14;
589 for (
size_t j=0;
j<ncol_sub; ++
j) {
590 out <<
"dots(" <<
j <<
") = " << dots[
j]
591 <<
" expected(" <<
j <<
") = " << vals[
j] << std::endl;
612 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
613 typedef Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_Vector;
614 typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsMatrix;
615 typedef Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsGraph;
618 if ( !Kokkos::is_initialized() )
619 Kokkos::initialize();
623 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
624 RCP<const Tpetra_Map> map =
625 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
627 RCP<Tpetra_CrsGraph> graph =
628 rcp(
new Tpetra_CrsGraph(map,
size_t(2)));
629 Array<GlobalOrdinal> columnIndices(2);
630 ArrayView<const GlobalOrdinal> myGIDs = map->getLocalElementList();
631 const size_t num_my_row = myGIDs.size();
632 for (
size_t i=0; i<num_my_row; ++i) {
634 columnIndices[0] = row;
637 columnIndices[1] = row+1;
640 graph->insertGlobalIndices(row, columnIndices(0,ncol));
642 graph->fillComplete();
643 RCP<Tpetra_CrsMatrix> matrix =
rcp(
new Tpetra_CrsMatrix(graph));
646 Array<Scalar> vals(2);
648 for (
size_t i=0; i<num_my_row; ++i) {
650 columnIndices[0] = row;
652 val.fastAccessCoeff(
j) = generate_vector_coefficient<BaseScalar,size_t>(
658 columnIndices[1] = row+1;
660 val.fastAccessCoeff(
j) = generate_vector_coefficient<BaseScalar,size_t>(
665 matrix->replaceGlobalValues(row, columnIndices(0,ncol), vals(0,ncol));
667 matrix->fillComplete();
670 RCP<Tpetra_Vector> x = Tpetra::createVector<Scalar>(map);
672 auto x_view = x->getLocalViewHost(Tpetra::Access::OverwriteAll);
673 for (
size_t i=0; i<num_my_row; ++i) {
676 val.fastAccessCoeff(
j) = generate_vector_coefficient<BaseScalar,size_t>(
689 RCP<Tpetra_Vector> y = Tpetra::createVector<Scalar>(map);
690 matrix->apply(*x, *y);
696 auto y_view = y->getLocalViewHost(Tpetra::Access::ReadOnly);
697 BaseScalar tol = 1.0e-14;
698 for (
size_t i=0; i<num_my_row; ++i) {
701 BaseScalar v = generate_vector_coefficient<BaseScalar,size_t>(
703 val.fastAccessCoeff(
j) = v*v;
707 BaseScalar v = generate_vector_coefficient<BaseScalar,size_t>(
709 val.fastAccessCoeff(
j) += v*v;
734 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
735 typedef Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_MultiVector;
736 typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsMatrix;
737 typedef Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsGraph;
740 if ( !Kokkos::is_initialized() )
741 Kokkos::initialize();
745 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
746 RCP<const Tpetra_Map> map =
747 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
749 RCP<Tpetra_CrsGraph> graph =
750 rcp(
new Tpetra_CrsGraph(map,
size_t(2)));
751 Array<GlobalOrdinal> columnIndices(2);
752 ArrayView<const GlobalOrdinal> myGIDs = map->getLocalElementList();
753 const size_t num_my_row = myGIDs.size();
754 for (
size_t i=0; i<num_my_row; ++i) {
756 columnIndices[0] = row;
759 columnIndices[1] = row+1;
762 graph->insertGlobalIndices(row, columnIndices(0,ncol));
764 graph->fillComplete();
765 RCP<Tpetra_CrsMatrix> matrix =
rcp(
new Tpetra_CrsMatrix(graph));
768 Array<Scalar> vals(2);
770 for (
size_t i=0; i<num_my_row; ++i) {
772 columnIndices[0] = row;
774 val.fastAccessCoeff(
j) = generate_vector_coefficient<BaseScalar,size_t>(
780 columnIndices[1] = row+1;
782 val.fastAccessCoeff(
j) = generate_vector_coefficient<BaseScalar,size_t>(
787 matrix->replaceGlobalValues(row, columnIndices(0,ncol), vals(0,ncol));
789 matrix->fillComplete();
793 RCP<Tpetra_MultiVector> x = Tpetra::createMultiVector<Scalar>(map, ncol);
795 auto x_view = x->getLocalViewHost(Tpetra::Access::OverwriteAll);
796 for (
size_t i=0; i<num_my_row; ++i) {
798 for (
size_t j=0;
j<ncol; ++
j) {
801 generate_multi_vector_coefficient<BaseScalar,size_t>(
803 val.fastAccessCoeff(k) = v;
817 RCP<Tpetra_MultiVector> y = Tpetra::createMultiVector<Scalar>(map, ncol);
818 matrix->apply(*x, *y);
824 auto y_view = y->getLocalViewHost(Tpetra::Access::ReadOnly);
825 BaseScalar tol = 1.0e-14;
826 for (
size_t i=0; i<num_my_row; ++i) {
828 for (
size_t j=0;
j<ncol; ++
j) {
830 BaseScalar v1 = generate_vector_coefficient<BaseScalar,size_t>(
832 BaseScalar v2 = generate_multi_vector_coefficient<BaseScalar,size_t>(
834 val.fastAccessCoeff(k) = v1*v2;
838 BaseScalar v1 = generate_vector_coefficient<BaseScalar,size_t>(
840 BaseScalar v2 = generate_multi_vector_coefficient<BaseScalar,size_t>(
842 val.fastAccessCoeff(k) += v1*v2;
848 val.fastAccessCoeff(k), tol );
869 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
870 typedef Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_Vector;
871 typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsMatrix;
872 typedef Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsGraph;
874 typedef Tpetra::Vector<BaseScalar,LocalOrdinal,GlobalOrdinal,Node> Flat_Tpetra_Vector;
875 typedef Tpetra::CrsMatrix<BaseScalar,LocalOrdinal,GlobalOrdinal,Node> Flat_Tpetra_CrsMatrix;
878 if ( !Kokkos::is_initialized() )
879 Kokkos::initialize();
883 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
884 RCP<const Tpetra_Map> map =
885 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
887 RCP<Tpetra_CrsGraph> graph =
888 rcp(
new Tpetra_CrsGraph(map,
size_t(2)));
889 Array<GlobalOrdinal> columnIndices(2);
890 ArrayView<const GlobalOrdinal> myGIDs = map->getLocalElementList();
891 const size_t num_my_row = myGIDs.size();
892 for (
size_t i=0; i<num_my_row; ++i) {
894 columnIndices[0] = row;
897 columnIndices[1] = row+1;
900 graph->insertGlobalIndices(row, columnIndices(0,ncol));
902 graph->fillComplete();
903 RCP<Tpetra_CrsMatrix> matrix =
rcp(
new Tpetra_CrsMatrix(graph));
906 Array<Scalar> vals(2);
908 for (
size_t i=0; i<num_my_row; ++i) {
910 columnIndices[0] = row;
912 val.fastAccessCoeff(
j) = generate_vector_coefficient<BaseScalar,size_t>(
918 columnIndices[1] = row+1;
920 val.fastAccessCoeff(
j) = generate_vector_coefficient<BaseScalar,size_t>(
925 matrix->replaceGlobalValues(row, columnIndices(0,ncol), vals(0,ncol));
927 matrix->fillComplete();
930 RCP<Tpetra_Vector> x = Tpetra::createVector<Scalar>(map);
932 auto x_view = x->getLocalViewHost(Tpetra::Access::OverwriteAll);
933 for (
size_t i=0; i<num_my_row; ++i) {
936 val.fastAccessCoeff(
j) = generate_vector_coefficient<BaseScalar,size_t>(
943 RCP<Tpetra_Vector> y = Tpetra::createVector<Scalar>(map);
944 matrix->apply(*x, *y);
947 RCP<const Tpetra_Map> flat_x_map, flat_y_map;
948 RCP<const Tpetra_CrsGraph> flat_graph =
950 RCP<Flat_Tpetra_CrsMatrix> flat_matrix =
954 RCP<Tpetra_Vector> y2 = Tpetra::createVector<Scalar>(map);
956 RCP<Flat_Tpetra_Vector> flat_x =
958 RCP<Flat_Tpetra_Vector> flat_y =
960 flat_matrix->apply(*flat_x, *flat_y);
967 BaseScalar tol = 1.0e-14;
968 auto y_view = y-> getLocalViewHost(Tpetra::Access::ReadOnly);
969 auto y2_view = y2->getLocalViewHost(Tpetra::Access::ReadOnly);
970 for (
size_t i=0; i<num_my_row; ++i) {
999 using DualViewType = Kokkos::DualView<Scalar*, typename Node::device_type>;
1000 using WDV = Tpetra::Details::WrappedDualView<DualViewType>;
1001 using values_view =
typename DualViewType::t_dev;
1004 if ( !Kokkos::is_initialized() )
1005 Kokkos::initialize();
1009 values_view myView(
"emptyTestView", 0);
1012 size_t use_h = wdv.getHostView(Tpetra::Access::ReadOnly).use_count();
1013 size_t use_d = wdv.getDeviceView(Tpetra::Access::ReadOnly).use_count();
1036 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
1037 typedef Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_Vector;
1038 typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsMatrix;
1039 typedef Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsGraph;
1042 if ( !Kokkos::is_initialized() )
1043 Kokkos::initialize();
1047 BaseScalar h = 1.0 /
static_cast<BaseScalar
>(nrow-1);
1048 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
1049 RCP<const Tpetra_Map> map =
1050 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
1052 RCP<Tpetra_CrsGraph> graph =
1053 rcp(
new Tpetra_CrsGraph(map,
size_t(3)));
1054 Array<GlobalOrdinal> columnIndices(3);
1055 ArrayView<const GlobalOrdinal> myGIDs = map->getLocalElementList();
1056 const size_t num_my_row = myGIDs.size();
1057 for (
size_t i=0; i<num_my_row; ++i) {
1059 if (row == 0 || row == nrow-1) {
1060 columnIndices[0] = row;
1061 graph->insertGlobalIndices(row, columnIndices(0,1));
1064 columnIndices[0] = row-1;
1065 columnIndices[1] = row;
1066 columnIndices[2] = row+1;
1067 graph->insertGlobalIndices(row, columnIndices(0,3));
1070 graph->fillComplete();
1071 RCP<Tpetra_CrsMatrix> matrix =
rcp(
new Tpetra_CrsMatrix(graph));
1074 Array<Scalar> vals(3);
1077 a_val.fastAccessCoeff(
j) =
1078 BaseScalar(1.0) + BaseScalar(
j) / BaseScalar(VectorSize);
1080 for (
size_t i=0; i<num_my_row; ++i) {
1082 if (row == 0 || row == nrow-1) {
1083 columnIndices[0] = row;
1085 matrix->replaceGlobalValues(row, columnIndices(0,1), vals(0,1));
1088 columnIndices[0] = row-1;
1089 columnIndices[1] = row;
1090 columnIndices[2] = row+1;
1091 vals[0] =
Scalar(-1.0) * a_val;
1092 vals[1] =
Scalar(2.0) * a_val;
1093 vals[2] =
Scalar(-1.0) * a_val;
1094 matrix->replaceGlobalValues(row, columnIndices(0,3), vals(0,3));
1097 matrix->fillComplete();
1099 matrix->describe(*(Teuchos::fancyOStream(
rcp(&std::cout,
false))),
1103 RCP<Tpetra_Vector> b = Tpetra::createVector<Scalar>(map);
1106 auto b_view = b->getLocalViewHost(Tpetra::Access::OverwriteAll);
1107 b_val =
Scalar(VectorSize, BaseScalar(0.0));
1109 b_val.fastAccessCoeff(
j) =
1110 BaseScalar(-1.0) + BaseScalar(
j) / BaseScalar(VectorSize);
1112 for (
size_t i=0; i<num_my_row; ++i) {
1114 if (row == 0 || row == nrow-1)
1115 b_view(i,0) =
Scalar(0.0);
1117 b_view(i,0) = -
Scalar(b_val * h * h);
1122 RCP<Tpetra_Vector> x = Tpetra::createVector<Scalar>(map);
1123 typedef Kokkos::ArithTraits<BaseScalar> BST;
1124 typedef typename BST::mag_type base_mag_type;
1125 typedef typename Tpetra_Vector::mag_type mag_type;
1126 base_mag_type btol = 1e-9;
1127 mag_type tol = btol;
1130 out.getOStream().get());
1138 auto x_view = x->getLocalViewHost(Tpetra::Access::ReadOnly);
1139 Scalar
val(VectorSize, BaseScalar(0.0));
1140 for (
size_t i=0; i<num_my_row; ++i) {
1142 BaseScalar xx = row * h;
1144 val.fastAccessCoeff(
j) =
1145 BaseScalar(0.5) * (b_val.coeff(
j)/a_val.coeff(
j)) * xx * (xx - BaseScalar(1.0));
1150 Scalar v = x_view(i,0);
1153 v.fastAccessCoeff(
j) = BaseScalar(0.0);
1155 val.fastAccessCoeff(
j) = BaseScalar(0.0);
1164 #if defined(HAVE_STOKHOS_MUELU) && defined(HAVE_STOKHOS_AMESOS2) && defined(HAVE_STOKHOS_IFPACK2)
1178 using Teuchos::getParametersFromXmlFile;
1184 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
1185 typedef Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_Vector;
1186 typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsMatrix;
1187 typedef Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsGraph;
1190 if ( !Kokkos::is_initialized() )
1191 Kokkos::initialize();
1195 BaseScalar h = 1.0 /
static_cast<BaseScalar
>(nrow-1);
1196 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
1197 RCP<const Tpetra_Map> map =
1198 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
1200 RCP<Tpetra_CrsGraph> graph =
1201 rcp(
new Tpetra_CrsGraph(map,
size_t(3)));
1202 Array<GlobalOrdinal> columnIndices(3);
1203 ArrayView<const GlobalOrdinal> myGIDs = map->getLocalElementList();
1204 const size_t num_my_row = myGIDs.size();
1205 for (
size_t i=0; i<num_my_row; ++i) {
1207 if (row == 0 || row == nrow-1) {
1208 columnIndices[0] = row;
1209 graph->insertGlobalIndices(row, columnIndices(0,1));
1212 columnIndices[0] = row-1;
1213 columnIndices[1] = row;
1214 columnIndices[2] = row+1;
1215 graph->insertGlobalIndices(row, columnIndices(0,3));
1218 graph->fillComplete();
1219 RCP<Tpetra_CrsMatrix> matrix =
rcp(
new Tpetra_CrsMatrix(graph));
1222 Array<Scalar> vals(3);
1225 a_val.fastAccessCoeff(
j) =
1226 BaseScalar(1.0) + BaseScalar(
j) / BaseScalar(VectorSize);
1228 for (
size_t i=0; i<num_my_row; ++i) {
1230 if (row == 0 || row == nrow-1) {
1231 columnIndices[0] = row;
1233 matrix->replaceGlobalValues(row, columnIndices(0,1), vals(0,1));
1236 columnIndices[0] = row-1;
1237 columnIndices[1] = row;
1238 columnIndices[2] = row+1;
1239 vals[0] =
Scalar(-1.0) * a_val;
1240 vals[1] =
Scalar(2.0) * a_val;
1241 vals[2] =
Scalar(-1.0) * a_val;
1242 matrix->replaceGlobalValues(row, columnIndices(0,3), vals(0,3));
1245 matrix->fillComplete();
1248 RCP<Tpetra_Vector> b = Tpetra::createVector<Scalar>(map);
1251 auto b_view = b->getLocalViewHost(Tpetra::Access::OverwriteAll);
1252 b_val =
Scalar(VectorSize, BaseScalar(0.0));
1254 b_val.fastAccessCoeff(
j) =
1255 BaseScalar(-1.0) + BaseScalar(
j) / BaseScalar(VectorSize);
1257 for (
size_t i=0; i<num_my_row; ++i) {
1259 if (row == 0 || row == nrow-1)
1260 b_view(i,0) =
Scalar(0.0);
1262 b_view(i,0) = -
Scalar(b_val * h * h);
1267 typedef Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> OP;
1268 RCP<OP> matrix_op = matrix;
1269 RCP<ParameterList> muelu_params =
1270 getParametersFromXmlFile(
"muelu_cheby.xml");
1272 MueLu::CreateTpetraPreconditioner<Scalar,LocalOrdinal,GlobalOrdinal,Node>(matrix_op, *muelu_params);
1275 RCP<Tpetra_Vector> x = Tpetra::createVector<Scalar>(map);
1276 typedef Kokkos::ArithTraits<BaseScalar> BST;
1277 typedef typename BST::mag_type base_mag_type;
1278 typedef typename Tpetra_Vector::mag_type mag_type;
1279 base_mag_type btol = 1e-9;
1280 mag_type tol = btol;
1283 out.getOStream().get());
1291 auto x_view = x->getLocalViewHost(Tpetra::Access::ReadOnly);
1292 Scalar
val(VectorSize, BaseScalar(0.0));
1293 for (
size_t i=0; i<num_my_row; ++i) {
1295 BaseScalar xx = row * h;
1297 val.fastAccessCoeff(
j) =
1298 BaseScalar(0.5) * (b_val.coeff(
j)/a_val.coeff(
j)) * xx * (xx - BaseScalar(1.0));
1303 Scalar v = x_view(i,0);
1305 if (BST::magnitude(v.coeff(
j)) < btol)
1306 v.fastAccessCoeff(
j) = BaseScalar(0.0);
1307 if (BST::magnitude(
val.coeff(
j)) < btol)
1308 val.fastAccessCoeff(
j) = BaseScalar(0.0);
1324 #if defined(HAVE_STOKHOS_BELOS)
1343 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
1344 typedef Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_Vector;
1345 typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsMatrix;
1346 typedef Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsGraph;
1349 if ( !Kokkos::is_initialized() )
1350 Kokkos::initialize();
1354 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
1355 RCP<const Tpetra_Map> map =
1356 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
1358 RCP<Tpetra_CrsGraph> graph =
1359 rcp(
new Tpetra_CrsGraph(map,
size_t(2)));
1360 Array<GlobalOrdinal> columnIndices(2);
1361 ArrayView<const GlobalOrdinal> myGIDs = map->getLocalElementList();
1362 const size_t num_my_row = myGIDs.size();
1363 for (
size_t i=0; i<num_my_row; ++i) {
1365 columnIndices[0] = row;
1367 if (row != nrow-1) {
1368 columnIndices[1] = row+1;
1371 graph->insertGlobalIndices(row, columnIndices(0,ncol));
1373 graph->fillComplete();
1374 RCP<Tpetra_CrsMatrix> matrix =
rcp(
new Tpetra_CrsMatrix(graph));
1377 Array<Scalar> vals(2);
1378 Scalar
val(VectorSize, BaseScalar(0.0));
1379 for (
size_t i=0; i<num_my_row; ++i) {
1381 columnIndices[0] = row;
1383 val.fastAccessCoeff(
j) =
j+1;
1387 if (row != nrow-1) {
1388 columnIndices[1] = row+1;
1390 val.fastAccessCoeff(
j) =
j+1;
1394 matrix->replaceGlobalValues(row, columnIndices(0,ncol), vals(0,ncol));
1396 matrix->fillComplete();
1399 RCP<Tpetra_Vector> b = Tpetra::createVector<Scalar>(map);
1401 auto b_view = b->getLocalViewHost(Tpetra::Access::OverwriteAll);
1402 for (
size_t i=0; i<num_my_row; ++i) {
1403 b_view(i,0) =
Scalar(1.0);
1409 #ifdef HAVE_STOKHOS_ENSEMBLE_REDUCT
1410 typedef BaseScalar BelosScalar;
1412 typedef Scalar BelosScalar;
1414 typedef Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> MV;
1415 typedef Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> OP;
1416 typedef Belos::LinearProblem<BelosScalar,MV,OP> BLinProb;
1417 RCP<Tpetra_Vector> x = Tpetra::createVector<Scalar>(map);
1418 RCP< BLinProb > problem =
rcp(
new BLinProb(matrix, x, b));
1419 RCP<ParameterList> belosParams =
rcp(
new ParameterList);
1420 typename ST::magnitudeType tol = 1e-9;
1421 belosParams->set(
"Flexible Gmres",
false);
1422 belosParams->set(
"Num Blocks", 100);
1423 belosParams->set(
"Convergence Tolerance", BelosScalar(tol));
1424 belosParams->set(
"Maximum Iterations", 100);
1425 belosParams->set(
"Verbosity", 33);
1426 belosParams->set(
"Output Style", 1);
1427 belosParams->set(
"Output Frequency", 1);
1428 belosParams->set(
"Output Stream", out.getOStream());
1429 RCP<Belos::SolverManager<BelosScalar,MV,OP> > solver =
1430 rcp(
new Belos::PseudoBlockGmresSolMgr<BelosScalar,MV,OP>(problem, belosParams));
1431 problem->setProblem();
1432 Belos::ReturnType ret = solver->solve();
1445 auto x_view = x->getLocalViewHost(Tpetra::Access::ReadOnly);
1446 for (
size_t i=0; i<num_my_row; ++i) {
1450 val.fastAccessCoeff(
j) = BaseScalar(1.0) / BaseScalar(
j+1);
1454 val =
Scalar(VectorSize, BaseScalar(0.0));
1458 Scalar v = x_view(i,0);
1460 if (ST::magnitude(v.coeff(
j)) < tol)
1461 v.fastAccessCoeff(
j) = BaseScalar(0.0);
1477 using Teuchos::tuple;
1487 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
1488 typedef Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_Vector;
1489 typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsMatrix;
1490 typedef Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsGraph;
1493 if ( !Kokkos::is_initialized() )
1494 Kokkos::initialize();
1498 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
1499 RCP<const Tpetra_Map> map =
1500 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
1502 RCP<Tpetra_CrsGraph> graph =
1503 rcp(
new Tpetra_CrsGraph(map,
size_t(1)));
1504 Array<GlobalOrdinal> columnIndices(1);
1505 ArrayView<const GlobalOrdinal> myGIDs = map->getLocalElementList();
1506 const size_t num_my_row = myGIDs.size();
1507 for (
size_t i=0; i<num_my_row; ++i) {
1509 columnIndices[0] = row;
1511 graph->insertGlobalIndices(row, columnIndices(0,ncol));
1513 graph->fillComplete();
1514 RCP<Tpetra_CrsMatrix> matrix =
rcp(
new Tpetra_CrsMatrix(graph));
1516 Array<Scalar> vals(1);
1517 for (
size_t i=0; i<num_my_row; ++i) {
1519 columnIndices[0] = row;
1521 matrix->replaceGlobalValues(row, columnIndices(0,1), vals(0,1));
1523 matrix->fillComplete();
1532 RCP<Tpetra_Vector> b = Tpetra::createVector<Scalar>(map);
1534 auto b_view = b->getLocalViewHost(Tpetra::Access::OverwriteAll);
1535 for (
size_t i=0; i<num_my_row; ++i) {
1537 b_view(i,0) =
Scalar(0.0);
1539 if (
int(
j+2+row-VectorSize) > 0)
1540 b_view(i,0).fastAccessCoeff(
j) = BaseScalar(row+1);
1546 #ifdef HAVE_STOKHOS_ENSEMBLE_REDUCT
1547 typedef BaseScalar BelosScalar;
1549 typedef Scalar BelosScalar;
1551 typedef Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> MV;
1552 typedef Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> OP;
1553 typedef Belos::LinearProblem<BelosScalar,MV,OP> BLinProb;
1554 RCP<Tpetra_Vector> x = Tpetra::createVector<Scalar>(map);
1555 RCP< BLinProb > problem =
rcp(
new BLinProb(matrix, x, b));
1556 RCP<ParameterList> belosParams =
rcp(
new ParameterList);
1557 typename ST::magnitudeType tol = 1e-9;
1558 belosParams->set(
"Flexible Gmres",
false);
1559 belosParams->set(
"Num Blocks", 100);
1560 belosParams->set(
"Convergence Tolerance", BelosScalar(tol));
1561 belosParams->set(
"Maximum Iterations", 100);
1562 belosParams->set(
"Verbosity", 33);
1563 belosParams->set(
"Output Style", 1);
1564 belosParams->set(
"Output Frequency", 1);
1565 belosParams->set(
"Output Stream", out.getOStream());
1566 belosParams->set(
"Orthogonalization",
"DGKS");
1567 RCP<Belos::PseudoBlockGmresSolMgr<BelosScalar,MV,OP> > solver =
1568 rcp(
new Belos::PseudoBlockGmresSolMgr<BelosScalar,MV,OP>(problem, belosParams));
1569 problem->setProblem();
1570 Belos::ReturnType ret = solver->solve();
1573 #ifndef HAVE_STOKHOS_ENSEMBLE_REDUCT
1574 int numItersExpected = nrow;
1575 int numIters = solver->getNumIters();
1576 out <<
"numIters = " << numIters << std::endl;
1580 std::vector<int> ensemble_iterations =
1582 out <<
"Ensemble iterations = ";
1583 for (
auto ensemble_iteration : ensemble_iterations)
1584 out << ensemble_iteration <<
" ";
1588 if (
int(
j+1+nrow-VectorSize) > 0) {
1604 auto x_view = x->getLocalViewHost(Tpetra::Access::ReadOnly);
1605 for (
size_t i=0; i<num_my_row; ++i) {
1607 Scalar v = x_view(i,0);
1610 if (ST::magnitude(v.coeff(
j)) < tol)
1611 v.fastAccessCoeff(
j) = BaseScalar(0.0);
1617 if (
j+2+row-VectorSize > 0)
1618 val.fastAccessCoeff(
j) = BaseScalar(1.0);
1633 using Teuchos::tuple;
1643 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
1644 typedef Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_Vector;
1645 typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsMatrix;
1646 typedef Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsGraph;
1649 if ( !Kokkos::is_initialized() )
1650 Kokkos::initialize();
1654 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
1655 RCP<const Tpetra_Map> map =
1656 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
1658 RCP<Tpetra_CrsGraph> graph =
1659 rcp(
new Tpetra_CrsGraph(map,
size_t(1)));
1660 Array<GlobalOrdinal> columnIndices(1);
1661 ArrayView<const GlobalOrdinal> myGIDs = map->getLocalElementList();
1662 const size_t num_my_row = myGIDs.size();
1663 for (
size_t i=0; i<num_my_row; ++i) {
1665 columnIndices[0] = row;
1667 graph->insertGlobalIndices(row, columnIndices(0,ncol));
1669 graph->fillComplete();
1670 RCP<Tpetra_CrsMatrix> matrix =
rcp(
new Tpetra_CrsMatrix(graph));
1672 Array<Scalar> vals(1);
1673 for (
size_t i=0; i<num_my_row; ++i) {
1675 columnIndices[0] = row;
1677 matrix->replaceGlobalValues(row, columnIndices(0,1), vals(0,1));
1679 matrix->fillComplete();
1688 RCP<Tpetra_Vector> b = Tpetra::createVector<Scalar>(map);
1690 auto b_view = b->getLocalViewHost(Tpetra::Access::OverwriteAll);
1691 for (
size_t i=0; i<num_my_row; ++i) {
1693 b_view(i,0) =
Scalar(0.0);
1695 if (
int(
j+2+row-VectorSize) > 0)
1696 b_view(i,0).fastAccessCoeff(
j) = BaseScalar(row+1);
1702 #ifdef HAVE_STOKHOS_ENSEMBLE_REDUCT
1703 typedef BaseScalar BelosScalar;
1705 typedef Scalar BelosScalar;
1707 typedef Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> MV;
1708 typedef Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> OP;
1709 typedef Belos::LinearProblem<BelosScalar,MV,OP> BLinProb;
1710 RCP<Tpetra_Vector> x = Tpetra::createVector<Scalar>(map);
1711 RCP< BLinProb > problem =
rcp(
new BLinProb(matrix, x, b));
1712 RCP<ParameterList> belosParams =
rcp(
new ParameterList);
1713 typename ST::magnitudeType tol = 1e-9;
1714 belosParams->set(
"Flexible Gmres",
false);
1715 belosParams->set(
"Num Blocks", 100);
1716 belosParams->set(
"Convergence Tolerance", BelosScalar(tol));
1717 belosParams->set(
"Maximum Iterations", 100);
1718 belosParams->set(
"Verbosity", 33);
1719 belosParams->set(
"Output Style", 1);
1720 belosParams->set(
"Output Frequency", 1);
1721 belosParams->set(
"Output Stream", out.getOStream());
1722 belosParams->set(
"Orthogonalization",
"ICGS");
1723 RCP<Belos::PseudoBlockGmresSolMgr<BelosScalar,MV,OP> > solver =
1724 rcp(
new Belos::PseudoBlockGmresSolMgr<BelosScalar,MV,OP>(problem, belosParams));
1725 problem->setProblem();
1726 Belos::ReturnType ret = solver->solve();
1729 #ifndef HAVE_STOKHOS_ENSEMBLE_REDUCT
1730 int numItersExpected = nrow;
1731 int numIters = solver->getNumIters();
1732 out <<
"numIters = " << numIters << std::endl;
1736 std::vector<int> ensemble_iterations =
1738 out <<
"Ensemble iterations = ";
1739 for (
auto ensemble_iteration : ensemble_iterations)
1740 out << ensemble_iteration <<
" ";
1744 if (
int(
j+1+nrow-VectorSize) > 0) {
1760 auto x_view = x->getLocalViewHost(Tpetra::Access::ReadOnly);
1761 for (
size_t i=0; i<num_my_row; ++i) {
1763 Scalar v = x_view(i,0);
1766 if (ST::magnitude(v.coeff(
j)) < tol)
1767 v.fastAccessCoeff(
j) = BaseScalar(0.0);
1770 Scalar val =
Scalar(0.0);
1773 if (
j+2+row-VectorSize > 0)
1774 val.fastAccessCoeff(
j) = BaseScalar(1.0);
1789 using Teuchos::tuple;
1799 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
1800 typedef Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_Vector;
1801 typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsMatrix;
1802 typedef Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsGraph;
1805 if ( !Kokkos::is_initialized() )
1806 Kokkos::initialize();
1810 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
1811 RCP<const Tpetra_Map> map =
1812 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
1814 RCP<Tpetra_CrsGraph> graph =
1815 rcp(
new Tpetra_CrsGraph(map,
size_t(1)));
1816 Array<GlobalOrdinal> columnIndices(1);
1817 ArrayView<const GlobalOrdinal> myGIDs = map->getLocalElementList();
1818 const size_t num_my_row = myGIDs.size();
1819 for (
size_t i=0; i<num_my_row; ++i) {
1821 columnIndices[0] = row;
1823 graph->insertGlobalIndices(row, columnIndices(0,ncol));
1825 graph->fillComplete();
1826 RCP<Tpetra_CrsMatrix> matrix =
rcp(
new Tpetra_CrsMatrix(graph));
1828 Array<Scalar> vals(1);
1829 for (
size_t i=0; i<num_my_row; ++i) {
1831 columnIndices[0] = row;
1833 matrix->replaceGlobalValues(row, columnIndices(0,1), vals(0,1));
1835 matrix->fillComplete();
1844 RCP<Tpetra_Vector> b = Tpetra::createVector<Scalar>(map);
1846 auto b_view = b->getLocalViewHost(Tpetra::Access::OverwriteAll);
1847 for (
size_t i=0; i<num_my_row; ++i) {
1849 b_view(i,0) =
Scalar(0.0);
1851 if (
int(
j+2+row-VectorSize) > 0)
1852 b_view(i,0).fastAccessCoeff(
j) = BaseScalar(row+1);
1858 #ifdef HAVE_STOKHOS_ENSEMBLE_REDUCT
1859 typedef BaseScalar BelosScalar;
1861 typedef Scalar BelosScalar;
1863 typedef Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> MV;
1864 typedef Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> OP;
1865 typedef Belos::LinearProblem<BelosScalar,MV,OP> BLinProb;
1866 RCP<Tpetra_Vector> x = Tpetra::createVector<Scalar>(map);
1867 RCP< BLinProb > problem =
rcp(
new BLinProb(matrix, x, b));
1868 RCP<ParameterList> belosParams =
rcp(
new ParameterList);
1869 typename ST::magnitudeType tol = 1e-9;
1870 belosParams->set(
"Flexible Gmres",
false);
1871 belosParams->set(
"Num Blocks", 100);
1872 belosParams->set(
"Convergence Tolerance", BelosScalar(tol));
1873 belosParams->set(
"Maximum Iterations", 100);
1874 belosParams->set(
"Verbosity", 33);
1875 belosParams->set(
"Output Style", 1);
1876 belosParams->set(
"Output Frequency", 1);
1877 belosParams->set(
"Output Stream", out.getOStream());
1878 belosParams->set(
"Orthogonalization",
"IMGS");
1879 RCP<Belos::PseudoBlockGmresSolMgr<BelosScalar,MV,OP> > solver =
1880 rcp(
new Belos::PseudoBlockGmresSolMgr<BelosScalar,MV,OP>(problem, belosParams));
1881 problem->setProblem();
1882 Belos::ReturnType ret = solver->solve();
1885 #ifndef HAVE_STOKHOS_ENSEMBLE_REDUCT
1886 int numItersExpected = nrow;
1887 int numIters = solver->getNumIters();
1888 out <<
"numIters = " << numIters << std::endl;
1892 std::vector<int> ensemble_iterations =
1894 out <<
"Ensemble iterations = ";
1895 for (
auto ensemble_iteration : ensemble_iterations)
1896 out << ensemble_iteration <<
" ";
1900 if (
int(
j+1+nrow-VectorSize) > 0) {
1916 auto x_view = x->getLocalViewHost(Tpetra::Access::ReadOnly);
1917 for (
size_t i=0; i<num_my_row; ++i) {
1919 Scalar v = x_view(i,0);
1922 if (ST::magnitude(v.coeff(
j)) < tol)
1923 v.fastAccessCoeff(
j) = BaseScalar(0.0);
1926 Scalar val =
Scalar(0.0);
1929 if (
j+2+row-VectorSize > 0)
1930 val.fastAccessCoeff(
j) = BaseScalar(1.0);
1957 #if defined(HAVE_STOKHOS_BELOS) && defined(HAVE_STOKHOS_IFPACK2)
1977 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
1978 typedef Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_Vector;
1979 typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsMatrix;
1980 typedef Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsGraph;
1983 if ( !Kokkos::is_initialized() )
1984 Kokkos::initialize();
1988 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
1989 RCP<const Tpetra_Map> map =
1990 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
1992 RCP<Tpetra_CrsGraph> graph =
1993 rcp(
new Tpetra_CrsGraph(map,
size_t(2)));
1994 Array<GlobalOrdinal> columnIndices(2);
1995 ArrayView<const GlobalOrdinal> myGIDs = map->getLocalElementList();
1996 const size_t num_my_row = myGIDs.size();
1997 for (
size_t i=0; i<num_my_row; ++i) {
1999 columnIndices[0] = row;
2001 if (row != nrow-1) {
2002 columnIndices[1] = row+1;
2005 graph->insertGlobalIndices(row, columnIndices(0,ncol));
2007 graph->fillComplete();
2008 RCP<Tpetra_CrsMatrix> matrix =
rcp(
new Tpetra_CrsMatrix(graph));
2011 Array<Scalar> vals(2);
2012 Scalar
val(VectorSize, BaseScalar(0.0));
2013 for (
size_t i=0; i<num_my_row; ++i) {
2015 columnIndices[0] = row;
2017 val.fastAccessCoeff(
j) =
j+1;
2021 if (row != nrow-1) {
2022 columnIndices[1] = row+1;
2024 val.fastAccessCoeff(
j) =
j+1;
2028 matrix->replaceGlobalValues(row, columnIndices(0,ncol), vals(0,ncol));
2030 matrix->fillComplete();
2033 RCP<Tpetra_Vector> b = Tpetra::createVector<Scalar>(map);
2035 auto b_view = b->getLocalViewHost(Tpetra::Access::OverwriteAll);
2036 for (
size_t i=0; i<num_my_row; ++i) {
2037 b_view(i,0) =
Scalar(1.0);
2042 typedef Ifpack2::Preconditioner<Scalar,LocalOrdinal,GlobalOrdinal,Node> Prec;
2043 Ifpack2::Factory factory;
2044 RCP<Prec> M = factory.create<Tpetra_CrsMatrix>(
"RILUK", matrix);
2050 #ifdef HAVE_STOKHOS_ENSEMBLE_REDUCT
2051 typedef BaseScalar BelosScalar;
2053 typedef Scalar BelosScalar;
2055 typedef Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> MV;
2056 typedef Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> OP;
2057 typedef Belos::LinearProblem<BelosScalar,MV,OP> BLinProb;
2058 RCP<Tpetra_Vector> x = Tpetra::createVector<Scalar>(map);
2059 RCP< BLinProb > problem =
rcp(
new BLinProb(matrix, x, b));
2060 problem->setRightPrec(M);
2061 problem->setProblem();
2062 RCP<ParameterList> belosParams =
rcp(
new ParameterList);
2063 typename ST::magnitudeType tol = 1e-9;
2064 belosParams->set(
"Flexible Gmres",
false);
2065 belosParams->set(
"Num Blocks", 100);
2066 belosParams->set(
"Convergence Tolerance", BelosScalar(tol));
2067 belosParams->set(
"Maximum Iterations", 100);
2068 belosParams->set(
"Verbosity", 33);
2069 belosParams->set(
"Output Style", 1);
2070 belosParams->set(
"Output Frequency", 1);
2071 belosParams->set(
"Output Stream", out.getOStream());
2073 RCP<Belos::SolverManager<BelosScalar,MV,OP> > solver =
2074 rcp(
new Belos::PseudoBlockGmresSolMgr<BelosScalar,MV,OP>(problem, belosParams));
2075 Belos::ReturnType ret = solver->solve();
2088 auto x_view = x->getLocalViewHost(Tpetra::Access::ReadOnly);
2089 for (
size_t i=0; i<num_my_row; ++i) {
2093 val.fastAccessCoeff(
j) = BaseScalar(1.0) / BaseScalar(
j+1);
2097 val =
Scalar(VectorSize, BaseScalar(0.0));
2101 Scalar v = x_view(i,0);
2103 if (ST::magnitude(v.coeff(
j)) < tol)
2104 v.fastAccessCoeff(
j) = BaseScalar(0.0);
2120 #if defined(HAVE_STOKHOS_BELOS) && defined(HAVE_STOKHOS_IFPACK2) && defined(HAVE_STOKHOS_MUELU) && defined(HAVE_STOKHOS_AMESOS2)
2134 using Teuchos::getParametersFromXmlFile;
2140 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
2141 typedef Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_Vector;
2142 typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsMatrix;
2143 typedef Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsGraph;
2146 if ( !Kokkos::is_initialized() )
2147 Kokkos::initialize();
2151 BaseScalar h = 1.0 /
static_cast<BaseScalar
>(nrow-1);
2152 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
2153 RCP<const Tpetra_Map> map =
2154 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
2156 RCP<Tpetra_CrsGraph> graph =
2157 rcp(
new Tpetra_CrsGraph(map,
size_t(3)));
2158 Array<GlobalOrdinal> columnIndices(3);
2159 ArrayView<const GlobalOrdinal> myGIDs = map->getLocalElementList();
2160 const size_t num_my_row = myGIDs.size();
2161 for (
size_t i=0; i<num_my_row; ++i) {
2163 if (row == 0 || row == nrow-1) {
2164 columnIndices[0] = row;
2165 graph->insertGlobalIndices(row, columnIndices(0,1));
2168 columnIndices[0] = row-1;
2169 columnIndices[1] = row;
2170 columnIndices[2] = row+1;
2171 graph->insertGlobalIndices(row, columnIndices(0,3));
2174 graph->fillComplete();
2175 RCP<Tpetra_CrsMatrix> matrix =
rcp(
new Tpetra_CrsMatrix(graph));
2178 Array<Scalar> vals(3);
2179 Scalar a_val(VectorSize, BaseScalar(0.0));
2181 a_val.fastAccessCoeff(
j) =
2182 BaseScalar(1.0) + BaseScalar(
j) / BaseScalar(VectorSize);
2184 for (
size_t i=0; i<num_my_row; ++i) {
2186 if (row == 0 || row == nrow-1) {
2187 columnIndices[0] = row;
2189 matrix->replaceGlobalValues(row, columnIndices(0,1), vals(0,1));
2192 columnIndices[0] = row-1;
2193 columnIndices[1] = row;
2194 columnIndices[2] = row+1;
2195 vals[0] =
Scalar(-1.0) * a_val;
2196 vals[1] =
Scalar(2.0) * a_val;
2197 vals[2] =
Scalar(-1.0) * a_val;
2198 matrix->replaceGlobalValues(row, columnIndices(0,3), vals(0,3));
2201 matrix->fillComplete();
2204 RCP<Tpetra_Vector> b = Tpetra::createVector<Scalar>(map);
2207 auto b_view = b->getLocalViewHost(Tpetra::Access::OverwriteAll);
2208 b_val =
Scalar(VectorSize, BaseScalar(0.0));
2210 b_val.fastAccessCoeff(
j) =
2211 BaseScalar(-1.0) + BaseScalar(
j) / BaseScalar(VectorSize);
2213 for (
size_t i=0; i<num_my_row; ++i) {
2215 if (row == 0 || row == nrow-1)
2216 b_view(i,0) =
Scalar(0.0);
2218 b_view(i,0) = -
Scalar(b_val * h * h);
2223 typedef Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> OP;
2224 RCP<ParameterList> muelu_params =
2225 getParametersFromXmlFile(
"muelu_cheby.xml");
2226 RCP<OP> matrix_op = matrix;
2228 MueLu::CreateTpetraPreconditioner<Scalar,LocalOrdinal,GlobalOrdinal,Node>(matrix_op, *muelu_params);
2232 #ifdef HAVE_STOKHOS_ENSEMBLE_REDUCT
2233 typedef BaseScalar BelosScalar;
2235 typedef Scalar BelosScalar;
2237 typedef Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> MV;
2238 typedef Belos::LinearProblem<BelosScalar,MV,OP> BLinProb;
2239 RCP<Tpetra_Vector> x = Tpetra::createVector<Scalar>(map);
2240 RCP< BLinProb > problem =
rcp(
new BLinProb(matrix, x, b));
2241 problem->setRightPrec(M);
2242 problem->setProblem();
2243 RCP<ParameterList> belosParams =
rcp(
new ParameterList);
2244 typename ST::magnitudeType tol = 1e-9;
2245 belosParams->set(
"Num Blocks", 100);
2246 belosParams->set(
"Convergence Tolerance", BelosScalar(tol));
2247 belosParams->set(
"Maximum Iterations", 100);
2248 belosParams->set(
"Verbosity", 33);
2249 belosParams->set(
"Output Style", 1);
2250 belosParams->set(
"Output Frequency", 1);
2251 belosParams->set(
"Output Stream", out.getOStream());
2254 belosParams->set(
"Implicit Residual Scaling",
"None");
2256 RCP<Belos::PseudoBlockCGSolMgr<BelosScalar,MV,OP,true> > solver =
2257 rcp(
new Belos::PseudoBlockCGSolMgr<BelosScalar,MV,OP,true>(problem, belosParams));
2258 Belos::ReturnType ret = solver->solve();
2261 #ifndef HAVE_STOKHOS_ENSEMBLE_REDUCT
2263 std::vector<int> ensemble_iterations =
2264 solver->getResidualStatusTest()->getEnsembleIterations();
2265 out <<
"Ensemble iterations = ";
2267 out << ensemble_iterations[i] <<
" ";
2276 auto x_view = x->getLocalViewHost(Tpetra::Access::ReadOnly);
2277 Scalar
val(VectorSize, BaseScalar(0.0));
2278 for (
size_t i=0; i<num_my_row; ++i) {
2280 BaseScalar xx = row * h;
2282 val.fastAccessCoeff(
j) =
2283 BaseScalar(0.5) * (b_val.coeff(
j)/a_val.coeff(
j)) * xx * (xx - BaseScalar(1.0));
2288 Scalar v = x_view(i,0);
2290 if (ST::magnitude(v.coeff(
j)) < tol)
2291 v.fastAccessCoeff(
j) = BaseScalar(0.0);
2292 if (ST::magnitude(val.coeff(
j)) < tol)
2293 val.fastAccessCoeff(
j) = BaseScalar(0.0);
2310 #if defined(HAVE_STOKHOS_AMESOS2)
2315 #define TEST_AMESOS2_SOLVER(SolverName) \
2316 TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(Tpetra_CrsMatrix_MP, Amesos2_##SolverName, Storage, LocalOrdinal, GlobalOrdinal, Node) \
2318 using Teuchos::RCP; \
2319 using Teuchos::rcp; \
2320 using Teuchos::ArrayView; \
2321 using Teuchos::Array; \
2322 using Teuchos::ArrayRCP; \
2323 using Teuchos::ParameterList; \
2325 typedef typename Storage::value_type BaseScalar; \
2326 typedef Sacado::MP::Vector<Storage> Scalar; \
2328 typedef Teuchos::Comm<int> Tpetra_Comm; \
2329 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map; \
2330 typedef Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_Vector; \
2331 typedef Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_MultiVector; \
2332 typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsMatrix; \
2333 typedef Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsGraph; \
2336 if ( !Kokkos::is_initialized() ) \
2337 Kokkos::initialize(); \
2340 GlobalOrdinal nrow = 50; \
2341 BaseScalar h = 1.0 / static_cast<BaseScalar>(nrow-1); \
2342 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm(); \
2343 RCP<const Tpetra_Map> map = \
2344 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>( \
2346 RCP<Tpetra_CrsGraph> graph = Tpetra::createCrsGraph(map, size_t(3)); \
2347 Array<GlobalOrdinal> columnIndices(3); \
2348 ArrayView<const GlobalOrdinal> myGIDs = map->getLocalElementList(); \
2349 const size_t num_my_row = myGIDs.size(); \
2350 for (size_t i=0; i<num_my_row; ++i) { \
2351 const GlobalOrdinal row = myGIDs[i]; \
2352 if (row == 0 || row == nrow-1) { \
2353 columnIndices[0] = row; \
2354 graph->insertGlobalIndices(row, columnIndices(0,1)); \
2357 columnIndices[0] = row-1; \
2358 columnIndices[1] = row; \
2359 columnIndices[2] = row+1; \
2360 graph->insertGlobalIndices(row, columnIndices(0,3)); \
2363 graph->fillComplete(); \
2364 RCP<Tpetra_CrsMatrix> matrix = rcp(new Tpetra_CrsMatrix(graph)); \
2367 Array<Scalar> vals(3); \
2368 Scalar a_val(VectorSize, BaseScalar(0.0)); \
2369 for (LocalOrdinal j=0; j<VectorSize; ++j) { \
2370 a_val.fastAccessCoeff(j) = \
2371 BaseScalar(1.0) + BaseScalar(j) / BaseScalar(VectorSize); \
2373 for (size_t i=0; i<num_my_row; ++i) { \
2374 const GlobalOrdinal row = myGIDs[i]; \
2375 if (row == 0 || row == nrow-1) { \
2376 columnIndices[0] = row; \
2377 vals[0] = Scalar(1.0); \
2378 matrix->replaceGlobalValues(row, columnIndices(0,1), vals(0,1)); \
2381 columnIndices[0] = row-1; \
2382 columnIndices[1] = row; \
2383 columnIndices[2] = row+1; \
2384 vals[0] = Scalar(-1.0) * a_val; \
2385 vals[1] = Scalar(2.0) * a_val; \
2386 vals[2] = Scalar(-1.0) * a_val; \
2387 matrix->replaceGlobalValues(row, columnIndices(0,3), vals(0,3)); \
2390 matrix->fillComplete();\
2393 RCP<Tpetra_Vector> b = Tpetra::createVector<Scalar>(map); \
2396 auto b_view = b->getLocalViewHost(Tpetra::Access::OverwriteAll); \
2397 b_val = Scalar(VectorSize, BaseScalar(0.0)); \
2398 for (LocalOrdinal j=0; j<VectorSize; ++j) { \
2399 b_val.fastAccessCoeff(j) = \
2400 BaseScalar(-1.0) + BaseScalar(j) / BaseScalar(VectorSize); \
2402 for (size_t i=0; i<num_my_row; ++i) { \
2403 const GlobalOrdinal row = myGIDs[i]; \
2404 if (row == 0 || row == nrow-1) \
2405 b_view(i,0) = Scalar(0.0); \
2407 b_view(i,0) = -Scalar(b_val * h * h); \
2412 typedef Amesos2::Solver<Tpetra_CrsMatrix,Tpetra_MultiVector> Solver; \
2413 RCP<Tpetra_Vector> x = Tpetra::createVector<Scalar>(map); \
2414 std::string solver_name(#SolverName); \
2415 out << "Solving linear system with " << solver_name << std::endl; \
2416 RCP<Solver> solver = Amesos2::create<Tpetra_CrsMatrix,Tpetra_MultiVector>( \
2417 solver_name, matrix, x, b); \
2421 solver = Teuchos::null; \
2422 typedef Teuchos::ScalarTraits<BaseScalar> ST; \
2423 typename ST::magnitudeType tol = 1e-9; \
2424 auto x_view = x->getLocalViewHost(Tpetra::Access::ReadOnly); \
2425 Scalar val(VectorSize, BaseScalar(0.0)); \
2426 for (size_t i=0; i<num_my_row; ++i) { \
2427 const GlobalOrdinal row = myGIDs[i]; \
2428 BaseScalar xx = row * h; \
2429 for (LocalOrdinal j=0; j<VectorSize; ++j) { \
2430 val.fastAccessCoeff(j) = \
2431 BaseScalar(0.5) * (b_val.coeff(j)/a_val.coeff(j)) * xx * (xx - BaseScalar(1.0)); \
2433 TEST_EQUALITY( x_view(i,0).size(), VectorSize ); \
2436 Scalar v = x_view(i,0); \
2437 for (LocalOrdinal j=0; j<VectorSize; ++j) { \
2438 if (ST::magnitude(v.coeff(j)) < tol) \
2439 v.fastAccessCoeff(j) = BaseScalar(0.0); \
2440 if (ST::magnitude(val.coeff(j)) < tol) \
2441 val.fastAccessCoeff(j) = BaseScalar(0.0); \
2444 for (LocalOrdinal j=0; j<VectorSize; ++j) \
2445 TEST_FLOATING_EQUALITY(v.coeff(j), val.coeff(j), tol); \
2449 #endif // defined(HAVE_STOKHOS_AMESOS2)
2451 #if defined(HAVE_STOKHOS_AMESOS2) && defined(HAVE_AMESOS2_BASKER)
2452 TEST_AMESOS2_SOLVER(basker)
2457 #if defined(HAVE_STOKHOS_AMESOS2) && defined(HAVE_AMESOS2_KLU2)
2458 TEST_AMESOS2_SOLVER(klu2)
2463 #if defined(HAVE_STOKHOS_AMESOS2) && defined(HAVE_AMESOS2_SUPERLUDIST)
2464 TEST_AMESOS2_SOLVER(superlu_dist)
2469 #if defined(HAVE_STOKHOS_AMESOS2) && defined(HAVE_AMESOS2_SUPERLUMT)
2470 TEST_AMESOS2_SOLVER(superlu_mt)
2475 #if defined(HAVE_STOKHOS_AMESOS2) && defined(HAVE_AMESOS2_SUPERLU)
2476 TEST_AMESOS2_SOLVER(superlu)
2481 #if defined(HAVE_STOKHOS_AMESOS2) && defined(HAVE_AMESOS2_PARDISO_MKL)
2482 TEST_AMESOS2_SOLVER(pardisomkl)
2487 #if defined(HAVE_STOKHOS_AMESOS2) && defined(HAVE_AMESOS2_LAPACK)
2488 TEST_AMESOS2_SOLVER(lapack)
2493 #if defined(HAVE_STOKHOS_AMESOS2) && defined(HAVE_AMESOS2_CHOLMOD) && defined (HAVE_AMESOS2_EXPERIMENTAL)
2494 TEST_AMESOS2_SOLVER(cholmod)
2499 #define CRSMATRIX_MP_VECTOR_TESTS_SLGN(S, LO, GO, N) \
2500 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, VectorAdd, S, LO, GO, N ) \
2501 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, VectorDot, S, LO, GO, N ) \
2502 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, MultiVectorAdd, S, LO, GO, N ) \
2503 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, MultiVectorDot, S, LO, GO, N ) \
2504 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, MultiVectorDotSub, S, LO, GO, N ) \
2505 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, MatrixVectorMultiply, S, LO, GO, N ) \
2506 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, MatrixMultiVectorMultiply, S, LO, GO, N ) \
2507 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, WrappedDualView, S, LO, GO, N ) \
2508 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, Flatten, S, LO, GO, N ) \
2509 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, SimpleCG, S, LO, GO, N ) \
2510 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, SimplePCG_Muelu, S, LO, GO, N ) \
2511 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, BelosGMRES, S, LO, GO, N ) \
2512 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, BelosGMRES_DGKS, S, LO, GO, N ) \
2513 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, BelosGMRES_ICGS, S, LO, GO, N ) \
2514 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, BelosGMRES_IMGS, S, LO, GO, N ) \
2515 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, BelosGMRES_RILUK, S, LO, GO, N ) \
2516 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, BelosCG_Muelu, S, LO, GO, N ) \
2517 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, Amesos2_basker, S, LO, GO, N ) \
2518 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, Amesos2_klu2, S, LO, GO, N ) \
2519 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, Amesos2_superlu_dist, S, LO, GO, N ) \
2520 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, Amesos2_superlu_mt, S, LO, GO, N ) \
2521 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, Amesos2_superlu, S, LO, GO, N ) \
2522 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, Amesos2_pardisomkl, S, LO, GO, N ) \
2523 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, Amesos2_lapack, S, LO, GO, N ) \
2524 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_MP, Amesos2_cholmod, S, LO, GO, N )
2526 #define CRSMATRIX_MP_VECTOR_TESTS_N_SFS(N) \
2527 typedef Stokhos::DeviceForNode<N>::type Device; \
2528 typedef Stokhos::StaticFixedStorage<int,double,VectorSize,Device::execution_space> SFS; \
2529 using default_global_ordinal_type = ::Tpetra::Map<>::global_ordinal_type; \
2530 using default_local_ordinal_type = ::Tpetra::Map<>::local_ordinal_type; \
2531 CRSMATRIX_MP_VECTOR_TESTS_SLGN(SFS, default_local_ordinal_type, default_global_ordinal_type, N)
2533 #define CRSMATRIX_MP_VECTOR_TESTS_N(N) \
2534 CRSMATRIX_MP_VECTOR_TESTS_N_SFS(N)
Teuchos::RCP< Tpetra::CrsMatrix< typename Storage::value_type, LocalOrdinal, GlobalOrdinal, Node > > create_flat_matrix(const Tpetra::CrsMatrix< Sacado::UQ::PCE< Storage >, LocalOrdinal, GlobalOrdinal, Node > &mat, const Teuchos::RCP< const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &flat_graph, const Teuchos::RCP< const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &cijk_graph, const CijkType &cijk_dev)
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)
Teuchos::RCP< const Tpetra::MultiVector< typename Storage::value_type, LocalOrdinal, GlobalOrdinal, Node > > create_flat_vector_view(const Tpetra::MultiVector< Sacado::UQ::PCE< Storage >, LocalOrdinal, GlobalOrdinal, Node > &vec, const Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > &flat_map)
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)
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)
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)
KOKKOS_INLINE_FUNCTION PCE< Storage > abs(const PCE< Storage > &a)
expr1 expr1 expr1 expr2 expr1 expr1 c expr2 expr1 c fastAccessCoeff(j)-expr2.val(j)
#define TEST_FLOATING_EQUALITY(v1, v2, tol)
Tpetra::KokkosClassic::DefaultNode::DefaultNodeType Node
#define TEST_EQUALITY(v1, v2)
const unsigned VectorSize