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