Ifpack2 Templated Preconditioning Package  Version 1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Ifpack2_AdditiveSchwarz_def.hpp
Go to the documentation of this file.
1 /*@HEADER
2 // ***********************************************************************
3 //
4 // Ifpack2: Templated Object-Oriented Algebraic Preconditioner Package
5 // Copyright (2009) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ***********************************************************************
40 //@HEADER
41 */
42 
54 
55 #ifndef IFPACK2_ADDITIVESCHWARZ_DEF_HPP
56 #define IFPACK2_ADDITIVESCHWARZ_DEF_HPP
57 
59 // We need Ifpack2's implementation of LinearSolver, because we use it
60 // to wrap the user-provided Ifpack2::Preconditioner in
61 // Ifpack2::AdditiveSchwarz::setInnerPreconditioner.
62 #include "Ifpack2_Details_LinearSolver.hpp"
63 
64 #if defined(HAVE_IFPACK2_XPETRA) && defined(HAVE_IFPACK2_ZOLTAN2)
65 #include "Zoltan2_TpetraRowGraphAdapter.hpp"
66 #include "Zoltan2_OrderingProblem.hpp"
67 #include "Zoltan2_OrderingSolution.hpp"
68 #endif
69 
71 #include "Ifpack2_LocalFilter.hpp"
72 #include "Ifpack2_OverlappingRowMatrix.hpp"
73 #include "Ifpack2_Parameters.hpp"
74 #include "Ifpack2_ReorderFilter.hpp"
75 #include "Ifpack2_SingletonFilter.hpp"
76 
77 #ifdef HAVE_MPI
79 #endif
80 
81 #include "Teuchos_StandardParameterEntryValidators.hpp"
82 #include <locale> // std::toupper
83 
84 
85 // FIXME (mfh 25 Aug 2015) Work-around for Bug 6392. This doesn't
86 // need to be a weak symbol because it only refers to a function in
87 // the Ifpack2 package.
88 namespace Ifpack2 {
89 namespace Details {
90  extern void registerLinearSolverFactory ();
91 } // namespace Details
92 } // namespace Ifpack2
93 
94 
95 namespace Ifpack2 {
96 
97 
98 template<class MatrixType, class LocalInverseType>
99 bool
100 AdditiveSchwarz<MatrixType, LocalInverseType>::hasInnerPrecName () const
101 {
102  const char* options[4] = {
103  "inner preconditioner name",
104  "subdomain solver name",
105  "schwarz: inner preconditioner name",
106  "schwarz: subdomain solver name"
107  };
108  const int numOptions = 4;
109  bool match = false;
110  for (int k = 0; k < numOptions && ! match; ++k) {
111  if (List_.isParameter (options[k])) {
112  return true;
113  }
114  }
115  return false;
116 }
117 
118 
119 template<class MatrixType, class LocalInverseType>
120 void
121 AdditiveSchwarz<MatrixType, LocalInverseType>::removeInnerPrecName ()
122 {
123  const char* options[4] = {
124  "inner preconditioner name",
125  "subdomain solver name",
126  "schwarz: inner preconditioner name",
127  "schwarz: subdomain solver name"
128  };
129  const int numOptions = 4;
130  for (int k = 0; k < numOptions; ++k) {
131  List_.remove (options[k], false);
132  }
133 }
134 
135 
136 template<class MatrixType, class LocalInverseType>
137 std::string
138 AdditiveSchwarz<MatrixType, LocalInverseType>::innerPrecName () const
139 {
140  const char* options[4] = {
141  "inner preconditioner name",
142  "subdomain solver name",
143  "schwarz: inner preconditioner name",
144  "schwarz: subdomain solver name"
145  };
146  const int numOptions = 4;
147  std::string newName;
148  bool match = false;
149 
150  // As soon as one parameter option matches, ignore all others.
151  for (int k = 0; k < numOptions && ! match; ++k) {
152  if (List_.isParameter (options[k])) {
153  // try-catch block protects against incorrect type errors.
154  //
155  // FIXME (mfh 04 Jan 2013) We should instead catch and report
156  // type errors.
157  try {
158  newName = List_.get<std::string> (options[k]);
159  match = true;
160  } catch (...) {}
161  }
162  }
163  return match ? newName : defaultInnerPrecName ();
164 }
165 
166 
167 template<class MatrixType, class LocalInverseType>
168 void
169 AdditiveSchwarz<MatrixType, LocalInverseType>::removeInnerPrecParams ()
170 {
171  const char* options[4] = {
172  "inner preconditioner parameters",
173  "subdomain solver parameters",
174  "schwarz: inner preconditioner parameters",
175  "schwarz: subdomain solver parameters"
176  };
177  const int numOptions = 4;
178 
179  // As soon as one parameter option matches, ignore all others.
180  for (int k = 0; k < numOptions; ++k) {
181  List_.remove (options[k], false);
182  }
183 }
184 
185 
186 template<class MatrixType, class LocalInverseType>
187 std::pair<Teuchos::ParameterList, bool>
188 AdditiveSchwarz<MatrixType, LocalInverseType>::innerPrecParams () const
189 {
190  const char* options[4] = {
191  "inner preconditioner parameters",
192  "subdomain solver parameters",
193  "schwarz: inner preconditioner parameters",
194  "schwarz: subdomain solver parameters"
195  };
196  const int numOptions = 4;
197  Teuchos::ParameterList params;
198 
199  // As soon as one parameter option matches, ignore all others.
200  bool match = false;
201  for (int k = 0; k < numOptions && ! match; ++k) {
202  if (List_.isSublist (options[k])) {
203  params = List_.sublist (options[k]);
204  match = true;
205  }
206  }
207  // Default is an empty list of parameters.
208  return std::make_pair (params, match);
209 }
210 
211 
212 template<class MatrixType, class LocalInverseType>
213 std::string
214 AdditiveSchwarz<MatrixType, LocalInverseType>::defaultInnerPrecName ()
215 {
216  // The default inner preconditioner is "ILUT", for backwards
217  // compatibility with the original AdditiveSchwarz implementation.
218  return "ILUT";
219 }
220 
221 
222 template<class MatrixType, class LocalInverseType>
225  Matrix_ (A),
226  IsInitialized_ (false),
227  IsComputed_ (false),
228  IsOverlapping_ (false),
229  OverlapLevel_ (0),
230  CombineMode_ (Tpetra::ZERO),
231  UseReordering_ (false),
232  ReorderingAlgorithm_ ("none"),
233  FilterSingletons_ (false),
234  NumIterations_(1),
235  ZeroStartingSolution_(true),
236  UpdateDamping_(Teuchos::ScalarTraits<scalar_type>::one()),
237  NumInitialize_ (0),
238  NumCompute_ (0),
239  NumApply_ (0),
240  InitializeTime_ (0.0),
241  ComputeTime_ (0.0),
242  ApplyTime_ (0.0)
243 {
245  setParameters (plist); // Set parameters to default values
246 }
247 
248 template<class MatrixType, class LocalInverseType>
251  const int overlapLevel) :
252  Matrix_ (A),
253  IsInitialized_ (false),
254  IsComputed_ (false),
255  IsOverlapping_ (false),
256  OverlapLevel_ (overlapLevel),
257  CombineMode_ (Tpetra::ZERO),
258  UseReordering_ (false),
259  ReorderingAlgorithm_ ("none"),
260  FilterSingletons_ (false),
261  NumIterations_(1),
262  ZeroStartingSolution_(true),
263  UpdateDamping_(Teuchos::ScalarTraits<scalar_type>::one()),
264  NumInitialize_ (0),
265  NumCompute_ (0),
266  NumApply_ (0),
267  InitializeTime_ (0.0),
268  ComputeTime_ (0.0),
269  ApplyTime_ (0.0)
270 {
272  setParameters (plist); // Set parameters to default values
273 }
274 
275 
276 template<class MatrixType,class LocalInverseType>
278 
279 
280 template<class MatrixType,class LocalInverseType>
283 {
285  Matrix_.is_null (), std::runtime_error, "Ifpack2::AdditiveSchwarz::"
286  "getDomainMap: The matrix to precondition is null. You must either pass "
287  "a nonnull matrix to the constructor, or call setMatrix() with a nonnull "
288  "input, before you may call this method.");
289  return Matrix_->getDomainMap ();
290 }
291 
292 
293 template<class MatrixType,class LocalInverseType>
296 {
298  Matrix_.is_null (), std::runtime_error, "Ifpack2::AdditiveSchwarz::"
299  "getRangeMap: The matrix to precondition is null. You must either pass "
300  "a nonnull matrix to the constructor, or call setMatrix() with a nonnull "
301  "input, before you may call this method.");
302  return Matrix_->getRangeMap ();
303 }
304 
305 
306 template<class MatrixType,class LocalInverseType>
308 {
309  return Matrix_;
310 }
311 
312 
313 template<class MatrixType,class LocalInverseType>
314 void
316 apply (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &B,
317  Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &Y,
318  Teuchos::ETransp mode,
319  scalar_type alpha,
320  scalar_type beta) const
321 {
322  using Teuchos::Time;
323  using Teuchos::TimeMonitor;
324  using Teuchos::RCP;
325  using Teuchos::rcp;
326  using Teuchos::rcp_dynamic_cast;
328  const char prefix[] = "Ifpack2::AdditiveSchwarz::apply: ";
329 
331  (! IsComputed_, std::runtime_error,
332  prefix << "isComputed() must be true before you may call apply().");
334  (Matrix_.is_null (), std::logic_error, prefix <<
335  "The input matrix A is null, but the preconditioner says that it has "
336  "been computed (isComputed() is true). This should never happen, since "
337  "setMatrix() should always mark the preconditioner as not computed if "
338  "its argument is null. "
339  "Please report this bug to the Ifpack2 developers.");
341  (Inverse_.is_null (), std::runtime_error,
342  prefix << "The subdomain solver is null. "
343  "This can only happen if you called setInnerPreconditioner() with a null "
344  "input, after calling initialize() or compute(). If you choose to call "
345  "setInnerPreconditioner() with a null input, you must then call it with "
346  "a nonnull input before you may call initialize() or compute().");
348  (B.getNumVectors() != Y.getNumVectors(), std::invalid_argument,
349  prefix << "B and Y must have the same number of columns. B has " <<
350  B.getNumVectors () << " columns, but Y has " << Y.getNumVectors() << ".");
352  (IsOverlapping_ && OverlappingMatrix_.is_null (), std::logic_error,
353  prefix << "The overlapping matrix is null. "
354  "This should never happen if IsOverlapping_ is true. "
355  "Please report this bug to the Ifpack2 developers.");
357  (! IsOverlapping_ && localMap_.is_null (), std::logic_error,
358  prefix << "localMap_ is null. "
359  "This should never happen if IsOverlapping_ is false. "
360  "Please report this bug to the Ifpack2 developers.");
362  (alpha != STS::one (), std::logic_error,
363  prefix << "Not implemented for alpha != 1.");
364  TEUCHOS_TEST_FOR_EXCEPTION
365  (beta != STS::zero (), std::logic_error,
366  prefix << "Not implemented for beta != 0.");
367 
368 #ifdef HAVE_IFPACK2_DEBUG
369  {
370  typedef typename STS::magnitudeType magnitude_type;
372  Teuchos::Array<magnitude_type> norms (B.getNumVectors ());
373  B.norm2 (norms ());
374  bool good = true;
375  for (size_t j = 0; j < B.getNumVectors (); ++j) {
376  if (STM::isnaninf (norms[j])) {
377  good = false;
378  break;
379  }
380  }
381  TEUCHOS_TEST_FOR_EXCEPTION
382  (! good, std::runtime_error, "Ifpack2::AdditiveSchwarz::apply: "
383  "The 2-norm of the input B is NaN or Inf.");
384  }
385 #endif // HAVE_IFPACK2_DEBUG
386 
387 #ifdef HAVE_IFPACK2_DEBUG
388  if (! ZeroStartingSolution_) {
389  typedef typename STS::magnitudeType magnitude_type;
391  Teuchos::Array<magnitude_type> norms (Y.getNumVectors ());
392  Y.norm2 (norms ());
393  bool good = true;
394  for (size_t j = 0; j < Y.getNumVectors (); ++j) {
395  if (STM::isnaninf (norms[j])) {
396  good = false;
397  break;
398  }
399  }
400  TEUCHOS_TEST_FOR_EXCEPTION
401  (! good, std::runtime_error, "Ifpack2::AdditiveSchwarz::apply: "
402  "On input, the initial guess Y has 2-norm NaN or Inf "
403  "(ZeroStartingSolution_ is false).");
404  }
405 #endif // HAVE_IFPACK2_DEBUG
406 
407  const std::string timerName ("Ifpack2::AdditiveSchwarz::apply");
408  RCP<Time> timer = TimeMonitor::lookupCounter (timerName);
409  if (timer.is_null ()) {
410  timer = TimeMonitor::getNewCounter (timerName);
411  }
412 
413  { // Start timing here.
414  TimeMonitor timeMon (*timer);
415 
417  //const scalar_type ONE = Teuchos::ScalarTraits<scalar_type>::one (); // unused
418  const size_t numVectors = B.getNumVectors ();
419 
420  // mfh 25 Apr 2015: Fix for currently failing
421  // Ifpack2_AdditiveSchwarz_RILUK test.
422  if (ZeroStartingSolution_) {
423  Y.putScalar (ZERO);
424  }
425 
426  // set up for overlap communication
427  RCP<MV> OverlappingB,OverlappingY;
428  RCP<MV> globalOverlappingB;
429  if (IsOverlapping_) {
430  // MV's constructor fills with zeros.
431  OverlappingB = rcp (new MV (OverlappingMatrix_->getRowMap (), numVectors));
432  OverlappingY = rcp (new MV (OverlappingMatrix_->getRowMap (), numVectors));
433  }
434  else {
435  // MV's constructor fills with zeros.
436  //
437  // localMap_ has the same number of indices on each process that
438  // Matrix_->getRowMap() does on that process. Thus, we can do
439  // the Import step without creating a new MV, just by viewing
440  // OverlappingB using Matrix_->getRowMap ().
441  OverlappingB = rcp (new MV (localMap_, numVectors));
442  OverlappingY = rcp (new MV (localMap_, numVectors));
443 
444  globalOverlappingB =
445  OverlappingB->offsetViewNonConst (Matrix_->getRowMap (), 0);
446 
447  // Create Import object on demand, if necessary.
448  if (DistributedImporter_.is_null ()) {
449  // FIXME (mfh 15 Apr 2014) Why can't we just ask the Matrix
450  // for its Import object? Of course a general RowMatrix might
451  // not necessarily have one.
452  DistributedImporter_ =
453  rcp (new import_type (Matrix_->getRowMap (),
454  Matrix_->getDomainMap ()));
455  }
456  }
457 
458  RCP<MV> R = rcp(new MV(B.getMap(),numVectors));
459  RCP<MV> C = rcp(new MV(Y.getMap(),numVectors)); //TODO no need to initialize to zero?
460 
461  for (int ni=0; ni<NumIterations_; ++ni)
462  {
463 #ifdef HAVE_IFPACK2_DEBUG
464  {
465  typedef typename STS::magnitudeType magnitude_type;
467  Teuchos::Array<magnitude_type> norms (Y.getNumVectors ());
468  Y.norm2 (norms ());
469  bool good = true;
470  for (size_t j = 0;
471  j < Y.getNumVectors (); ++j) {
472  if (STM::isnaninf (norms[j])) {
473  good = false;
474  break;
475  }
476  }
477  TEUCHOS_TEST_FOR_EXCEPTION
478  (! good, std::runtime_error, "Ifpack2::AdditiveSchwarz::apply: "
479  "At top of iteration " << ni << ", the 2-norm of Y is NaN or Inf.");
480  }
481 #endif // HAVE_IFPACK2_DEBUG
482 
483  Tpetra::deep_copy(*R, B);
484 
485  // if (ZeroStartingSolution_ && ni == 0) {
486  // Y.putScalar (STS::zero ());
487  // }
488  if (!ZeroStartingSolution_ || ni > 0) {
489  //calculate residual
490  Matrix_->apply (Y, *R, mode, -STS::one(), STS::one());
491 
492 #ifdef HAVE_IFPACK2_DEBUG
493  {
494  typedef typename STS::magnitudeType magnitude_type;
496  Teuchos::Array<magnitude_type> norms (R->getNumVectors ());
497  R->norm2 (norms ());
498  bool good = true;
499  for (size_t j = 0; j < R->getNumVectors (); ++j) {
500  if (STM::isnaninf (norms[j])) {
501  good = false;
502  break;
503  }
504  }
505  TEUCHOS_TEST_FOR_EXCEPTION
506  (! good, std::runtime_error, "Ifpack2::AdditiveSchwarz::apply: "
507  "At iteration " << ni << ", the 2-norm of R (result of computing "
508  "residual with Y) is NaN or Inf.");
509  }
510 #endif // HAVE_IFPACK2_DEBUG
511  }
512 
513  typedef OverlappingRowMatrix<row_matrix_type> overlap_mat_type;
514  RCP<overlap_mat_type> overlapMatrix;
515  if (IsOverlapping_) {
516  overlapMatrix = rcp_dynamic_cast<overlap_mat_type> (OverlappingMatrix_);
517  TEUCHOS_TEST_FOR_EXCEPTION
518  (overlapMatrix.is_null (), std::logic_error, prefix <<
519  "IsOverlapping_ is true, but OverlappingMatrix_, while nonnull, is "
520  "not an OverlappingRowMatrix<row_matrix_type>. Please report this "
521  "bug to the Ifpack2 developers.");
522  }
523 
524  // do communication if necessary
525  if (IsOverlapping_) {
526  TEUCHOS_TEST_FOR_EXCEPTION
527  (overlapMatrix.is_null (), std::logic_error, prefix
528  << "overlapMatrix is null when it shouldn't be. "
529  "Please report this bug to the Ifpack2 developers.");
530  overlapMatrix->importMultiVector (*R, *OverlappingB, Tpetra::INSERT);
531 
532  //JJH We don't need to import the solution Y we are always solving AY=R with initial guess zero
533  //if (ZeroStartingSolution_ == false)
534  // overlapMatrix->importMultiVector (Y, *OverlappingY, Tpetra::INSERT);
535  /*
536  FIXME from Ifpack1: Will not work with non-zero starting solutions.
537  TODO JJH 3/20/15 I don't know whether this comment is still valid.
538 
539  Here is the log for the associated commit 720b2fa4 to Ifpack1:
540 
541  "Added a note to recall that the nonzero starting solution will not
542  work properly if reordering, filtering or wider overlaps are used. This only
543  applied to methods like Jacobi, Gauss-Seidel, and SGS (in both point and block
544  version), and not to ILU-type preconditioners."
545  */
546 
547 #ifdef HAVE_IFPACK2_DEBUG
548  {
549  typedef typename STS::magnitudeType magnitude_type;
551  Teuchos::Array<magnitude_type> norms (OverlappingB->getNumVectors ());
552  OverlappingB->norm2 (norms ());
553  bool good = true;
554  for (size_t j = 0;
555  j < OverlappingB->getNumVectors (); ++j) {
556  if (STM::isnaninf (norms[j])) {
557  good = false;
558  break;
559  }
560  }
561  TEUCHOS_TEST_FOR_EXCEPTION
562  (! good, std::runtime_error, "Ifpack2::AdditiveSchwarz::apply: "
563  "At iteration " << ni << ", result of importMultiVector from R "
564  "to OverlappingB, has 2-norm NaN or Inf.");
565  }
566 #endif // HAVE_IFPACK2_DEBUG
567  } else {
568  globalOverlappingB->doImport (*R, *DistributedImporter_, Tpetra::INSERT);
569 
570 #ifdef HAVE_IFPACK2_DEBUG
571  {
572  typedef typename STS::magnitudeType magnitude_type;
574  Teuchos::Array<magnitude_type> norms (globalOverlappingB->getNumVectors ());
575  globalOverlappingB->norm2 (norms ());
576  bool good = true;
577  for (size_t j = 0;
578  j < globalOverlappingB->getNumVectors (); ++j) {
579  if (STM::isnaninf (norms[j])) {
580  good = false;
581  break;
582  }
583  }
584  TEUCHOS_TEST_FOR_EXCEPTION
585  (! good, std::runtime_error, "Ifpack2::AdditiveSchwarz::apply: "
586  "At iteration " << ni << ", result of doImport from R, has 2-norm "
587  "NaN or Inf.");
588  }
589 #endif // HAVE_IFPACK2_DEBUG
590  }
591 
592 #ifdef HAVE_IFPACK2_DEBUG
593  {
594  typedef typename STS::magnitudeType magnitude_type;
596  Teuchos::Array<magnitude_type> norms (OverlappingB->getNumVectors ());
597  OverlappingB->norm2 (norms ());
598  bool good = true;
599  for (size_t j = 0;
600  j < OverlappingB->getNumVectors (); ++j) {
601  if (STM::isnaninf (norms[j])) {
602  good = false;
603  break;
604  }
605  }
606  TEUCHOS_TEST_FOR_EXCEPTION
607  (! good, std::runtime_error, "Ifpack2::AdditiveSchwarz::apply: "
608  "At iteration " << ni << ", right before localApply, the 2-norm of "
609  "OverlappingB is NaN or Inf.");
610  }
611 #endif // HAVE_IFPACK2_DEBUG
612 
613  // local solve
614  localApply(*OverlappingB, *OverlappingY);
615 
616 #ifdef HAVE_IFPACK2_DEBUG
617  {
618  typedef typename STS::magnitudeType magnitude_type;
620  Teuchos::Array<magnitude_type> norms (OverlappingY->getNumVectors ());
621  OverlappingY->norm2 (norms ());
622  bool good = true;
623  for (size_t j = 0;
624  j < OverlappingY->getNumVectors (); ++j) {
625  if (STM::isnaninf (norms[j])) {
626  good = false;
627  break;
628  }
629  }
630  TEUCHOS_TEST_FOR_EXCEPTION
631  (! good, std::runtime_error, "Ifpack2::AdditiveSchwarz::apply: "
632  "At iteration " << ni << ", after localApply and before export / "
633  "copy, the 2-norm of OverlappingY is NaN or Inf.");
634  }
635 #endif // HAVE_IFPACK2_DEBUG
636 
637 #ifdef HAVE_IFPACK2_DEBUG
638  {
639  typedef typename STS::magnitudeType magnitude_type;
641  Teuchos::Array<magnitude_type> norms (C->getNumVectors ());
642  C->norm2 (norms ());
643  bool good = true;
644  for (size_t j = 0;
645  j < C->getNumVectors (); ++j) {
646  if (STM::isnaninf (norms[j])) {
647  good = false;
648  break;
649  }
650  }
651  TEUCHOS_TEST_FOR_EXCEPTION
652  (! good, std::runtime_error, "Ifpack2::AdditiveSchwarz::apply: "
653  "At iteration " << ni << ", before export / copy, the 2-norm of C "
654  "is NaN or Inf.");
655  }
656 #endif // HAVE_IFPACK2_DEBUG
657 
658  // do communication if necessary
659  if (IsOverlapping_) {
660  TEUCHOS_TEST_FOR_EXCEPTION
661  (overlapMatrix.is_null (), std::logic_error, prefix
662  << "overlapMatrix is null when it shouldn't be. "
663  "Please report this bug to the Ifpack2 developers.");
664  overlapMatrix->exportMultiVector (*OverlappingY, *C, CombineMode_);
665  }
666  else {
667  // mfh 16 Apr 2014: Make a view of Y with the same Map as
668  // OverlappingY, so that we can copy OverlappingY into Y. This
669  // replaces code that iterates over all entries of OverlappingY,
670  // copying them one at a time into Y. That code assumed that
671  // the rows of Y and the rows of OverlappingY have the same
672  // global indices in the same order; see Bug 5992.
673  RCP<MV> C_view = C->offsetViewNonConst (OverlappingY->getMap (), 0);
674  Tpetra::deep_copy (*C_view, *OverlappingY);
675  }
676 
677 #ifdef HAVE_IFPACK2_DEBUG
678  {
679  typedef typename STS::magnitudeType magnitude_type;
681  Teuchos::Array<magnitude_type> norms (C->getNumVectors ());
682  C->norm2 (norms ());
683  bool good = true;
684  for (size_t j = 0;
685  j < C->getNumVectors (); ++j) {
686  if (STM::isnaninf (norms[j])) {
687  good = false;
688  break;
689  }
690  }
691  TEUCHOS_TEST_FOR_EXCEPTION
692  (! good, std::runtime_error, "Ifpack2::AdditiveSchwarz::apply: "
693  "At iteration " << ni << ", before Y := C + Y, the 2-norm of C "
694  "is NaN or Inf.");
695  }
696 #endif // HAVE_IFPACK2_DEBUG
697 
698 #ifdef HAVE_IFPACK2_DEBUG
699  {
700  typedef typename STS::magnitudeType magnitude_type;
702  Teuchos::Array<magnitude_type> norms (Y.getNumVectors ());
703  Y.norm2 (norms ());
704  bool good = true;
705  for (size_t j = 0;
706  j < Y.getNumVectors (); ++j) {
707  if (STM::isnaninf (norms[j])) {
708  good = false;
709  break;
710  }
711  }
712  TEUCHOS_TEST_FOR_EXCEPTION
713  (! good, std::runtime_error, "Ifpack2::AdditiveSchwarz::apply: "
714  "Before Y := C + Y, at iteration " << ni << ", the 2-norm of Y "
715  "is NaN or Inf.");
716  }
717 #endif // HAVE_IFPACK2_DEBUG
718 
719  Y.update(UpdateDamping_, *C, STS::one());
720 
721 #ifdef HAVE_IFPACK2_DEBUG
722  {
723  typedef typename STS::magnitudeType magnitude_type;
725  Teuchos::Array<magnitude_type> norms (Y.getNumVectors ());
726  Y.norm2 (norms ());
727  bool good = true;
728  for (size_t j = 0; j < Y.getNumVectors (); ++j) {
729  if (STM::isnaninf (norms[j])) {
730  good = false;
731  break;
732  }
733  }
734  TEUCHOS_TEST_FOR_EXCEPTION
735  ( ! good, std::runtime_error, "Ifpack2::AdditiveSchwarz::apply: "
736  "At iteration " << ni << ", after Y := C + Y, the 2-norm of Y "
737  "is NaN or Inf.");
738  }
739 #endif // HAVE_IFPACK2_DEBUG
740  }
741 
742  } // Stop timing here.
743 
744 #ifdef HAVE_IFPACK2_DEBUG
745  {
746  typedef typename STS::magnitudeType magnitude_type;
748  Teuchos::Array<magnitude_type> norms (Y.getNumVectors ());
749  Y.norm2 (norms ());
750  bool good = true;
751  for (size_t j = 0; j < Y.getNumVectors (); ++j) {
752  if (STM::isnaninf (norms[j])) {
753  good = false;
754  break;
755  }
756  }
757  TEUCHOS_TEST_FOR_EXCEPTION
758  ( ! good, std::runtime_error, "Ifpack2::AdditiveSchwarz::apply: "
759  "The 2-norm of the output Y is NaN or Inf.");
760  }
761 #endif // HAVE_IFPACK2_DEBUG
762 
763  ++NumApply_;
764 
765  // timer->totalElapsedTime() returns the total time over all timer
766  // calls. Thus, we use = instead of +=.
767  ApplyTime_ = timer->totalElapsedTime ();
768 }
769 
770 template<class MatrixType,class LocalInverseType>
771 void
773 localApply(MV &OverlappingB, MV &OverlappingY) const
774 {
775  using Teuchos::RCP;
776  using Teuchos::rcp_dynamic_cast;
777 
778  const size_t numVectors = OverlappingB.getNumVectors ();
779  if (FilterSingletons_) {
780  // process singleton filter
781  MV ReducedB (SingletonMatrix_->getRowMap (), numVectors);
782  MV ReducedY (SingletonMatrix_->getRowMap (), numVectors);
783 
784  RCP<SingletonFilter<row_matrix_type> > singletonFilter =
785  rcp_dynamic_cast<SingletonFilter<row_matrix_type> > (SingletonMatrix_);
787  (! SingletonMatrix_.is_null () && singletonFilter.is_null (),
788  std::logic_error, "Ifpack2::AdditiveSchwarz::localApply: "
789  "SingletonFilter_ is nonnull but is not a SingletonFilter"
790  "<row_matrix_type>. This should never happen. Please report this bug "
791  "to the Ifpack2 developers.");
792  singletonFilter->SolveSingletons (OverlappingB, OverlappingY);
793  singletonFilter->CreateReducedRHS (OverlappingY, OverlappingB, ReducedB);
794 
795  // process reordering
796  if (! UseReordering_) {
797  Inverse_->solve (ReducedY, ReducedB);
798  }
799  else {
800  RCP<ReorderFilter<row_matrix_type> > rf =
801  rcp_dynamic_cast<ReorderFilter<row_matrix_type> > (ReorderedLocalizedMatrix_);
803  (! ReorderedLocalizedMatrix_.is_null () && rf.is_null (), std::logic_error,
804  "Ifpack2::AdditiveSchwarz::localApply: ReorderedLocalizedMatrix_ is "
805  "nonnull but is not a ReorderFilter<row_matrix_type>. This should "
806  "never happen. Please report this bug to the Ifpack2 developers.");
807  MV ReorderedB (ReducedB, Teuchos::Copy);
808  MV ReorderedY (ReducedY, Teuchos::Copy);
809  rf->permuteOriginalToReordered (ReducedB, ReorderedB);
810  Inverse_->solve (ReorderedY, ReorderedB);
811  rf->permuteReorderedToOriginal (ReorderedY, ReducedY);
812  }
813 
814  // finish up with singletons
815  singletonFilter->UpdateLHS (ReducedY, OverlappingY);
816  }
817  else {
818 
819  // process reordering
820  if (! UseReordering_) {
821  Inverse_->solve (OverlappingY, OverlappingB);
822  }
823  else {
824  MV ReorderedB (OverlappingB, Teuchos::Copy);
825  MV ReorderedY (OverlappingY, Teuchos::Copy);
826 
827  RCP<ReorderFilter<row_matrix_type> > rf =
828  rcp_dynamic_cast<ReorderFilter<row_matrix_type> > (ReorderedLocalizedMatrix_);
830  (! ReorderedLocalizedMatrix_.is_null () && rf.is_null (), std::logic_error,
831  "Ifpack2::AdditiveSchwarz::localApply: ReorderedLocalizedMatrix_ is "
832  "nonnull but is not a ReorderFilter<row_matrix_type>. This should "
833  "never happen. Please report this bug to the Ifpack2 developers.");
834  rf->permuteOriginalToReordered (OverlappingB, ReorderedB);
835  Inverse_->solve (ReorderedY, ReorderedB);
836  rf->permuteReorderedToOriginal (ReorderedY, OverlappingY);
837  }
838  }
839 }
840 
841 
842 template<class MatrixType,class LocalInverseType>
845 {
846  // mfh 18 Nov 2013: Ifpack2's setParameters() method passes in the
847  // input list as const. This means that we have to copy it before
848  // validation or passing into setParameterList().
849  List_ = plist;
850  this->setParameterList (Teuchos::rcpFromRef (List_));
851 }
852 
853 
854 
855 template<class MatrixType,class LocalInverseType>
858 {
859  using Tpetra::CombineMode;
860  using Teuchos::getIntegralValue;
864  using Teuchos::RCP;
865  using Teuchos::rcp;
866  using Teuchos::rcp_dynamic_cast;
868 
869  if (plist.is_null ()) {
870  // Assume that the user meant to set default parameters by passing
871  // in an empty list.
872  this->setParameterList (rcp (new ParameterList ()));
873  }
874  // FIXME (mfh 26 Aug 2015) It's not necessarily true that plist is
875  // nonnull at this point.
876 
877  // At this point, plist should be nonnull.
879  plist.is_null (), std::logic_error, "Ifpack2::AdditiveSchwarz::"
880  "setParameterList: plist is null. This should never happen, since the "
881  "method should have replaced a null input list with a nonnull empty list "
882  "by this point. Please report this bug to the Ifpack2 developers.");
883 
884  // TODO JJH 24March2015 The list needs to be validated. Not sure why this is commented out.
885  // try {
886  // List_.validateParameters (* getValidParameters ());
887  // }
888  // catch (std::exception& e) {
889  // std::cerr << "Ifpack2::AdditiveSchwarz::setParameterList: Validation failed with the following error message: " << e.what () << std::endl;
890  // throw e;
891  // }
892 
893  // mfh 18 Nov 2013: Supplying the current value as the default value
894  // when calling ParameterList::get() ensures "delta" behavior when
895  // users pass in new parameters: any unspecified parameters in the
896  // new list retain their values in the old list. This preserves
897  // backwards compatiblity with this class' previous behavior. Note
898  // that validateParametersAndSetDefaults() would have different
899  // behavior: any parameters not in the new list would get default
900  // values, which could be different than their values in the
901  // original list.
902 
903  bool gotCombineMode = false;
904  try {
905  CombineMode_ = getIntegralValue<Tpetra::CombineMode> (List_, "schwarz: combine mode");
906  gotCombineMode = true;
907  }
909  // The caller didn't provide that parameter. Just keep the
910  // existing value of CombineMode_.
911  gotCombineMode = true;
912  }
914  // The user perhaps supplied it as an Tpetra::CombineMode enum
915  // value. Let's try again (below). If it doesn't succeed, we
916  // know that the type is wrong, so we can let it throw whatever
917  // exception it would throw.
918  }
919  // Try to get the combine mode as an integer.
920  if (! gotCombineMode) {
921  try {
922  CombineMode_ = plist->get ("schwarz: combine mode", CombineMode_);
923  gotCombineMode = true;
924  }
926  }
927  // Try to get the combine mode as a string. If this works, use the
928  // validator to convert to int. This is painful, but necessary in
929  // order to do validation, since the input list doesn't come with a
930  // validator.
931  if (! gotCombineMode) {
932  const ParameterEntry& validEntry =
933  getValidParameters ()->getEntry ("schwarz: combine mode");
934  RCP<const ParameterEntryValidator> v = validEntry.validator ();
935  typedef StringToIntegralParameterEntryValidator<CombineMode> vs2e_type;
936  RCP<const vs2e_type> vs2e = rcp_dynamic_cast<const vs2e_type> (v, true);
937 
938  const ParameterEntry& inputEntry = plist->getEntry ("schwarz: combine mode");
939  CombineMode_ = vs2e->getIntegralValue (inputEntry, "schwarz: combine mode");
940  gotCombineMode = true;
941  }
942  (void) gotCombineMode; // forestall "set but not used" compiler warning
943 
944  OverlapLevel_ = plist->get ("schwarz: overlap level", OverlapLevel_);
945 
946  // We set IsOverlapping_ in initialize(), once we know that Matrix_ is nonnull.
947 
948  // Will we be doing reordering? Unlike Ifpack, we'll use a
949  // "schwarz: reordering list" to give to Zoltan2.
950  UseReordering_ = plist->get ("schwarz: use reordering", UseReordering_);
951 
952 #if !defined(HAVE_IFPACK2_XPETRA) || !defined(HAVE_IFPACK2_ZOLTAN2)
954  UseReordering_, std::invalid_argument, "Ifpack2::AdditiveSchwarz::"
955  "setParameters: You specified \"schwarz: use reordering\" = true. "
956  "This is only valid when Trilinos was built with Ifpack2, Xpetra, and "
957  "Zoltan2 enabled. Either Xpetra or Zoltan2 was not enabled in your build "
958  "of Trilinos.");
959 #endif
960 
961  // FIXME (mfh 18 Nov 2013) Now would be a good time to validate the
962  // "schwarz: reordering list" parameter list. Currently, that list
963  // gets extracted in setup().
964 
965  // if true, filter singletons. NOTE: the filtered matrix can still have
966  // singletons! A simple example: upper triangular matrix, if I remove
967  // the lower node, I still get a matrix with a singleton! However, filter
968  // singletons should help for PDE problems with Dirichlet BCs.
969  FilterSingletons_ = plist->get ("schwarz: filter singletons", FilterSingletons_);
970 
971  // Allow for damped Schwarz updates
972  UpdateDamping_ = Teuchos::as<scalar_type>(plist->get("schwarz: update damping",UpdateDamping_));
973 
974  // If the inner solver doesn't exist yet, don't create it.
975  // initialize() creates it.
976  //
977  // If the inner solver _does_ exist, there are three cases,
978  // depending on what the user put in the input ParameterList.
979  //
980  // 1. The user did /not/ provide a parameter specifying the inner
981  // solver's type, nor did the user specify a sublist of
982  // parameters for the inner solver
983  // 2. The user did /not/ provide a parameter specifying the inner
984  // solver's type, but /did/ specify a sublist of parameters for
985  // the inner solver
986  // 3. The user provided a parameter specifying the inner solver's
987  // type (it does not matter in this case whether the user gave
988  // a sublist of parameters for the inner solver)
989  //
990  // AdditiveSchwarz has "delta" (relative) semantics for setting
991  // parameters. This means that if the user did not specify the
992  // inner solver's type, we presume that the type has not changed.
993  // Thus, if the inner solver exists, we don't need to recreate it.
994  //
995  // In Case 3, if the user bothered to specify the inner solver's
996  // type, then we must assume it may differ than the current inner
997  // solver's type. Thus, we have to recreate the inner solver. We
998  // achieve this here by assigning null to Inverse_; initialize()
999  // will recreate the solver when it is needed. Our assumption here
1000  // is necessary because Ifpack2::Preconditioner does not have a
1001  // method for querying a preconditioner's "type" (i.e., name) as a
1002  // string. Remember that the user may have previously set an
1003  // arbitrary inner solver by calling setInnerPreconditioner().
1004  //
1005  // See note at the end of setInnerPreconditioner().
1006 
1007  if (! Inverse_.is_null ()) {
1008  // "CUSTOM" explicitly indicates that the user called or plans to
1009  // call setInnerPreconditioner.
1010  if (hasInnerPrecName () && innerPrecName () != "CUSTOM") {
1011  // Wipe out the current inner solver. initialize() will
1012  // recreate it with the correct type.
1013  Inverse_ = Teuchos::null;
1014  }
1015  else {
1016  // Extract and apply the sublist of parameters to give to the
1017  // inner solver, if there is such a sublist of parameters.
1018  std::pair<Teuchos::ParameterList, bool> result = innerPrecParams ();
1019  if (result.second) {
1020  // FIXME (mfh 26 Aug 2015) Rewrite innerPrecParams() so this
1021  // isn't another deep copy.
1022  Inverse_->setParameters (rcp (new ParameterList (result.first)));
1023  }
1024  }
1025  }
1026 
1027  NumIterations_ = plist->get<int>("schwarz: num iterations", NumIterations_);
1028  ZeroStartingSolution_ = plist->get<bool>("schwarz: zero starting solution", ZeroStartingSolution_);
1029 }
1030 
1031 
1032 
1033 template<class MatrixType,class LocalInverseType>
1037 {
1038  using Teuchos::ParameterList;
1039  using Teuchos::parameterList;
1040  using Teuchos::RCP;
1041  using Teuchos::rcp_const_cast;
1042 
1043  if (validParams_.is_null ()) {
1044  const int overlapLevel = 0;
1045  const bool useReordering = false;
1046  const bool filterSingletons = false;
1047  const int numIterations = 1;
1048  const bool zeroStartingSolution = true;
1049  const double updateDamping = 1;
1050  ParameterList reorderingSublist;
1051  reorderingSublist.set ("order_method", std::string ("rcm"));
1052 
1053  RCP<ParameterList> plist = parameterList ("Ifpack2::AdditiveSchwarz");
1054 
1055  Tpetra::setCombineModeParameter (*plist, "schwarz: combine mode");
1056  plist->set ("schwarz: overlap level", overlapLevel);
1057  plist->set ("schwarz: use reordering", useReordering);
1058  plist->set ("schwarz: reordering list", reorderingSublist);
1059  // mfh 24 Mar 2015: We accept this for backwards compatibility
1060  // ONLY. It is IGNORED.
1061  plist->set ("schwarz: compute condest", false);
1062  plist->set ("schwarz: filter singletons", filterSingletons);
1063  plist->set ("schwarz: num iterations", numIterations);
1064  plist->set ("schwarz: zero starting solution", zeroStartingSolution);
1065  plist->set ("schwarz: update damping", updateDamping);
1066 
1067  // FIXME (mfh 18 Nov 2013) Get valid parameters from inner solver.
1068  // JJH The inner solver should handle its own validation.
1069  //
1070  // FIXME (mfh 18 Nov 2013) Get valid parameters from Zoltan2, if
1071  // Zoltan2 was enabled in the build.
1072  // JJH Zoltan2 should handle its own validation.
1073  //
1074 
1075  validParams_ = rcp_const_cast<const ParameterList> (plist);
1076  }
1077  return validParams_;
1078 }
1079 
1080 
1081 template<class MatrixType,class LocalInverseType>
1083 {
1084  using Tpetra::global_size_t;
1085  using Teuchos::RCP;
1086  using Teuchos::rcp;
1087  using Teuchos::SerialComm;
1088  using Teuchos::Time;
1089  using Teuchos::TimeMonitor;
1090 
1091  const std::string timerName ("Ifpack2::AdditiveSchwarz::initialize");
1092  RCP<Time> timer = TimeMonitor::lookupCounter (timerName);
1093  if (timer.is_null ()) {
1094  timer = TimeMonitor::getNewCounter (timerName);
1095  }
1096 
1097  { // Start timing here.
1098  TimeMonitor timeMon (*timer);
1099 
1101  Matrix_.is_null (), std::runtime_error, "Ifpack2::AdditiveSchwarz::"
1102  "initialize: The matrix to precondition is null. You must either pass "
1103  "a nonnull matrix to the constructor, or call setMatrix() with a nonnull "
1104  "input, before you may call this method.");
1105 
1106  IsInitialized_ = false;
1107  IsComputed_ = false;
1108 
1109  RCP<const Teuchos::Comm<int> > comm = Matrix_->getComm ();
1110  RCP<const map_type> rowMap = Matrix_->getRowMap ();
1111  const global_size_t INVALID =
1113 
1114  // If there's only one process in the matrix's communicator,
1115  // then there's no need to compute overlap.
1116  if (comm->getSize () == 1) {
1117  OverlapLevel_ = 0;
1118  IsOverlapping_ = false;
1119  } else if (OverlapLevel_ != 0) {
1120  IsOverlapping_ = true;
1121  }
1122 
1123  if (OverlapLevel_ == 0) {
1124  const global_ordinal_type indexBase = rowMap->getIndexBase ();
1125  RCP<const SerialComm<int> > localComm (new SerialComm<int> ());
1126  // FIXME (mfh 15 Apr 2014) What if indexBase isn't the least
1127  // global index in the list of GIDs on this process?
1128  localMap_ =
1129  rcp (new map_type (INVALID, rowMap->getNodeNumElements (),
1130  indexBase, localComm));
1131  }
1132 
1133  // compute the overlapping matrix if necessary
1134  if (IsOverlapping_) {
1135  OverlappingMatrix_ = rcp (new OverlappingRowMatrix<row_matrix_type> (Matrix_, OverlapLevel_));
1136  }
1137 
1138  setup (); // This does a lot of the initialization work.
1139 
1140  if (! Inverse_.is_null ()) {
1141  Inverse_->symbolic (); // Initialize subdomain solver.
1142  }
1143 
1144  } // Stop timing here.
1145 
1146  IsInitialized_ = true;
1147  ++NumInitialize_;
1148 
1149  // timer->totalElapsedTime() returns the total time over all timer
1150  // calls. Thus, we use = instead of +=.
1151  InitializeTime_ = timer->totalElapsedTime ();
1152 }
1153 
1154 
1155 template<class MatrixType,class LocalInverseType>
1157 {
1158  return IsInitialized_;
1159 }
1160 
1161 
1162 template<class MatrixType,class LocalInverseType>
1164 {
1165  using Teuchos::RCP;
1166  using Teuchos::Time;
1167  using Teuchos::TimeMonitor;
1168 
1169  if (! IsInitialized_) {
1170  initialize ();
1171  }
1172 
1174  ! isInitialized (), std::logic_error, "Ifpack2::AdditiveSchwarz::compute: "
1175  "The preconditioner is not yet initialized, "
1176  "even though initialize() supposedly has been called. "
1177  "This should never happen. "
1178  "Please report this bug to the Ifpack2 developers.");
1179 
1181  Inverse_.is_null (), std::runtime_error,
1182  "Ifpack2::AdditiveSchwarz::compute: The subdomain solver is null. "
1183  "This can only happen if you called setInnerPreconditioner() with a null "
1184  "input, after calling initialize() or compute(). If you choose to call "
1185  "setInnerPreconditioner() with a null input, you must then call it with a "
1186  "nonnull input before you may call initialize() or compute().");
1187 
1188  const std::string timerName ("Ifpack2::AdditiveSchwarz::compute");
1189  RCP<Time> timer = TimeMonitor::lookupCounter (timerName);
1190  if (timer.is_null ()) {
1191  timer = TimeMonitor::getNewCounter (timerName);
1192  }
1193 
1194  { // Start timing here.
1195  TimeMonitor timeMon (*timer);
1196 
1197  IsComputed_ = false;
1198  Inverse_->numeric ();
1199  } // Stop timing here.
1200 
1201  IsComputed_ = true;
1202  ++NumCompute_;
1203 
1204  // timer->totalElapsedTime() returns the total time over all timer
1205  // calls. Thus, we use = instead of +=.
1206  ComputeTime_ = timer->totalElapsedTime ();
1207 }
1208 
1209 //==============================================================================
1210 // Returns true if the preconditioner has been successfully computed, false otherwise.
1211 template<class MatrixType,class LocalInverseType>
1213 {
1214  return IsComputed_;
1215 }
1216 
1217 
1218 template<class MatrixType,class LocalInverseType>
1220 {
1221  return NumInitialize_;
1222 }
1223 
1224 
1225 template<class MatrixType,class LocalInverseType>
1227 {
1228  return NumCompute_;
1229 }
1230 
1231 
1232 template<class MatrixType,class LocalInverseType>
1234 {
1235  return NumApply_;
1236 }
1237 
1238 
1239 template<class MatrixType,class LocalInverseType>
1241 {
1242  return InitializeTime_;
1243 }
1244 
1245 
1246 template<class MatrixType,class LocalInverseType>
1248 {
1249  return ComputeTime_;
1250 }
1251 
1252 
1253 template<class MatrixType,class LocalInverseType>
1255 {
1256  return ApplyTime_;
1257 }
1258 
1259 
1260 template<class MatrixType,class LocalInverseType>
1262 {
1263  std::ostringstream out;
1264 
1265  out << "\"Ifpack2::AdditiveSchwarz\": {";
1266  if (this->getObjectLabel () != "") {
1267  out << "Label: \"" << this->getObjectLabel () << "\", ";
1268  }
1269  out << "Initialized: " << (isInitialized () ? "true" : "false")
1270  << ", Computed: " << (isComputed () ? "true" : "false")
1271  << ", Iterations: " << NumIterations_
1272  << ", Overlap level: " << OverlapLevel_
1273  << ", Subdomain reordering: \"" << ReorderingAlgorithm_ << "\"";
1274  out << ", Combine mode: \"";
1275  if (CombineMode_ == Tpetra::INSERT) {
1276  out << "INSERT";
1277  } else if (CombineMode_ == Tpetra::ADD) {
1278  out << "ADD";
1279  } else if (CombineMode_ == Tpetra::REPLACE) {
1280  out << "REPLACE";
1281  } else if (CombineMode_ == Tpetra::ABSMAX) {
1282  out << "ABSMAX";
1283  } else if (CombineMode_ == Tpetra::ZERO) {
1284  out << "ZERO";
1285  }
1286  out << "\"";
1287  if (Matrix_.is_null ()) {
1288  out << ", Matrix: null";
1289  }
1290  else {
1291  out << ", Global matrix dimensions: ["
1292  << Matrix_->getGlobalNumRows () << ", "
1293  << Matrix_->getGlobalNumCols () << "]";
1294  }
1295  out << ", Inner solver: ";
1296  if (! Inverse_.is_null ()) {
1298  Teuchos::rcp_dynamic_cast<Teuchos::Describable> (Inverse_);
1299  if (! inv.is_null ()) {
1300  out << "{" << inv->description () << "}";
1301  } else {
1302  out << "{" << "Some inner solver" << "}";
1303  }
1304  } else {
1305  out << "null";
1306  }
1307 
1308  out << "}";
1309  return out.str ();
1310 }
1311 
1312 
1313 template<class MatrixType,class LocalInverseType>
1314 void
1317  const Teuchos::EVerbosityLevel verbLevel) const
1318 {
1319  using Teuchos::OSTab;
1321  using std::endl;
1322 
1323  const int myRank = Matrix_->getComm ()->getRank ();
1324  const int numProcs = Matrix_->getComm ()->getSize ();
1325  const Teuchos::EVerbosityLevel vl =
1326  (verbLevel == Teuchos::VERB_DEFAULT) ? Teuchos::VERB_LOW : verbLevel;
1327 
1328  if (vl > Teuchos::VERB_NONE) {
1329  // describe() starts with a tab, by convention.
1330  OSTab tab0 (out);
1331  if (myRank == 0) {
1332  out << "\"Ifpack2::AdditiveSchwarz\":";
1333  }
1334  OSTab tab1 (out);
1335  if (myRank == 0) {
1336  out << "MatrixType: " << TypeNameTraits<MatrixType>::name () << endl;
1337  out << "LocalInverseType: " << TypeNameTraits<LocalInverseType>::name () << endl;
1338  if (this->getObjectLabel () != "") {
1339  out << "Label: \"" << this->getObjectLabel () << "\"" << endl;
1340  }
1341 
1342  out << "Overlap level: " << OverlapLevel_ << endl
1343  << "Combine mode: \"";
1344  if (CombineMode_ == Tpetra::INSERT) {
1345  out << "INSERT";
1346  } else if (CombineMode_ == Tpetra::ADD) {
1347  out << "ADD";
1348  } else if (CombineMode_ == Tpetra::REPLACE) {
1349  out << "REPLACE";
1350  } else if (CombineMode_ == Tpetra::ABSMAX) {
1351  out << "ABSMAX";
1352  } else if (CombineMode_ == Tpetra::ZERO) {
1353  out << "ZERO";
1354  }
1355  out << "\"" << endl
1356  << "Subdomain reordering: \"" << ReorderingAlgorithm_ << "\"" << endl;
1357  }
1358 
1359  if (Matrix_.is_null ()) {
1360  if (myRank == 0) {
1361  out << "Matrix: null" << endl;
1362  }
1363  }
1364  else {
1365  if (myRank == 0) {
1366  out << "Matrix:" << endl;
1367  std::flush (out);
1368  }
1369  Matrix_->getComm ()->barrier (); // wait for output to finish
1370  Matrix_->describe (out, Teuchos::VERB_LOW);
1371  }
1372 
1373  if (myRank == 0) {
1374  out << "Number of initialize calls: " << getNumInitialize () << endl
1375  << "Number of compute calls: " << getNumCompute () << endl
1376  << "Number of apply calls: " << getNumApply () << endl
1377  << "Total time in seconds for initialize: " << getInitializeTime () << endl
1378  << "Total time in seconds for compute: " << getComputeTime () << endl
1379  << "Total time in seconds for apply: " << getApplyTime () << endl;
1380  }
1381 
1382  if (Inverse_.is_null ()) {
1383  if (myRank == 0) {
1384  out << "Subdomain solver: null" << endl;
1385  }
1386  }
1387  else {
1388  if (vl < Teuchos::VERB_EXTREME) {
1389  if (myRank == 0) {
1390  out << "Subdomain solver: not null" << endl;
1391  }
1392  }
1393  else { // vl >= Teuchos::VERB_EXTREME
1394  for (int p = 0; p < numProcs; ++p) {
1395  if (p == myRank) {
1396  out << "Subdomain solver on Process " << myRank << ":";
1397  if (Inverse_.is_null ()) {
1398  out << "null" << endl;
1399  } else {
1401  Teuchos::rcp_dynamic_cast<Teuchos::Describable> (Inverse_);
1402  if (! inv.is_null ()) {
1403  out << endl;
1404  inv->describe (out, vl);
1405  } else {
1406  out << "null" << endl;
1407  }
1408  }
1409  }
1410  Matrix_->getComm ()->barrier ();
1411  Matrix_->getComm ()->barrier ();
1412  Matrix_->getComm ()->barrier (); // wait for output to finish
1413  }
1414  }
1415  }
1416 
1417  Matrix_->getComm ()->barrier (); // wait for output to finish
1418  }
1419 }
1420 
1421 
1422 template<class MatrixType,class LocalInverseType>
1423 std::ostream& AdditiveSchwarz<MatrixType,LocalInverseType>::print(std::ostream& os) const
1424 {
1425  Teuchos::FancyOStream fos(Teuchos::rcp(&os,false));
1426  fos.setOutputToRootOnly(0);
1427  describe(fos);
1428  return(os);
1429 }
1430 
1431 
1432 template<class MatrixType,class LocalInverseType>
1434 {
1435  return OverlapLevel_;
1436 }
1437 
1438 
1439 template<class MatrixType,class LocalInverseType>
1441 {
1442 #ifdef HAVE_MPI
1443  using Teuchos::MpiComm;
1444 #endif // HAVE_MPI
1445  using Teuchos::ArrayRCP;
1446  using Teuchos::ParameterList;
1447  using Teuchos::RCP;
1448  using Teuchos::rcp;
1449  using Teuchos::rcp_dynamic_cast;
1450  using Teuchos::rcpFromRef;
1451 
1453  Matrix_.is_null (), std::runtime_error, "Ifpack2::AdditiveSchwarz::"
1454  "initialize: The matrix to precondition is null. You must either pass "
1455  "a nonnull matrix to the constructor, or call setMatrix() with a nonnull "
1456  "input, before you may call this method.");
1457 
1458  // Localized version of Matrix_ or OverlappingMatrix_.
1459  RCP<row_matrix_type> LocalizedMatrix;
1460 
1461  // The "most current local matrix." At the end of this method, this
1462  // will be handed off to the inner solver.
1463  RCP<row_matrix_type> ActiveMatrix;
1464 
1465  // Create localized matrix.
1466  if (! OverlappingMatrix_.is_null ()) {
1467  LocalizedMatrix = rcp (new LocalFilter<row_matrix_type> (OverlappingMatrix_));
1468  }
1469  else {
1470  LocalizedMatrix = rcp (new LocalFilter<row_matrix_type> (Matrix_));
1471  }
1472 
1473  // Sanity check; I don't trust the logic above to have created LocalizedMatrix.
1475  LocalizedMatrix.is_null (), std::logic_error,
1476  "Ifpack2::AdditiveSchwarz::setup: LocalizedMatrix is null, after the code "
1477  "that claimed to have created it. This should never be the case. Please "
1478  "report this bug to the Ifpack2 developers.");
1479 
1480  // Mark localized matrix as active
1481  ActiveMatrix = LocalizedMatrix;
1482 
1483  // Singleton Filtering
1484  if (FilterSingletons_) {
1485  SingletonMatrix_ = rcp (new SingletonFilter<row_matrix_type> (LocalizedMatrix));
1486  ActiveMatrix = SingletonMatrix_;
1487  }
1488 
1489  // Do reordering
1490  if (UseReordering_) {
1491 #if defined(HAVE_IFPACK2_XPETRA) && defined(HAVE_IFPACK2_ZOLTAN2)
1492  // Unlike Ifpack, Zoltan2 does all the dirty work here.
1493  typedef ReorderFilter<row_matrix_type> reorder_filter_type;
1494  Teuchos::ParameterList zlist = List_.sublist ("schwarz: reordering list");
1495  ReorderingAlgorithm_ = zlist.get<std::string> ("order_method", "rcm");
1496 
1497  ArrayRCP<local_ordinal_type> perm;
1498  ArrayRCP<local_ordinal_type> revperm;
1499 
1500  if(ReorderingAlgorithm_ == "user") {
1501  // User-provided reordering
1502  perm = zlist.get<Teuchos::ArrayRCP<local_ordinal_type> >("user ordering");
1503  revperm = zlist.get<Teuchos::ArrayRCP<local_ordinal_type> >("user reverse ordering");
1504  }
1505  else {
1506  // Zoltan2 reordering
1507  typedef Tpetra::RowGraph
1508  <local_ordinal_type, global_ordinal_type, node_type> row_graph_type;
1509  typedef Zoltan2::TpetraRowGraphAdapter<row_graph_type> z2_adapter_type;
1510  RCP<const row_graph_type> constActiveGraph =
1511  Teuchos::rcp_const_cast<const row_graph_type>(ActiveMatrix->getGraph());
1512  z2_adapter_type Zoltan2Graph (constActiveGraph);
1513 
1514  typedef Zoltan2::OrderingProblem<z2_adapter_type> ordering_problem_type;
1515 #ifdef HAVE_MPI
1516  // Grab the MPI Communicator and build the ordering problem with that
1517  MPI_Comm myRawComm;
1518 
1519  RCP<const MpiComm<int> > mpicomm =
1520  rcp_dynamic_cast<const MpiComm<int> > (ActiveMatrix->getComm ());
1521  if (mpicomm == Teuchos::null) {
1522  myRawComm = MPI_COMM_SELF;
1523  } else {
1524  myRawComm = * (mpicomm->getRawMpiComm ());
1525  }
1526  ordering_problem_type MyOrderingProblem (&Zoltan2Graph, &zlist, myRawComm);
1527 #else
1528  ordering_problem_type MyOrderingProblem (&Zoltan2Graph, &zlist);
1529 #endif
1530  MyOrderingProblem.solve ();
1531 
1532  {
1533  typedef Zoltan2::LocalOrderingSolution<local_ordinal_type>
1534  ordering_solution_type;
1535 
1536  ordering_solution_type sol (*MyOrderingProblem.getLocalOrderingSolution());
1537 
1538  // perm[i] gives the where OLD index i shows up in the NEW
1539  // ordering. revperm[i] gives the where NEW index i shows
1540  // up in the OLD ordering. Note that perm is actually the
1541  // "inverse permutation," in Zoltan2 terms.
1542  perm = sol.getPermutationRCPConst (true);
1543  revperm = sol.getPermutationRCPConst ();
1544  }
1545  }
1546  // All reorderings here...
1547  ReorderedLocalizedMatrix_ = rcp (new reorder_filter_type (ActiveMatrix, perm, revperm));
1548 
1549 
1550  ActiveMatrix = ReorderedLocalizedMatrix_;
1551 #else
1552  // This is a logic_error, not a runtime_error, because
1553  // setParameters() should have excluded this case already.
1555  true, std::logic_error, "Ifpack2::AdditiveSchwarz::setup: "
1556  "The Zoltan2 and Xpetra packages must be enabled in order "
1557  "to support reordering.");
1558 #endif
1559  }
1560 
1561  innerMatrix_ = ActiveMatrix;
1562 
1564  innerMatrix_.is_null (), std::logic_error, "Ifpack2::AdditiveSchwarz::"
1565  "setup: Inner matrix is null right before constructing inner solver. "
1566  "Please report this bug to the Ifpack2 developers.");
1567 
1568  // Construct the inner solver if necessary.
1569  if (Inverse_.is_null ()) {
1570  const std::string innerName = innerPrecName ();
1572  innerName == "INVALID", std::logic_error,
1573  "Ifpack2::AdditiveSchwarz::initialize: AdditiveSchwarz doesn't "
1574  "know how to create an instance of your LocalInverseType \""
1576  "Please talk to the Ifpack2 developers for details.");
1577 
1579  innerName == "CUSTOM", std::runtime_error, "Ifpack2::AdditiveSchwarz::"
1580  "initialize: If the \"inner preconditioner name\" parameter (or any "
1581  "alias thereof) has the value \"CUSTOM\", then you must first call "
1582  "setInnerPreconditioner with a nonnull inner preconditioner input before "
1583  "you may call initialize().");
1584 
1585  // FIXME (mfh 26 Aug 2015) Once we fix Bug 6392, the following
1586  // three lines of code can and SHOULD go away.
1588  Ifpack2::Details::registerLinearSolverFactory ();
1589  }
1590 
1591  // FIXME (mfh 26 Aug 2015) Provide the capability to get inner
1592  // solvers from packages other than Ifpack2.
1593  typedef typename MV::mag_type MT;
1594  RCP<inner_solver_type> innerPrec =
1595  Trilinos::Details::getLinearSolver<MV, OP, MT> ("Ifpack2", innerName);
1597  innerPrec.is_null (), std::logic_error,
1598  "Ifpack2::AdditiveSchwarz::setup: Failed to create inner preconditioner "
1599  "with name \"" << innerName << "\".");
1600  innerPrec->setMatrix (innerMatrix_);
1601 
1602  // Extract and apply the sublist of parameters to give to the
1603  // inner solver, if there is such a sublist of parameters.
1604  std::pair<Teuchos::ParameterList, bool> result = innerPrecParams ();
1605  if (result.second) {
1606  // FIXME (mfh 26 Aug 2015) We don't really want to use yet
1607  // another deep copy of the ParameterList here.
1608  innerPrec->setParameters (rcp (new ParameterList (result.first)));
1609  }
1610  Inverse_ = innerPrec; // "Commit" the inner solver.
1611  }
1612  else if (Inverse_->getMatrix ().getRawPtr () != innerMatrix_.getRawPtr ()) {
1613  // The new inner matrix is different from the inner
1614  // preconditioner's current matrix, so give the inner
1615  // preconditioner the new inner matrix.
1616  Inverse_->setMatrix (innerMatrix_);
1617  }
1619  Inverse_.is_null (), std::logic_error, "Ifpack2::AdditiveSchwarz::"
1620  "setup: Inverse_ is null right after we were supposed to have created it."
1621  " Please report this bug to the Ifpack2 developers.");
1622 
1623  // We don't have to call setInnerPreconditioner() here, because we
1624  // had the inner matrix (innerMatrix_) before creation of the inner
1625  // preconditioner. Calling setInnerPreconditioner here would be
1626  // legal, but it would require an unnecessary reset of the inner
1627  // preconditioner (i.e., calling initialize() and compute() again).
1628 }
1629 
1630 
1631 template<class MatrixType, class LocalInverseType>
1634  local_ordinal_type,
1635  global_ordinal_type,
1636  node_type> >& innerPrec)
1637 {
1638  if (! innerPrec.is_null ()) {
1639  // Make sure that the new inner solver knows how to have its matrix changed.
1640  typedef Details::CanChangeMatrix<row_matrix_type> can_change_type;
1641  can_change_type* innerSolver = dynamic_cast<can_change_type*> (&*innerPrec);
1643  innerSolver == NULL, std::invalid_argument, "Ifpack2::AdditiveSchwarz::"
1644  "setInnerPreconditioner: The input preconditioner does not implement the "
1645  "setMatrix() feature. Only input preconditioners that inherit from "
1646  "Ifpack2::Details::CanChangeMatrix implement this feature.");
1647 
1648  // If users provide an inner solver, we assume that
1649  // AdditiveSchwarz's current inner solver parameters no longer
1650  // apply. (In fact, we will remove those parameters from
1651  // AdditiveSchwarz's current list below.) Thus, we do /not/ apply
1652  // the current sublist of inner solver parameters to the input
1653  // inner solver.
1654 
1655  // mfh 03 Jan 2014: Thanks to Paul Tsuji for pointing out that
1656  // it's perfectly legal for innerMatrix_ to be null here. This
1657  // can happen if initialize() has not been called yet. For
1658  // example, when Ifpack2::Factory creates an AdditiveSchwarz
1659  // instance, it calls setInnerPreconditioner() without first
1660  // calling initialize().
1661 
1662  // Give the local matrix to the new inner solver.
1663  innerSolver->setMatrix (innerMatrix_);
1664 
1665  // If the user previously specified a parameter for the inner
1666  // preconditioner's type, then clear out that parameter and its
1667  // associated sublist. Replace the inner preconditioner's type with
1668  // "CUSTOM", to make it obvious that AdditiveSchwarz's ParameterList
1669  // does not necessarily describe the current inner preconditioner.
1670  // We have to remove all allowed aliases of "inner preconditioner
1671  // name" before we may set it to "CUSTOM". Users may also set this
1672  // parameter to "CUSTOM" themselves, but this is not required.
1673  removeInnerPrecName ();
1674  removeInnerPrecParams ();
1675  List_.set ("inner preconditioner name", "CUSTOM");
1676 
1677  // Bring the new inner solver's current status (initialized or
1678  // computed) in line with AdditiveSchwarz's current status.
1679  if (isInitialized ()) {
1680  innerPrec->initialize ();
1681  }
1682  if (isComputed ()) {
1683  innerPrec->compute ();
1684  }
1685  }
1686 
1687  // If the new inner solver is null, we don't change the initialized
1688  // or computed status of AdditiveSchwarz. That way, AdditiveSchwarz
1689  // won't have to recompute innerMatrix_ if the inner solver changes.
1690  // This does introduce a new error condition in compute() and
1691  // apply(), but that's OK.
1692 
1693  // Set the new inner solver.
1694  typedef Ifpack2::Details::LinearSolver<scalar_type, local_ordinal_type,
1695  global_ordinal_type, node_type> inner_solver_impl_type;
1696  Inverse_ = Teuchos::rcp (new inner_solver_impl_type (innerPrec, "CUSTOM"));
1697 }
1698 
1699 template<class MatrixType, class LocalInverseType>
1702 {
1703  // Don't set the matrix unless it is different from the current one.
1704  if (A.getRawPtr () != Matrix_.getRawPtr ()) {
1705  IsInitialized_ = false;
1706  IsComputed_ = false;
1707 
1708  // Reset all the state computed in initialize() and compute().
1709  OverlappingMatrix_ = Teuchos::null;
1710  ReorderedLocalizedMatrix_ = Teuchos::null;
1711  innerMatrix_ = Teuchos::null;
1712  SingletonMatrix_ = Teuchos::null;
1713  localMap_ = Teuchos::null;
1714  DistributedImporter_ = Teuchos::null;
1715 
1716  Matrix_ = A;
1717  }
1718 }
1719 
1720 } // namespace Ifpack2
1721 
1722 // NOTE (mfh 26 Aug 2015) There's no need to instantiate for CrsMatrix
1723 // too. All Ifpack2 preconditioners can and should do dynamic casts
1724 // internally, if they need a type more specific than RowMatrix.
1725 #define IFPACK2_ADDITIVESCHWARZ_INSTANT(S,LO,GO,N) \
1726  template class Ifpack2::AdditiveSchwarz< Tpetra::RowMatrix<S, LO, GO, N> >;
1727 
1728 #endif // IFPACK2_ADDITIVESCHWARZ_DECL_HPP
Mix-in interface for preconditioners that can change their matrix after construction.
Definition: Ifpack2_Details_CanChangeMatrix.hpp:93
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > &plist)
Set the preconditioner&#39;s parameters.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:857
virtual void compute()
Computes all (coefficient) data necessary to apply the preconditioner.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:1163
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:316
basic_OSTab< char > OSTab
virtual int getNumApply() const
Returns the number of calls to apply().
Definition: Ifpack2_AdditiveSchwarz_def.hpp:1233
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:1156
virtual double getInitializeTime() const
Returns the time spent in initialize().
Definition: Ifpack2_AdditiveSchwarz_def.hpp:1240
#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:1316
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:282
MatrixType::node_type node_type
The Node type used by the input MatrixType.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:321
virtual double getComputeTime() const
Returns the time spent in compute().
Definition: Ifpack2_AdditiveSchwarz_def.hpp:1247
virtual ~AdditiveSchwarz()
Destructor.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:277
Teuchos::ScalarTraits< scalar_type >::magnitudeType magnitude_type
The type of the magnitude (absolute value) of a matrix entry.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:324
std::string description() const
Return a simple one-line description of this object.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:1261
virtual std::ostream & print(std::ostream &os) const
Prints basic information on iostream. This function is used by operator&lt;&lt;.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:1423
AdditiveSchwarz(const Teuchos::RCP< const row_matrix_type > &A)
Constructor that takes a matrix.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:224
virtual double getApplyTime() const
Returns the time spent in apply().
Definition: Ifpack2_AdditiveSchwarz_def.hpp:1254
virtual void initialize()
Computes all (graph-related) data necessary to initialize the preconditioner.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:1082
MatrixType::global_ordinal_type global_ordinal_type
The type of global indices in the input MatrixType.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:318
MatrixType::scalar_type scalar_type
The type of the entries of the input MatrixType.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:312
bool registeredSomeLinearSolverFactory(const std::string &packageName)
T * getRawPtr() const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
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:1633
Ifpack2&#39;s implementation of Trilinos::Details::LinearSolver interface.
Definition: Ifpack2_Details_LinearSolver_decl.hpp:105
virtual std::string description() const
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Get a list of the preconditioner&#39;s default parameters.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:1036
Interface for all Ifpack2 preconditioners.
Definition: Ifpack2_Preconditioner.hpp:107
virtual Teuchos::RCP< const row_matrix_type > getMatrix() const
The input matrix.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:307
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:295
virtual void setParameters(const Teuchos::ParameterList &plist)
Set the preconditioner&#39;s parameters.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:844
virtual int getNumCompute() const
Returns the number of calls to compute().
Definition: Ifpack2_AdditiveSchwarz_def.hpp:1226
Sparse matrix (Tpetra::RowMatrix subclass) with ghost rows.
Definition: Ifpack2_OverlappingRowMatrix_decl.hpp:58
Additive Schwarz domain decomposition for Tpetra sparse matrices.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:281
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:1212
Access only local rows and columns of a sparse matrix.
Definition: Ifpack2_LocalFilter_decl.hpp:160
ParameterEntry & getEntry(const std::string &name)
void registerLinearSolverFactory()
Filter based on matrix entries.
Definition: Ifpack2_SingletonFilter_decl.hpp:64
virtual void setMatrix(const Teuchos::RCP< const row_matrix_type > &A)
Change the matrix to be preconditioned.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:1701
void getValidParameters(Teuchos::ParameterList &params)
Fills a list which contains all the parameters possibly used by Ifpack2.
Definition: Ifpack2_Parameters.cpp:50
virtual int getOverlapLevel() const
Returns the level of overlap.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:1433
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:1219
bool is_null() const