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>
60 IsInitialized_ =
false;
62 Partitioner_ = Teuchos::null;
66 IsParallel_ = (A->getRowMap ()->getComm ()->getSize () != 1);
68 Teuchos::rcp_dynamic_cast<
const block_crs_matrix_type> (A);
69 hasBlockCrsMatrix_ = !A_bcrs.
is_null();
71 if (! Container_.is_null ()) {
74 Container_->clearBlocks();
83 template<
class MatrixType,
class ContainerType>
87 Time_ (Teuchos::
rcp (new Teuchos::Time (
"Ifpack2::BlockRelaxation"))),
88 Container_ (Teuchos::null),
89 Partitioner_ (Teuchos::null),
90 PartitionerType_ (
"linear"),
93 containerType_ (
"TriDi"),
94 PrecType_ (Ifpack2::Details::JACOBI),
95 ZeroStartingSolution_ (true),
96 hasBlockCrsMatrix_ (false),
97 DoBackwardGS_ (false),
99 DampingFactor_ (
STS::one ()),
100 IsInitialized_ (false),
105 InitializeTime_ (0.0),
109 NumGlobalNonzeros_ (0),
111 Importer_ (Teuchos::null)
116 template<
class MatrixType,
class ContainerType>
121 template<
class MatrixType,
class ContainerType>
128 validParams->
set(
"relaxation: container",
"TriDi");
129 validParams->
set(
"relaxation: backward mode",
false);
130 validParams->
set(
"relaxation: type",
"Jacobi");
131 validParams->
set(
"relaxation: sweeps", 1);
132 validParams->
set(
"relaxation: damping factor", STS::one());
133 validParams->
set(
"relaxation: zero starting solution",
true);
134 validParams->
set(
"block relaxation: decouple dofs",
false);
135 validParams->
set(
"schwarz: compute condest",
false);
136 validParams->
set(
"schwarz: combine mode",
"ZERO");
137 validParams->
set(
"schwarz: use reordering",
true);
138 validParams->
set(
"schwarz: filter singletons",
false);
139 validParams->
set(
"schwarz: overlap level", 0);
140 validParams->
set(
"partitioner: type",
"greedy");
141 validParams->
set(
"partitioner: local parts", 1);
142 validParams->
set(
"partitioner: overlap", 0);
144 validParams->
set(
"partitioner: parts", tmp0);
145 validParams->
set(
"partitioner: maintain sparsity",
false);
146 validParams->
set(
"fact: ilut level-of-fill", 1.0);
147 validParams->
set(
"fact: absolute threshold", 0.0);
148 validParams->
set(
"fact: relative threshold", 1.0);
149 validParams->
set(
"fact: relax value", 0.0);
152 validParams->
set(
"Amesos2",dummyList);
154 validParams->
set(
"Amesos2 solver name",
"KLU2");
157 validParams->
set(
"partitioner: map", tmp);
159 validParams->
set(
"partitioner: line detection threshold", 0.0);
160 validParams->
set(
"partitioner: PDE equations", 1);
162 typename MatrixType::local_ordinal_type,
163 typename MatrixType::global_ordinal_type,
164 typename MatrixType::node_type> > dummy;
165 validParams->
set(
"partitioner: coordinates",dummy);
170 template<
class MatrixType,
class ContainerType>
186 containerType_ = List.
get<std::string> (
"relaxation: container");
188 if(containerType_ ==
"Tridiagonal") {
189 containerType_ =
"TriDi";
191 if(containerType_ ==
"Block Tridiagonal") {
192 containerType_ =
"BlockTriDi";
197 const std::string relaxType = List.
get<std::string> (
"relaxation: type");
199 if (relaxType ==
"Jacobi") {
200 PrecType_ = Ifpack2::Details::JACOBI;
202 else if (relaxType ==
"MT Split Jacobi") {
203 PrecType_ = Ifpack2::Details::MTSPLITJACOBI;
205 else if (relaxType ==
"Gauss-Seidel") {
206 PrecType_ = Ifpack2::Details::GS;
208 else if (relaxType ==
"Symmetric Gauss-Seidel") {
209 PrecType_ = Ifpack2::Details::SGS;
213 (
true, std::invalid_argument,
"Ifpack2::BlockRelaxation::"
214 "setParameters: Invalid parameter value \"" << relaxType
215 <<
"\" for parameter \"relaxation: type\".");
220 NumSweeps_ = List.
get<
int> (
"relaxation: sweeps");
226 if (List.
isParameter (
"relaxation: damping factor")) {
227 if (List.
isType<
double> (
"relaxation: damping factor")) {
228 const double dampingFactor =
229 List.
get<
double> (
"relaxation: damping factor");
230 DampingFactor_ =
static_cast<scalar_type> (dampingFactor);
233 DampingFactor_ = List.
get<
scalar_type> (
"relaxation: damping factor");
238 DampingFactor_ =
static_cast<scalar_type> (dampingFactor);
242 (
true, std::invalid_argument,
"Ifpack2::BlockRelaxation::"
243 "setParameters: Parameter \"relaxation: damping factor\" "
244 "has the wrong type.");
248 if (List.
isParameter (
"relaxation: zero starting solution")) {
249 ZeroStartingSolution_ = List.
get<
bool> (
"relaxation: zero starting solution");
252 if (List.
isParameter (
"relaxation: backward mode")) {
253 DoBackwardGS_ = List.
get<
bool> (
"relaxation: backward mode");
257 PartitionerType_ = List.
get<std::string> (
"partitioner: type");
262 if (List.
isParameter (
"partitioner: local parts")) {
266 else if (! std::is_same<int, local_ordinal_type>::value &&
267 List.
isType<
int> (
"partitioner: local parts")) {
268 NumLocalBlocks_ = List.
get<
int> (
"partitioner: local parts");
272 (
true, std::invalid_argument,
"Ifpack2::BlockRelaxation::"
273 "setParameters: Parameter \"partitioner: local parts\" "
274 "has the wrong type.");
278 if (List.
isParameter (
"partitioner: overlap level")) {
279 if (List.
isType<
int> (
"partitioner: overlap level")) {
280 OverlapLevel_ = List.
get<
int> (
"partitioner: overlap level");
282 else if (! std::is_same<int, local_ordinal_type>::value &&
288 (
true, std::invalid_argument,
"Ifpack2::BlockRelaxation::"
289 "setParameters: Parameter \"partitioner: overlap level\" "
290 "has the wrong type.");
294 std::string defaultContainer =
"TriDi";
301 if (PrecType_ != Ifpack2::Details::JACOBI) {
304 if (NumLocalBlocks_ < static_cast<local_ordinal_type> (0)) {
305 NumLocalBlocks_ = A_->getNodeNumRows() / (-NumLocalBlocks_);
309 if(List.
isParameter(
"block relaxation: decouple dofs"))
310 decouple_ = List.
get<
bool>(
"block relaxation: decouple dofs");
316 DoBackwardGS_, std::runtime_error,
317 "Ifpack2::BlockRelaxation:setParameters: Setting the \"relaxation: "
318 "backward mode\" parameter to true is not yet supported.");
325 template<
class MatrixType,
class ContainerType>
330 (A_.is_null (), std::runtime_error,
"Ifpack2::BlockRelaxation::getComm: "
331 "The matrix is null. You must call setMatrix() with a nonnull matrix "
332 "before you may call this method.");
333 return A_->getComm ();
336 template<
class MatrixType,
class ContainerType>
337 Teuchos::RCP<
const Tpetra::RowMatrix<
typename MatrixType::scalar_type,
338 typename MatrixType::local_ordinal_type,
339 typename MatrixType::global_ordinal_type,
340 typename MatrixType::node_type> >
345 template<
class MatrixType,
class ContainerType>
346 Teuchos::RCP<
const Tpetra::Map<
typename MatrixType::local_ordinal_type,
347 typename MatrixType::global_ordinal_type,
348 typename MatrixType::node_type> >
353 (A_.is_null (), std::runtime_error,
"Ifpack2::BlockRelaxation::"
354 "getDomainMap: The matrix is null. You must call setMatrix() with a "
355 "nonnull matrix before you may call this method.");
356 return A_->getDomainMap ();
359 template<
class MatrixType,
class ContainerType>
360 Teuchos::RCP<
const Tpetra::Map<
typename MatrixType::local_ordinal_type,
361 typename MatrixType::global_ordinal_type,
362 typename MatrixType::node_type> >
367 (A_.is_null (), std::runtime_error,
"Ifpack2::BlockRelaxation::"
368 "getRangeMap: The matrix is null. You must call setMatrix() with a "
369 "nonnull matrix before you may call this method.");
370 return A_->getRangeMap ();
373 template<
class MatrixType,
class ContainerType>
380 template<
class MatrixType,
class ContainerType>
384 return NumInitialize_;
387 template<
class MatrixType,
class ContainerType>
395 template<
class MatrixType,
class ContainerType>
403 template<
class MatrixType,
class ContainerType>
408 return InitializeTime_;
411 template<
class MatrixType,
class ContainerType>
419 template<
class MatrixType,
class ContainerType>
428 template<
class MatrixType,
class ContainerType>
431 A_.is_null (), std::runtime_error,
"Ifpack2::BlockRelaxation::getNodeSmootherComplexity: "
432 "The input matrix A is null. Please call setMatrix() with a nonnull "
433 "input matrix, then call compute(), before calling this method.");
436 size_t block_nnz = 0;
438 block_nnz += Partitioner_->numRowsInPart(i) *Partitioner_->numRowsInPart(i);
440 return block_nnz + A_->getNodeNumEntries();
443 template<
class MatrixType,
class ContainerType>
446 apply (
const Tpetra::MultiVector<
typename MatrixType::scalar_type,
447 typename MatrixType::local_ordinal_type,
448 typename MatrixType::global_ordinal_type,
449 typename MatrixType::node_type>& X,
450 Tpetra::MultiVector<
typename MatrixType::scalar_type,
451 typename MatrixType::local_ordinal_type,
452 typename MatrixType::global_ordinal_type,
453 typename MatrixType::node_type>& Y,
459 (A_.is_null (), std::runtime_error,
"Ifpack2::BlockRelaxation::apply: "
460 "The matrix is null. You must call setMatrix() with a nonnull matrix, "
461 "then call initialize() and compute() (in that order), before you may "
462 "call this method.");
464 ! isComputed (), std::runtime_error,
"Ifpack2::BlockRelaxation::apply: "
465 "isComputed() must be true prior to calling apply.");
466 TEUCHOS_TEST_FOR_EXCEPTION(
467 X.getNumVectors () != Y.getNumVectors (), std::invalid_argument,
468 "Ifpack2::BlockRelaxation::apply: X.getNumVectors() = "
469 << X.getNumVectors () <<
" != Y.getNumVectors() = "
470 << Y.getNumVectors () <<
".");
471 TEUCHOS_TEST_FOR_EXCEPTION(
473 "apply: This method currently only implements the case mode == Teuchos::"
474 "NO_TRANS. Transposed modes are not currently supported.");
475 TEUCHOS_TEST_FOR_EXCEPTION(
477 "Ifpack2::BlockRelaxation::apply: This method currently only implements "
478 "the case alpha == 1. You specified alpha = " << alpha <<
".");
479 TEUCHOS_TEST_FOR_EXCEPTION(
481 "Ifpack2::BlockRelaxation::apply: This method currently only implements "
482 "the case beta == 0. You specified beta = " << beta <<
".");
490 auto X_lcl_host = X.getLocalViewHost ();
491 auto Y_lcl_host = Y.getLocalViewHost ();
493 if (X_lcl_host.data () == Y_lcl_host.data ()) {
496 X_copy = rcpFromRef (X);
500 if (ZeroStartingSolution_) {
501 Y.putScalar (STS::zero ());
506 case Ifpack2::Details::JACOBI:
507 ApplyInverseJacobi(*X_copy,Y);
509 case Ifpack2::Details::GS:
510 ApplyInverseGS(*X_copy,Y);
512 case Ifpack2::Details::SGS:
513 ApplyInverseSGS(*X_copy,Y);
515 case Ifpack2::Details::MTSPLITJACOBI:
517 Container_->applyInverseJacobi(*X_copy, Y, DampingFactor_, ZeroStartingSolution_, NumSweeps_);
520 TEUCHOS_TEST_FOR_EXCEPTION
521 (
true, std::logic_error,
"Ifpack2::BlockRelaxation::apply: Invalid "
522 "PrecType_ enum value " << PrecType_ <<
". Valid values are Ifpack2::"
523 "Details::JACOBI = " << Ifpack2::Details::JACOBI <<
", Ifpack2::Details"
524 "::GS = " << Ifpack2::Details::GS <<
", and Ifpack2::Details::SGS = "
525 << Ifpack2::Details::SGS <<
". Please report this bug to the Ifpack2 "
531 ApplyTime_ += Time_->totalElapsedTime();
534 template<
class MatrixType,
class ContainerType>
537 applyMat (
const Tpetra::MultiVector<
typename MatrixType::scalar_type,
538 typename MatrixType::local_ordinal_type,
539 typename MatrixType::global_ordinal_type,
540 typename MatrixType::node_type>& X,
541 Tpetra::MultiVector<
typename MatrixType::scalar_type,
542 typename MatrixType::local_ordinal_type,
543 typename MatrixType::global_ordinal_type,
544 typename MatrixType::node_type>& Y,
547 A_->apply (X, Y, mode);
550 template<
class MatrixType,
class ContainerType>
556 typedef Tpetra::RowGraph<local_ordinal_type, global_ordinal_type, node_type>
560 (A_.is_null (), std::runtime_error,
"Ifpack2::BlockRelaxation::initialize: "
561 "The matrix is null. You must call setMatrix() with a nonnull matrix "
562 "before you may call this method.");
566 Teuchos::rcp_dynamic_cast<
const block_crs_matrix_type> (A_);
567 hasBlockCrsMatrix_ = !A_bcrs.
is_null();
568 if (A_bcrs.is_null ()) {
569 hasBlockCrsMatrix_ =
false;
572 hasBlockCrsMatrix_ =
true;
575 IsInitialized_ =
false;
578 NumLocalRows_ = A_->getNodeNumRows ();
579 NumGlobalRows_ = A_->getGlobalNumRows ();
580 NumGlobalNonzeros_ = A_->getGlobalNumEntries ();
585 Partitioner_ = Teuchos::null;
587 if (PartitionerType_ ==
"linear") {
590 }
else if (PartitionerType_ ==
"line") {
593 }
else if (PartitionerType_ ==
"user") {
600 (
true, std::logic_error,
"Ifpack2::BlockRelaxation::initialize: Unknown "
601 "partitioner type " << PartitionerType_ <<
". Valid values are "
602 "\"linear\", \"line\", and \"user\".");
606 Partitioner_->setParameters (List_);
607 Partitioner_->compute ();
610 NumLocalBlocks_ = Partitioner_->numLocalParts ();
615 if (A_->getComm()->getSize() != 1) {
624 (NumSweeps_ < 0, std::logic_error,
"Ifpack2::BlockRelaxation::initialize: "
625 "NumSweeps_ = " << NumSweeps_ <<
" < 0.");
628 ExtractSubmatricesStructure ();
632 if (PrecType_ == Ifpack2::Details::JACOBI && OverlapLevel_ > 0) {
634 (hasBlockCrsMatrix_, std::runtime_error,
635 "Ifpack2::BlockRelaxation::initialize: "
636 "We do not support overlapped Jacobi yet for Tpetra::BlockCrsMatrix. Sorry!");
639 W_ =
rcp (
new vector_type (A_->getRowMap ()));
640 W_->putScalar (STS::zero ());
644 for (
size_t j = 0 ; j < Partitioner_->numRowsInPart(i) ; ++j) {
646 w_ptr[LID] += STS::one();
649 W_->reciprocal (*W_);
654 InitializeTime_ += Time_->totalElapsedTime ();
655 IsInitialized_ =
true;
659 template<
class MatrixType,
class ContainerType>
667 (A_.is_null (), std::runtime_error,
"Ifpack2::BlockRelaxation::compute: "
668 "The matrix is null. You must call setMatrix() with a nonnull matrix, "
669 "then call initialize(), before you may call this method.");
671 if (! isInitialized ()) {
680 Container_->compute();
684 ComputeTime_ += Time_->totalElapsedTime();
688 template<
class MatrixType,
class ContainerType>
694 (Partitioner_.is_null (), std::runtime_error,
"Ifpack2::BlockRelaxation::"
695 "ExtractSubmatricesStructure: Partitioner object is null.");
697 std::string containerType = ContainerType::getName ();
698 if (containerType ==
"Generic") {
702 containerType = containerType_;
706 bool pointIndexed = decouple_ && hasBlockCrsMatrix_;
711 auto A_bcrs = Teuchos::rcp_dynamic_cast<
const block_crs_matrix_type>(A_);
712 local_ordinal_type dofs = hasBlockCrsMatrix_ ?
713 A_bcrs->getBlockSize() : List_.get<
int>(
"partitioner: PDE equations");
714 blockRows.
resize(NumLocalBlocks_ * dofs);
715 if(hasBlockCrsMatrix_)
717 for(local_ordinal_type i = 0; i < NumLocalBlocks_; i++)
719 size_t blockSize = Partitioner_->numRowsInPart(i);
722 for(local_ordinal_type j = 0; j < dofs; j++)
724 local_ordinal_type blockIndex = i * dofs + j;
725 blockRows[blockIndex].
resize(blockSize);
726 for(
size_t k = 0; k < blockSize; k++)
730 blockRows[blockIndex][k] = (*Partitioner_)(i, k) * dofs + j;
739 for(local_ordinal_type i = 0; i < NumLocalBlocks_; i++)
743 "Expected size of all blocks (partitions) to be divisible by MueLu dofs/node.");
744 size_t blockSize = Partitioner_->numRowsInPart(i) / dofs;
748 for(local_ordinal_type j = 0; j < dofs; j++)
750 local_ordinal_type blockIndex = i * dofs + j;
751 blockRows[blockIndex].
resize(blockSize);
752 for(
size_t k = 0; k < blockSize; k++)
754 blockRows[blockIndex][k] = (*Partitioner_)(i, k * dofs + j);
763 blockRows.
resize(NumLocalBlocks_);
764 for(local_ordinal_type i = 0; i < NumLocalBlocks_; ++i)
766 const size_t numRows = Partitioner_->numRowsInPart (i);
767 blockRows[i].
resize(numRows);
769 for (
size_t j = 0; j < numRows; ++j)
771 blockRows[i][j] = (*Partitioner_) (i,j);
777 Container_->setParameters(List_);
778 Container_->initialize();
781 template<
class MatrixType,
class ContainerType>
783 BlockRelaxation<MatrixType,ContainerType>::
784 ApplyInverseJacobi (
const MV& X, MV& Y)
const
786 const size_t NumVectors = X.getNumVectors ();
787 auto XView = X.getLocalViewHost ();
788 auto YView = Y.getLocalViewHost ();
790 MV AY (Y.getMap (), NumVectors);
792 auto AYView = AY.getLocalViewHost ();
795 int starting_iteration = 0;
796 if (OverlapLevel_ > 0)
799 auto WView = W_->getLocalViewHost ();
800 if(ZeroStartingSolution_) {
801 Container_->DoOverlappingJacobi(XView, YView, WView, DampingFactor_);
802 starting_iteration = 1;
804 const scalar_type ONE = STS::one();
805 for(
int j = starting_iteration; j < NumSweeps_; j++)
808 AY.update (ONE, X, -ONE);
809 Container_->DoOverlappingJacobi (AYView, YView, WView, DampingFactor_);
815 if(ZeroStartingSolution_)
817 Container_->DoJacobi (XView, YView, DampingFactor_);
818 starting_iteration = 1;
820 const scalar_type ONE = STS::one();
821 for(
int j = starting_iteration; j < NumSweeps_; j++)
824 AY.update (ONE, X, -ONE);
825 Container_->DoJacobi (AYView, YView, DampingFactor_);
830 template<
class MatrixType,
class ContainerType>
832 BlockRelaxation<MatrixType,ContainerType>::
833 ApplyInverseGS (
const MV& X, MV& Y)
const
837 size_t numVecs = X.getNumVectors();
839 auto XView = X.getLocalViewHost ();
840 auto YView = Y.getLocalViewHost ();
843 bool deleteY2 =
false;
846 Y2 = ptr(
new MV(Importer_->getTargetMap(), numVecs));
853 for(
int j = 0; j < NumSweeps_; ++j)
856 Y2->doImport(Y, *Importer_, Tpetra::INSERT);
857 auto Y2View = Y2->getLocalViewHost ();
858 Container_->DoGaussSeidel(XView, YView, Y2View, DampingFactor_);
863 auto Y2View = Y2->getLocalViewHost ();
864 for(
int j = 0; j < NumSweeps_; ++j)
866 Container_->DoGaussSeidel(XView, YView, Y2View, DampingFactor_);
873 template<
class MatrixType,
class ContainerType>
875 BlockRelaxation<MatrixType,ContainerType>::
876 ApplyInverseSGS (
const MV& X, MV& Y)
const
881 auto XView = X.getLocalViewHost ();
882 auto YView = Y.getLocalViewHost ();
885 bool deleteY2 =
false;
888 Y2 = ptr(
new MV(Importer_->getTargetMap(), X.getNumVectors()));
895 for(
int j = 0; j < NumSweeps_; ++j)
898 Y2->doImport(Y, *Importer_, Tpetra::INSERT);
899 auto Y2View = Y2->getLocalViewHost ();
900 Container_->DoSGS(XView, YView, Y2View, DampingFactor_);
905 auto Y2View = Y2->getLocalViewHost ();
906 for(
int j = 0; j < NumSweeps_; ++j)
908 Container_->DoSGS(XView, YView, Y2View, DampingFactor_);
915 template<
class MatrixType,
class ContainerType>
916 void BlockRelaxation<MatrixType,ContainerType>::computeImporter ()
const
924 using Teuchos::rcp_dynamic_cast;
927 if(hasBlockCrsMatrix_)
929 const RCP<const block_crs_matrix_type> bcrs =
930 rcp_dynamic_cast<
const block_crs_matrix_type>(A_);
931 int bs_ = bcrs->getBlockSize();
932 RCP<const map_type> oldDomainMap = A_->getDomainMap();
933 RCP<const map_type> oldColMap = A_->getColMap();
936 global_size_t numGlobalElements = oldColMap->getGlobalNumElements() * bs_;
937 global_ordinal_type indexBase = oldColMap->getIndexBase();
938 RCP<const Comm<int>> comm = oldColMap->getComm();
939 ArrayView<const global_ordinal_type> oldColElements = oldColMap->getNodeElementList();
940 Array<global_ordinal_type> newColElements(bs_ * oldColElements.size());
941 for(
int i = 0; i < oldColElements.size(); i++)
943 for(
int j = 0; j < bs_; j++)
944 newColElements[i * bs_ + j] = oldColElements[i] * bs_ + j;
946 RCP<map_type> colMap(
new map_type(numGlobalElements, newColElements, indexBase, comm));
948 Importer_ =
rcp(
new import_type(oldDomainMap, colMap));
950 else if(!A_.is_null())
952 Importer_ = A_->getGraph()->getImporter();
953 if(Importer_.is_null())
954 Importer_ =
rcp(
new import_type(A_->getDomainMap(), A_->getColMap()));
960 template<
class MatrixType,
class ContainerType>
965 std::ostringstream out;
970 out <<
"\"Ifpack2::BlockRelaxation\": {";
971 if (this->getObjectLabel () !=
"") {
972 out <<
"Label: \"" << this->getObjectLabel () <<
"\", ";
977 out <<
"Matrix: null, ";
982 out <<
"Global matrix dimensions: ["
983 << A_->getGlobalNumRows () <<
", " << A_->getGlobalNumCols () <<
"], ";
988 out <<
"\"relaxation: type\": ";
989 if (PrecType_ == Ifpack2::Details::JACOBI) {
990 out <<
"Block Jacobi";
991 }
else if (PrecType_ == Ifpack2::Details::GS) {
992 out <<
"Block Gauss-Seidel";
993 }
else if (PrecType_ == Ifpack2::Details::SGS) {
994 out <<
"Block Symmetric Gauss-Seidel";
999 int approx_rows_per_part = A_->getNodeNumRows()/Partitioner_->numLocalParts();
1000 out <<
", blocksize: "<<approx_rows_per_part;
1002 out <<
", overlap: " << OverlapLevel_;
1004 out <<
", " <<
"sweeps: " << NumSweeps_ <<
", "
1005 <<
"damping factor: " << DampingFactor_ <<
", ";
1007 std::string containerType = ContainerType::getName();
1008 out <<
"block container: " << ((containerType ==
"Generic") ? containerType_ : containerType);
1009 if(List_.isParameter(
"partitioner: PDE equations"))
1010 out <<
", dofs/node: "<<List_.get<
int>(
"partitioner: PDE equations");
1017 template<
class MatrixType,
class ContainerType>
1035 const int myImageID = A_->getComm()->getRank();
1045 if (vl !=
VERB_NONE && myImageID == 0) {
1046 out <<
"Ifpack2::BlockRelaxation<"
1047 << TypeNameTraits<MatrixType>::name () <<
", "
1048 << TypeNameTraits<ContainerType>::name () <<
" >:";
1051 if (this->getObjectLabel () !=
"") {
1052 out <<
"label: \"" << this->getObjectLabel () <<
"\"" << endl;
1054 out <<
"initialized: " << (isInitialized () ?
"true" :
"false") << endl
1055 <<
"computed: " << (isComputed () ?
"true" :
"false") << endl;
1057 std::string precType;
1058 if (PrecType_ == Ifpack2::Details::JACOBI) {
1059 precType =
"Block Jacobi";
1060 }
else if (PrecType_ == Ifpack2::Details::GS) {
1061 precType =
"Block Gauss-Seidel";
1062 }
else if (PrecType_ == Ifpack2::Details::SGS) {
1063 precType =
"Block Symmetric Gauss-Seidel";
1065 out <<
"type: " << precType << endl
1066 <<
"global number of rows: " << A_->getGlobalNumRows () << endl
1067 <<
"global number of columns: " << A_->getGlobalNumCols () << endl
1068 <<
"number of sweeps: " << NumSweeps_ << endl
1069 <<
"damping factor: " << DampingFactor_ << endl
1070 <<
"backwards mode: "
1071 << ((PrecType_ == Ifpack2::Details::GS && DoBackwardGS_) ?
"true" :
"false")
1073 <<
"zero starting solution: "
1074 << (ZeroStartingSolution_ ?
"true" :
"false") << endl;
1092 #ifdef HAVE_IFPACK2_EXPLICIT_INSTANTIATION
1094 #define IFPACK2_BLOCKRELAXATION_INSTANT(S,LO,GO,N) \
1096 class Ifpack2::BlockRelaxation< \
1097 Tpetra::RowMatrix<S, LO, GO, N>, \
1098 Ifpack2::Container<Tpetra::RowMatrix<S, LO, GO, N> > >;
1100 #endif // HAVE_IFPACK2_EXPLICIT_INSTANTIATION
1102 #endif // IFPACK2_BLOCKRELAXATION_DEF_HPP
Ifpack2::BlockRelaxation class declaration.
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
The communicator over which the input matrix is distributed.
Definition: Ifpack2_BlockRelaxation_def.hpp:327
ParameterList & disableRecursiveValidation()
std::string description() const
A one-line description of this object.
Definition: Ifpack2_BlockRelaxation_def.hpp:963
double getApplyTime() const
Returns the time spent in apply().
Definition: Ifpack2_BlockRelaxation_def.hpp:422
T & get(const std::string &name, T def_value)
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
int getNumApply() const
Returns the number of calls to apply().
Definition: Ifpack2_BlockRelaxation_def.hpp:398
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 map_type > getRangeMap() const
Returns the Tpetra::Map object associated with the range of this operator.
Definition: Ifpack2_BlockRelaxation_def.hpp:364
int getNumCompute() const
Returns the number of calls to compute().
Definition: Ifpack2_BlockRelaxation_def.hpp:390
void setParameters(const Teuchos::ParameterList ¶ms)
Sets all the parameters for the preconditioner.
Definition: Ifpack2_BlockRelaxation_def.hpp:173
void compute()
compute the preconditioner for the specified matrix, diagonal perturbation thresholds and relaxation ...
Definition: Ifpack2_BlockRelaxation_def.hpp:662
Block relaxation preconditioners (or smoothers) for Tpetra::RowMatrix and Tpetra::CrsMatrix sparse ma...
Definition: Ifpack2_BlockRelaxation_decl.hpp:83
double getInitializeTime() const
Returns the time spent in initialize().
Definition: Ifpack2_BlockRelaxation_def.hpp:406
Declaration of a user-defined partitioner in which the user can define a partition of the graph...
bool isParameter(const std::string &name) const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
double getComputeTime() const
Returns the time spent in compute().
Definition: Ifpack2_BlockRelaxation_def.hpp:414
size_t getNodeSmootherComplexity() const
Get a rough estimate of cost per iteration.
Definition: Ifpack2_BlockRelaxation_def.hpp:429
Teuchos::ScalarTraits< scalar_type >::magnitudeType magnitude_type
The type of the magnitude (absolute value) of a matrix entry.
Definition: Ifpack2_BlockRelaxation_decl.hpp:109
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:118
Teuchos::RCP< const map_type > getDomainMap() const
Returns the Tpetra::Map object associated with the domain of this operator.
Definition: Ifpack2_BlockRelaxation_def.hpp:350
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 resize(size_type new_size, const value_type &x=value_type())
int getNumInitialize() const
Returns the number of calls to initialize().
Definition: Ifpack2_BlockRelaxation_def.hpp:383
void initialize()
Initialize.
Definition: Ifpack2_BlockRelaxation_def.hpp:553
void validateParameters(ParameterList const &validParamList, int const depth=1000, EValidateUsed const validateUsed=VALIDATE_USED_ENABLED, EValidateDefaults const validateDefaults=VALIDATE_DEFAULTS_ENABLED) const
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:1020
MatrixType::local_ordinal_type local_ordinal_type
The type of local indices in the input MatrixType.
Definition: Ifpack2_BlockRelaxation_decl.hpp:101
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:537
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 set of local linear problems.
Definition: Ifpack2_Container_decl.hpp:112
bool isType(const std::string &name) const
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
static Teuchos::RCP< BaseContainer > build(std::string containerType, const Teuchos::RCP< const MatrixType > &A, const Teuchos::Array< Teuchos::Array< local_ordinal_type >> &partitions, const Teuchos::RCP< const import_type > importer, bool pointIndexed)
Build a specialization of Ifpack2::Container given a key that has been registered.
Definition: Ifpack2_ContainerFactory_def.hpp:89
Teuchos::RCP< const row_matrix_type > getMatrix() const
The input matrix of this preconditioner's constructor.
Definition: Ifpack2_BlockRelaxation_def.hpp:341
void getValidParameters(Teuchos::ParameterList ¶ms)
Fills a list which contains all the parameters possibly used by Ifpack2.
Definition: Ifpack2_Parameters.cpp:51
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
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Return a list of all the parameters that this class accepts.
Definition: Ifpack2_BlockRelaxation_def.hpp:124
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:446
BlockRelaxation(const Teuchos::RCP< const row_matrix_type > &Matrix)
Constructor.
Definition: Ifpack2_BlockRelaxation_def.hpp:85