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"
29 #ifdef HAVE_STOKHOS_BELOS
31 #include "BelosLinearProblem.hpp"
32 #include "BelosPseudoBlockGmresSolMgr.hpp"
33 #include "BelosPseudoBlockCGSolMgr.hpp"
37 #ifdef HAVE_STOKHOS_IFPACK2
39 #include "Ifpack2_Factory.hpp"
43 #ifdef HAVE_STOKHOS_MUELU
45 #include "MueLu_CreateTpetraPreconditioner.hpp"
49 #ifdef HAVE_STOKHOS_AMESOS2
51 #include "Amesos2_Factory.hpp"
64 #define USE_SCALAR_MEAN_BASED_PREC 1
66 template <
typename scalar,
typename ordinal>
70 const ordinal iColFEM,
71 const ordinal iStoch )
73 const scalar X_fem = 100.0 + scalar(iColFEM) / scalar(nFEM);
74 const scalar X_stoch = 1.0 + scalar(iStoch) / scalar(nStoch);
75 return X_fem + X_stoch;
79 template <
typename scalar,
typename ordinal>
84 const ordinal iColFEM,
88 const scalar X_fem = 100.0 + scalar(iColFEM) / scalar(nFEM);
89 const scalar X_stoch = 1.0 + scalar(iStoch) / scalar(nStoch);
90 const scalar X_col = 0.01 + scalar(iVec) / scalar(nVec);
91 return X_fem + X_stoch + X_col;
95 template <
typename scalar,
typename ordinal>
99 const ordinal iRowFEM,
100 const ordinal iColFEM,
101 const ordinal iStoch )
103 const scalar A_fem = ( 10.0 + scalar(iRowFEM) / scalar(nFEM) ) +
104 ( 5.0 + scalar(iColFEM) / scalar(nFEM) );
106 const scalar A_stoch = ( 1.0 + scalar(iStoch) / scalar(nStoch) );
108 return A_fem + A_stoch;
112 template <
typename kokkos_cijk_type,
typename ordinal_type>
128 Array< RCP<const one_d_basis> > bases(stoch_dim);
130 bases[i] =
rcp(
new legendre_basis(poly_ord,
true));
131 RCP<const product_basis> basis =
rcp(
new product_basis(bases));
134 RCP<Cijk>
cijk = basis->computeTripleProductTensor();
137 kokkos_cijk_type kokkos_cijk =
138 Stokhos::create_product_tensor<execution_space>(*basis, *
cijk);
165 typedef typename Scalar::cijk_type Cijk;
168 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
169 typedef Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_Vector;
172 if ( !Kokkos::is_initialized() )
173 Kokkos::initialize();
181 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
185 RCP<const Tpetra_Map> map =
186 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
188 ArrayView<const GlobalOrdinal> myGIDs = map->getLocalElementList();
189 const size_t num_my_row = myGIDs.size();
192 RCP<Tpetra_Vector> x1 = Tpetra::createVector<Scalar>(map);
193 RCP<Tpetra_Vector> x2 = Tpetra::createVector<Scalar>(map);
194 ArrayRCP<Scalar> x1_view = x1->get1dViewNonConst();
195 ArrayRCP<Scalar> x2_view = x2->get1dViewNonConst();
196 Scalar val1(cijk), val2(cijk);
197 for (
size_t i=0; i<num_my_row; ++i) {
200 val1.fastAccessCoeff(
j) = generate_vector_coefficient<BaseScalar,size_t>(nrow, pce_size, row,
j);
201 val2.fastAccessCoeff(
j) = 0.12345 * generate_vector_coefficient<BaseScalar,size_t>(nrow, pce_size, row,
j);
212 RCP<Tpetra_Vector> y = Tpetra::createVector<Scalar>(map);
213 y->update(alpha, *x1, beta, *x2,
Scalar(0.0));
219 ArrayRCP<Scalar> y_view = y->get1dViewNonConst();
221 BaseScalar tol = 1.0e-14;
222 for (
size_t i=0; i<num_my_row; ++i) {
225 BaseScalar v = generate_vector_coefficient<BaseScalar,size_t>(
226 nrow, pce_size, row,
j);
227 val.fastAccessCoeff(
j) = alpha.coeff(0)*v + 0.12345*beta.coeff(0)*v;
252 typedef typename Scalar::cijk_type Cijk;
255 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
256 typedef Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_Vector;
257 typedef typename Tpetra_Vector::dot_type dot_type;
260 if ( !Kokkos::is_initialized() )
261 Kokkos::initialize();
269 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
273 RCP<const Tpetra_Map> map =
274 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
276 ArrayView<const GlobalOrdinal> myGIDs = map->getLocalElementList();
277 const size_t num_my_row = myGIDs.size();
280 RCP<Tpetra_Vector> x1 = Tpetra::createVector<Scalar>(map);
281 RCP<Tpetra_Vector> x2 = Tpetra::createVector<Scalar>(map);
282 ArrayRCP<Scalar> x1_view = x1->get1dViewNonConst();
283 ArrayRCP<Scalar> x2_view = x2->get1dViewNonConst();
284 Scalar val1(cijk), val2(cijk);
285 for (
size_t i=0; i<num_my_row; ++i) {
288 val1.fastAccessCoeff(
j) = generate_vector_coefficient<BaseScalar,size_t>(nrow, pce_size, row,
j);
289 val2.fastAccessCoeff(
j) = 0.12345 * generate_vector_coefficient<BaseScalar,size_t>(nrow, pce_size, row,
j);
298 dot_type
dot = x1->dot(*x2);
303 dot_type local_val(0);
304 for (
size_t i=0; i<num_my_row; ++i) {
307 BaseScalar v = generate_vector_coefficient<BaseScalar,size_t>(
308 nrow, pce_size, row,
j);
309 local_val += 0.12345 * v * v;
316 Teuchos::outArg(val));
318 out <<
"dot = " << dot <<
" expected = " << val << std::endl;
320 BaseScalar tol = 1.0e-14;
341 typedef typename Scalar::cijk_type Cijk;
344 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
345 typedef Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_MultiVector;
348 if ( !Kokkos::is_initialized() )
349 Kokkos::initialize();
357 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
361 RCP<const Tpetra_Map> map =
362 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
364 ArrayView<const GlobalOrdinal> myGIDs = map->getLocalElementList();
365 const size_t num_my_row = myGIDs.size();
369 RCP<Tpetra_MultiVector> x1 = Tpetra::createMultiVector<Scalar>(map, ncol);
370 RCP<Tpetra_MultiVector> x2 = Tpetra::createMultiVector<Scalar>(map, ncol);
371 ArrayRCP< ArrayRCP<Scalar> > x1_view = x1->get2dViewNonConst();
372 ArrayRCP< ArrayRCP<Scalar> > x2_view = x2->get2dViewNonConst();
373 Scalar val1(cijk), val2(cijk);
374 for (
size_t i=0; i<num_my_row; ++i) {
376 for (
size_t j=0;
j<ncol; ++
j) {
379 generate_multi_vector_coefficient<BaseScalar,size_t>(
380 nrow, ncol, pce_size, row,
j, k);
381 val1.fastAccessCoeff(k) = v;
382 val2.fastAccessCoeff(k) = 0.12345 * v;
384 x1_view[
j][i] = val1;
385 x2_view[
j][i] = val2;
394 RCP<Tpetra_MultiVector> y = Tpetra::createMultiVector<Scalar>(map, ncol);
395 y->update(alpha, *x1, beta, *x2,
Scalar(0.0));
401 ArrayRCP< ArrayRCP<Scalar> > y_view = y->get2dViewNonConst();
403 BaseScalar tol = 1.0e-14;
404 for (
size_t i=0; i<num_my_row; ++i) {
406 for (
size_t j=0;
j<ncol; ++
j) {
408 BaseScalar v = generate_multi_vector_coefficient<BaseScalar,size_t>(
409 nrow, ncol, pce_size, row,
j, k);
410 val.fastAccessCoeff(k) = alpha.coeff(0)*v + 0.12345*beta.coeff(0)*v;
415 val.fastAccessCoeff(k), tol );
437 typedef typename Scalar::cijk_type Cijk;
440 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
441 typedef Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_MultiVector;
442 typedef typename Tpetra_MultiVector::dot_type dot_type;
445 if ( !Kokkos::is_initialized() )
446 Kokkos::initialize();
454 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
458 RCP<const Tpetra_Map> map =
459 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
461 ArrayView<const GlobalOrdinal> myGIDs = map->getLocalElementList();
462 const size_t num_my_row = myGIDs.size();
466 RCP<Tpetra_MultiVector> x1 = Tpetra::createMultiVector<Scalar>(map, ncol);
467 RCP<Tpetra_MultiVector> x2 = Tpetra::createMultiVector<Scalar>(map, ncol);
468 ArrayRCP< ArrayRCP<Scalar> > x1_view = x1->get2dViewNonConst();
469 ArrayRCP< ArrayRCP<Scalar> > x2_view = x2->get2dViewNonConst();
470 Scalar val1(cijk), val2(cijk);
471 for (
size_t i=0; i<num_my_row; ++i) {
473 for (
size_t j=0;
j<ncol; ++
j) {
476 generate_multi_vector_coefficient<BaseScalar,size_t>(
477 nrow, ncol, pce_size, row,
j, k);
478 val1.fastAccessCoeff(k) = v;
479 val2.fastAccessCoeff(k) = 0.12345 * v;
481 x1_view[
j][i] = val1;
482 x2_view[
j][i] = val2;
489 Array<dot_type> dots(ncol);
490 x1->dot(*x2, dots());
495 Array<dot_type> local_vals(ncol, dot_type(0));
496 for (
size_t i=0; i<num_my_row; ++i) {
498 for (
size_t j=0;
j<ncol; ++
j) {
500 BaseScalar v = generate_multi_vector_coefficient<BaseScalar,size_t>(
501 nrow, ncol, pce_size, row,
j, k);
502 local_vals[
j] += 0.12345 * v * v;
508 Array<dot_type> vals(ncol, dot_type(0));
510 local_vals.getRawPtr(), vals.getRawPtr());
512 BaseScalar tol = 1.0e-14;
513 for (
size_t j=0;
j<ncol; ++
j) {
514 out <<
"dots(" <<
j <<
") = " << dots[
j]
515 <<
" expected(" <<
j <<
") = " << vals[
j] << std::endl;
537 typedef typename Scalar::cijk_type Cijk;
540 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
541 typedef Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_MultiVector;
542 typedef typename Tpetra_MultiVector::dot_type dot_type;
545 if ( !Kokkos::is_initialized() )
546 Kokkos::initialize();
554 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
558 RCP<const Tpetra_Map> map =
559 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
561 ArrayView<const GlobalOrdinal> myGIDs = map->getLocalElementList();
562 const size_t num_my_row = myGIDs.size();
566 RCP<Tpetra_MultiVector> x1 = Tpetra::createMultiVector<Scalar>(map, ncol);
567 RCP<Tpetra_MultiVector> x2 = Tpetra::createMultiVector<Scalar>(map, ncol);
568 ArrayRCP< ArrayRCP<Scalar> > x1_view = x1->get2dViewNonConst();
569 ArrayRCP< ArrayRCP<Scalar> > x2_view = x2->get2dViewNonConst();
570 Scalar val1(cijk), val2(cijk);
571 for (
size_t i=0; i<num_my_row; ++i) {
573 for (
size_t j=0;
j<ncol; ++
j) {
576 generate_multi_vector_coefficient<BaseScalar,size_t>(
577 nrow, ncol, pce_size, row,
j, k);
578 val1.fastAccessCoeff(k) = v;
579 val2.fastAccessCoeff(k) = 0.12345 * v;
581 x1_view[
j][i] = val1;
582 x2_view[
j][i] = val2;
591 cols[0] = 4; cols[1] = 2;
592 RCP<const Tpetra_MultiVector> x1_sub = x1->subView(cols());
593 RCP<const Tpetra_MultiVector> x2_sub = x2->subView(cols());
596 Array<dot_type> dots(ncol_sub);
597 x1_sub->dot(*x2_sub, dots());
602 Array<dot_type> local_vals(ncol_sub, dot_type(0));
603 for (
size_t i=0; i<num_my_row; ++i) {
605 for (
size_t j=0;
j<ncol_sub; ++
j) {
607 BaseScalar v = generate_multi_vector_coefficient<BaseScalar,size_t>(
608 nrow, ncol, pce_size, row, cols[
j], k);
609 local_vals[
j] += 0.12345 * v * v;
615 Array<dot_type> vals(ncol_sub, dot_type(0));
617 Teuchos::as<int>(ncol_sub), local_vals.getRawPtr(),
620 BaseScalar tol = 1.0e-14;
621 for (
size_t j=0;
j<ncol_sub; ++
j) {
622 out <<
"dots(" <<
j <<
") = " << dots[
j]
623 <<
" expected(" <<
j <<
") = " << vals[
j] << std::endl;
645 typedef typename Scalar::cijk_type Cijk;
648 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
649 typedef Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_Vector;
650 typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsMatrix;
651 typedef Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsGraph;
654 if ( !Kokkos::is_initialized() )
655 Kokkos::initialize();
664 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
665 RCP<const Tpetra_Map> map =
666 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
668 RCP<Tpetra_CrsGraph> graph =
669 rcp(
new Tpetra_CrsGraph(map,
size_t(2)));
670 Array<GlobalOrdinal> columnIndices(2);
671 ArrayView<const GlobalOrdinal> myGIDs = map->getLocalElementList();
672 const size_t num_my_row = myGIDs.size();
673 for (
size_t i=0; i<num_my_row; ++i) {
675 columnIndices[0] = row;
678 columnIndices[1] = row+1;
681 graph->insertGlobalIndices(row, columnIndices(0,ncol));
683 graph->fillComplete();
684 RCP<Tpetra_CrsMatrix> matrix =
rcp(
new Tpetra_CrsMatrix(graph));
687 Array<Scalar> vals(2);
689 for (
size_t local_row=0; local_row<num_my_row; ++local_row) {
691 const size_t num_col = row == nrow - 1 ? 1 : 2;
692 for (
size_t local_col=0; local_col<num_col; ++local_col) {
694 columnIndices[local_col] = col;
696 val.fastAccessCoeff(k) =
697 generate_matrix_coefficient<BaseScalar,size_t>(
698 nrow, pce_size, row, col, k);
699 vals[local_col] =
val;
701 matrix->replaceGlobalValues(row, columnIndices(0,num_col), vals(0,num_col));
703 matrix->fillComplete();
706 RCP<Tpetra_Vector> x = Tpetra::createVector<Scalar>(map);
707 ArrayRCP<Scalar> x_view = x->get1dViewNonConst();
708 for (
size_t local_row=0; local_row<num_my_row; ++local_row) {
711 val.fastAccessCoeff(
j) = generate_vector_coefficient<BaseScalar,size_t>(
712 nrow, pce_size, row,
j);
713 x_view[local_row] =
val;
724 RCP<Tpetra_Vector> y = Tpetra::createVector<Scalar>(map);
725 matrix->apply(*x, *y);
731 ArrayRCP<Scalar> y_view = y->get1dViewNonConst();
732 BaseScalar tol = 1.0e-14;
733 typename Cijk::HostMirror host_cijk =
736 for (
size_t local_row=0; local_row<num_my_row; ++local_row) {
738 const size_t num_col = row == nrow - 1 ? 1 : 2;
740 for (
size_t local_col=0; local_col<num_col; ++local_col) {
744 const LocalOrdinal entry_beg = host_cijk.entry_begin(i);
747 for (
LocalOrdinal entry = entry_beg; entry < entry_end; ++entry) {
750 const BaseScalar a_j =
751 generate_matrix_coefficient<BaseScalar,size_t>(
752 nrow, pce_size, row, col,
j);
753 const BaseScalar a_k =
754 generate_matrix_coefficient<BaseScalar,size_t>(
755 nrow, pce_size, row, col, k);
756 const BaseScalar x_j =
757 generate_vector_coefficient<BaseScalar,size_t>(
758 nrow, pce_size, col,
j);
759 const BaseScalar x_k =
760 generate_vector_coefficient<BaseScalar,size_t>(
761 nrow, pce_size, col, k);
762 tmp += host_cijk.value(entry) * ( a_j * x_k + a_k * x_j );
764 val.fastAccessCoeff(i) += tmp;
770 val.fastAccessCoeff(i), tol );
791 typedef typename Scalar::cijk_type Cijk;
794 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
795 typedef Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_MultiVector;
796 typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsMatrix;
797 typedef Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsGraph;
800 if ( !Kokkos::is_initialized() )
801 Kokkos::initialize();
810 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
811 RCP<const Tpetra_Map> map =
812 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
814 RCP<Tpetra_CrsGraph> graph =
815 rcp(
new Tpetra_CrsGraph(map,
size_t(2)));
816 Array<GlobalOrdinal> columnIndices(2);
817 ArrayView<const GlobalOrdinal> myGIDs = map->getLocalElementList();
818 const size_t num_my_row = myGIDs.size();
819 for (
size_t i=0; i<num_my_row; ++i) {
821 columnIndices[0] = row;
824 columnIndices[1] = row+1;
827 graph->insertGlobalIndices(row, columnIndices(0,ncol));
829 graph->fillComplete();
830 RCP<Tpetra_CrsMatrix> matrix =
rcp(
new Tpetra_CrsMatrix(graph));
833 Array<Scalar> vals(2);
835 for (
size_t local_row=0; local_row<num_my_row; ++local_row) {
837 const size_t num_col = row == nrow - 1 ? 1 : 2;
838 for (
size_t local_col=0; local_col<num_col; ++local_col) {
840 columnIndices[local_col] = col;
842 val.fastAccessCoeff(k) =
843 generate_matrix_coefficient<BaseScalar,size_t>(
844 nrow, pce_size, row, col, k);
845 vals[local_col] =
val;
847 matrix->replaceGlobalValues(row, columnIndices(0,num_col), vals(0,num_col));
849 matrix->fillComplete();
853 RCP<Tpetra_MultiVector> x = Tpetra::createMultiVector<Scalar>(map, ncol);
854 ArrayRCP< ArrayRCP<Scalar> > x_view = x->get2dViewNonConst();
855 for (
size_t local_row=0; local_row<num_my_row; ++local_row) {
857 for (
size_t col=0; col<ncol; ++col) {
860 generate_multi_vector_coefficient<BaseScalar,size_t>(
861 nrow, ncol, pce_size, row, col, k);
862 val.fastAccessCoeff(k) = v;
864 x_view[col][local_row] =
val;
876 RCP<Tpetra_MultiVector> y = Tpetra::createMultiVector<Scalar>(map, ncol);
877 matrix->apply(*x, *y);
883 ArrayRCP< ArrayRCP<Scalar> > y_view = y->get2dViewNonConst();
884 BaseScalar tol = 1.0e-14;
885 typename Cijk::HostMirror host_cijk =
888 for (
size_t local_row=0; local_row<num_my_row; ++local_row) {
890 for (
size_t xcol=0; xcol<ncol; ++xcol) {
891 const size_t num_col = row == nrow - 1 ? 1 : 2;
893 for (
size_t local_col=0; local_col<num_col; ++local_col) {
897 const LocalOrdinal entry_beg = host_cijk.entry_begin(i);
900 for (
LocalOrdinal entry = entry_beg; entry < entry_end; ++entry) {
903 const BaseScalar a_j =
904 generate_matrix_coefficient<BaseScalar,size_t>(
905 nrow, pce_size, row, col,
j);
906 const BaseScalar a_k =
907 generate_matrix_coefficient<BaseScalar,size_t>(
908 nrow, pce_size, row, col, k);
909 const BaseScalar x_j =
910 generate_multi_vector_coefficient<BaseScalar,size_t>(
911 nrow, ncol, pce_size, col, xcol,
j);
912 const BaseScalar x_k =
913 generate_multi_vector_coefficient<BaseScalar,size_t>(
914 nrow, ncol, pce_size, col, xcol, k);
915 tmp += host_cijk.value(entry) * ( a_j * x_k + a_k * x_j );
917 val.fastAccessCoeff(i) += tmp;
923 val.fastAccessCoeff(i), tol );
945 typedef typename Scalar::cijk_type Cijk;
948 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
949 typedef Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_Vector;
950 typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsMatrix;
951 typedef Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsGraph;
953 typedef Tpetra::Vector<BaseScalar,LocalOrdinal,GlobalOrdinal,Node> Flat_Tpetra_Vector;
954 typedef Tpetra::CrsMatrix<BaseScalar,LocalOrdinal,GlobalOrdinal,Node> Flat_Tpetra_CrsMatrix;
957 if ( !Kokkos::is_initialized() )
958 Kokkos::initialize();
967 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
968 RCP<const Tpetra_Map> map =
969 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
971 RCP<Tpetra_CrsGraph> graph =
972 rcp(
new Tpetra_CrsGraph(map,
size_t(2)));
973 Array<GlobalOrdinal> columnIndices(2);
974 ArrayView<const GlobalOrdinal> myGIDs = map->getLocalElementList();
975 const size_t num_my_row = myGIDs.size();
976 for (
size_t i=0; i<num_my_row; ++i) {
978 columnIndices[0] = row;
981 columnIndices[1] = row+1;
984 graph->insertGlobalIndices(row, columnIndices(0,ncol));
986 graph->fillComplete();
987 RCP<Tpetra_CrsMatrix> matrix =
rcp(
new Tpetra_CrsMatrix(graph));
990 Array<Scalar> vals(2);
992 for (
size_t local_row=0; local_row<num_my_row; ++local_row) {
994 const size_t num_col = row == nrow - 1 ? 1 : 2;
995 for (
size_t local_col=0; local_col<num_col; ++local_col) {
997 columnIndices[local_col] = col;
999 val.fastAccessCoeff(k) =
1000 generate_matrix_coefficient<BaseScalar,size_t>(
1001 nrow, pce_size, row, col, k);
1002 vals[local_col] =
val;
1004 matrix->replaceGlobalValues(row, columnIndices(0,num_col), vals(0,num_col));
1006 matrix->fillComplete();
1009 RCP<Tpetra_Vector> x = Tpetra::createVector<Scalar>(map);
1011 ArrayRCP<Scalar> x_view = x->get1dViewNonConst();
1012 for (
size_t i=0; i<num_my_row; ++i) {
1015 val.fastAccessCoeff(
j) = generate_vector_coefficient<BaseScalar,size_t>(
1016 nrow, pce_size, row,
j);
1022 RCP<Tpetra_Vector> y = Tpetra::createVector<Scalar>(map);
1023 matrix->apply(*x, *y);
1040 RCP<const Tpetra_Map> flat_x_map, flat_y_map;
1041 RCP<const Tpetra_CrsGraph> flat_graph, cijk_graph;
1044 cijk_graph, pce_size);
1045 RCP<Flat_Tpetra_CrsMatrix> flat_matrix =
1049 RCP<Tpetra_Vector> y2 = Tpetra::createVector<Scalar>(map);
1051 RCP<Flat_Tpetra_Vector> flat_x =
1053 RCP<Flat_Tpetra_Vector> flat_y =
1055 flat_matrix->apply(*flat_x, *flat_y);
1076 BaseScalar tol = 1.0e-14;
1077 ArrayRCP<Scalar> y_view = y->get1dViewNonConst();
1078 ArrayRCP<Scalar> y2_view = y2->get1dViewNonConst();
1079 for (
size_t i=0; i<num_my_row; ++i) {
1106 typedef typename Scalar::cijk_type Cijk;
1109 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
1110 typedef Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_Vector;
1111 typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsMatrix;
1112 typedef Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsGraph;
1115 if ( !Kokkos::is_initialized() )
1116 Kokkos::initialize();
1125 BaseScalar h = 1.0 /
static_cast<BaseScalar
>(nrow-1);
1126 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
1127 RCP<const Tpetra_Map> map =
1128 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
1130 RCP<Tpetra_CrsGraph> graph =
1131 rcp(
new Tpetra_CrsGraph(map,
size_t(3)));
1132 Array<GlobalOrdinal> columnIndices(3);
1133 ArrayView<const GlobalOrdinal> myGIDs = map->getLocalElementList();
1134 const size_t num_my_row = myGIDs.size();
1135 for (
size_t i=0; i<num_my_row; ++i) {
1137 if (row == 0 || row == nrow-1) {
1138 columnIndices[0] = row;
1139 graph->insertGlobalIndices(row, columnIndices(0,1));
1142 columnIndices[0] = row-1;
1143 columnIndices[1] = row;
1144 columnIndices[2] = row+1;
1145 graph->insertGlobalIndices(row, columnIndices(0,3));
1148 graph->fillComplete();
1149 RCP<Tpetra_CrsMatrix> matrix =
rcp(
new Tpetra_CrsMatrix(graph));
1152 Array<Scalar> vals(3);
1155 a_val.fastAccessCoeff(
j) =
1156 BaseScalar(1.0) + BaseScalar(1.0) / BaseScalar(
j+1);
1158 for (
size_t i=0; i<num_my_row; ++i) {
1160 if (row == 0 || row == nrow-1) {
1161 columnIndices[0] = row;
1163 matrix->replaceGlobalValues(row, columnIndices(0,1), vals(0,1));
1166 columnIndices[0] = row-1;
1167 columnIndices[1] = row;
1168 columnIndices[2] = row+1;
1169 vals[0] =
Scalar(1.0) * a_val;
1170 vals[1] =
Scalar(-2.0) * a_val;
1171 vals[2] =
Scalar(1.0) * a_val;
1172 matrix->replaceGlobalValues(row, columnIndices(0,3), vals(0,3));
1175 matrix->fillComplete();
1181 RCP<Tpetra_Vector> b = Tpetra::createVector<Scalar>(map);
1183 ArrayRCP<Scalar> b_view = b->get1dViewNonConst();
1186 b_val.fastAccessCoeff(
j) =
1187 BaseScalar(2.0) - BaseScalar(1.0) / BaseScalar(
j+1);
1189 for (
size_t i=0; i<num_my_row; ++i) {
1191 if (row == 0 || row == nrow-1)
1194 b_view[i] = b_val * (h*h);
1202 RCP<Tpetra_Vector> x = Tpetra::createVector<Scalar>(map);
1203 typedef Kokkos::ArithTraits<BaseScalar> BST;
1204 typedef typename BST::mag_type base_mag_type;
1205 typedef typename Tpetra_Vector::mag_type mag_type;
1206 base_mag_type btol = 1e-9;
1207 mag_type tol = btol;
1210 out.getOStream().get());
1217 typedef Tpetra::Vector<BaseScalar,LocalOrdinal,GlobalOrdinal,Node> Flat_Tpetra_Vector;
1218 typedef Tpetra::CrsMatrix<BaseScalar,LocalOrdinal,GlobalOrdinal,Node> Flat_Tpetra_CrsMatrix;
1219 RCP<const Tpetra_Map> flat_x_map, flat_b_map;
1220 RCP<const Tpetra_CrsGraph> flat_graph, cijk_graph;
1223 cijk_graph, pce_size);
1224 RCP<Flat_Tpetra_CrsMatrix> flat_matrix =
1226 RCP<Tpetra_Vector> x2 = Tpetra::createVector<Scalar>(map);
1228 RCP<Flat_Tpetra_Vector> flat_x =
1230 RCP<Flat_Tpetra_Vector> flat_b =
1233 tol, max_its, out.getOStream().get());
1234 TEST_EQUALITY_CONST( solved_flat,
true );
1238 ArrayRCP<Scalar> x_view = x->get1dViewNonConst();
1239 ArrayRCP<Scalar> x2_view = x2->get1dViewNonConst();
1240 for (
size_t i=0; i<num_my_row; ++i) {
1245 Scalar v = x_view[i];
1246 Scalar v2 = x2_view[i];
1248 if (
j < v.size() &&
BST::abs(v.coeff(
j)) < btol)
1249 v.fastAccessCoeff(
j) = BaseScalar(0.0);
1250 if (
j < v2.size() &&
BST::abs(v2.coeff(
j)) < btol)
1251 v2.fastAccessCoeff(
j) = BaseScalar(0.0);
1263 #if defined(HAVE_STOKHOS_MUELU) && defined(HAVE_STOKHOS_AMESOS2) && defined(HAVE_STOKHOS_IFPACK2) && defined(HAVE_TPETRA_EXPLICIT_INSTANTIATION)
1280 using Teuchos::getParametersFromXmlFile;
1284 typedef typename Scalar::cijk_type Cijk;
1287 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
1288 typedef Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_Vector;
1289 typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsMatrix;
1290 typedef Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsGraph;
1293 if ( !Kokkos::is_initialized() )
1294 Kokkos::initialize();
1303 BaseScalar h = 1.0 /
static_cast<BaseScalar
>(nrow-1);
1304 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
1305 RCP<const Tpetra_Map> map =
1306 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
1308 RCP<Tpetra_CrsGraph> graph =
1309 rcp(
new Tpetra_CrsGraph(map,
size_t(3)));
1310 Array<GlobalOrdinal> columnIndices(3);
1311 ArrayView<const GlobalOrdinal> myGIDs = map->getLocalElementList();
1312 const size_t num_my_row = myGIDs.size();
1313 for (
size_t i=0; i<num_my_row; ++i) {
1315 if (row == 0 || row == nrow-1) {
1316 columnIndices[0] = row;
1317 graph->insertGlobalIndices(row, columnIndices(0,1));
1320 columnIndices[0] = row-1;
1321 columnIndices[1] = row;
1322 columnIndices[2] = row+1;
1323 graph->insertGlobalIndices(row, columnIndices(0,3));
1326 graph->fillComplete();
1327 RCP<Tpetra_CrsMatrix> matrix =
rcp(
new Tpetra_CrsMatrix(graph));
1330 Array<Scalar> vals(3);
1333 a_val.fastAccessCoeff(
j) =
1334 BaseScalar(1.0) + BaseScalar(1.0) / BaseScalar(
j+1);
1336 for (
size_t i=0; i<num_my_row; ++i) {
1338 if (row == 0 || row == nrow-1) {
1339 columnIndices[0] = row;
1341 matrix->replaceGlobalValues(row, columnIndices(0,1), vals(0,1));
1344 columnIndices[0] = row-1;
1345 columnIndices[1] = row;
1346 columnIndices[2] = row+1;
1347 vals[0] =
Scalar(1.0) * a_val;
1348 vals[1] =
Scalar(-2.0) * a_val;
1349 vals[2] =
Scalar(1.0) * a_val;
1350 matrix->replaceGlobalValues(row, columnIndices(0,3), vals(0,3));
1353 matrix->fillComplete();
1356 RCP<Tpetra_Vector> b = Tpetra::createVector<Scalar>(map);
1358 ArrayRCP<Scalar> b_view = b->get1dViewNonConst();
1361 b_val.fastAccessCoeff(
j) =
1362 BaseScalar(2.0) - BaseScalar(1.0) / BaseScalar(
j+1);
1364 for (
size_t i=0; i<num_my_row; ++i) {
1366 if (row == 0 || row == nrow-1)
1369 b_view[i] = b_val * (h*h);
1373 RCP<Tpetra_Vector> x = Tpetra::createVector<Scalar>(map);
1374 typedef Kokkos::ArithTraits<BaseScalar> BST;
1375 typedef typename BST::mag_type base_mag_type;
1376 typedef typename Tpetra_Vector::mag_type mag_type;
1377 base_mag_type btol = 1e-9;
1378 mag_type tol = btol;
1382 typedef Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> OP;
1383 RCP<ParameterList> muelu_params =
1384 getParametersFromXmlFile(
"muelu_cheby.xml");
1385 #if USE_SCALAR_MEAN_BASED_PREC
1386 typedef Tpetra::Operator<BaseScalar,LocalOrdinal,GlobalOrdinal,Node> Scalar_OP;
1387 typedef Tpetra::CrsMatrix<BaseScalar,LocalOrdinal,GlobalOrdinal,Node> Scalar_Tpetra_CrsMatrix;
1388 RCP<Scalar_Tpetra_CrsMatrix> mean_matrix =
1390 RCP<Scalar_OP> mean_matrix_op = mean_matrix;
1391 RCP<Scalar_OP> M_s =
1392 MueLu::CreateTpetraPreconditioner<BaseScalar,LocalOrdinal,GlobalOrdinal,Node>(mean_matrix_op, *muelu_params);
1396 Stokhos::create_mean_based_product_tensor<typename Storage::execution_space,typename Storage::ordinal_type,BaseScalar>();
1399 RCP<OP> mean_matrix_op = mean_matrix;
1401 MueLu::CreateTpetraPreconditioner<Scalar,LocalOrdinal,GlobalOrdinal,Node>(mean_matrix_op, *muelu_params);
1407 out.getOStream().get());
1415 RCP<Tpetra_Vector> x2 = Tpetra::createVector<Scalar>(map);
1417 typedef Tpetra::Vector<BaseScalar,LocalOrdinal,GlobalOrdinal,Node> Flat_Tpetra_Vector;
1418 typedef Tpetra::CrsMatrix<BaseScalar,LocalOrdinal,GlobalOrdinal,Node> Flat_Tpetra_CrsMatrix;
1419 RCP<const Tpetra_Map> flat_x_map, flat_b_map;
1420 RCP<const Tpetra_CrsGraph> flat_graph, cijk_graph;
1423 cijk_graph, pce_size);
1424 RCP<Flat_Tpetra_CrsMatrix> flat_matrix =
1426 RCP<Flat_Tpetra_Vector> flat_x =
1428 RCP<Flat_Tpetra_Vector> flat_b =
1436 tol, max_its, out.getOStream().get());
1441 ArrayRCP<Scalar> x_view = x->get1dViewNonConst();
1442 ArrayRCP<Scalar> x2_view = x2->get1dViewNonConst();
1443 for (
size_t i=0; i<num_my_row; ++i) {
1448 Scalar v = x_view[i];
1449 Scalar v2 = x2_view[i];
1451 if (
j < v.size() &&
BST::abs(v.coeff(
j)) < btol)
1452 v.fastAccessCoeff(
j) = BaseScalar(0.0);
1453 if (
j < v2.size() &&
BST::abs(v2.coeff(
j)) < btol)
1454 v2.fastAccessCoeff(
j) = BaseScalar(0.0);
1473 #if defined(HAVE_STOKHOS_BELOS)
1490 typedef typename Scalar::cijk_type Cijk;
1493 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
1494 typedef Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_Vector;
1495 typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsMatrix;
1496 typedef Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsGraph;
1499 if ( !Kokkos::is_initialized() )
1500 Kokkos::initialize();
1509 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
1510 RCP<const Tpetra_Map> map =
1511 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
1513 RCP<Tpetra_CrsGraph> graph =
1514 rcp(
new Tpetra_CrsGraph(map,
size_t(2)));
1515 Array<GlobalOrdinal> columnIndices(2);
1516 ArrayView<const GlobalOrdinal> myGIDs = map->getLocalElementList();
1517 const size_t num_my_row = myGIDs.size();
1518 for (
size_t i=0; i<num_my_row; ++i) {
1520 columnIndices[0] = row;
1522 if (row != nrow-1) {
1523 columnIndices[1] = row+1;
1526 graph->insertGlobalIndices(row, columnIndices(0,ncol));
1528 graph->fillComplete();
1529 RCP<Tpetra_CrsMatrix> matrix =
rcp(
new Tpetra_CrsMatrix(graph));
1532 Array<Scalar> vals(2);
1534 for (
size_t local_row=0; local_row<num_my_row; ++local_row) {
1536 const size_t num_col = row == nrow - 1 ? 1 : 2;
1537 for (
size_t local_col=0; local_col<num_col; ++local_col) {
1539 columnIndices[local_col] = col;
1541 val.fastAccessCoeff(k) =
1542 BaseScalar(1.0) + BaseScalar(1.0) / BaseScalar(k+1);
1543 vals[local_col] =
val;
1545 matrix->replaceGlobalValues(row, columnIndices(0,num_col), vals(0,num_col));
1547 matrix->fillComplete();
1550 RCP<Tpetra_Vector> b = Tpetra::createVector<Scalar>(map);
1552 ArrayRCP<Scalar> b_view = b->get1dViewNonConst();
1553 for (
size_t i=0; i<num_my_row; ++i) {
1560 typedef BaseScalar BelosScalar;
1561 typedef Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> MV;
1562 typedef Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> OP;
1563 typedef Belos::LinearProblem<BelosScalar,MV,OP> BLinProb;
1564 RCP<Tpetra_Vector> x = Tpetra::createVector<Scalar>(map);
1565 RCP< BLinProb > problem =
rcp(
new BLinProb(matrix, x, b));
1566 RCP<ParameterList> belosParams =
rcp(
new ParameterList);
1567 typename ST::magnitudeType tol = 1e-9;
1568 belosParams->set(
"Flexible Gmres",
false);
1569 belosParams->set(
"Num Blocks", 100);
1570 belosParams->set(
"Convergence Tolerance", BelosScalar(tol));
1571 belosParams->set(
"Maximum Iterations", 100);
1572 belosParams->set(
"Verbosity", 33);
1573 belosParams->set(
"Output Style", 1);
1574 belosParams->set(
"Output Frequency", 1);
1575 belosParams->set(
"Output Stream", out.getOStream());
1576 RCP<Belos::SolverManager<BelosScalar,MV,OP> > solver =
1577 rcp(
new Belos::PseudoBlockGmresSolMgr<BelosScalar,MV,OP>(problem, belosParams));
1578 problem->setProblem();
1579 Belos::ReturnType ret = solver->solve();
1586 typedef Tpetra::Vector<BaseScalar,LocalOrdinal,GlobalOrdinal,Node> Flat_Tpetra_Vector;
1587 typedef Tpetra::CrsMatrix<BaseScalar,LocalOrdinal,GlobalOrdinal,Node> Flat_Tpetra_CrsMatrix;
1588 RCP<const Tpetra_Map> flat_x_map, flat_b_map;
1589 RCP<const Tpetra_CrsGraph> flat_graph, cijk_graph;
1592 cijk_graph, pce_size);
1593 RCP<Flat_Tpetra_CrsMatrix> flat_matrix =
1595 RCP<Tpetra_Vector> x2 = Tpetra::createVector<Scalar>(map);
1597 RCP<Flat_Tpetra_Vector> flat_x =
1599 RCP<Flat_Tpetra_Vector> flat_b =
1601 typedef Tpetra::MultiVector<BaseScalar,LocalOrdinal,GlobalOrdinal,Node> FMV;
1602 typedef Tpetra::Operator<BaseScalar,LocalOrdinal,GlobalOrdinal,Node> FOP;
1603 typedef Belos::LinearProblem<BelosScalar,FMV,FOP> FBLinProb;
1604 RCP< FBLinProb > flat_problem =
1605 rcp(
new FBLinProb(flat_matrix, flat_x, flat_b));
1606 RCP<Belos::SolverManager<BelosScalar,FMV,FOP> > flat_solver =
1607 rcp(
new Belos::PseudoBlockGmresSolMgr<BelosScalar,FMV,FOP>(flat_problem,
1609 flat_problem->setProblem();
1610 Belos::ReturnType flat_ret = flat_solver->solve();
1614 typename ST::magnitudeType btol = 100*tol;
1615 ArrayRCP<Scalar> x_view = x->get1dViewNonConst();
1616 ArrayRCP<Scalar> x2_view = x2->get1dViewNonConst();
1617 for (
size_t i=0; i<num_my_row; ++i) {
1622 Scalar v = x_view[i];
1623 Scalar v2 = x2_view[i];
1625 if (
j < v.size() && ST::magnitude(v.coeff(
j)) < btol)
1626 v.fastAccessCoeff(
j) = BaseScalar(0.0);
1627 if (
j < v2.size() && ST::magnitude(v2.coeff(
j)) < btol)
1628 v2.fastAccessCoeff(
j) = BaseScalar(0.0);
1649 #if defined(HAVE_STOKHOS_BELOS) && defined(HAVE_STOKHOS_IFPACK2)
1667 typedef typename Scalar::cijk_type Cijk;
1670 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
1671 typedef Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_Vector;
1672 typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsMatrix;
1673 typedef Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsGraph;
1676 if ( !Kokkos::is_initialized() )
1677 Kokkos::initialize();
1686 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
1687 RCP<const Tpetra_Map> map =
1688 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
1690 RCP<Tpetra_CrsGraph> graph =
1691 rcp(
new Tpetra_CrsGraph(map,
size_t(2)));
1692 Array<GlobalOrdinal> columnIndices(2);
1693 ArrayView<const GlobalOrdinal> myGIDs = map->getLocalElementList();
1694 const size_t num_my_row = myGIDs.size();
1695 for (
size_t i=0; i<num_my_row; ++i) {
1697 columnIndices[0] = row;
1699 if (row != nrow-1) {
1700 columnIndices[1] = row+1;
1703 graph->insertGlobalIndices(row, columnIndices(0,ncol));
1705 graph->fillComplete();
1706 RCP<Tpetra_CrsMatrix> matrix =
rcp(
new Tpetra_CrsMatrix(graph));
1709 Array<Scalar> vals(2);
1711 for (
size_t local_row=0; local_row<num_my_row; ++local_row) {
1713 const size_t num_col = row == nrow - 1 ? 1 : 2;
1714 for (
size_t local_col=0; local_col<num_col; ++local_col) {
1716 columnIndices[local_col] = col;
1718 val.fastAccessCoeff(k) =
1719 BaseScalar(1.0) + BaseScalar(1.0) / BaseScalar(k+1);
1720 vals[local_col] =
val;
1722 matrix->replaceGlobalValues(row, columnIndices(0,num_col), vals(0,num_col));
1724 matrix->fillComplete();
1727 RCP<Tpetra_Vector> b = Tpetra::createVector<Scalar>(map);
1729 ArrayRCP<Scalar> b_view = b->get1dViewNonConst();
1730 for (
size_t i=0; i<num_my_row; ++i) {
1735 RCP<Tpetra_Vector> x = Tpetra::createVector<Scalar>(map);
1736 RCP<ParameterList> belosParams =
rcp(
new ParameterList);
1737 typedef BaseScalar BelosScalar;
1739 typename ST::magnitudeType tol = 1e-9;
1741 typedef Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> MV;
1742 typedef Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> OP;
1743 typedef Belos::LinearProblem<BelosScalar,MV,OP> BLinProb;
1745 #if USE_SCALAR_MEAN_BASED_PREC
1746 typedef Tpetra::CrsMatrix<BaseScalar,LocalOrdinal,GlobalOrdinal,Node> Scalar_Tpetra_CrsMatrix;
1747 RCP<Scalar_Tpetra_CrsMatrix> mean_matrix =
1749 typedef Ifpack2::Preconditioner<BaseScalar,LocalOrdinal,GlobalOrdinal,Node> Scalar_Prec;
1750 Ifpack2::Factory factory;
1751 RCP<Scalar_Prec> M_s = factory.create<Scalar_Tpetra_CrsMatrix>(
"RILUK", mean_matrix);
1757 typedef Ifpack2::Preconditioner<Scalar,LocalOrdinal,GlobalOrdinal,Node> Prec;
1758 Ifpack2::Factory factory;
1759 RCP<Prec> M = factory.create<Tpetra_CrsMatrix>(
"RILUK", mean_matrix);
1765 RCP< BLinProb > problem =
rcp(
new BLinProb(matrix, x, b));
1766 problem->setRightPrec(M);
1767 problem->setProblem();
1768 belosParams->set(
"Flexible Gmres",
false);
1769 belosParams->set(
"Num Blocks", 100);
1770 belosParams->set(
"Convergence Tolerance", BelosScalar(tol));
1771 belosParams->set(
"Maximum Iterations", 100);
1772 belosParams->set(
"Verbosity", 33);
1773 belosParams->set(
"Output Style", 1);
1774 belosParams->set(
"Output Frequency", 1);
1775 belosParams->set(
"Output Stream", out.getOStream());
1777 RCP<Belos::SolverManager<BelosScalar,MV,OP> > solver =
1778 rcp(
new Belos::PseudoBlockGmresSolMgr<BelosScalar,MV,OP>(problem, belosParams));
1779 Belos::ReturnType ret = solver->solve();
1784 RCP<Tpetra_Vector> x2 = Tpetra::createVector<Scalar>(map);
1786 typedef Tpetra::Vector<BaseScalar,LocalOrdinal,GlobalOrdinal,Node> Flat_Tpetra_Vector;
1787 typedef Tpetra::CrsMatrix<BaseScalar,LocalOrdinal,GlobalOrdinal,Node> Flat_Tpetra_CrsMatrix;
1788 RCP<const Tpetra_Map> flat_x_map, flat_b_map;
1789 RCP<const Tpetra_CrsGraph> flat_graph, cijk_graph;
1792 cijk_graph, pce_size);
1793 RCP<Flat_Tpetra_CrsMatrix> flat_matrix =
1795 RCP<Flat_Tpetra_Vector> flat_x =
1797 RCP<Flat_Tpetra_Vector> flat_b =
1799 typedef Tpetra::MultiVector<BaseScalar,LocalOrdinal,GlobalOrdinal,Node> FMV;
1800 typedef Tpetra::Operator<BaseScalar,LocalOrdinal,GlobalOrdinal,Node> FOP;
1801 typedef Belos::LinearProblem<BelosScalar,FMV,FOP> FBLinProb;
1802 RCP< FBLinProb > flat_problem =
1803 rcp(
new FBLinProb(flat_matrix, flat_x, flat_b));
1804 RCP<Belos::SolverManager<BelosScalar,FMV,FOP> > flat_solver =
1805 rcp(
new Belos::PseudoBlockGmresSolMgr<BelosScalar,FMV,FOP>(flat_problem,
1807 flat_problem->setProblem();
1808 Belos::ReturnType flat_ret = flat_solver->solve();
1812 typename ST::magnitudeType btol = 100*tol;
1813 ArrayRCP<Scalar> x_view = x->get1dViewNonConst();
1814 ArrayRCP<Scalar> x2_view = x2->get1dViewNonConst();
1815 for (
size_t i=0; i<num_my_row; ++i) {
1820 Scalar v = x_view[i];
1821 Scalar v2 = x2_view[i];
1823 if (
j < v.size() && ST::magnitude(v.coeff(
j)) < btol)
1824 v.fastAccessCoeff(
j) = BaseScalar(0.0);
1825 if (
j < v2.size() && ST::magnitude(v2.coeff(
j)) < btol)
1826 v2.fastAccessCoeff(
j) = BaseScalar(0.0);
1845 #if defined(HAVE_STOKHOS_BELOS) && defined(HAVE_STOKHOS_IFPACK2) && defined(HAVE_STOKHOS_MUELU) && defined(HAVE_STOKHOS_AMESOS2) && defined(HAVE_TPETRA_EXPLICIT_INSTANTIATION)
1862 using Teuchos::getParametersFromXmlFile;
1866 typedef typename Scalar::cijk_type Cijk;
1869 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
1870 typedef Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_Vector;
1871 typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsMatrix;
1872 typedef Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsGraph;
1875 if ( !Kokkos::is_initialized() )
1876 Kokkos::initialize();
1885 BaseScalar h = 1.0 /
static_cast<BaseScalar
>(nrow-1);
1886 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
1887 RCP<const Tpetra_Map> map =
1888 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
1890 RCP<Tpetra_CrsGraph> graph =
1891 rcp(
new Tpetra_CrsGraph(map,
size_t(3)));
1892 Array<GlobalOrdinal> columnIndices(3);
1893 ArrayView<const GlobalOrdinal> myGIDs = map->getLocalElementList();
1894 const size_t num_my_row = myGIDs.size();
1895 for (
size_t i=0; i<num_my_row; ++i) {
1897 if (row == 0 || row == nrow-1) {
1898 columnIndices[0] = row;
1899 graph->insertGlobalIndices(row, columnIndices(0,1));
1902 columnIndices[0] = row-1;
1903 columnIndices[1] = row;
1904 columnIndices[2] = row+1;
1905 graph->insertGlobalIndices(row, columnIndices(0,3));
1908 graph->fillComplete();
1909 RCP<Tpetra_CrsMatrix> matrix =
rcp(
new Tpetra_CrsMatrix(graph));
1912 Array<Scalar> vals(3);
1915 a_val.fastAccessCoeff(
j) =
1916 BaseScalar(1.0) + BaseScalar(1.0) / BaseScalar(
j+1);
1918 for (
size_t i=0; i<num_my_row; ++i) {
1920 if (row == 0 || row == nrow-1) {
1921 columnIndices[0] = row;
1923 matrix->replaceGlobalValues(row, columnIndices(0,1), vals(0,1));
1926 columnIndices[0] = row-1;
1927 columnIndices[1] = row;
1928 columnIndices[2] = row+1;
1929 vals[0] =
Scalar(1.0) * a_val;
1930 vals[1] =
Scalar(-2.0) * a_val;
1931 vals[2] =
Scalar(1.0) * a_val;
1932 matrix->replaceGlobalValues(row, columnIndices(0,3), vals(0,3));
1935 matrix->fillComplete();
1938 RCP<Tpetra_Vector> b = Tpetra::createVector<Scalar>(map);
1940 ArrayRCP<Scalar> b_view = b->get1dViewNonConst();
1943 b_val.fastAccessCoeff(
j) =
1944 BaseScalar(2.0) - BaseScalar(1.0) / BaseScalar(
j+1);
1946 for (
size_t i=0; i<num_my_row; ++i) {
1948 if (row == 0 || row == nrow-1)
1951 b_view[i] = b_val * (h*h);
1956 typedef Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> OP;
1957 RCP<ParameterList> muelu_params =
1958 getParametersFromXmlFile(
"muelu_cheby.xml");
1959 #if USE_SCALAR_MEAN_BASED_PREC
1960 typedef Tpetra::Operator<BaseScalar,LocalOrdinal,GlobalOrdinal,Node> Scalar_OP;
1961 typedef Tpetra::CrsMatrix<BaseScalar,LocalOrdinal,GlobalOrdinal,Node> Scalar_Tpetra_CrsMatrix;
1962 RCP<Scalar_Tpetra_CrsMatrix> mean_matrix =
1964 RCP<Scalar_OP> mean_matrix_op = mean_matrix;
1965 RCP<Scalar_OP> M_s =
1966 MueLu::CreateTpetraPreconditioner<BaseScalar,LocalOrdinal,GlobalOrdinal,Node>(mean_matrix_op, *muelu_params);
1970 Stokhos::create_mean_based_product_tensor<typename Storage::execution_space,typename Storage::ordinal_type,BaseScalar>();
1973 RCP<OP> mean_matrix_op = mean_matrix;
1975 MueLu::CreateTpetraPreconditioner<Scalar,LocalOrdinal,GlobalOrdinal,Node>(mean_matrix_op, *muelu_params);
1981 typedef BaseScalar BelosScalar;
1982 typedef Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> MV;
1983 typedef Belos::LinearProblem<BelosScalar,MV,OP> BLinProb;
1984 RCP<Tpetra_Vector> x = Tpetra::createVector<Scalar>(map);
1985 RCP< BLinProb > problem =
rcp(
new BLinProb(matrix, x, b));
1986 problem->setRightPrec(M);
1987 problem->setProblem();
1988 RCP<ParameterList> belosParams =
rcp(
new ParameterList);
1989 typename ST::magnitudeType tol = 1e-9;
1990 belosParams->set(
"Num Blocks", 100);
1991 belosParams->set(
"Convergence Tolerance", BelosScalar(tol));
1992 belosParams->set(
"Maximum Iterations", 100);
1993 belosParams->set(
"Verbosity", 33);
1994 belosParams->set(
"Output Style", 1);
1995 belosParams->set(
"Output Frequency", 1);
1996 belosParams->set(
"Output Stream", out.getOStream());
1998 RCP<Belos::SolverManager<BelosScalar,MV,OP> > solver =
1999 rcp(
new Belos::PseudoBlockGmresSolMgr<BelosScalar,MV,OP>(problem, belosParams));
2002 Belos::ReturnType ret = solver->solve();
2009 typedef Tpetra::Vector<BaseScalar,LocalOrdinal,GlobalOrdinal,Node> Flat_Tpetra_Vector;
2010 typedef Tpetra::CrsMatrix<BaseScalar,LocalOrdinal,GlobalOrdinal,Node> Flat_Tpetra_CrsMatrix;
2011 RCP<const Tpetra_Map> flat_x_map, flat_b_map;
2012 RCP<const Tpetra_CrsGraph> flat_graph, cijk_graph;
2015 cijk_graph, pce_size);
2016 RCP<Flat_Tpetra_CrsMatrix> flat_matrix =
2018 RCP<Tpetra_Vector> x2 = Tpetra::createVector<Scalar>(map);
2020 RCP<Flat_Tpetra_Vector> flat_x =
2022 RCP<Flat_Tpetra_Vector> flat_b =
2024 typedef Tpetra::MultiVector<BaseScalar,LocalOrdinal,GlobalOrdinal,Node> FMV;
2025 typedef Tpetra::Operator<BaseScalar,LocalOrdinal,GlobalOrdinal,Node> FOP;
2026 typedef Belos::LinearProblem<BelosScalar,FMV,FOP> FBLinProb;
2027 RCP< FBLinProb > flat_problem =
2028 rcp(
new FBLinProb(flat_matrix, flat_x, flat_b));
2029 RCP<Belos::SolverManager<BelosScalar,FMV,FOP> > flat_solver =
2030 rcp(
new Belos::PseudoBlockGmresSolMgr<BelosScalar,FMV,FOP>(flat_problem,
2035 flat_problem->setProblem();
2036 Belos::ReturnType flat_ret = flat_solver->solve();
2040 typename ST::magnitudeType btol = 100*tol;
2041 ArrayRCP<Scalar> x_view = x->get1dViewNonConst();
2042 ArrayRCP<Scalar> x2_view = x2->get1dViewNonConst();
2043 for (
size_t i=0; i<num_my_row; ++i) {
2048 Scalar v = x_view[i];
2049 Scalar v2 = x2_view[i];
2051 if (
j < v.size() && ST::magnitude(v.coeff(
j)) < btol)
2052 v.fastAccessCoeff(
j) = BaseScalar(0.0);
2053 if (
j < v2.size() && ST::magnitude(v2.coeff(
j)) < btol)
2054 v2.fastAccessCoeff(
j) = BaseScalar(0.0);
2074 #if defined(HAVE_STOKHOS_AMESOS2)
2091 typedef typename Scalar::cijk_type Cijk;
2094 typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> Tpetra_Map;
2095 typedef Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_Vector;
2096 typedef Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_MultiVector;
2097 typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsMatrix;
2098 typedef Tpetra::CrsGraph<LocalOrdinal,GlobalOrdinal,Node> Tpetra_CrsGraph;
2101 if ( !Kokkos::is_initialized() )
2102 Kokkos::initialize();
2111 BaseScalar h = 1.0 /
static_cast<BaseScalar
>(nrow-1);
2112 RCP<const Tpetra_Comm> comm = Tpetra::getDefaultComm();
2113 RCP<const Tpetra_Map> map =
2114 Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
2116 RCP<Tpetra_CrsGraph> graph = Tpetra::createCrsGraph(map,
size_t(3));
2117 Array<GlobalOrdinal> columnIndices(3);
2118 ArrayView<const GlobalOrdinal> myGIDs = map->getLocalElementList();
2119 const size_t num_my_row = myGIDs.size();
2120 for (
size_t i=0; i<num_my_row; ++i) {
2122 if (row == 0 || row == nrow-1) {
2123 columnIndices[0] = row;
2124 graph->insertGlobalIndices(row, columnIndices(0,1));
2127 columnIndices[0] = row-1;
2128 columnIndices[1] = row;
2129 columnIndices[2] = row+1;
2130 graph->insertGlobalIndices(row, columnIndices(0,3));
2133 graph->fillComplete();
2134 RCP<Tpetra_CrsMatrix> matrix =
rcp(
new Tpetra_CrsMatrix(graph));
2137 Array<Scalar> vals(3);
2140 a_val.fastAccessCoeff(
j) =
2141 BaseScalar(1.0) + BaseScalar(1.0) / BaseScalar(
j+1);
2143 for (
size_t i=0; i<num_my_row; ++i) {
2145 if (row == 0 || row == nrow-1) {
2146 columnIndices[0] = row;
2148 matrix->replaceGlobalValues(row, columnIndices(0,1), vals(0,1));
2151 columnIndices[0] = row-1;
2152 columnIndices[1] = row;
2153 columnIndices[2] = row+1;
2154 vals[0] =
Scalar(1.0) * a_val;
2155 vals[1] =
Scalar(-2.0) * a_val;
2156 vals[2] =
Scalar(1.0) * a_val;
2157 matrix->replaceGlobalValues(row, columnIndices(0,3), vals(0,3));
2160 matrix->fillComplete();
2163 RCP<Tpetra_Vector> b = Tpetra::createVector<Scalar>(map);
2165 ArrayRCP<Scalar> b_view = b->get1dViewNonConst();
2168 b_val.fastAccessCoeff(
j) =
2169 BaseScalar(2.0) - BaseScalar(1.0) / BaseScalar(
j+1);
2171 for (
size_t i=0; i<num_my_row; ++i) {
2173 if (row == 0 || row == nrow-1)
2176 b_view[i] = b_val * (h*h);
2181 typedef Amesos2::Solver<Tpetra_CrsMatrix,Tpetra_MultiVector> Solver;
2182 RCP<Tpetra_Vector> x = Tpetra::createVector<Scalar>(map);
2183 std::string solver_name;
2184 #if defined(HAVE_AMESOS2_BASKER)
2185 solver_name =
"basker";
2186 #elif defined(HAVE_AMESOS2_KLU2)
2187 solver_name =
"klu2";
2188 #elif defined(HAVE_AMESOS2_SUPERLUDIST)
2189 solver_name =
"superlu_dist";
2190 #elif defined(HAVE_AMESOS2_SUPERLUMT)
2191 solver_name =
"superlu_mt";
2192 #elif defined(HAVE_AMESOS2_SUPERLU)
2193 solver_name =
"superlu";
2194 #elif defined(HAVE_AMESOS2_PARDISO_MKL)
2195 solver_name =
"pardisomkl";
2196 #elif defined(HAVE_AMESOS2_LAPACK)
2197 solver_name =
"lapack";
2198 #elif defined(HAVE_AMESOS2_CHOLMOD) && defined (HAVE_AMESOS2_EXPERIMENTAL)
2199 solver_name =
"lapack";
2205 out <<
"Solving linear system with " << solver_name << std::endl;
2207 RCP<Solver> solver = Amesos2::create<Tpetra_CrsMatrix,Tpetra_MultiVector>(
2208 solver_name, matrix, x, b);
2215 typedef Tpetra::Vector<BaseScalar,LocalOrdinal,GlobalOrdinal,Node> Flat_Tpetra_Vector;
2216 typedef Tpetra::MultiVector<BaseScalar,LocalOrdinal,GlobalOrdinal,Node> Flat_Tpetra_MultiVector;
2217 typedef Tpetra::CrsMatrix<BaseScalar,LocalOrdinal,GlobalOrdinal,Node> Flat_Tpetra_CrsMatrix;
2218 RCP<const Tpetra_Map> flat_x_map, flat_b_map;
2219 RCP<const Tpetra_CrsGraph> flat_graph, cijk_graph;
2222 cijk_graph, pce_size);
2223 RCP<Flat_Tpetra_CrsMatrix> flat_matrix =
2225 RCP<Tpetra_Vector> x2 = Tpetra::createVector<Scalar>(map);
2227 RCP<Flat_Tpetra_Vector> flat_x =
2229 RCP<Flat_Tpetra_Vector> flat_b =
2231 typedef Amesos2::Solver<Flat_Tpetra_CrsMatrix,Flat_Tpetra_MultiVector> Flat_Solver;
2232 RCP<Flat_Solver> flat_solver =
2233 Amesos2::create<Flat_Tpetra_CrsMatrix,Flat_Tpetra_MultiVector>(
2234 solver_name, flat_matrix, flat_x, flat_b);
2235 flat_solver->solve();
2238 typedef Kokkos::ArithTraits<BaseScalar> ST;
2239 typename ST::mag_type btol = 1e-12;
2240 ArrayRCP<Scalar> x_view = x->get1dViewNonConst();
2241 ArrayRCP<Scalar> x2_view = x2->get1dViewNonConst();
2242 for (
size_t i=0; i<num_my_row; ++i) {
2247 Scalar v = x_view[i];
2248 Scalar v2 = x2_view[i];
2250 if (
j < v.size() && ST::magnitude(v.coeff(
j)) < btol)
2251 v.fastAccessCoeff(
j) = BaseScalar(0.0);
2252 if (
j < v2.size() && ST::magnitude(v2.coeff(
j)) < btol)
2253 v2.fastAccessCoeff(
j) = BaseScalar(0.0);
2272 #define CRSMATRIX_UQ_PCE_TESTS_SLGN(S, LO, GO, N) \
2273 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_PCE, VectorAdd, S, LO, GO, N ) \
2274 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_PCE, VectorDot, S, LO, GO, N ) \
2275 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_PCE, MultiVectorAdd, S, LO, GO, N ) \
2276 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_PCE, MultiVectorDot, S, LO, GO, N ) \
2277 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_PCE, MultiVectorDotSub, S, LO, GO, N ) \
2278 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_PCE, MatrixVectorMultiply, S, LO, GO, N ) \
2279 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_PCE, MatrixMultiVectorMultiply, S, LO, GO, N ) \
2280 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_PCE, Flatten, S, LO, GO, N ) \
2281 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_PCE, SimpleCG, S, LO, GO, N ) \
2282 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_PCE, SimplePCG_Muelu, S, LO, GO, N ) \
2283 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_PCE, BelosGMRES, S, LO, GO, N ) \
2284 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_PCE, BelosGMRES_RILUK, S, LO, GO, N ) \
2285 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_PCE, BelosCG_Muelu, S, LO, GO, N ) \
2286 TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Tpetra_CrsMatrix_PCE, Amesos2, S, LO, GO, N )
2288 #define CRSMATRIX_UQ_PCE_TESTS_N(N) \
2289 typedef Stokhos::DeviceForNode2<N>::type Device; \
2290 typedef Stokhos::DynamicStorage<int,double,Device::execution_space> DS; \
2291 using default_local_ordinal_type = Tpetra::Map<>::local_ordinal_type; \
2292 using default_global_ordinal_type = Tpetra::Map<>::global_ordinal_type; \
2293 CRSMATRIX_UQ_PCE_TESTS_SLGN(DS, default_local_ordinal_type, default_global_ordinal_type, 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)
Teuchos::RCP< Tpetra::CrsMatrix< Scalar, LO, GO, N > > build_mean_matrix(const Tpetra::CrsMatrix< Scalar, LO, GO, N > &A)
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)
Data structure storing a sparse 3-tensor C(i,j,k) in a a compressed format.
#define TEST_EQUALITY_CONST(v1, v2)
Kokkos::DefaultExecutionSpace execution_space
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::RCP< Tpetra::CrsMatrix< typename Scalar::value_type, LO, GO, N > > build_mean_scalar_matrix(const Tpetra::CrsMatrix< Scalar, LO, GO, N > &A)
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)
void deep_copy(const Stokhos::CrsMatrix< ValueType, DstDevice, Layout > &dst, const Stokhos::CrsMatrix< ValueType, SrcDevice, Layout > &src)
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)
void setGlobalCijkTensor(const cijk_type &cijk)
Multivariate orthogonal polynomial basis generated from a total-order complete-polynomial tensor prod...
kokkos_cijk_type build_cijk(ordinal_type stoch_dim, ordinal_type poly_ord)
#define TEST_FLOATING_EQUALITY(v1, v2, tol)
KOKKOS_INLINE_FUNCTION constexpr std::enable_if< is_view_uq_pce< view_type >::value, typename CijkType< view_type >::type >::type cijk(const view_type &view)
Legendre polynomial basis.
scalar generate_matrix_coefficient(const ordinal nFEM, const ordinal nStoch, const ordinal iRowFEM, const ordinal iColFEM, const ordinal iStoch)
Abstract base class for 1-D orthogonal polynomials.
Tpetra::KokkosClassic::DefaultNode::DefaultNodeType Node
Teuchos::RCP< Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > create_flat_pce_graph(const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > &graph, const CijkType &cijk, Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > &flat_domain_map, Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > &flat_range_map, Teuchos::RCP< const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &cijk_graph, const size_t matrix_pce_size)
#define TEST_EQUALITY(v1, v2)
Stokhos::CrsMatrix< ValueType, Device, Layout >::HostMirror create_mirror_view(const Stokhos::CrsMatrix< ValueType, Device, Layout > &A)