43 #ifndef IFPACK2_BLOCKRELAXATION_DEF_HPP 44 #define IFPACK2_BLOCKRELAXATION_DEF_HPP 47 #include "Ifpack2_LinearPartitioner.hpp" 48 #include "Ifpack2_LinePartitioner.hpp" 50 #include "Ifpack2_Details_UserPartitioner_def.hpp" 51 #include <Ifpack2_Parameters.hpp> 55 template<
class MatrixType,
class ContainerType>
57 setMatrix (
const Teuchos::RCP<const row_matrix_type>& A)
59 if (A.getRawPtr () != A_.getRawPtr ()) {
60 IsInitialized_ =
false;
62 Partitioner_ = Teuchos::null;
63 Importer_ = Teuchos::null;
67 IsParallel_ = (A->getRowMap ()->getComm ()->getSize () > 1);
70 std::vector<Teuchos::RCP<ContainerType> > emptyVec;
71 std::swap (Containers_, emptyVec);
78 template<
class MatrixType,
class ContainerType>
82 Time_ (
Teuchos::rcp (new
Teuchos::Time (
"Ifpack2::BlockRelaxation"))),
84 PartitionerType_ (
"linear"),
88 DampingFactor_ (STS::one ()),
90 ZeroStartingSolution_ (true),
91 DoBackwardGS_ (false),
92 IsInitialized_ (false),
97 InitializeTime_ (0.0),
104 NumGlobalNonzeros_ (0)
106 TEUCHOS_TEST_FOR_EXCEPTION(
107 A_.is_null (), std::invalid_argument,
108 Teuchos::typeName(*
this) <<
"::BlockRelaxation(): input matrix is null.");
112 template<
class MatrixType,
class ContainerType>
116 template<
class MatrixType,
class ContainerType>
121 Teuchos::ParameterList validparams;
123 List.validateParameters (validparams);
126 if (PrecType_ == Ifpack2::Details::JACOBI) {
128 }
else if (PrecType_ == Ifpack2::Details::GS) {
130 }
else if (PrecType_ == Ifpack2::Details::SGS) {
131 PT =
"Symmetric Gauss-Seidel";
136 if (PT ==
"Jacobi") {
137 PrecType_ = Ifpack2::Details::JACOBI;
139 else if (PT ==
"Gauss-Seidel") {
140 PrecType_ = Ifpack2::Details::GS;
142 else if (PT ==
"Symmetric Gauss-Seidel") {
143 PrecType_ = Ifpack2::Details::SGS;
146 TEUCHOS_TEST_FOR_EXCEPTION(
147 true, std::invalid_argument,
"Ifpack2::BlockRelaxation::setParameters: " 148 "Invalid parameter value \"" << PT <<
"\" for parameter \"relaxation: type\".");
160 if (PrecType_ != Ifpack2::Details::JACOBI) {
163 if (NumLocalBlocks_ < 0) {
164 NumLocalBlocks_ = A_->getNodeNumRows() / (-NumLocalBlocks_);
169 TEUCHOS_TEST_FOR_EXCEPTION(
170 DoBackwardGS_, std::runtime_error,
171 "Ifpack2::BlockRelaxation:setParameters: \"relaxation: backward mode\" == " 172 "true is not supported yet.");
180 template<
class MatrixType,
class ContainerType>
181 Teuchos::RCP<const Teuchos::Comm<int> >
183 return A_->getComm();
187 template<
class MatrixType,
class ContainerType>
188 Teuchos::RCP<
const Tpetra::RowMatrix<
typename MatrixType::scalar_type,
189 typename MatrixType::local_ordinal_type,
190 typename MatrixType::global_ordinal_type,
191 typename MatrixType::node_type> >
197 template<
class MatrixType,
class ContainerType>
198 Teuchos::RCP<
const Tpetra::Map<
typename MatrixType::local_ordinal_type,
199 typename MatrixType::global_ordinal_type,
200 typename MatrixType::node_type> >
202 return A_->getDomainMap();
206 template<
class MatrixType,
class ContainerType>
207 Teuchos::RCP<
const Tpetra::Map<
typename MatrixType::local_ordinal_type,
208 typename MatrixType::global_ordinal_type,
209 typename MatrixType::node_type> >
211 return A_->getRangeMap();
215 template<
class MatrixType,
class ContainerType>
221 template<
class MatrixType,
class ContainerType>
223 return(NumInitialize_);
227 template<
class MatrixType,
class ContainerType>
233 template<
class MatrixType,
class ContainerType>
239 template<
class MatrixType,
class ContainerType>
241 return(InitializeTime_);
245 template<
class MatrixType,
class ContainerType>
247 return(ComputeTime_);
251 template<
class MatrixType,
class ContainerType>
257 template<
class MatrixType,
class ContainerType>
259 return(ComputeFlops_);
263 template<
class MatrixType,
class ContainerType>
269 template<
class MatrixType,
class ContainerType>
272 apply (
const Tpetra::MultiVector<
typename MatrixType::scalar_type,
273 typename MatrixType::local_ordinal_type,
274 typename MatrixType::global_ordinal_type,
275 typename MatrixType::node_type>& X,
276 Tpetra::MultiVector<
typename MatrixType::scalar_type,
277 typename MatrixType::local_ordinal_type,
278 typename MatrixType::global_ordinal_type,
279 typename MatrixType::node_type>& Y,
280 Teuchos::ETransp mode,
284 TEUCHOS_TEST_FOR_EXCEPTION(
285 !
isComputed (), std::runtime_error,
"Ifpack2::BlockRelaxation::apply: " 286 "isComputed() must be true prior to calling apply.");
287 TEUCHOS_TEST_FOR_EXCEPTION(
288 X.getNumVectors () != Y.getNumVectors (), std::invalid_argument,
289 "Ifpack2::BlockRelaxation::apply: X.getNumVectors() = " 290 << X.getNumVectors () <<
" != Y.getNumVectors() = " 291 << Y.getNumVectors () <<
".");
292 TEUCHOS_TEST_FOR_EXCEPTION(
293 mode != Teuchos::NO_TRANS, std::logic_error,
"Ifpack2::BlockRelaxation::" 294 "apply: This method currently only implements the case mode == Teuchos::" 295 "NO_TRANS. Transposed modes are not currently supported.");
296 TEUCHOS_TEST_FOR_EXCEPTION(
297 alpha != Teuchos::ScalarTraits<scalar_type>::one (), std::logic_error,
298 "Ifpack2::BlockRelaxation::apply: This method currently only implements " 299 "the case alpha == 1. You specified alpha = " << alpha <<
".");
300 TEUCHOS_TEST_FOR_EXCEPTION(
301 beta != Teuchos::ScalarTraits<scalar_type>::zero (), std::logic_error,
302 "Ifpack2::BlockRelaxation::apply: This method currently only implements " 303 "the case beta == 0. You specified beta = " << beta <<
".");
309 Teuchos::RCP<const MV> X_copy;
311 auto X_lcl_host = X.template getLocalView<Kokkos::HostSpace> ();
312 auto Y_lcl_host = Y.template getLocalView<Kokkos::HostSpace> ();
313 if (X_lcl_host.ptr_on_device () == Y_lcl_host.ptr_on_device ()) {
314 X_copy = rcp (
new MV (X, Teuchos::Copy));
316 X_copy = rcpFromRef (X);
320 if (ZeroStartingSolution_) {
321 Y.putScalar (STS::zero ());
326 case Ifpack2::Details::JACOBI:
327 ApplyInverseJacobi(*X_copy,Y);
329 case Ifpack2::Details::GS:
330 ApplyInverseGS(*X_copy,Y);
332 case Ifpack2::Details::SGS:
333 ApplyInverseSGS(*X_copy,Y);
336 throw std::runtime_error(
"Ifpack2::BlockRelaxation::apply internal logic error.");
341 ApplyTime_ += Time_->totalElapsedTime();
345 template<
class MatrixType,
class ContainerType>
347 const Tpetra::MultiVector<
typename MatrixType::scalar_type,
348 typename MatrixType::local_ordinal_type,
349 typename MatrixType::global_ordinal_type,
350 typename MatrixType::node_type>& X,
351 Tpetra::MultiVector<
typename MatrixType::scalar_type,
352 typename MatrixType::local_ordinal_type,
353 typename MatrixType::global_ordinal_type,
354 typename MatrixType::node_type>& Y,
355 Teuchos::ETransp mode)
const 357 TEUCHOS_TEST_FOR_EXCEPTION(
isComputed() ==
false, std::runtime_error,
358 "Ifpack2::BlockRelaxation::applyMat() ERROR: isComputed() must be true prior to calling applyMat().");
359 TEUCHOS_TEST_FOR_EXCEPTION(X.getNumVectors() != Y.getNumVectors(), std::runtime_error,
360 "Ifpack2::BlockRelaxation::applyMat() ERROR: X.getNumVectors() != Y.getNumVectors().");
361 A_->apply (X, Y, mode);
365 template<
class MatrixType,
class ContainerType>
368 typedef Tpetra::RowGraph<local_ordinal_type, global_ordinal_type, node_type>
371 IsInitialized_ =
false;
374 NumMyRows_ = A_->getNodeNumRows ();
375 NumGlobalRows_ = A_->getGlobalNumRows ();
376 NumGlobalNonzeros_ = A_->getGlobalNumEntries ();
382 if (PartitionerType_ ==
"linear") {
385 }
else if (PartitionerType_ ==
"line") {
388 }
else if (PartitionerType_ ==
"user") {
394 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
395 "Ifpack2::BlockRelaxation::initialize, invalid partitioner type.");
399 Partitioner_->setParameters (List_);
400 Partitioner_->compute ();
403 NumLocalBlocks_ = Partitioner_->numLocalParts ();
408 if (A_->getComm()->getSize() != 1) {
416 InitializeTime_ += Time_->totalElapsedTime ();
417 IsInitialized_ =
true;
421 template<
class MatrixType,
class ContainerType>
432 TEUCHOS_TEST_FOR_EXCEPTION(NumSweeps_ < 0, std::logic_error,
433 "Ifpack2::BlockRelaxation::compute, NumSweeps_ must be >= 0");
444 ExtractSubmatrices ();
448 if (PrecType_ == Ifpack2::Details::JACOBI && OverlapLevel_ > 0) {
450 W_ = rcp (
new vector_type (A_->getRowMap ()));
451 W_->putScalar (STS::zero ());
452 Teuchos::ArrayRCP<scalar_type > w_ptr = W_->getDataNonConst(0);
454 for (local_ordinal_type i = 0 ; i < NumLocalBlocks_ ; ++i) {
455 for (
size_t j = 0 ; j < Partitioner_->numRowsInPart(i) ; ++j) {
458 int LID = (*Partitioner_)(i,j);
459 w_ptr[LID]+= STS::one();
462 W_->reciprocal (*W_);
471 if (IsParallel_ && (PrecType_ == Ifpack2::Details::GS ||
472 PrecType_ == Ifpack2::Details::SGS)) {
473 Importer_ = A_->getGraph ()->getImporter ();
474 if (Importer_.is_null ()) {
475 Importer_ = rcp (
new import_type (A_->getDomainMap (), A_->getColMap ()));
481 ComputeTime_ += Time_->totalElapsedTime();
486 template<
class MatrixType,
class ContainerType>
491 TEUCHOS_TEST_FOR_EXCEPTION(
492 Partitioner_.is_null (), std::runtime_error,
493 "Ifpack2::BlockRelaxation::ExtractSubmatrices: Partitioner object is null.");
495 NumLocalBlocks_ = Partitioner_->numLocalParts ();
496 Containers_.resize (NumLocalBlocks_);
497 vec_type D (A_->getRowMap ());
498 A_->getLocalDiagCopy (D);
499 DiagRCP = D.getData ();
501 for (local_ordinal_type i = 0; i < NumLocalBlocks_; ++i) {
502 const size_t numRows = Partitioner_->numRowsInPart (i);
505 Teuchos::Array<local_ordinal_type> localRows (numRows);
506 for (
size_t j = 0; j < numRows; ++j) {
507 localRows[j] = (*Partitioner_) (i,j);
510 Containers_[i] = Teuchos::rcp (
new ContainerType (A_, localRows ()));
511 Containers_[i]->setParameters (List_);
512 Containers_[i]->initialize ();
513 Containers_[i]->compute ();
521 template<
class MatrixType,
class ContainerType>
524 const size_t NumVectors = X.getNumVectors ();
525 MV AY (Y.getMap (), NumVectors);
528 int starting_iteration = 0;
529 if (ZeroStartingSolution_) {
531 starting_iteration = 1;
535 for (
int j = starting_iteration; j < NumSweeps_; ++j) {
537 AY.update (ONE, X, -ONE);
541 ApplyFlops_ += NumVectors * (2 * NumGlobalNonzeros_ + 2 * NumGlobalRows_);
548 template<
class MatrixType,
class ContainerType>
551 const size_t NumVectors = X.getNumVectors ();
555 if (OverlapLevel_ == 0) {
559 if( Partitioner_->numRowsInPart (i) != 1 ) {
560 if(Containers_[i]->getNumRows () == 0 )
continue;
561 Containers_[i]->apply (X, Y, Teuchos::NO_TRANS, DampingFactor_, one);
562 ApplyFlops_ += NumVectors * 2 * NumGlobalRows_;
566 Teuchos::ArrayView< const scalar_type > Diag = DiagRCP();
568 for(
unsigned int nv = 0;nv < NumVectors ; ++nv ) {
569 Teuchos::ArrayRCP< const scalar_type > xRCP = X.getData(nv);
571 Teuchos::ArrayRCP< scalar_type > yRCP = Y.getDataNonConst(nv);
583 if(Containers_[i]->getNumRows() == 0)
continue;
584 if ( Partitioner_->numRowsInPart (i) != 1 ) {
586 Containers_[i]->weightedApply(X,Y,*W_,Teuchos::NO_TRANS,DampingFactor_,one);
587 }
catch (std::exception& e) {
588 std::cerr <<
"BlockRelaxation::DoJacobi: Containers_[" << i
589 <<
"]->weightedApply() threw an exception: " << e.what ()
596 ApplyFlops_ += NumVectors * 4 * NumGlobalRows_;
602 template<
class MatrixType,
class ContainerType>
606 MV Xcopy (X, Teuchos::Copy);
607 for (
int j = 0; j < NumSweeps_; ++j) {
608 DoGaussSeidel (Xcopy, Y);
609 if (j != NumSweeps_ - 1) {
610 Tpetra::deep_copy (Xcopy, X);
617 template<
class MatrixType,
class ContainerType>
621 using Teuchos::Array;
622 using Teuchos::ArrayRCP;
623 using Teuchos::ArrayView;
626 using Teuchos::rcpFromRef;
631 const size_t Length = A_->getNodeMaxNumRowEntries();
632 const size_t NumVectors = X.getNumVectors();
633 Array<scalar_type> Values;
634 Array<local_ordinal_type> Indices;
635 Values.resize (Length);
636 Indices.resize (Length);
643 Y2 = rcp (
new MV (Importer_->getTargetMap (), NumVectors));
652 MV Residual (X.getMap (), NumVectors,
false);
654 ArrayRCP<ArrayRCP<scalar_type> > x_ptr = X.get2dViewNonConst();
655 ArrayRCP<ArrayRCP<scalar_type> > y_ptr = Y.get2dViewNonConst();
656 ArrayRCP<ArrayRCP<scalar_type> > y2_ptr = Y2->get2dViewNonConst();
657 ArrayRCP<ArrayRCP<scalar_type> > residual_ptr = Residual.get2dViewNonConst();
660 if (IsParallel_) Y2->doImport(Y,*Importer_,Tpetra::INSERT);
663 if( Partitioner_->numRowsInPart (i) != 1 ) {
664 if (Containers_[i]->getNumRows () == 0)
continue;
666 ArrayView<const local_ordinal_type> localRows =
667 Containers_[i]->getLocalRows ();
668 const size_t localNumRows = Containers_[i]->getNumRows ();
669 for (
size_t j = 0; j < localNumRows; ++j) {
672 A_->getLocalRowCopy (LID, Indices (), Values (), NumEntries);
674 for (
size_t m = 0; m < NumVectors; ++m) {
675 ArrayView<const scalar_type> x_local = (x_ptr())[m]();
676 ArrayView<scalar_type> y2_local = (y2_ptr())[m]();
677 ArrayView<scalar_type> r_local = (residual_ptr())[m]();
679 r_local[LID] = x_local[LID];
680 for (
size_t k = 0; k < NumEntries; ++k) {
682 r_local[LID] -= Values[k] * y2_local[col];
692 Containers_[i]->apply (Residual, *Y2, Teuchos::NO_TRANS,
696 ApplyFlops_ += NumVectors * (2 * NumGlobalNonzeros_ + 2 * NumGlobalRows_);
701 Teuchos::ArrayView< const scalar_type > Diag = DiagRCP();
703 ArrayRCP<ArrayRCP<scalar_type> > y2_ptr2 = Y2->get2dViewNonConst();
704 for(
unsigned int nv = 0;nv < NumVectors ; ++nv ) {
705 Teuchos::ArrayRCP< const scalar_type > xRCP = X.getData(nv);
707 ArrayView<scalar_type> y2_local = (y2_ptr2())[nv]();
709 y2_local[LRID]= newy;
716 for (
size_t m = 0; m < NumVectors; ++m) {
717 ArrayView<scalar_type> y2_local = (y2_ptr())[m]();
718 ArrayView<scalar_type> y_local = (y_ptr())[m]();
719 for (
size_t i = 0; i < NumMyRows_; ++i) {
720 y_local[i] = y2_local[i];
727 template<
class MatrixType,
class ContainerType>
732 MV Xcopy (X, Teuchos::Copy);
733 for (
int j = 0; j < NumSweeps_; ++j) {
735 if (j != NumSweeps_ - 1) {
736 Tpetra::deep_copy (Xcopy, X);
742 template<
class MatrixType,
class ContainerType>
746 using Teuchos::Array;
747 using Teuchos::ArrayRCP;
748 using Teuchos::ArrayView;
751 using Teuchos::rcpFromRef;
754 const size_t Length = A_->getNodeMaxNumRowEntries();
755 const size_t NumVectors = X.getNumVectors();
756 Array<scalar_type> Values;
757 Array<local_ordinal_type> Indices;
758 Values.resize(Length);
759 Indices.resize(Length);
766 Y2 = rcp (
new MV (Importer_->getTargetMap (), NumVectors));
775 MV Residual (X.getMap (), NumVectors,
false);
777 ArrayRCP<ArrayRCP<scalar_type> > x_ptr = X.get2dViewNonConst();
778 ArrayRCP<ArrayRCP<scalar_type> > y_ptr = Y.get2dViewNonConst();
779 ArrayRCP<ArrayRCP<scalar_type> > y2_ptr = Y2->get2dViewNonConst();
780 ArrayRCP<ArrayRCP<scalar_type> > residual_ptr = Residual.get2dViewNonConst();
784 Y2->doImport (Y, *Importer_, Tpetra::INSERT);
789 if( Partitioner_->numRowsInPart (i) != 1 ) {
790 if (Containers_[i]->getNumRows () == 0) {
794 ArrayView<const local_ordinal_type> localRows =
795 Containers_[i]->getLocalRows ();
796 for (
size_t j = 0; j < Containers_[i]->getNumRows (); ++j) {
799 A_->getLocalRowCopy (LID, Indices (), Values (), NumEntries);
802 for (
size_t m = 0; m < NumVectors; ++m) {
803 ArrayView<const scalar_type> x_local = (x_ptr())[m]();
804 ArrayView<scalar_type> y2_local = (y2_ptr())[m]();
805 ArrayView<scalar_type> r_local = (residual_ptr())[m]();
807 r_local[LID] = x_local[LID];
808 for (
size_t k = 0 ; k < NumEntries ; k++) {
810 r_local[LID] -= Values[k] * y2_local[col];
820 Containers_[i]->apply (Residual, *Y2, Teuchos::NO_TRANS,
821 DampingFactor_, one);
824 ApplyFlops_ += NumVectors * (2 * NumGlobalNonzeros_ + 2 * NumGlobalRows_);
829 Teuchos::ArrayView< const scalar_type > Diag = DiagRCP();
831 for(
unsigned int nv = 0;nv < NumVectors ; ++nv ) {
832 Teuchos::ArrayRCP< const scalar_type > xRCP = X.getData(nv);
834 Teuchos::ArrayRCP< scalar_type > yRCP = Y.getDataNonConst(nv);
850 if( Partitioner_->numRowsInPart (i) != 1 ) {
851 if (Containers_[i-1]->getNumRows () == 0)
continue;
854 ArrayView<const local_ordinal_type> localRows =
855 Containers_[i-1]->getLocalRows ();
856 for (
size_t j = 0; j < Containers_[i-1]->getNumRows (); ++j) {
859 A_->getLocalRowCopy (LID, Indices (), Values (), NumEntries);
862 for (
size_t m = 0; m < NumVectors; ++m) {
863 ArrayView<const scalar_type> x_local = (x_ptr())[m]();
864 ArrayView<scalar_type> y2_local = (y2_ptr())[m]();
865 ArrayView<scalar_type> r_local = (residual_ptr())[m]();
867 r_local [LID] = x_local[LID];
868 for (
size_t k = 0; k < NumEntries; ++k) {
870 r_local[LID] -= Values[k] * y2_local[col];
881 Containers_[i-1]->apply (Residual, *Y2, Teuchos::NO_TRANS,
882 DampingFactor_, one);
885 ApplyFlops_ += NumVectors * (2 * NumGlobalNonzeros_ + 2 * NumGlobalRows_);
893 for (
size_t m = 0; m < NumVectors; ++m) {
894 ArrayView<scalar_type> y_local = (y_ptr())[m]();
895 ArrayView<scalar_type> y2_local = (y2_ptr())[m]();
896 for (
size_t i = 0 ; i < NumMyRows_ ; ++i) {
897 y_local[i] = y2_local[i];
903 template<
class MatrixType,
class ContainerType>
906 std::ostringstream out;
911 out <<
"\"Ifpack2::BlockRelaxation\": {";
912 if (this->getObjectLabel () !=
"") {
913 out <<
"Label: \"" << this->getObjectLabel () <<
"\", ";
915 out <<
"Initialized: " << (
isInitialized () ?
"true" :
"false") <<
", ";
916 out <<
"Computed: " << (
isComputed () ?
"true" :
"false") <<
", ";
919 out <<
"Matrix: null, ";
922 out <<
"Matrix: not null" 923 <<
", Global matrix dimensions: [" 924 << A_->getGlobalNumRows () <<
", " << A_->getGlobalNumCols () <<
"], ";
929 out <<
"\"relaxation: type\": ";
930 if (PrecType_ == Ifpack2::Details::JACOBI) {
931 out <<
"Block Jacobi";
932 }
else if (PrecType_ == Ifpack2::Details::GS) {
933 out <<
"Block Gauss-Seidel";
934 }
else if (PrecType_ == Ifpack2::Details::SGS) {
935 out <<
"Block Symmetric Gauss-Seidel";
940 out <<
", " <<
"sweeps: " << NumSweeps_ <<
", " 941 <<
"damping factor: " << DampingFactor_ <<
", ";
948 template<
class MatrixType,
class ContainerType>
950 describe (Teuchos::FancyOStream &out,
const Teuchos::EVerbosityLevel verbLevel)
const 954 using Teuchos::TypeNameTraits;
955 using Teuchos::VERB_DEFAULT;
956 using Teuchos::VERB_NONE;
957 using Teuchos::VERB_LOW;
958 using Teuchos::VERB_MEDIUM;
959 using Teuchos::VERB_HIGH;
960 using Teuchos::VERB_EXTREME;
962 Teuchos::EVerbosityLevel vl = verbLevel;
963 if (vl == VERB_DEFAULT) vl = VERB_LOW;
964 const int myImageID = A_->getComm()->getRank();
967 Teuchos::OSTab tab (out);
974 if (vl != VERB_NONE && myImageID == 0) {
975 out <<
"Ifpack2::BlockRelaxation<" 976 << TypeNameTraits<MatrixType>::name () <<
", " 977 << TypeNameTraits<ContainerType>::name () <<
" >:";
978 Teuchos::OSTab tab1 (out);
980 if (this->getObjectLabel () !=
"") {
981 out <<
"label: \"" << this->getObjectLabel () <<
"\"" << endl;
983 out <<
"initialized: " << (
isInitialized () ?
"true" :
"false") << endl
984 <<
"computed: " << (
isComputed () ?
"true" :
"false") << endl;
986 std::string precType;
987 if (PrecType_ == Ifpack2::Details::JACOBI) {
988 precType =
"Block Jacobi";
989 }
else if (PrecType_ == Ifpack2::Details::GS) {
990 precType =
"Block Gauss-Seidel";
991 }
else if (PrecType_ == Ifpack2::Details::SGS) {
992 precType =
"Block Symmetric Gauss-Seidel";
994 out <<
"type: " << precType << endl
995 <<
"global number of rows: " << A_->getGlobalNumRows () << endl
996 <<
"global number of columns: " << A_->getGlobalNumCols () << endl
997 <<
"number of sweeps: " << NumSweeps_ << endl
998 <<
"damping factor: " << DampingFactor_ << endl
999 <<
"backwards mode: " 1000 << ((PrecType_ == Ifpack2::Details::GS && DoBackwardGS_) ?
"true" :
"false")
1002 <<
"zero starting solution: " 1003 << (ZeroStartingSolution_ ?
"true" :
"false") << endl;
1005 out <<
"===============================================================================" << endl;
1006 out <<
"Phase # calls Total Time (s) Total MFlops MFlops/s " << endl;
1007 out <<
"------------ ------- --------------- --------------- ---------------" << endl;
1015 out <<
"===============================================================================" << endl;
1023 #ifdef HAVE_IFPACK2_EXPLICIT_INSTANTIATION 1036 #define IFPACK2_BLOCKRELAXATION_INSTANT(S,LO,GO,N) \ 1038 class Ifpack2::BlockRelaxation< \ 1039 Tpetra::RowMatrix<S, LO, GO, N>, \ 1040 Ifpack2::SparseContainer< \ 1041 Tpetra::RowMatrix<S, LO, GO, N>, \ 1042 Ifpack2::ILUT< ::Tpetra::RowMatrix<S,LO,GO,N> > > >; \ 1044 class Ifpack2::BlockRelaxation< \ 1045 Tpetra::RowMatrix<S, LO, GO, N>, \ 1046 Ifpack2::DenseContainer< \ 1047 Tpetra::RowMatrix<S, LO, GO, N>, \ 1050 class Ifpack2::BlockRelaxation< \ 1051 Tpetra::RowMatrix<S, LO, GO, N>, \ 1052 Ifpack2::TriDiContainer< \ 1053 Tpetra::RowMatrix<S, LO, GO, N>, \ 1056 class Ifpack2::BlockRelaxation< \ 1057 Tpetra::RowMatrix<S, LO, GO, N>, \ 1058 Ifpack2::BandedContainer< \ 1059 Tpetra::RowMatrix<S, LO, GO, N>, \ 1062 #endif // HAVE_IFPACK2_EXPLICIT_INSTANTIATION 1064 #endif // IFPACK2_BLOCKRELAXATION_DEF_HPP double getApplyFlops() const
Returns the number of flops for the application of the preconditioner.
Definition: Ifpack2_BlockRelaxation_def.hpp:264
void applyMat(const Tpetra::MultiVector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > &X, Tpetra::MultiVector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS) const
Applies the matrix to a Tpetra::MultiVector.
Definition: Ifpack2_BlockRelaxation_def.hpp:346
Ifpack2::BlockRelaxation class declaration.
Ifpack2::TriDiContainer class declaration.
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
The communicator over which the input matrix is distributed.
Definition: Ifpack2_BlockRelaxation_def.hpp:182
MatrixType::global_ordinal_type global_ordinal_type
The type of global indices in the input MatrixType.
Definition: Ifpack2_BlockRelaxation_decl.hpp:101
std::string description() const
A one-line description of this object.
Definition: Ifpack2_BlockRelaxation_def.hpp:904
double getApplyTime() const
Returns the time spent in apply().
Definition: Ifpack2_BlockRelaxation_def.hpp:252
int getNumApply() const
Returns the number of calls to apply().
Definition: Ifpack2_BlockRelaxation_def.hpp:234
void getParameter(const Teuchos::ParameterList ¶ms, const std::string &name, T &value)
Set a value from a ParameterList if a parameter with the specified name exists.
Definition: Ifpack2_Parameters.hpp:59
Teuchos::RCP< const Tpetra::Map< local_ordinal_type, global_ordinal_type, node_type > > getRangeMap() const
Returns the Tpetra::Map object associated with the range of this operator.
Definition: Ifpack2_BlockRelaxation_def.hpp:210
int getNumCompute() const
Returns the number of calls to compute().
Definition: Ifpack2_BlockRelaxation_def.hpp:228
void setParameters(const Teuchos::ParameterList ¶ms)
Sets all the parameters for the preconditioner.
Definition: Ifpack2_BlockRelaxation_def.hpp:119
void compute()
compute the preconditioner for the specified matrix, diagonal perturbation thresholds and relaxation ...
Definition: Ifpack2_BlockRelaxation_def.hpp:422
Block relaxation preconditioners (or smoothers) for Tpetra::RowMatrix and Tpetra::CrsMatrix sparse ma...
Definition: Ifpack2_BlockRelaxation_decl.hpp:80
Ifpack2 implementation details.
double getInitializeTime() const
Returns the time spent in initialize().
Definition: Ifpack2_BlockRelaxation_def.hpp:240
Declaration of a user-defined partitioner in which the user can define a nonoverlapping partition of ...
double getComputeFlops() const
Returns the number of flops in the computation phase.
Definition: Ifpack2_BlockRelaxation_def.hpp:258
double getComputeTime() const
Returns the time spent in compute().
Definition: Ifpack2_BlockRelaxation_def.hpp:246
bool isComputed() const
Return true if compute() has been called.
Definition: Ifpack2_BlockRelaxation_decl.hpp:189
virtual void setMatrix(const Teuchos::RCP< const row_matrix_type > &A)
Change the matrix to be preconditioned.
Definition: Ifpack2_BlockRelaxation_def.hpp:57
virtual ~BlockRelaxation()
Destructor.
Definition: Ifpack2_BlockRelaxation_def.hpp:113
Teuchos::RCP< const Tpetra::Map< local_ordinal_type, global_ordinal_type, node_type > > getDomainMap() const
Returns the Tpetra::Map object associated with the domain of this operator.
Definition: Ifpack2_BlockRelaxation_def.hpp:201
Partition in which the user can define a nonoverlapping partition of the graph in any way they choose...
Definition: Ifpack2_Details_UserPartitioner_decl.hpp:66
bool isInitialized() const
Returns true if the preconditioner has been successfully initialized.
Definition: Ifpack2_BlockRelaxation_decl.hpp:181
int getNumInitialize() const
Returns the number of calls to initialize().
Definition: Ifpack2_BlockRelaxation_def.hpp:222
void initialize()
Initialize.
Definition: Ifpack2_BlockRelaxation_def.hpp:366
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with some verbosity level to an FancyOStream object.
Definition: Ifpack2_BlockRelaxation_def.hpp:950
Ifpack2::BandedContainer class declaration.
Ifpack2::DenseContainer class declaration.
MatrixType::node_type node_type
Node type of the input MatrixType.
Definition: Ifpack2_BlockRelaxation_decl.hpp:104
MatrixType::local_ordinal_type local_ordinal_type
The type of local indices in the input MatrixType.
Definition: Ifpack2_BlockRelaxation_decl.hpp:98
Definition: Ifpack2_Details_Amesos2Wrapper_decl.hpp:63
MatrixType::scalar_type scalar_type
The type of the entries of the input MatrixType.
Definition: Ifpack2_BlockRelaxation_decl.hpp:95
Preconditioners and smoothers for Tpetra sparse matrices.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:72
Declaration of ILUT preconditioner.
Teuchos::RCP< const Tpetra::RowMatrix< scalar_type, local_ordinal_type, global_ordinal_type, node_type > > getMatrix() const
The input matrix of this preconditioner's constructor.
Definition: Ifpack2_BlockRelaxation_def.hpp:192
void getValidParameters(Teuchos::ParameterList ¶ms)
Fills a list which contains all the parameters possibly used by Ifpack2.
Definition: Ifpack2_Parameters.cpp:50
Ifpack2::SparseContainer class declaration.
Definition: Ifpack2_LinePartitioner_decl.hpp:75
A class to define linear partitions.
Definition: Ifpack2_LinearPartitioner_decl.hpp:54
void apply(const Tpetra::MultiVector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > &X, Tpetra::MultiVector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, scalar_type alpha=Teuchos::ScalarTraits< scalar_type >::one(), scalar_type beta=Teuchos::ScalarTraits< scalar_type >::zero()) const
Applies the preconditioner to X, returns the result in Y.
Definition: Ifpack2_BlockRelaxation_def.hpp:272
BlockRelaxation(const Teuchos::RCP< const row_matrix_type > &Matrix)
Constructor.
Definition: Ifpack2_BlockRelaxation_def.hpp:80