Ifpack2 Templated Preconditioning Package  Version 1.0
Ifpack2_AdditiveSchwarz_decl.hpp
1 /*@HEADER
2 // ***********************************************************************
3 //
4 // Ifpack2: Tempated 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 
43 #ifndef IFPACK2_ADDITIVESCHWARZ_DECL_HPP
44 #define IFPACK2_ADDITIVESCHWARZ_DECL_HPP
45 
46 #include "Ifpack2_ConfigDefs.hpp"
47 #include "Tpetra_ConfigDefs.hpp"
48 #include "Ifpack2_Preconditioner.hpp"
49 #include "Ifpack2_Parameters.hpp"
50 #include "Teuchos_ParameterList.hpp"
51 #include "Teuchos_RefCountPtr.hpp"
52 #include "Teuchos_Time.hpp"
53 
54 #include "Tpetra_MultiVector.hpp"
55 #include "Tpetra_Map.hpp"
56 #include "Tpetra_CrsMatrix.hpp"
57 
58 #include "Ifpack2_ReorderFilter.hpp"
59 #include "Ifpack2_SingletonFilter.hpp"
60 #include "Ifpack2_OverlappingRowMatrix.hpp"
61 
62 #ifdef HAVE_IFPACK2_ZOLTAN2
63 #include "Zoltan2_OrderingSolution.hpp"
64 #endif
65 
66 
67 namespace Ifpack2 {
68 
122 template<class MatrixType,class LocalInverseType>
123 class AdditiveSchwarz : virtual public Ifpack2::Preconditioner<typename MatrixType::scalar_type,typename MatrixType::local_ordinal_type,typename MatrixType::global_ordinal_type,typename MatrixType::node_type> {
124 
125 public:
126  typedef typename MatrixType::scalar_type Scalar;
127  typedef typename MatrixType::local_ordinal_type LocalOrdinal;
128  typedef typename MatrixType::global_ordinal_type GlobalOrdinal;
129  typedef typename MatrixType::node_type Node;
130  typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType magnitudeType;
131  typedef typename Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> LocalMatrixType;
132 
134 
146  AdditiveSchwarz(const Teuchos::RCP<const Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> > & Matrix_in, int OverlapLevel_in = 0);
147 
149  virtual ~AdditiveSchwarz();
151 
154 
156  virtual const Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > & getDomainMap() const;
157 
159  virtual const Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > & getRangeMap() const;
160 
162  virtual Teuchos::RCP<const Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> > getMatrix() const;
163 
164 
165 
167  virtual void apply(const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &X,
168  Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &Y,
169  Teuchos::ETransp mode = Teuchos::NO_TRANS,
170  Scalar alpha = Teuchos::ScalarTraits<Scalar>::one(),
171  Scalar beta = Teuchos::ScalarTraits<Scalar>::zero()) const;
172 
174 
176  template <class DomainScalar, class RangeScalar>
177  void applyTempl(const Tpetra::MultiVector<DomainScalar,LocalOrdinal,GlobalOrdinal,Node> &X,
178  Tpetra::MultiVector<RangeScalar,LocalOrdinal,GlobalOrdinal,Node> &Y,
179  Teuchos::ETransp mode = Teuchos::NO_TRANS,
180  RangeScalar alpha = Teuchos::ScalarTraits<Scalar>::one(),
181  RangeScalar beta = Teuchos::ScalarTraits<Scalar>::zero()) const;
182 
184  virtual void setParameters(const Teuchos::ParameterList& List);
185 
187  virtual void initialize();
188 
190  virtual bool isInitialized() const;
191 
193  virtual void compute();
194 
196  virtual bool isComputed() const;
197 
199  virtual magnitudeType computeCondEst(CondestType CT = Ifpack2::Cheap,
200  LocalOrdinal MaxIters = 1550,
201  magnitudeType Tol = 1e-9,
202  const Teuchos::Ptr<const Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &Matrix = Teuchos::null);
203 
205  virtual magnitudeType getCondEst() const;
206 
208  virtual int getNumInitialize() const;
209 
211  virtual int getNumCompute() const;
212 
214  virtual int getNumApply() const;
215 
217  virtual double getInitializeTime() const;
218 
220  virtual double getComputeTime() const;
221 
223  virtual double getApplyTime() const;
224 
226 
227 
229  std::string description() const;
230 
232  void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const;
233 
235 
237  virtual std::ostream& print(std::ostream& os) const;
238 
240  virtual int getOverlapLevel() const;
241 
242 protected:
243 
244  // @}
245 
246  // @{ Internal merhods.
247 
249  AdditiveSchwarz(const AdditiveSchwarz& RHS);
250 
252  void setup();
253 
254  // @}
255 
256  // @{ Internal data.
258  const Teuchos::RCP<const Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> > Matrix_;
259 
261  Teuchos::RCP<Ifpack2::OverlappingRowMatrix<LocalMatrixType> >OverlappingMatrix_;
262 
264  // CMS: Probably not a great idea, but this will remove the Local/Subdomain conflict here
265  Teuchos::RCP<LocalMatrixType > LocalizedMatrix_;
267  Teuchos::RCP<Ifpack2::ReorderFilter<LocalMatrixType> > ReorderedLocalizedMatrix_;
268 
278  Teuchos::ParameterList List_;
280  Tpetra::CombineMode CombineMode_;
282  magnitudeType Condest_;
289 
293  Teuchos::RCP<Ifpack2::SingletonFilter<LocalMatrixType> > SingletonMatrix_;
299  mutable int NumApply_;
303  double ComputeTime_;
305  mutable double ApplyTime_;
311  mutable double ApplyFlops_;
313  Teuchos::RCP<Teuchos::Time> Time_;
315  Teuchos::RCP<LocalInverseType> Inverse_;
316 
317 }; // class AdditiveSchwarz
318 
319 }// end namespace
320 
321 #endif // IFPACK2_ADDITIVESCHWARZ_DECL_HPP
int NumInitialize_
Contains the number of successful calls to Initialize().
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:295
void applyTempl(const Tpetra::MultiVector< DomainScalar, LocalOrdinal, GlobalOrdinal, Node > &X, Tpetra::MultiVector< RangeScalar, LocalOrdinal, GlobalOrdinal, Node > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, RangeScalar alpha=Teuchos::ScalarTraits< Scalar >::one(), RangeScalar beta=Teuchos::ScalarTraits< Scalar >::zero()) const
Applies the effect of the preconditioner.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:220
double ComputeTime_
Contains the time for all successful calls to compute().
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:303
Tpetra::CombineMode CombineMode_
Combine mode for off-process elements (only if overlap is used)
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:280
CondestType
Ifpack2::CondestType: enum to define the type of condition number estimate.
Definition: Ifpack2_CondestType.hpp:50
virtual void compute()
Computes all (coefficient) data necessary to apply the preconditioner.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:422
virtual const Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > & getDomainMap() const
Returns the Map associated with the domain of this operator, which must be compatible with X...
Definition: Ifpack2_AdditiveSchwarz_def.hpp:110
virtual int getNumApply() const
Returns the number of calls to apply().
Definition: Ifpack2_AdditiveSchwarz_def.hpp:492
void setup()
Sets up the localized matrix and the singleton filter.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:600
virtual bool isInitialized() const
Returns true if the preconditioner has been successfully initialized, false otherwise.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:414
virtual double getInitializeTime() const
Returns the time spent in initialize().
Definition: Ifpack2_AdditiveSchwarz_def.hpp:500
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:546
Teuchos::RCP< Ifpack2::OverlappingRowMatrix< LocalMatrixType > > OverlappingMatrix_
Pointers to the overlapping matrix.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:261
virtual void setParameters(const Teuchos::ParameterList &List)
Sets all parameters for the preconditioner.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:304
virtual magnitudeType computeCondEst(CondestType CT=Ifpack2::Cheap, LocalOrdinal MaxIters=1550, magnitudeType Tol=1e-9, const Teuchos::Ptr< const Tpetra::RowMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &Matrix=Teuchos::null)
Computes the condition number estimate and returns its value.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:450
virtual double getComputeTime() const
Returns the time spent in compute().
Definition: Ifpack2_AdditiveSchwarz_def.hpp:508
const Teuchos::RCP< const Tpetra::RowMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Matrix_
Pointers to the matrix to be preconditioned.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:258
virtual ~AdditiveSchwarz()
Destructor.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:103
std::string description() const
Return a simple one-line description of this object.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:523
virtual std::ostream & print(std::ostream &os) const
Prints basic information on iostream. This function is used by operator<<.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:581
virtual double getApplyTime() const
Returns the time spent in apply().
Definition: Ifpack2_AdditiveSchwarz_def.hpp:516
double InitializeTime_
Contains the time for all successful calls to initialize().
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:301
virtual void initialize()
Computes all (graph-related) data necessary to initialize the preconditioner.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:371
virtual magnitudeType getCondEst() const
Returns the computed condition number estimate, or -1.0 if not computed.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:468
bool IsComputed_
If true, the preconditioner has been successfully computed.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:272
AdditiveSchwarz(const Teuchos::RCP< const Tpetra::RowMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &Matrix_in, int OverlapLevel_in=0)
Ifpack2::AdditiveSchwarz constructor with given Tpetra::RowMatrix.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:68
Teuchos::RCP< Teuchos::Time > Time_
Object used for timing purposes.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:313
Teuchos::RCP< Ifpack2::SingletonFilter< LocalMatrixType > > SingletonMatrix_
filtering object.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:293
bool ComputeCondest_
If true, compute the condition number estimate each time Compute() is called.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:284
Base class for all Ifpack2 preconditioners.
Definition: Ifpack2_Preconditioner.hpp:130
bool FilterSingletons_
Filter for singletons.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:291
virtual Teuchos::RCP< const Tpetra::RowMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getMatrix() const
Returns a pointer to the input matrix.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:125
int NumApply_
Contains the number of successful call to apply().
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:299
double ApplyTime_
Contains the time for all successful calls to apply().
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:305
bool IsOverlapping_
If true, overlapping is used.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:274
virtual const Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > & getRangeMap() const
Returns the Map associated with the range of this operator, which must be compatible with Y...
Definition: Ifpack2_AdditiveSchwarz_def.hpp:118
bool IsInitialized_
If true, the preconditioner has been successfully initialized.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:270
double ApplyFlops_
Contain sthe number of flops for ApplyInverse().
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:311
bool UseSubdomain_
If true, subdomain filtering is used.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:288
Teuchos::RCP< Ifpack2::ReorderFilter< LocalMatrixType > > ReorderedLocalizedMatrix_
Pointer to the reordered matrix.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:267
bool UseReordering_
If true, reorder the local matrix.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:286
int NumCompute_
Contains the number of successful call to Compute().
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:297
Teuchos::RCP< LocalInverseType > Inverse_
Pointer to the local solver.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:315
int OverlapLevel_
Level of overlap among the processors.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:276
virtual int getNumCompute() const
Returns the number of calls to compute().
Definition: Ifpack2_AdditiveSchwarz_def.hpp:484
double InitializeFlops_
Contains the number of flops for Initialize().
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:307
Additive Schwarz domain decomposition for Tpetra::RowMatrix objects.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:123
virtual bool isComputed() const
Returns true if the preconditioner has been successfully computed, false otherwise.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:441
Teuchos::RCP< LocalMatrixType > LocalizedMatrix_
Localized version of Matrix_ or OverlappingMatrix_.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:265
double ComputeFlops_
Contains the number of flops for Compute().
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:309
Ifpack2::Container: a pure virtual class for creating and solving local linear problems.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:67
magnitudeType Condest_
Contains the estimated condition number.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:282
virtual int getOverlapLevel() const
Returns the level of overlap.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:592
cheap estimate
Definition: Ifpack2_CondestType.hpp:51
virtual void apply(const Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=Teuchos::ScalarTraits< Scalar >::one(), Scalar beta=Teuchos::ScalarTraits< Scalar >::zero()) const
Applies the effect of the preconditioner.
Definition: Ifpack2_AdditiveSchwarz_def.hpp:133
virtual int getNumInitialize() const
Returns the number of calls to initialize().
Definition: Ifpack2_AdditiveSchwarz_def.hpp:476
Teuchos::ParameterList List_
Stores a copy of the list given in SetParameters()
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:278