22 #ifndef IFPACK2_ADDITIVESCHWARZ_DEF_HPP
23 #define IFPACK2_ADDITIVESCHWARZ_DEF_HPP
30 #include "Ifpack2_Details_LinearSolver.hpp"
31 #include "Ifpack2_Details_getParamTryingTypes.hpp"
33 #if defined(HAVE_IFPACK2_XPETRA) && defined(HAVE_IFPACK2_ZOLTAN2)
34 #include "Zoltan2_TpetraRowGraphAdapter.hpp"
35 #include "Zoltan2_OrderingProblem.hpp"
36 #include "Zoltan2_OrderingSolution.hpp"
40 #include "Ifpack2_Parameters.hpp"
41 #include "Ifpack2_LocalFilter.hpp"
42 #include "Ifpack2_ReorderFilter.hpp"
43 #include "Ifpack2_SingletonFilter.hpp"
44 #include "Ifpack2_Details_AdditiveSchwarzFilter.hpp"
50 #include "Teuchos_StandardParameterEntryValidators.hpp"
53 #include <Tpetra_BlockMultiVector.hpp>
65 #ifdef HAVE_IFPACK2_DEBUG
74 using magnitude_type =
typename STS::magnitudeType;
80 for (
size_t j = 0; j < X.getNumVectors (); ++j) {
81 if (STM::isnaninf (norms[j])) {
91 #endif // HAVE_IFPACK2_DEBUG
95 template<
class MatrixType,
class LocalInverseType>
97 AdditiveSchwarz<MatrixType, LocalInverseType>::hasInnerPrecName ()
const
99 const char* options[4] = {
100 "inner preconditioner name",
101 "subdomain solver name",
102 "schwarz: inner preconditioner name",
103 "schwarz: subdomain solver name"
105 const int numOptions = 4;
107 for (
int k = 0; k < numOptions && ! match; ++k) {
108 if (List_.isParameter (options[k])) {
116 template<
class MatrixType,
class LocalInverseType>
118 AdditiveSchwarz<MatrixType, LocalInverseType>::removeInnerPrecName ()
120 const char* options[4] = {
121 "inner preconditioner name",
122 "subdomain solver name",
123 "schwarz: inner preconditioner name",
124 "schwarz: subdomain solver name"
126 const int numOptions = 4;
127 for (
int k = 0; k < numOptions; ++k) {
128 List_.
remove (options[k],
false);
133 template<
class MatrixType,
class LocalInverseType>
135 AdditiveSchwarz<MatrixType, LocalInverseType>::innerPrecName ()
const
137 const char* options[4] = {
138 "inner preconditioner name",
139 "subdomain solver name",
140 "schwarz: inner preconditioner name",
141 "schwarz: subdomain solver name"
143 const int numOptions = 4;
148 for (
int k = 0; k < numOptions && ! match; ++k) {
150 List_.getEntryPtr (options[k]);
151 if (paramEnt !=
nullptr && paramEnt->
isType<std::string> ()) {
152 newName = Teuchos::getValue<std::string> (*paramEnt);
156 return match ? newName : defaultInnerPrecName ();
160 template<
class MatrixType,
class LocalInverseType>
162 AdditiveSchwarz<MatrixType, LocalInverseType>::removeInnerPrecParams ()
164 const char* options[4] = {
165 "inner preconditioner parameters",
166 "subdomain solver parameters",
167 "schwarz: inner preconditioner parameters",
168 "schwarz: subdomain solver parameters"
170 const int numOptions = 4;
173 for (
int k = 0; k < numOptions; ++k) {
174 List_.remove (options[k],
false);
179 template<
class MatrixType,
class LocalInverseType>
180 std::pair<Teuchos::ParameterList, bool>
181 AdditiveSchwarz<MatrixType, LocalInverseType>::innerPrecParams ()
const
183 const char* options[4] = {
184 "inner preconditioner parameters",
185 "subdomain solver parameters",
186 "schwarz: inner preconditioner parameters",
187 "schwarz: subdomain solver parameters"
189 const int numOptions = 4;
194 for (
int k = 0; k < numOptions && ! match; ++k) {
195 if (List_.isSublist (options[k])) {
196 params = List_.
sublist (options[k]);
201 return std::make_pair (params, match);
204 template<
class MatrixType,
class LocalInverseType>
206 AdditiveSchwarz<MatrixType, LocalInverseType>::defaultInnerPrecName ()
213 template<
class MatrixType,
class LocalInverseType>
219 template<
class MatrixType,
class LocalInverseType>
222 const int overlapLevel) :
224 OverlapLevel_ (overlapLevel)
227 template<
class MatrixType,
class LocalInverseType>
233 Matrix_.is_null (), std::runtime_error,
"Ifpack2::AdditiveSchwarz::"
234 "getDomainMap: The matrix to precondition is null. You must either pass "
235 "a nonnull matrix to the constructor, or call setMatrix() with a nonnull "
236 "input, before you may call this method.");
237 return Matrix_->getDomainMap ();
241 template<
class MatrixType,
class LocalInverseType>
246 Matrix_.is_null (), std::runtime_error,
"Ifpack2::AdditiveSchwarz::"
247 "getRangeMap: The matrix to precondition is null. You must either pass "
248 "a nonnull matrix to the constructor, or call setMatrix() with a nonnull "
249 "input, before you may call this method.");
250 return Matrix_->getRangeMap ();
254 template<
class MatrixType,
class LocalInverseType>
264 template<
class MatrixType,
class map_type>
268 using BMV = Tpetra::BlockMultiVector<
269 typename MatrixType::scalar_type,
270 typename MatrixType::local_ordinal_type,
271 typename MatrixType::global_ordinal_type,
272 typename MatrixType::node_type>;
274 if (blockSize == 1)
return meshMap;
279 template <
typename MV,
typename Map>
280 void resetMultiVecIfNeeded(std::unique_ptr<MV> &mv_ptr,
const Map &map,
const size_t numVectors,
bool initialize)
282 if(!mv_ptr || mv_ptr->getNumVectors() != numVectors) {
283 mv_ptr.reset(
new MV(map, numVectors, initialize));
289 template<
class MatrixType,
class LocalInverseType>
292 apply (
const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &B,
293 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &Y,
302 using Teuchos::rcp_dynamic_cast;
304 const char prefix[] =
"Ifpack2::AdditiveSchwarz::apply: ";
307 (! IsComputed_, std::runtime_error,
308 prefix <<
"isComputed() must be true before you may call apply().");
310 (Matrix_.is_null (), std::logic_error, prefix <<
311 "The input matrix A is null, but the preconditioner says that it has "
312 "been computed (isComputed() is true). This should never happen, since "
313 "setMatrix() should always mark the preconditioner as not computed if "
314 "its argument is null. "
315 "Please report this bug to the Ifpack2 developers.");
317 (Inverse_.is_null (), std::runtime_error,
318 prefix <<
"The subdomain solver is null. "
319 "This can only happen if you called setInnerPreconditioner() with a null "
320 "input, after calling initialize() or compute(). If you choose to call "
321 "setInnerPreconditioner() with a null input, you must then call it with "
322 "a nonnull input before you may call initialize() or compute().");
324 (B.getNumVectors() != Y.getNumVectors(), std::invalid_argument,
325 prefix <<
"B and Y must have the same number of columns. B has " <<
326 B.getNumVectors () <<
" columns, but Y has " << Y.getNumVectors() <<
".");
328 (IsOverlapping_ && OverlappingMatrix_.is_null (), std::logic_error,
329 prefix <<
"The overlapping matrix is null. "
330 "This should never happen if IsOverlapping_ is true. "
331 "Please report this bug to the Ifpack2 developers.");
333 (! IsOverlapping_ && localMap_.is_null (), std::logic_error,
334 prefix <<
"localMap_ is null. "
335 "This should never happen if IsOverlapping_ is false. "
336 "Please report this bug to the Ifpack2 developers.");
338 (alpha != STS::one (), std::logic_error,
339 prefix <<
"Not implemented for alpha != 1.");
340 TEUCHOS_TEST_FOR_EXCEPTION
341 (beta != STS::zero (), std::logic_error,
342 prefix <<
"Not implemented for beta != 0.");
344 #ifdef HAVE_IFPACK2_DEBUG
346 const bool bad = anyBad (B);
347 TEUCHOS_TEST_FOR_EXCEPTION
348 (bad, std::runtime_error,
"Ifpack2::AdditiveSchwarz::apply: "
349 "The 2-norm of the input B is NaN or Inf.");
351 #endif // HAVE_IFPACK2_DEBUG
353 #ifdef HAVE_IFPACK2_DEBUG
354 if (! ZeroStartingSolution_) {
355 const bool bad = anyBad (Y);
356 TEUCHOS_TEST_FOR_EXCEPTION
357 (bad, std::runtime_error,
"Ifpack2::AdditiveSchwarz::apply: "
358 "On input, the initial guess Y has 2-norm NaN or Inf "
359 "(ZeroStartingSolution_ is false).");
361 #endif // HAVE_IFPACK2_DEBUG
363 const std::string timerName (
"Ifpack2::AdditiveSchwarz::apply");
364 RCP<Time> timer = TimeMonitor::lookupCounter (timerName);
365 if (timer.is_null ()) {
366 timer = TimeMonitor::getNewCounter (timerName);
368 double startTime = timer->wallTime();
371 TimeMonitor timeMon (*timer);
374 const size_t numVectors = B.getNumVectors ();
378 if (ZeroStartingSolution_) {
383 MV* OverlappingB =
nullptr;
384 MV* OverlappingY =
nullptr;
386 RCP<const map_type> B_and_Y_map = pointMapFromMeshMap<MatrixType>(IsOverlapping_ ?
387 OverlappingMatrix_->getRowMap () : localMap_ , Matrix_->getBlockSize());
388 resetMultiVecIfNeeded(overlapping_B_, B_and_Y_map, numVectors,
false);
389 resetMultiVecIfNeeded(overlapping_Y_, B_and_Y_map, numVectors,
false);
390 OverlappingB = overlapping_B_.get ();
391 OverlappingY = overlapping_Y_.get ();
394 OverlappingB->putScalar (ZERO);
395 OverlappingY->putScalar (ZERO);
398 RCP<MV> globalOverlappingB;
399 if (! IsOverlapping_) {
400 auto matrixPointRowMap = pointMapFromMeshMap<MatrixType>(Matrix_->getRowMap (),Matrix_->getBlockSize ());
403 OverlappingB->offsetViewNonConst (matrixPointRowMap, 0);
406 if (DistributedImporter_.is_null ()) {
410 DistributedImporter_ =
411 rcp (
new import_type (matrixPointRowMap,
412 Matrix_->getDomainMap ()));
416 resetMultiVecIfNeeded(R_, B.getMap(), numVectors,
false);
417 resetMultiVecIfNeeded(C_, Y.getMap(), numVectors,
false);
421 if (IsOverlapping_ && AvgOverlap_) {
422 if (num_overlap_copies_.get() ==
nullptr) {
423 num_overlap_copies_.reset (
new MV (Y.getMap (), 1,
false));
424 RCP<MV> onesVec(
new MV(OverlappingMatrix_->getRowMap(), 1,
false) );
428 dataNumOverlapCopies = num_overlap_copies_.get ()->getDataNonConst(0);
438 for (
int ni=0; ni<NumIterations_; ++ni)
440 #ifdef HAVE_IFPACK2_DEBUG
442 const bool bad = anyBad (Y);
443 TEUCHOS_TEST_FOR_EXCEPTION
444 (bad, std::runtime_error,
"Ifpack2::AdditiveSchwarz::apply: "
445 "At top of iteration " << ni <<
", the 2-norm of Y is NaN or Inf.");
447 #endif // HAVE_IFPACK2_DEBUG
449 Tpetra::deep_copy(*R, B);
454 if (!ZeroStartingSolution_ || ni > 0) {
456 Matrix_->apply (Y, *R, mode, -STS::one(), STS::one());
458 #ifdef HAVE_IFPACK2_DEBUG
460 const bool bad = anyBad (*R);
461 TEUCHOS_TEST_FOR_EXCEPTION
462 (bad, std::runtime_error,
"Ifpack2::AdditiveSchwarz::apply: "
463 "At iteration " << ni <<
", the 2-norm of R (result of computing "
464 "residual with Y) is NaN or Inf.");
466 #endif // HAVE_IFPACK2_DEBUG
470 if (IsOverlapping_) {
471 TEUCHOS_TEST_FOR_EXCEPTION
472 (OverlappingMatrix_.is_null (), std::logic_error, prefix <<
473 "IsOverlapping_ is true, but OverlappingMatrix_, while nonnull, is "
474 "not an OverlappingRowMatrix<row_matrix_type>. Please report this "
475 "bug to the Ifpack2 developers.");
476 OverlappingMatrix_->importMultiVector (*R, *OverlappingB, Tpetra::INSERT);
493 #ifdef HAVE_IFPACK2_DEBUG
495 const bool bad = anyBad (*OverlappingB);
496 TEUCHOS_TEST_FOR_EXCEPTION
497 (bad, std::runtime_error,
"Ifpack2::AdditiveSchwarz::apply: "
498 "At iteration " << ni <<
", result of importMultiVector from R "
499 "to OverlappingB, has 2-norm NaN or Inf.");
501 #endif // HAVE_IFPACK2_DEBUG
503 globalOverlappingB->doImport (*R, *DistributedImporter_, Tpetra::INSERT);
505 #ifdef HAVE_IFPACK2_DEBUG
507 const bool bad = anyBad (*globalOverlappingB);
508 TEUCHOS_TEST_FOR_EXCEPTION
509 (bad, std::runtime_error,
"Ifpack2::AdditiveSchwarz::apply: "
510 "At iteration " << ni <<
", result of doImport from R, has 2-norm "
513 #endif // HAVE_IFPACK2_DEBUG
516 #ifdef HAVE_IFPACK2_DEBUG
518 const bool bad = anyBad (*OverlappingB);
519 TEUCHOS_TEST_FOR_EXCEPTION
520 (bad, std::runtime_error,
"Ifpack2::AdditiveSchwarz::apply: "
521 "At iteration " << ni <<
", right before localApply, the 2-norm of "
522 "OverlappingB is NaN or Inf.");
524 #endif // HAVE_IFPACK2_DEBUG
527 localApply(*OverlappingB, *OverlappingY);
529 #ifdef HAVE_IFPACK2_DEBUG
531 const bool bad = anyBad (*OverlappingY);
532 TEUCHOS_TEST_FOR_EXCEPTION
533 (bad, std::runtime_error,
"Ifpack2::AdditiveSchwarz::apply: "
534 "At iteration " << ni <<
", after localApply and before export / "
535 "copy, the 2-norm of OverlappingY is NaN or Inf.");
537 #endif // HAVE_IFPACK2_DEBUG
539 #ifdef HAVE_IFPACK2_DEBUG
541 const bool bad = anyBad (*C);
542 TEUCHOS_TEST_FOR_EXCEPTION
543 (bad, std::runtime_error,
"Ifpack2::AdditiveSchwarz::apply: "
544 "At iteration " << ni <<
", before export / copy, the 2-norm of C "
547 #endif // HAVE_IFPACK2_DEBUG
550 if (IsOverlapping_) {
551 TEUCHOS_TEST_FOR_EXCEPTION
552 (OverlappingMatrix_.is_null (), std::logic_error, prefix
553 <<
"OverlappingMatrix_ is null when it shouldn't be. "
554 "Please report this bug to the Ifpack2 developers.");
555 OverlappingMatrix_->exportMultiVector (*OverlappingY, *C, CombineMode_);
560 for (
int i = 0; i < (int) C->getMap()->getLocalNumElements(); i++) {
561 dataC[i] = dataC[i]/dataNumOverlapCopies[i];
572 RCP<MV> C_view = C->offsetViewNonConst (OverlappingY->getMap (), 0);
573 Tpetra::deep_copy (*C_view, *OverlappingY);
576 #ifdef HAVE_IFPACK2_DEBUG
578 const bool bad = anyBad (*C);
579 TEUCHOS_TEST_FOR_EXCEPTION
580 (bad, std::runtime_error,
"Ifpack2::AdditiveSchwarz::apply: "
581 "At iteration " << ni <<
", before Y := C + Y, the 2-norm of C "
584 #endif // HAVE_IFPACK2_DEBUG
586 #ifdef HAVE_IFPACK2_DEBUG
588 const bool bad = anyBad (Y);
589 TEUCHOS_TEST_FOR_EXCEPTION
590 (bad, std::runtime_error,
"Ifpack2::AdditiveSchwarz::apply: "
591 "Before Y := C + Y, at iteration " << ni <<
", the 2-norm of Y "
594 #endif // HAVE_IFPACK2_DEBUG
596 Y.update(UpdateDamping_, *C, STS::one());
598 #ifdef HAVE_IFPACK2_DEBUG
600 const bool bad = anyBad (Y);
601 TEUCHOS_TEST_FOR_EXCEPTION
602 (bad, std::runtime_error,
"Ifpack2::AdditiveSchwarz::apply: "
603 "At iteration " << ni <<
", after Y := C + Y, the 2-norm of Y "
606 #endif // HAVE_IFPACK2_DEBUG
611 #ifdef HAVE_IFPACK2_DEBUG
613 const bool bad = anyBad (Y);
614 TEUCHOS_TEST_FOR_EXCEPTION
615 (bad, std::runtime_error,
"Ifpack2::AdditiveSchwarz::apply: "
616 "The 2-norm of the output Y is NaN or Inf.");
618 #endif // HAVE_IFPACK2_DEBUG
622 ApplyTime_ += (timer->wallTime() - startTime);
625 template<
class MatrixType,
class LocalInverseType>
628 localApply (MV& OverlappingB, MV& OverlappingY)
const
631 using Teuchos::rcp_dynamic_cast;
633 const size_t numVectors = OverlappingB.getNumVectors ();
635 auto additiveSchwarzFilter = rcp_dynamic_cast<Details::AdditiveSchwarzFilter<MatrixType>>(innerMatrix_);
636 if(additiveSchwarzFilter)
643 resetMultiVecIfNeeded(reduced_reordered_B_, additiveSchwarzFilter->getRowMap(), numVectors,
true);
644 resetMultiVecIfNeeded(reduced_reordered_Y_, additiveSchwarzFilter->getRowMap(), numVectors,
true);
645 additiveSchwarzFilter->CreateReducedProblem(OverlappingB, OverlappingY, *reduced_reordered_B_);
647 Inverse_->solve (*reduced_reordered_Y_, *reduced_reordered_B_);
649 additiveSchwarzFilter->UpdateLHS(*reduced_reordered_Y_, OverlappingY);
653 if (FilterSingletons_) {
655 resetMultiVecIfNeeded(reduced_B_, SingletonMatrix_->getRowMap(), numVectors,
true);
656 resetMultiVecIfNeeded(reduced_Y_, SingletonMatrix_->getRowMap(), numVectors,
true);
658 RCP<SingletonFilter<row_matrix_type> > singletonFilter =
659 rcp_dynamic_cast<SingletonFilter<row_matrix_type> > (SingletonMatrix_);
661 (! SingletonMatrix_.is_null () && singletonFilter.is_null (),
662 std::logic_error,
"Ifpack2::AdditiveSchwarz::localApply: "
663 "SingletonFilter_ is nonnull but is not a SingletonFilter"
664 "<row_matrix_type>. This should never happen. Please report this bug "
665 "to the Ifpack2 developers.");
666 singletonFilter->SolveSingletons (OverlappingB, OverlappingY);
667 singletonFilter->CreateReducedRHS (OverlappingY, OverlappingB, *reduced_B_);
670 if (! UseReordering_) {
671 Inverse_->solve (*reduced_Y_, *reduced_B_);
674 RCP<ReorderFilter<row_matrix_type> > rf =
675 rcp_dynamic_cast<ReorderFilter<row_matrix_type> > (ReorderedLocalizedMatrix_);
677 (! ReorderedLocalizedMatrix_.is_null () && rf.is_null (), std::logic_error,
678 "Ifpack2::AdditiveSchwarz::localApply: ReorderedLocalizedMatrix_ is "
679 "nonnull but is not a ReorderFilter<row_matrix_type>. This should "
680 "never happen. Please report this bug to the Ifpack2 developers.");
681 resetMultiVecIfNeeded(reordered_B_, reduced_B_->getMap(), numVectors,
false);
682 resetMultiVecIfNeeded(reordered_Y_, reduced_Y_->getMap(), numVectors,
false);
683 rf->permuteOriginalToReordered (*reduced_B_, *reordered_B_);
684 Inverse_->solve (*reordered_Y_, *reordered_B_);
685 rf->permuteReorderedToOriginal (*reordered_Y_, *reduced_Y_);
689 singletonFilter->UpdateLHS (*reduced_Y_, OverlappingY);
693 if (! UseReordering_) {
694 Inverse_->solve (OverlappingY, OverlappingB);
697 resetMultiVecIfNeeded(reordered_B_, OverlappingB.getMap(), numVectors,
false);
698 resetMultiVecIfNeeded(reordered_Y_, OverlappingY.getMap(), numVectors,
false);
700 RCP<ReorderFilter<row_matrix_type> > rf =
701 rcp_dynamic_cast<ReorderFilter<row_matrix_type> > (ReorderedLocalizedMatrix_);
703 (! ReorderedLocalizedMatrix_.is_null () && rf.is_null (), std::logic_error,
704 "Ifpack2::AdditiveSchwarz::localApply: ReorderedLocalizedMatrix_ is "
705 "nonnull but is not a ReorderFilter<row_matrix_type>. This should "
706 "never happen. Please report this bug to the Ifpack2 developers.");
707 rf->permuteOriginalToReordered (OverlappingB, *reordered_B_);
708 Inverse_->solve (*reordered_Y_, *reordered_B_);
709 rf->permuteReorderedToOriginal (*reordered_Y_, OverlappingY);
716 template<
class MatrixType,
class LocalInverseType>
724 this->setParameterList (Teuchos::rcpFromRef (List_));
729 template<
class MatrixType,
class LocalInverseType>
733 using Tpetra::CombineMode;
739 using Teuchos::rcp_dynamic_cast;
741 using Details::getParamTryingTypes;
742 const char prefix[] =
"Ifpack2::AdditiveSchwarz: ";
747 this->setParameterList (
rcp (
new ParameterList ()));
754 plist.
is_null (), std::logic_error,
"Ifpack2::AdditiveSchwarz::"
755 "setParameterList: plist is null. This should never happen, since the "
756 "method should have replaced a null input list with a nonnull empty list "
757 "by this point. Please report this bug to the Ifpack2 developers.");
778 const std::string cmParamName (
"schwarz: combine mode");
779 const ParameterEntry* cmEnt = plist->
getEntryPtr (cmParamName);
780 if (cmEnt !=
nullptr) {
781 if (cmEnt->isType<CombineMode> ()) {
782 CombineMode_ = Teuchos::getValue<CombineMode> (*cmEnt);
784 else if (cmEnt->isType<
int> ()) {
785 const int cm = Teuchos::getValue<int> (*cmEnt);
786 CombineMode_ =
static_cast<CombineMode
> (cm);
788 else if (cmEnt->isType<std::string> ()) {
793 const ParameterEntry& validEntry =
795 RCP<const ParameterEntryValidator> v = validEntry.validator ();
796 using vs2e_type = StringToIntegralParameterEntryValidator<CombineMode>;
797 RCP<const vs2e_type> vs2e = rcp_dynamic_cast<
const vs2e_type> (v,
true);
799 ParameterEntry& inputEntry = plist->
getEntry (cmParamName);
804 if (strncmp(Teuchos::getValue<std::string>(inputEntry).c_str(),
"AVG",3) == 0) {
805 inputEntry.template setValue<std::string>(
"ADD");
808 CombineMode_ = vs2e->getIntegralValue (inputEntry, cmParamName);
816 if (plist->
get<std::string>(
"subdomain solver name") ==
"BLOCK_RELAXATION") {
817 if (plist->
isSublist(
"subdomain solver parameters")) {
819 if (plist->
sublist(
"subdomain solver parameters").
get<std::string>(
"relaxation: type") ==
"Jacobi" ) {
821 if (plist->
sublist(
"subdomain solver parameters").
get<std::string>(
"partitioner: type") ==
"user") {
822 if (CombineMode_ == Tpetra::ADD) plist->
sublist(
"subdomain solver parameters").
set(
"partitioner: combine mode",
"ADD");
823 if (CombineMode_ == Tpetra::ZERO) plist->
sublist(
"subdomain solver parameters").
set(
"partitioner: combine mode",
"ZERO");
833 OverlapLevel_ = plist->
get (
"schwarz: overlap level", OverlapLevel_);
839 UseReordering_ = plist->
get (
"schwarz: use reordering", UseReordering_);
841 #if !defined(HAVE_IFPACK2_XPETRA) || !defined(HAVE_IFPACK2_ZOLTAN2)
843 UseReordering_, std::invalid_argument,
"Ifpack2::AdditiveSchwarz::"
844 "setParameters: You specified \"schwarz: use reordering\" = true. "
845 "This is only valid when Trilinos was built with Ifpack2, Xpetra, and "
846 "Zoltan2 enabled. Either Xpetra or Zoltan2 was not enabled in your build "
858 FilterSingletons_ = plist->
get (
"schwarz: filter singletons", FilterSingletons_);
861 getParamTryingTypes<scalar_type, scalar_type, double>
862 (UpdateDamping_, *plist,
"schwarz: update damping", prefix);
897 if (! Inverse_.is_null ()) {
900 if (hasInnerPrecName () && innerPrecName () !=
"CUSTOM") {
903 Inverse_ = Teuchos::null;
908 std::pair<ParameterList, bool> result = innerPrecParams ();
912 Inverse_->setParameters (
rcp (
new ParameterList (result.first)));
917 NumIterations_ = plist->get (
"schwarz: num iterations", NumIterations_);
918 ZeroStartingSolution_ =
919 plist->get (
"schwarz: zero starting solution", ZeroStartingSolution_);
924 template<
class MatrixType,
class LocalInverseType>
930 using Teuchos::parameterList;
932 using Teuchos::rcp_const_cast;
934 if (validParams_.is_null ()) {
935 const int overlapLevel = 0;
936 const bool useReordering =
false;
937 const bool filterSingletons =
false;
938 const int numIterations = 1;
939 const bool zeroStartingSolution =
true;
941 ParameterList reorderingSublist;
942 reorderingSublist.set (
"order_method", std::string (
"rcm"));
944 RCP<ParameterList> plist = parameterList (
"Ifpack2::AdditiveSchwarz");
946 Tpetra::setCombineModeParameter (*plist,
"schwarz: combine mode");
947 plist->set (
"schwarz: overlap level", overlapLevel);
948 plist->set (
"schwarz: use reordering", useReordering);
949 plist->set (
"schwarz: reordering list", reorderingSublist);
952 plist->set (
"schwarz: compute condest",
false);
953 plist->set (
"schwarz: filter singletons", filterSingletons);
954 plist->set (
"schwarz: num iterations", numIterations);
955 plist->set (
"schwarz: zero starting solution", zeroStartingSolution);
956 plist->set (
"schwarz: update damping", updateDamping);
966 validParams_ = rcp_const_cast<
const ParameterList> (plist);
972 template<
class MatrixType,
class LocalInverseType>
975 using Tpetra::global_size_t;
982 const std::string timerName (
"Ifpack2::AdditiveSchwarz::initialize");
983 RCP<Time> timer = TimeMonitor::lookupCounter (timerName);
984 if (timer.is_null ()) {
985 timer = TimeMonitor::getNewCounter (timerName);
987 double startTime = timer->wallTime();
990 TimeMonitor timeMon (*timer);
993 Matrix_.is_null (), std::runtime_error,
"Ifpack2::AdditiveSchwarz::"
994 "initialize: The matrix to precondition is null. You must either pass "
995 "a nonnull matrix to the constructor, or call setMatrix() with a nonnull "
996 "input, before you may call this method.");
998 IsInitialized_ =
false;
1000 overlapping_B_.reset (
nullptr);
1001 overlapping_Y_.reset (
nullptr);
1004 reduced_reordered_B_.reset (
nullptr);
1005 reduced_reordered_Y_.reset (
nullptr);
1006 reduced_B_.reset (
nullptr);
1007 reduced_Y_.reset (
nullptr);
1008 reordered_B_.reset (
nullptr);
1009 reordered_Y_.reset (
nullptr);
1011 RCP<const Teuchos::Comm<int> > comm = Matrix_->getComm ();
1012 RCP<const map_type> rowMap = Matrix_->getRowMap ();
1013 const global_size_t INVALID =
1018 if (comm->getSize () == 1) {
1020 IsOverlapping_ =
false;
1021 }
else if (OverlapLevel_ != 0) {
1022 IsOverlapping_ =
true;
1025 if (OverlapLevel_ == 0) {
1027 RCP<const SerialComm<int> > localComm (
new SerialComm<int> ());
1031 rcp (
new map_type (INVALID, rowMap->getLocalNumElements (),
1032 indexBase, localComm));
1036 if (IsOverlapping_) {
1043 if (! Inverse_.is_null ()) {
1044 Inverse_->symbolic ();
1049 IsInitialized_ =
true;
1052 InitializeTime_ += (timer->wallTime() - startTime);
1055 template<
class MatrixType,
class LocalInverseType>
1058 return IsInitialized_;
1062 template<
class MatrixType,
class LocalInverseType>
1069 if (! IsInitialized_) {
1074 ! isInitialized (), std::logic_error,
"Ifpack2::AdditiveSchwarz::compute: "
1075 "The preconditioner is not yet initialized, "
1076 "even though initialize() supposedly has been called. "
1077 "This should never happen. "
1078 "Please report this bug to the Ifpack2 developers.");
1081 Inverse_.is_null (), std::runtime_error,
1082 "Ifpack2::AdditiveSchwarz::compute: The subdomain solver is null. "
1083 "This can only happen if you called setInnerPreconditioner() with a null "
1084 "input, after calling initialize() or compute(). If you choose to call "
1085 "setInnerPreconditioner() with a null input, you must then call it with a "
1086 "nonnull input before you may call initialize() or compute().");
1088 const std::string timerName (
"Ifpack2::AdditiveSchwarz::compute");
1089 RCP<Time> timer = TimeMonitor::lookupCounter (timerName);
1090 if (timer.is_null ()) {
1091 timer = TimeMonitor::getNewCounter (timerName);
1093 TimeMonitor timeMon (*timer);
1094 double startTime = timer->wallTime();
1098 if (IsOverlapping_) {
1100 OverlappingMatrix_->doExtImport();
1105 if(
auto asf = Teuchos::rcp_dynamic_cast<Details::AdditiveSchwarzFilter<MatrixType>>(innerMatrix_))
1110 asf->updateMatrixValues();
1117 IsComputed_ =
false;
1118 Inverse_->numeric ();
1124 ComputeTime_ += (timer->wallTime() - startTime);
1129 template<
class MatrixType,
class LocalInverseType>
1136 template<
class MatrixType,
class LocalInverseType>
1139 return NumInitialize_;
1143 template<
class MatrixType,
class LocalInverseType>
1150 template<
class MatrixType,
class LocalInverseType>
1157 template<
class MatrixType,
class LocalInverseType>
1160 return InitializeTime_;
1164 template<
class MatrixType,
class LocalInverseType>
1167 return ComputeTime_;
1171 template<
class MatrixType,
class LocalInverseType>
1178 template<
class MatrixType,
class LocalInverseType>
1181 std::ostringstream out;
1183 out <<
"\"Ifpack2::AdditiveSchwarz\": {";
1184 if (this->getObjectLabel () !=
"") {
1185 out <<
"Label: \"" << this->getObjectLabel () <<
"\", ";
1187 out <<
"Initialized: " << (isInitialized () ?
"true" :
"false")
1188 <<
", Computed: " << (isComputed () ?
"true" :
"false")
1189 <<
", Iterations: " << NumIterations_
1190 <<
", Overlap level: " << OverlapLevel_
1191 <<
", Subdomain reordering: \"" << ReorderingAlgorithm_ <<
"\"";
1192 out <<
", Combine mode: \"";
1193 if (CombineMode_ == Tpetra::INSERT) {
1195 }
else if (CombineMode_ == Tpetra::ADD) {
1197 }
else if (CombineMode_ == Tpetra::REPLACE) {
1199 }
else if (CombineMode_ == Tpetra::ABSMAX) {
1201 }
else if (CombineMode_ == Tpetra::ZERO) {
1205 if (Matrix_.is_null ()) {
1206 out <<
", Matrix: null";
1209 out <<
", Global matrix dimensions: ["
1210 << Matrix_->getGlobalNumRows () <<
", "
1211 << Matrix_->getGlobalNumCols () <<
"]";
1213 out <<
", Inner solver: ";
1214 if (! Inverse_.is_null ()) {
1220 out <<
"{" <<
"Some inner solver" <<
"}";
1231 template<
class MatrixType,
class LocalInverseType>
1241 const int myRank = Matrix_->getComm ()->getRank ();
1242 const int numProcs = Matrix_->getComm ()->getSize ();
1250 out <<
"\"Ifpack2::AdditiveSchwarz\":";
1254 out <<
"MatrixType: " << TypeNameTraits<MatrixType>::name () << endl;
1255 out <<
"LocalInverseType: " << TypeNameTraits<LocalInverseType>::name () << endl;
1256 if (this->getObjectLabel () !=
"") {
1257 out <<
"Label: \"" << this->getObjectLabel () <<
"\"" << endl;
1260 out <<
"Overlap level: " << OverlapLevel_ << endl
1261 <<
"Combine mode: \"";
1262 if (CombineMode_ == Tpetra::INSERT) {
1264 }
else if (CombineMode_ == Tpetra::ADD) {
1266 }
else if (CombineMode_ == Tpetra::REPLACE) {
1268 }
else if (CombineMode_ == Tpetra::ABSMAX) {
1270 }
else if (CombineMode_ == Tpetra::ZERO) {
1274 <<
"Subdomain reordering: \"" << ReorderingAlgorithm_ <<
"\"" << endl;
1277 if (Matrix_.is_null ()) {
1279 out <<
"Matrix: null" << endl;
1284 out <<
"Matrix:" << endl;
1287 Matrix_->getComm ()->barrier ();
1292 out <<
"Number of initialize calls: " << getNumInitialize () << endl
1293 <<
"Number of compute calls: " << getNumCompute () << endl
1294 <<
"Number of apply calls: " << getNumApply () << endl
1295 <<
"Total time in seconds for initialize: " << getInitializeTime () << endl
1296 <<
"Total time in seconds for compute: " << getComputeTime () << endl
1297 <<
"Total time in seconds for apply: " << getApplyTime () << endl;
1300 if (Inverse_.is_null ()) {
1302 out <<
"Subdomain solver: null" << endl;
1309 if(ifpack2_inverse.is_null())
1310 out <<
"Subdomain solver: not null" << endl;
1312 out <<
"Subdomain solver: "; ifpack2_inverse->describe (out,
Teuchos::VERB_LOW);
1317 for (
int p = 0; p < numProcs; ++p) {
1319 out <<
"Subdomain solver on Process " << myRank <<
":";
1320 if (Inverse_.is_null ()) {
1321 out <<
"null" << endl;
1329 out <<
"null" << endl;
1333 Matrix_->getComm ()->barrier ();
1334 Matrix_->getComm ()->barrier ();
1335 Matrix_->getComm ()->barrier ();
1340 Matrix_->getComm ()->barrier ();
1345 template<
class MatrixType,
class LocalInverseType>
1355 template<
class MatrixType,
class LocalInverseType>
1358 return OverlapLevel_;
1362 template<
class MatrixType,
class LocalInverseType>
1366 using Teuchos::MpiComm;
1372 using Teuchos::rcp_dynamic_cast;
1373 using Teuchos::rcpFromRef;
1376 Matrix_.is_null (), std::runtime_error,
"Ifpack2::AdditiveSchwarz::"
1377 "initialize: The matrix to precondition is null. You must either pass "
1378 "a nonnull matrix to the constructor, or call setMatrix() with a nonnull "
1379 "input, before you may call this method.");
1383 auto matrixCrs = rcp_dynamic_cast<
const crs_matrix_type>(Matrix_);
1384 if(!OverlappingMatrix_.is_null() || !matrixCrs.is_null())
1386 ArrayRCP<local_ordinal_type> perm;
1387 ArrayRCP<local_ordinal_type> revperm;
1388 if (UseReordering_) {
1390 #if defined(HAVE_IFPACK2_XPETRA) && defined(HAVE_IFPACK2_ZOLTAN2)
1393 ReorderingAlgorithm_ = zlist.
get<std::string> (
"order_method",
"rcm");
1395 if(ReorderingAlgorithm_ ==
"user") {
1402 typedef Tpetra::RowGraph
1403 <local_ordinal_type, global_ordinal_type, node_type> row_graph_type;
1404 typedef Zoltan2::TpetraRowGraphAdapter<row_graph_type> z2_adapter_type;
1405 auto constActiveGraph = Teuchos::rcp_const_cast<
const row_graph_type>(
1406 IsOverlapping_ ? OverlappingMatrix_->getGraph() : Matrix_->getGraph());
1407 z2_adapter_type Zoltan2Graph (constActiveGraph);
1409 typedef Zoltan2::OrderingProblem<z2_adapter_type> ordering_problem_type;
1414 RCP<const MpiComm<int> > mpicomm =
1415 rcp_dynamic_cast<
const MpiComm<int> > (Matrix_->getComm ());
1416 if (mpicomm == Teuchos::null) {
1417 myRawComm = MPI_COMM_SELF;
1419 myRawComm = * (mpicomm->getRawMpiComm ());
1421 ordering_problem_type MyOrderingProblem (&Zoltan2Graph, &zlist, myRawComm);
1423 ordering_problem_type MyOrderingProblem (&Zoltan2Graph, &zlist);
1425 MyOrderingProblem.solve ();
1428 typedef Zoltan2::LocalOrderingSolution<local_ordinal_type>
1429 ordering_solution_type;
1431 ordering_solution_type sol (*MyOrderingProblem.getLocalOrderingSolution());
1437 perm = sol.getPermutationRCPConst (
true);
1438 revperm = sol.getPermutationRCPConst ();
1445 true, std::logic_error,
"Ifpack2::AdditiveSchwarz::setup: "
1446 "The Zoltan2 and Xpetra packages must be enabled in order "
1447 "to support reordering.");
1452 local_ordinal_type numLocalRows = OverlappingMatrix_.is_null() ? matrixCrs->getLocalNumRows() : OverlappingMatrix_->getLocalNumRows();
1456 perm = ArrayRCP<local_ordinal_type>(numLocalRows);
1457 revperm = ArrayRCP<local_ordinal_type>(numLocalRows);
1458 for(local_ordinal_type i = 0; i < numLocalRows; i++)
1467 RCP<Details::AdditiveSchwarzFilter<MatrixType>> asf;
1468 if(OverlappingMatrix_.is_null())
1469 asf =
rcp(
new Details::AdditiveSchwarzFilter<MatrixType>(matrixCrs, perm, revperm, FilterSingletons_));
1471 asf =
rcp(
new Details::AdditiveSchwarzFilter<MatrixType>(OverlappingMatrix_, perm, revperm, FilterSingletons_));
1478 RCP<row_matrix_type> LocalizedMatrix;
1482 RCP<row_matrix_type> ActiveMatrix;
1485 if (! OverlappingMatrix_.is_null ()) {
1486 LocalizedMatrix =
rcp (
new LocalFilter<row_matrix_type> (OverlappingMatrix_));
1489 LocalizedMatrix =
rcp (
new LocalFilter<row_matrix_type> (Matrix_));
1494 LocalizedMatrix.is_null (), std::logic_error,
1495 "Ifpack2::AdditiveSchwarz::setup: LocalizedMatrix is null, after the code "
1496 "that claimed to have created it. This should never be the case. Please "
1497 "report this bug to the Ifpack2 developers.");
1500 ActiveMatrix = LocalizedMatrix;
1503 if (FilterSingletons_) {
1504 SingletonMatrix_ =
rcp (
new SingletonFilter<row_matrix_type> (LocalizedMatrix));
1505 ActiveMatrix = SingletonMatrix_;
1509 if (UseReordering_) {
1510 #if defined(HAVE_IFPACK2_XPETRA) && defined(HAVE_IFPACK2_ZOLTAN2)
1512 typedef ReorderFilter<row_matrix_type> reorder_filter_type;
1514 ReorderingAlgorithm_ = zlist.
get<std::string> (
"order_method",
"rcm");
1516 ArrayRCP<local_ordinal_type> perm;
1517 ArrayRCP<local_ordinal_type> revperm;
1519 if(ReorderingAlgorithm_ ==
"user") {
1526 typedef Tpetra::RowGraph
1527 <local_ordinal_type, global_ordinal_type, node_type> row_graph_type;
1528 typedef Zoltan2::TpetraRowGraphAdapter<row_graph_type> z2_adapter_type;
1529 RCP<const row_graph_type> constActiveGraph =
1530 Teuchos::rcp_const_cast<
const row_graph_type>(ActiveMatrix->getGraph());
1531 z2_adapter_type Zoltan2Graph (constActiveGraph);
1533 typedef Zoltan2::OrderingProblem<z2_adapter_type> ordering_problem_type;
1538 RCP<const MpiComm<int> > mpicomm =
1539 rcp_dynamic_cast<
const MpiComm<int> > (ActiveMatrix->getComm ());
1540 if (mpicomm == Teuchos::null) {
1541 myRawComm = MPI_COMM_SELF;
1543 myRawComm = * (mpicomm->getRawMpiComm ());
1545 ordering_problem_type MyOrderingProblem (&Zoltan2Graph, &zlist, myRawComm);
1547 ordering_problem_type MyOrderingProblem (&Zoltan2Graph, &zlist);
1549 MyOrderingProblem.solve ();
1552 typedef Zoltan2::LocalOrderingSolution<local_ordinal_type>
1553 ordering_solution_type;
1555 ordering_solution_type sol (*MyOrderingProblem.getLocalOrderingSolution());
1561 perm = sol.getPermutationRCPConst (
true);
1562 revperm = sol.getPermutationRCPConst ();
1566 ReorderedLocalizedMatrix_ =
rcp (
new reorder_filter_type (ActiveMatrix, perm, revperm));
1569 ActiveMatrix = ReorderedLocalizedMatrix_;
1574 true, std::logic_error,
"Ifpack2::AdditiveSchwarz::setup: "
1575 "The Zoltan2 and Xpetra packages must be enabled in order "
1576 "to support reordering.");
1579 innerMatrix_ = ActiveMatrix;
1583 innerMatrix_.is_null (), std::logic_error,
"Ifpack2::AdditiveSchwarz::"
1584 "setup: Inner matrix is null right before constructing inner solver. "
1585 "Please report this bug to the Ifpack2 developers.");
1588 if (Inverse_.is_null ()) {
1589 const std::string innerName = innerPrecName ();
1591 innerName ==
"INVALID", std::logic_error,
1592 "Ifpack2::AdditiveSchwarz::initialize: AdditiveSchwarz doesn't "
1593 "know how to create an instance of your LocalInverseType \""
1595 "Please talk to the Ifpack2 developers for details.");
1598 innerName ==
"CUSTOM", std::runtime_error,
"Ifpack2::AdditiveSchwarz::"
1599 "initialize: If the \"inner preconditioner name\" parameter (or any "
1600 "alias thereof) has the value \"CUSTOM\", then you must first call "
1601 "setInnerPreconditioner with a nonnull inner preconditioner input before "
1602 "you may call initialize().");
1607 Ifpack2::Details::registerLinearSolverFactory ();
1612 typedef typename MV::mag_type MT;
1613 RCP<inner_solver_type> innerPrec =
1614 Trilinos::Details::getLinearSolver<MV, OP, MT> (
"Ifpack2", innerName);
1616 innerPrec.is_null (), std::logic_error,
1617 "Ifpack2::AdditiveSchwarz::setup: Failed to create inner preconditioner "
1618 "with name \"" << innerName <<
"\".");
1619 innerPrec->setMatrix (innerMatrix_);
1623 std::pair<Teuchos::ParameterList, bool> result = innerPrecParams ();
1624 if (result.second) {
1627 innerPrec->setParameters (rcp (
new ParameterList (result.first)));
1629 Inverse_ = innerPrec;
1631 else if (Inverse_->getMatrix ().getRawPtr () != innerMatrix_.getRawPtr ()) {
1635 Inverse_->setMatrix (innerMatrix_);
1638 Inverse_.is_null (), std::logic_error,
"Ifpack2::AdditiveSchwarz::"
1639 "setup: Inverse_ is null right after we were supposed to have created it."
1640 " Please report this bug to the Ifpack2 developers.");
1650 template<
class MatrixType,
class LocalInverseType>
1654 global_ordinal_type,
1657 if (! innerPrec.is_null ()) {
1660 can_change_type* innerSolver =
dynamic_cast<can_change_type*
> (&*innerPrec);
1662 innerSolver == NULL, std::invalid_argument,
"Ifpack2::AdditiveSchwarz::"
1663 "setInnerPreconditioner: The input preconditioner does not implement the "
1664 "setMatrix() feature. Only input preconditioners that inherit from "
1665 "Ifpack2::Details::CanChangeMatrix implement this feature.");
1682 if(
auto asf = Teuchos::rcp_dynamic_cast<Details::AdditiveSchwarzFilter<MatrixType>>(innerMatrix_))
1683 innerSolver->setMatrix (asf->getFilteredMatrix());
1685 innerSolver->setMatrix (innerMatrix_);
1695 removeInnerPrecName ();
1696 removeInnerPrecParams ();
1697 List_.set (
"inner preconditioner name",
"CUSTOM");
1701 if (isInitialized ()) {
1702 innerPrec->initialize ();
1704 if (isComputed ()) {
1705 innerPrec->compute ();
1717 global_ordinal_type,
node_type> inner_solver_impl_type;
1718 Inverse_ =
Teuchos::rcp (
new inner_solver_impl_type (innerPrec,
"CUSTOM"));
1721 template<
class MatrixType,
class LocalInverseType>
1726 if (A.
getRawPtr () != Matrix_.getRawPtr ()) {
1727 IsInitialized_ =
false;
1728 IsComputed_ =
false;
1731 OverlappingMatrix_ = Teuchos::null;
1732 ReorderedLocalizedMatrix_ = Teuchos::null;
1733 innerMatrix_ = Teuchos::null;
1734 SingletonMatrix_ = Teuchos::null;
1735 localMap_ = Teuchos::null;
1736 overlapping_B_.reset (
nullptr);
1737 overlapping_Y_.reset (
nullptr);
1740 DistributedImporter_ = Teuchos::null;
1751 #define IFPACK2_ADDITIVESCHWARZ_INSTANT(S,LO,GO,N) \
1752 template class Ifpack2::AdditiveSchwarz< Tpetra::RowMatrix<S, LO, GO, N> >;
1754 #endif // IFPACK2_ADDITIVESCHWARZ_DECL_HPP
Mix-in interface for preconditioners that can change their matrix after construction.
Definition: Ifpack2_Details_CanChangeMatrix.hpp:60
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > &plist)
Set the preconditioner's parameters.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:731
virtual void compute()
Computes all (coefficient) data necessary to apply the preconditioner.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:1063
virtual 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
Apply the preconditioner to X, putting the result in Y.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:292
basic_OSTab< char > OSTab
virtual int getNumApply() const
Returns the number of calls to apply().
Definition: Ifpack2_AdditiveSchwarz_def.hpp:1151
T & get(const std::string &name, T def_value)
virtual bool isInitialized() const
Returns true if the preconditioner has been successfully initialized, false otherwise.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:1056
virtual double getInitializeTime() const
Returns the time spent in initialize().
Definition: Ifpack2_AdditiveSchwarz_def.hpp:1158
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
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_AdditiveSchwarz_def.hpp:1234
virtual Teuchos::RCP< const Tpetra::Map< local_ordinal_type, global_ordinal_type, node_type > > getDomainMap() const
The domain Map of this operator.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:230
virtual double getComputeTime() const
Returns the time spent in compute().
Definition: Ifpack2_AdditiveSchwarz_def.hpp:1165
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
std::string description() const
Return a simple one-line description of this object.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:1179
virtual std::ostream & print(std::ostream &os) const
Prints basic information on iostream. This function is used by operator<<.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:1346
AdditiveSchwarz(const Teuchos::RCP< const row_matrix_type > &A)
Constructor that takes a matrix.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:215
virtual double getApplyTime() const
Returns the time spent in apply().
Definition: Ifpack2_AdditiveSchwarz_def.hpp:1172
typename MatrixType::node_type node_type
The Node type used by the input MatrixType.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:290
virtual void initialize()
Computes all (graph-related) data necessary to initialize the preconditioner.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:973
static RCP< Time > getNewTimer(const std::string &name)
ParameterEntry * getEntryPtr(const std::string &name)
bool registeredSomeLinearSolverFactory(const std::string &packageName)
bool isParameter(const std::string &name) const
typename MatrixType::global_ordinal_type global_ordinal_type
The type of global indices in the input MatrixType.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:287
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
bool isSublist(const std::string &name) const
virtual void setInnerPreconditioner(const Teuchos::RCP< Preconditioner< scalar_type, local_ordinal_type, global_ordinal_type, node_type > > &innerPrec)
Set the inner preconditioner.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:1652
Ifpack2's implementation of Trilinos::Details::LinearSolver interface.
Definition: Ifpack2_Details_LinearSolver_decl.hpp:72
virtual std::string description() const
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Get a list of the preconditioner's default parameters.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:927
Interface for all Ifpack2 preconditioners.
Definition: Ifpack2_Preconditioner.hpp:74
virtual Teuchos::RCP< const row_matrix_type > getMatrix() const
The input matrix.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:255
basic_FancyOStream & setOutputToRootOnly(const int rootRank)
Declaration of interface for preconditioners that can change their matrix after construction.
virtual Teuchos::RCP< const Tpetra::Map< local_ordinal_type, global_ordinal_type, node_type > > getRangeMap() const
The range Map of this operator.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:243
virtual void setParameters(const Teuchos::ParameterList &plist)
Set the preconditioner's parameters.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:718
virtual int getNumCompute() const
Returns the number of calls to compute().
Definition: Ifpack2_AdditiveSchwarz_def.hpp:1144
Sparse matrix (Tpetra::RowMatrix subclass) with ghost rows.
Definition: Ifpack2_OverlappingRowMatrix_decl.hpp:25
Additive Schwarz domain decomposition for Tpetra sparse matrices.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:250
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
virtual bool isComputed() const
Returns true if the preconditioner has been successfully computed, false otherwise.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:1130
Declaration of Ifpack2::AdditiveSchwarz, which implements additive Schwarz preconditioning with an ar...
ParameterEntry & getEntry(const std::string &name)
void registerLinearSolverFactory()
virtual void setMatrix(const Teuchos::RCP< const row_matrix_type > &A)
Change the matrix to be preconditioned.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:1723
void getValidParameters(Teuchos::ParameterList ¶ms)
Fills a list which contains all the parameters possibly used by Ifpack2.
Definition: Ifpack2_Parameters.cpp:18
virtual int getOverlapLevel() const
Returns the level of overlap.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:1356
typename MatrixType::scalar_type scalar_type
The type of the entries of the input MatrixType.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:281
virtual void describe(FancyOStream &out, const EVerbosityLevel verbLevel=verbLevel_default) const
virtual int getNumInitialize() const
Returns the number of calls to initialize().
Definition: Ifpack2_AdditiveSchwarz_def.hpp:1137