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;
66 IsParallel_ = (A->getRowMap ()->getComm ()->getSize () != 1);
67 Teuchos::RCP<const block_crs_matrix_type> A_bcrs =
68 Teuchos::rcp_dynamic_cast<
const block_crs_matrix_type> (A);
69 hasBlockCrsMatrix_ = !A_bcrs.is_null();
71 if (! Container_.is_null ()) {
72 Container_->clearBlocks();
81 template<
class MatrixType,
class ContainerType>
85 Time_ (
Teuchos::rcp (new
Teuchos::Time (
"Ifpack2::BlockRelaxation"))),
88 PartitionerType_ (
"linear"),
91 containerType_ (
"Dense"),
93 ZeroStartingSolution_ (true),
94 hasBlockCrsMatrix_ (false),
95 DoBackwardGS_ (false),
97 DampingFactor_ (STS::one ()),
98 IsInitialized_ (false),
103 InitializeTime_ (0.0),
107 NumGlobalNonzeros_ (0),
114 template<
class MatrixType,
class ContainerType>
119 template<
class MatrixType,
class ContainerType>
125 Teuchos::ParameterList validparams;
127 List.validateParameters (validparams);
129 if (List.isParameter (
"relaxation: container")) {
132 containerType_ = List.get<std::string> (
"relaxation: container");
135 if (List.isParameter (
"relaxation: type")) {
136 const std::string relaxType = List.get<std::string> (
"relaxation: type");
138 if (relaxType ==
"Jacobi") {
139 PrecType_ = Ifpack2::Details::JACOBI;
141 else if (relaxType ==
"Gauss-Seidel") {
142 PrecType_ = Ifpack2::Details::GS;
144 else if (relaxType ==
"Symmetric Gauss-Seidel") {
145 PrecType_ = Ifpack2::Details::SGS;
148 TEUCHOS_TEST_FOR_EXCEPTION
149 (
true, std::invalid_argument,
"Ifpack2::BlockRelaxation::" 150 "setParameters: Invalid parameter value \"" << relaxType
151 <<
"\" for parameter \"relaxation: type\".");
155 if (List.isParameter (
"relaxation: sweeps")) {
156 NumSweeps_ = List.get<
int> (
"relaxation: sweeps");
162 if (List.isParameter (
"relaxation: damping factor")) {
163 if (List.isType<
double> (
"relaxation: damping factor")) {
164 const double dampingFactor =
165 List.get<
double> (
"relaxation: damping factor");
166 DampingFactor_ =
static_cast<scalar_type> (dampingFactor);
168 else if (List.isType<
scalar_type> (
"relaxation: damping factor")) {
169 DampingFactor_ = List.get<
scalar_type> (
"relaxation: damping factor");
171 else if (List.isType<
magnitude_type> (
"relaxation: damping factor")) {
174 DampingFactor_ =
static_cast<scalar_type> (dampingFactor);
177 TEUCHOS_TEST_FOR_EXCEPTION
178 (
true, std::invalid_argument,
"Ifpack2::BlockRelaxation::" 179 "setParameters: Parameter \"relaxation: damping factor\" " 180 "has the wrong type.");
184 if (List.isParameter (
"relaxation: zero starting solution")) {
185 ZeroStartingSolution_ = List.get<
bool> (
"relaxation: zero starting solution");
188 if (List.isParameter (
"relaxation: backward mode")) {
189 DoBackwardGS_ = List.get<
bool> (
"relaxation: backward mode");
192 if (List.isParameter (
"partitioner: type")) {
193 PartitionerType_ = List.get<std::string> (
"partitioner: type");
198 if (List.isParameter (
"partitioner: local parts")) {
202 else if (! std::is_same<int, local_ordinal_type>::value &&
203 List.isType<
int> (
"partitioner: local parts")) {
204 NumLocalBlocks_ = List.get<
int> (
"partitioner: local parts");
207 TEUCHOS_TEST_FOR_EXCEPTION
208 (
true, std::invalid_argument,
"Ifpack2::BlockRelaxation::" 209 "setParameters: Parameter \"partitioner: local parts\" " 210 "has the wrong type.");
214 if (List.isParameter (
"partitioner: overlap level")) {
215 if (List.isType<
int> (
"partitioner: overlap level")) {
216 OverlapLevel_ = List.get<
int> (
"partitioner: overlap level");
218 else if (! std::is_same<int, local_ordinal_type>::value &&
223 TEUCHOS_TEST_FOR_EXCEPTION
224 (
true, std::invalid_argument,
"Ifpack2::BlockRelaxation::" 225 "setParameters: Parameter \"partitioner: overlap level\" " 226 "has the wrong type.");
230 std::string defaultContainer =
"Dense";
237 if (PrecType_ != Ifpack2::Details::JACOBI) {
240 if (NumLocalBlocks_ < static_cast<local_ordinal_type> (0)) {
241 NumLocalBlocks_ = A_->getNodeNumRows() / (-NumLocalBlocks_);
246 TEUCHOS_TEST_FOR_EXCEPTION(
247 DoBackwardGS_, std::runtime_error,
248 "Ifpack2::BlockRelaxation:setParameters: Setting the \"relaxation: " 249 "backward mode\" parameter to true is not yet supported.");
256 template<
class MatrixType,
class ContainerType>
257 Teuchos::RCP<const Teuchos::Comm<int> >
260 TEUCHOS_TEST_FOR_EXCEPTION
261 (A_.is_null (), std::runtime_error,
"Ifpack2::BlockRelaxation::getComm: " 262 "The matrix is null. You must call setMatrix() with a nonnull matrix " 263 "before you may call this method.");
264 return A_->getComm ();
267 template<
class MatrixType,
class ContainerType>
268 Teuchos::RCP<
const Tpetra::RowMatrix<
typename MatrixType::scalar_type,
269 typename MatrixType::local_ordinal_type,
270 typename MatrixType::global_ordinal_type,
271 typename MatrixType::node_type> >
276 template<
class MatrixType,
class ContainerType>
277 Teuchos::RCP<
const Tpetra::Map<
typename MatrixType::local_ordinal_type,
278 typename MatrixType::global_ordinal_type,
279 typename MatrixType::node_type> >
283 TEUCHOS_TEST_FOR_EXCEPTION
284 (A_.is_null (), std::runtime_error,
"Ifpack2::BlockRelaxation::" 285 "getDomainMap: The matrix is null. You must call setMatrix() with a " 286 "nonnull matrix before you may call this method.");
287 return A_->getDomainMap ();
290 template<
class MatrixType,
class ContainerType>
291 Teuchos::RCP<
const Tpetra::Map<
typename MatrixType::local_ordinal_type,
292 typename MatrixType::global_ordinal_type,
293 typename MatrixType::node_type> >
297 TEUCHOS_TEST_FOR_EXCEPTION
298 (A_.is_null (), std::runtime_error,
"Ifpack2::BlockRelaxation::" 299 "getRangeMap: The matrix is null. You must call setMatrix() with a " 300 "nonnull matrix before you may call this method.");
301 return A_->getRangeMap ();
304 template<
class MatrixType,
class ContainerType>
311 template<
class MatrixType,
class ContainerType>
315 return NumInitialize_;
318 template<
class MatrixType,
class ContainerType>
326 template<
class MatrixType,
class ContainerType>
334 template<
class MatrixType,
class ContainerType>
339 return InitializeTime_;
342 template<
class MatrixType,
class ContainerType>
350 template<
class MatrixType,
class ContainerType>
359 template<
class MatrixType,
class ContainerType>
361 TEUCHOS_TEST_FOR_EXCEPTION(
362 A_.is_null (), std::runtime_error,
"Ifpack2::BlockRelaxation::getNodeSmootherComplexity: " 363 "The input matrix A is null. Please call setMatrix() with a nonnull " 364 "input matrix, then call compute(), before calling this method.");
367 size_t block_nnz = 0;
369 block_nnz += Partitioner_->numRowsInPart(i) *Partitioner_->numRowsInPart(i);
371 return block_nnz + A_->getNodeNumEntries();
374 template<
class MatrixType,
class ContainerType>
377 apply (
const Tpetra::MultiVector<
typename MatrixType::scalar_type,
378 typename MatrixType::local_ordinal_type,
379 typename MatrixType::global_ordinal_type,
380 typename MatrixType::node_type>& X,
381 Tpetra::MultiVector<
typename MatrixType::scalar_type,
382 typename MatrixType::local_ordinal_type,
383 typename MatrixType::global_ordinal_type,
384 typename MatrixType::node_type>& Y,
385 Teuchos::ETransp mode,
389 TEUCHOS_TEST_FOR_EXCEPTION
390 (A_.is_null (), std::runtime_error,
"Ifpack2::BlockRelaxation::apply: " 391 "The matrix is null. You must call setMatrix() with a nonnull matrix, " 392 "then call initialize() and compute() (in that order), before you may " 393 "call this method.");
394 TEUCHOS_TEST_FOR_EXCEPTION(
395 !
isComputed (), std::runtime_error,
"Ifpack2::BlockRelaxation::apply: " 396 "isComputed() must be true prior to calling apply.");
397 TEUCHOS_TEST_FOR_EXCEPTION(
398 X.getNumVectors () != Y.getNumVectors (), std::invalid_argument,
399 "Ifpack2::BlockRelaxation::apply: X.getNumVectors() = " 400 << X.getNumVectors () <<
" != Y.getNumVectors() = " 401 << Y.getNumVectors () <<
".");
402 TEUCHOS_TEST_FOR_EXCEPTION(
403 mode != Teuchos::NO_TRANS, std::logic_error,
"Ifpack2::BlockRelaxation::" 404 "apply: This method currently only implements the case mode == Teuchos::" 405 "NO_TRANS. Transposed modes are not currently supported.");
406 TEUCHOS_TEST_FOR_EXCEPTION(
407 alpha != Teuchos::ScalarTraits<scalar_type>::one (), std::logic_error,
408 "Ifpack2::BlockRelaxation::apply: This method currently only implements " 409 "the case alpha == 1. You specified alpha = " << alpha <<
".");
410 TEUCHOS_TEST_FOR_EXCEPTION(
411 beta != Teuchos::ScalarTraits<scalar_type>::zero (), std::logic_error,
412 "Ifpack2::BlockRelaxation::apply: This method currently only implements " 413 "the case beta == 0. You specified beta = " << beta <<
".");
419 Teuchos::RCP<const MV> X_copy;
421 auto X_lcl_host = X.template getLocalView<Kokkos::HostSpace> ();
422 auto Y_lcl_host = Y.template getLocalView<Kokkos::HostSpace> ();
423 if (X_lcl_host.ptr_on_device () == Y_lcl_host.ptr_on_device ()) {
424 X_copy = rcp (
new MV (X, Teuchos::Copy));
426 X_copy = rcpFromRef (X);
430 if (ZeroStartingSolution_) {
431 Y.putScalar (STS::zero ());
436 case Ifpack2::Details::JACOBI:
437 ApplyInverseJacobi(*X_copy,Y);
439 case Ifpack2::Details::GS:
440 ApplyInverseGS(*X_copy,Y);
442 case Ifpack2::Details::SGS:
443 ApplyInverseSGS(*X_copy,Y);
446 TEUCHOS_TEST_FOR_EXCEPTION
447 (
true, std::logic_error,
"Ifpack2::BlockRelaxation::apply: Invalid " 448 "PrecType_ enum value " << PrecType_ <<
". Valid values are Ifpack2::" 449 "Details::JACOBI = " << Ifpack2::Details::JACOBI <<
", Ifpack2::Details" 450 "::GS = " << Ifpack2::Details::GS <<
", and Ifpack2::Details::SGS = " 451 << Ifpack2::Details::SGS <<
". Please report this bug to the Ifpack2 " 457 ApplyTime_ += Time_->totalElapsedTime();
460 template<
class MatrixType,
class ContainerType>
463 applyMat (
const Tpetra::MultiVector<
typename MatrixType::scalar_type,
464 typename MatrixType::local_ordinal_type,
465 typename MatrixType::global_ordinal_type,
466 typename MatrixType::node_type>& X,
467 Tpetra::MultiVector<
typename MatrixType::scalar_type,
468 typename MatrixType::local_ordinal_type,
469 typename MatrixType::global_ordinal_type,
470 typename MatrixType::node_type>& Y,
471 Teuchos::ETransp mode)
const 473 A_->apply (X, Y, mode);
476 template<
class MatrixType,
class ContainerType>
482 typedef Tpetra::RowGraph<local_ordinal_type, global_ordinal_type, node_type>
485 TEUCHOS_TEST_FOR_EXCEPTION
486 (A_.is_null (), std::runtime_error,
"Ifpack2::BlockRelaxation::initialize: " 487 "The matrix is null. You must call setMatrix() with a nonnull matrix " 488 "before you may call this method.");
491 Teuchos::RCP<const block_crs_matrix_type> A_bcrs =
492 Teuchos::rcp_dynamic_cast<
const block_crs_matrix_type> (A_);
493 hasBlockCrsMatrix_ = !A_bcrs.is_null();
494 if (A_bcrs.is_null ()) {
495 hasBlockCrsMatrix_ =
false;
498 hasBlockCrsMatrix_ =
true;
501 IsInitialized_ =
false;
504 NumLocalRows_ = A_->getNodeNumRows ();
505 NumGlobalRows_ = A_->getGlobalNumRows ();
506 NumGlobalNonzeros_ = A_->getGlobalNumEntries ();
511 Partitioner_ = Teuchos::null;
513 if (PartitionerType_ ==
"linear") {
516 }
else if (PartitionerType_ ==
"line") {
519 }
else if (PartitionerType_ ==
"user") {
525 TEUCHOS_TEST_FOR_EXCEPTION
526 (
true, std::logic_error,
"Ifpack2::BlockRelaxation::initialize: Unknown " 527 "partitioner type " << PartitionerType_ <<
". Valid values are " 528 "\"linear\", \"line\", and \"user\".");
532 Partitioner_->setParameters (List_);
533 Partitioner_->compute ();
536 NumLocalBlocks_ = Partitioner_->numLocalParts ();
541 if (A_->getComm()->getSize() != 1) {
549 InitializeTime_ += Time_->totalElapsedTime ();
550 IsInitialized_ =
true;
554 template<
class MatrixType,
class ContainerType>
564 using Teuchos::Array;
565 using Teuchos::ArrayView;
573 ExtractSubmatrices ();
577 TEUCHOS_TEST_FOR_EXCEPTION
578 (PrecType_ == Ifpack2::Details::JACOBI && OverlapLevel_ > 0, std::runtime_error,
579 "Ifpack2::BlockRelaxation::computeBlockCrs: " 580 "We do not support overlapped Jacobi yet for Tpetra::BlockCrsMatrix. Sorry!");
584 ComputeTime_ += Time_->totalElapsedTime();
589 template<
class MatrixType,
class ContainerType>
600 TEUCHOS_TEST_FOR_EXCEPTION
601 (A_.is_null (), std::runtime_error,
"Ifpack2::BlockRelaxation::compute: " 602 "The matrix is null. You must call setMatrix() with a nonnull matrix, " 603 "then call initialize(), before you may call this method.");
607 TEUCHOS_TEST_FOR_EXCEPTION
608 (NumSweeps_ < 0, std::logic_error,
"Ifpack2::BlockRelaxation::compute: " 609 "NumSweeps_ = " << NumSweeps_ <<
" < 0.");
615 if (hasBlockCrsMatrix_) {
626 ExtractSubmatrices ();
630 if (PrecType_ == Ifpack2::Details::JACOBI && OverlapLevel_ > 0) {
632 W_ = rcp (
new vector_type (A_->getRowMap ()));
633 W_->putScalar (STS::zero ());
634 Teuchos::ArrayRCP<scalar_type > w_ptr = W_->getDataNonConst(0);
636 for (local_ordinal_type i = 0 ; i < NumLocalBlocks_ ; ++i) {
637 for (
size_t j = 0 ; j < Partitioner_->numRowsInPart(i) ; ++j) {
640 int LID = (*Partitioner_)(i,j);
641 w_ptr[LID]+= STS::one();
644 W_->reciprocal (*W_);
648 ComputeTime_ += Time_->totalElapsedTime();
652 template<
class MatrixType,
class ContainerType>
657 TEUCHOS_TEST_FOR_EXCEPTION
658 (Partitioner_.is_null (), std::runtime_error,
"Ifpack2::BlockRelaxation::" 659 "ExtractSubmatrices: Partitioner object is null.");
661 NumLocalBlocks_ = Partitioner_->numLocalParts ();
662 std::string containerType = ContainerType::getName ();
663 if (containerType ==
"Generic") {
667 containerType = containerType_;
670 Teuchos::Array<Teuchos::Array<local_ordinal_type> > localRows(NumLocalBlocks_);
672 const size_t numRows = Partitioner_->numRowsInPart (i);
674 localRows[i].resize(numRows);
676 for (
size_t j = 0; j < numRows; ++j) {
677 localRows[i][j] = (*Partitioner_) (i,j);
681 (Details::createContainer<row_matrix_type> (containerType, A_, localRows, Importer_,
682 OverlapLevel_, DampingFactor_));
683 Container_->setParameters(List_);
684 Container_->initialize();
685 Container_->compute();
688 template<
class MatrixType,
class ContainerType>
693 const size_t NumVectors = X.getNumVectors ();
694 typename ContainerType::HostView XView = X.template getLocalView<Kokkos::HostSpace>();
695 typename ContainerType::HostView YView = Y.template getLocalView<Kokkos::HostSpace>();
696 MV AY (Y.getMap (), NumVectors);
698 typename ContainerType::HostView AYView = AY.template getLocalView<Kokkos::HostSpace>();
700 int starting_iteration = 0;
701 if (OverlapLevel_ > 0)
704 typename ContainerType::HostView WView = W_->template getLocalView<Kokkos::HostSpace>();
705 if(ZeroStartingSolution_) {
706 Container_->DoOverlappingJacobi(XView, YView, WView, X.getStride());
707 starting_iteration = 1;
710 for(
int j = starting_iteration; j < NumSweeps_; j++)
713 AY.update (ONE, X, -ONE);
714 Container_->DoOverlappingJacobi (AYView, YView, WView, X.getStride());
720 if(ZeroStartingSolution_)
722 Container_->DoJacobi (XView, YView, X.getStride());
723 starting_iteration = 1;
726 for(
int j = starting_iteration; j < NumSweeps_; j++)
729 AY.update (ONE, X, -ONE);
730 Container_->DoJacobi (AYView, YView, X.getStride());
735 template<
class MatrixType,
class ContainerType>
742 size_t numVecs = X.getNumVectors();
744 typename ContainerType::HostView XView = X.template getLocalView<Kokkos::HostSpace>();
745 typename ContainerType::HostView YView = Y.template getLocalView<Kokkos::HostSpace>();
748 bool deleteY2 =
false;
751 Y2 = ptr(
new MV(Importer_->getTargetMap(), numVecs));
758 for(
int j = 0; j < NumSweeps_; ++j)
761 Y2->doImport(Y, *Importer_, Tpetra::INSERT);
762 typename ContainerType::HostView Y2View = Y2->template getLocalView<Kokkos::HostSpace>();
763 Container_->DoGaussSeidel(XView, YView, Y2View, X.getStride());
768 typename ContainerType::HostView Y2View = Y2->template getLocalView<Kokkos::HostSpace>();
769 for(
int j = 0; j < NumSweeps_; ++j)
771 Container_->DoGaussSeidel(XView, YView, Y2View, X.getStride());
778 template<
class MatrixType,
class ContainerType>
786 typename ContainerType::HostView XView = X.template getLocalView<Kokkos::HostSpace>();
787 typename ContainerType::HostView YView = Y.template getLocalView<Kokkos::HostSpace>();
790 bool deleteY2 =
false;
793 Y2 = ptr(
new MV(Importer_->getTargetMap(), X.getNumVectors()));
800 for(
int j = 0; j < NumSweeps_; ++j)
803 Y2->doImport(Y, *Importer_, Tpetra::INSERT);
804 typename ContainerType::HostView Y2View = Y2->template getLocalView<Kokkos::HostSpace>();
805 Container_->DoSGS(XView, YView, Y2View, X.getStride());
810 typename ContainerType::HostView Y2View = Y2->template getLocalView<Kokkos::HostSpace>();
811 for(
int j = 0; j < NumSweeps_; ++j)
813 Container_->DoSGS(XView, YView, Y2View, X.getStride());
820 template<
class MatrixType,
class ContainerType>
826 using Teuchos::ArrayView;
827 using Teuchos::Array;
829 using Teuchos::rcp_dynamic_cast;
832 if(hasBlockCrsMatrix_)
834 const RCP<const block_crs_matrix_type> bcrs =
835 rcp_dynamic_cast<
const block_crs_matrix_type>(A_);
836 int bs_ = bcrs->getBlockSize();
837 RCP<const map_type> oldDomainMap = A_->getDomainMap();
838 RCP<const map_type> oldColMap = A_->getColMap();
841 global_size_t numGlobalElements = oldColMap->getGlobalNumElements() * bs_;
843 RCP<const Comm<int>> comm = oldColMap->getComm();
844 ArrayView<const global_ordinal_type> oldColElements = oldColMap->getNodeElementList();
845 Array<global_ordinal_type> newColElements(bs_ * oldColElements.size());
846 for(
int i = 0; i < oldColElements.size(); i++)
848 for(
int j = 0; j < bs_; j++)
849 newColElements[i * bs_ + j] = oldColElements[i] * bs_ + j;
851 RCP<map_type> colMap(
new map_type(numGlobalElements, newColElements, indexBase, comm));
853 Importer_ = rcp(
new import_type(oldDomainMap, colMap));
855 else if(!A_.is_null())
857 Importer_ = A_->getGraph()->getImporter();
858 if(Importer_.is_null())
859 Importer_ = rcp(
new import_type(A_->getDomainMap(), A_->getColMap()));
865 template<
class MatrixType,
class ContainerType>
870 std::ostringstream out;
875 out <<
"\"Ifpack2::BlockRelaxation\": {";
876 if (this->getObjectLabel () !=
"") {
877 out <<
"Label: \"" << this->getObjectLabel () <<
"\", ";
879 out <<
"Initialized: " << (
isInitialized () ?
"true" :
"false") <<
", ";
880 out <<
"Computed: " << (
isComputed () ?
"true" :
"false") <<
", ";
882 out <<
"Matrix: null, ";
885 out <<
"Matrix: not null" 886 <<
", Global matrix dimensions: [" 887 << A_->getGlobalNumRows () <<
", " << A_->getGlobalNumCols () <<
"], ";
892 out <<
"\"relaxation: type\": ";
893 if (PrecType_ == Ifpack2::Details::JACOBI) {
894 out <<
"Block Jacobi";
895 }
else if (PrecType_ == Ifpack2::Details::GS) {
896 out <<
"Block Gauss-Seidel";
897 }
else if (PrecType_ == Ifpack2::Details::SGS) {
898 out <<
"Block Symmetric Gauss-Seidel";
903 out <<
", overlap: " << OverlapLevel_;
905 out <<
", " <<
"sweeps: " << NumSweeps_ <<
", " 906 <<
"damping factor: " << DampingFactor_ <<
", ";
908 std::string containerType = ContainerType::getName();
909 out <<
"block container: " << ((containerType ==
"Generic") ? containerType_ : containerType);
915 template<
class MatrixType,
class ContainerType>
919 const Teuchos::EVerbosityLevel verbLevel)
const 923 using Teuchos::TypeNameTraits;
924 using Teuchos::VERB_DEFAULT;
925 using Teuchos::VERB_NONE;
926 using Teuchos::VERB_LOW;
927 using Teuchos::VERB_MEDIUM;
928 using Teuchos::VERB_HIGH;
929 using Teuchos::VERB_EXTREME;
931 Teuchos::EVerbosityLevel vl = verbLevel;
932 if (vl == VERB_DEFAULT) vl = VERB_LOW;
933 const int myImageID = A_->getComm()->getRank();
936 Teuchos::OSTab tab (out);
943 if (vl != VERB_NONE && myImageID == 0) {
944 out <<
"Ifpack2::BlockRelaxation<" 945 << TypeNameTraits<MatrixType>::name () <<
", " 946 << TypeNameTraits<ContainerType>::name () <<
" >:";
947 Teuchos::OSTab tab1 (out);
949 if (this->getObjectLabel () !=
"") {
950 out <<
"label: \"" << this->getObjectLabel () <<
"\"" << endl;
952 out <<
"initialized: " << (
isInitialized () ?
"true" :
"false") << endl
953 <<
"computed: " << (
isComputed () ?
"true" :
"false") << endl;
955 std::string precType;
956 if (PrecType_ == Ifpack2::Details::JACOBI) {
957 precType =
"Block Jacobi";
958 }
else if (PrecType_ == Ifpack2::Details::GS) {
959 precType =
"Block Gauss-Seidel";
960 }
else if (PrecType_ == Ifpack2::Details::SGS) {
961 precType =
"Block Symmetric Gauss-Seidel";
963 out <<
"type: " << precType << endl
964 <<
"global number of rows: " << A_->getGlobalNumRows () << endl
965 <<
"global number of columns: " << A_->getGlobalNumCols () << endl
966 <<
"number of sweeps: " << NumSweeps_ << endl
967 <<
"damping factor: " << DampingFactor_ << endl
968 <<
"backwards mode: " 969 << ((PrecType_ == Ifpack2::Details::GS && DoBackwardGS_) ?
"true" :
"false")
971 <<
"zero starting solution: " 972 << (ZeroStartingSolution_ ?
"true" :
"false") << endl;
990 #ifdef HAVE_IFPACK2_EXPLICIT_INSTANTIATION 992 #define IFPACK2_BLOCKRELAXATION_INSTANT(S,LO,GO,N) \ 994 class Ifpack2::BlockRelaxation< \ 995 Tpetra::RowMatrix<S, LO, GO, N>, \ 996 Ifpack2::Container<Tpetra::RowMatrix<S, LO, GO, N> > >; 998 #endif // HAVE_IFPACK2_EXPLICIT_INSTANTIATION 1000 #endif // IFPACK2_BLOCKRELAXATION_DEF_HPP Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
The communicator over which the input matrix is distributed.
Definition: Ifpack2_BlockRelaxation_def.hpp:258
Ifpack2::BlockRelaxation class declaration.
double getApplyTime() const
Returns the time spent in apply().
Definition: Ifpack2_BlockRelaxation_def.hpp:353
size_t getNodeSmootherComplexity() const
Get a rough estimate of cost per iteration.
Definition: Ifpack2_BlockRelaxation_def.hpp:360
MatrixType::global_ordinal_type global_ordinal_type
The type of global indices in the input MatrixType.
Definition: Ifpack2_BlockRelaxation_decl.hpp:104
double getComputeTime() const
Returns the time spent in compute().
Definition: Ifpack2_BlockRelaxation_def.hpp:345
int getNumInitialize() const
Returns the number of calls to initialize().
Definition: Ifpack2_BlockRelaxation_def.hpp:314
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:918
double getInitializeTime() const
Returns the time spent in initialize().
Definition: Ifpack2_BlockRelaxation_def.hpp:337
Teuchos::RCP< const row_matrix_type > getMatrix() const
The input matrix of this preconditioner's constructor.
Definition: Ifpack2_BlockRelaxation_def.hpp:272
Teuchos::RCP< const map_type > getDomainMap() const
Returns the Tpetra::Map object associated with the domain of this operator.
Definition: Ifpack2_BlockRelaxation_def.hpp:281
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
void apply(const MV &X, MV &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:377
std::string description() const
A one-line description of this object.
Definition: Ifpack2_BlockRelaxation_def.hpp:868
Teuchos::RCP< const map_type > getRangeMap() const
Returns the Tpetra::Map object associated with the range of this operator.
Definition: Ifpack2_BlockRelaxation_def.hpp:295
void setParameters(const Teuchos::ParameterList ¶ms)
Sets all the parameters for the preconditioner.
Definition: Ifpack2_BlockRelaxation_def.hpp:122
bool isInitialized() const
Returns true if the preconditioner has been successfully initialized.
Definition: Ifpack2_BlockRelaxation_decl.hpp:216
void compute()
compute the preconditioner for the specified matrix, diagonal perturbation thresholds and relaxation ...
Definition: Ifpack2_BlockRelaxation_def.hpp:592
Block relaxation preconditioners (or smoothers) for Tpetra::RowMatrix and Tpetra::CrsMatrix sparse ma...
Definition: Ifpack2_BlockRelaxation_decl.hpp:83
Ifpack2 implementation details.
Declaration of a user-defined partitioner in which the user can define a partition of the graph...
void applyMat(const MV &X, MV &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS) const
Applies the matrix to a Tpetra::MultiVector.
Definition: Ifpack2_BlockRelaxation_def.hpp:463
Teuchos::ScalarTraits< scalar_type >::magnitudeType magnitude_type
The type of the magnitude (absolute value) of a matrix entry.
Definition: Ifpack2_BlockRelaxation_decl.hpp:109
Tpetra::Import< local_ordinal_type, global_ordinal_type, node_type > import_type
Tpetra::Importer specialization for use with MatrixType and compatible MultiVectors.
Definition: Ifpack2_BlockRelaxation_decl.hpp:115
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:116
Partition in which the user can define a nonoverlapping partition of the graph in any way they choose...
Definition: Ifpack2_Details_UserPartitioner_decl.hpp:69
void initialize()
Initialize.
Definition: Ifpack2_BlockRelaxation_def.hpp:479
bool isComputed() const
Return true if compute() has been called.
Definition: Ifpack2_BlockRelaxation_decl.hpp:226
MatrixType::node_type node_type
Node type of the input MatrixType.
Definition: Ifpack2_BlockRelaxation_decl.hpp:106
MatrixType::local_ordinal_type local_ordinal_type
The type of local indices in the input MatrixType.
Definition: Ifpack2_BlockRelaxation_decl.hpp:101
int getNumCompute() const
Returns the number of calls to compute().
Definition: Ifpack2_BlockRelaxation_def.hpp:321
Definition: Ifpack2_Container.hpp:761
int getNumApply() const
Returns the number of calls to apply().
Definition: Ifpack2_BlockRelaxation_def.hpp:329
MatrixType::scalar_type scalar_type
The type of the entries of the input MatrixType.
Definition: Ifpack2_BlockRelaxation_decl.hpp:98
Interface for creating and solving a local linear problem.
Definition: Ifpack2_Container.hpp:114
Preconditioners and smoothers for Tpetra sparse matrices.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:72
void getValidParameters(Teuchos::ParameterList ¶ms)
Fills a list which contains all the parameters possibly used by Ifpack2.
Definition: Ifpack2_Parameters.cpp:50
Ifpack2::LinePartitioner: A class to define partitions into a set of lines.
Definition: Ifpack2_LinePartitioner_decl.hpp:77
A class to define linear partitions.
Definition: Ifpack2_LinearPartitioner_decl.hpp:60
BlockRelaxation(const Teuchos::RCP< const row_matrix_type > &Matrix)
Constructor.
Definition: Ifpack2_BlockRelaxation_def.hpp:83