|
Ifpack2 Templated Preconditioning Package
Version 1.0
|
00001 /*@HEADER 00002 // *********************************************************************** 00003 // 00004 // Ifpack2: Tempated Object-Oriented Algebraic Preconditioner Package 00005 // Copyright (2009) Sandia Corporation 00006 // 00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00008 // license for use of this work by or on behalf of the U.S. Government. 00009 // 00010 // This library is free software; you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as 00012 // published by the Free Software Foundation; either version 2.1 of the 00013 // License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, but 00016 // WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00023 // USA 00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00025 // 00026 // *********************************************************************** 00027 //@HEADER 00028 */ 00029 00030 #ifndef IFPACK2_RELAXATION_DECL_HPP 00031 #define IFPACK2_RELAXATION_DECL_HPP 00032 00033 #include "Ifpack2_ConfigDefs.hpp" 00034 #include "Ifpack2_Preconditioner.hpp" 00035 #include "Ifpack2_Condest.hpp" 00036 #include "Ifpack2_Parameters.hpp" 00037 00038 #include <Tpetra_Vector.hpp> 00039 00040 #include <Teuchos_Assert.hpp> 00041 #include <Teuchos_RCP.hpp> 00042 #include <Teuchos_Time.hpp> 00043 #include <Teuchos_TypeNameTraits.hpp> 00044 #include <Teuchos_ScalarTraits.hpp> 00045 00046 #include <string> 00047 #include <iostream> 00048 #include <sstream> 00049 00050 namespace Teuchos { 00051 // forward declaration 00052 class ParameterList; 00053 } 00054 00055 namespace Ifpack2 { 00056 enum RelaxationType { 00057 JACOBI, 00058 GS, 00059 SGS 00060 }; 00061 00063 00122 template<class MatrixType> 00123 class Relaxation : virtual public Ifpack2::Preconditioner<typename MatrixType::scalar_type,typename MatrixType::local_ordinal_type,typename MatrixType::global_ordinal_type,typename MatrixType::node_type> { 00124 00125 public: 00126 typedef typename MatrixType::scalar_type Scalar; 00127 typedef typename MatrixType::local_ordinal_type LocalOrdinal; 00128 typedef typename MatrixType::global_ordinal_type GlobalOrdinal; 00129 typedef typename MatrixType::node_type Node; 00130 typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType magnitudeType; 00131 00132 // \name Constructors and Destructors 00134 00136 explicit Relaxation(const Teuchos::RCP<const Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> >& Matrix); 00137 00139 virtual ~Relaxation(); 00140 00142 00144 00146 00163 void setParameters(const Teuchos::ParameterList& params); 00164 00166 void initialize(); 00167 00169 inline bool isInitialized() const { 00170 return(IsInitialized_); 00171 } 00172 00174 void compute(); 00175 00177 inline bool isComputed() const { 00178 return(IsComputed_); 00179 } 00180 00182 00184 00185 00187 00197 void apply(const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& X, 00198 Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& Y, 00199 Teuchos::ETransp mode = Teuchos::NO_TRANS, 00200 Scalar alpha = Teuchos::ScalarTraits<Scalar>::one(), 00201 Scalar beta = Teuchos::ScalarTraits<Scalar>::zero()) const; 00202 00204 const Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> >& getDomainMap() const; 00205 00207 const Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> >& getRangeMap() const; 00208 00209 bool hasTransposeApply() const; 00210 00212 00218 void applyMat(const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& X, 00219 Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& Y, 00220 Teuchos::ETransp mode = Teuchos::NO_TRANS) const; 00221 00223 00225 00226 00228 magnitudeType computeCondEst(CondestType CT = Cheap, 00229 LocalOrdinal MaxIters = 1550, 00230 magnitudeType Tol = 1e-9, 00231 const Teuchos::Ptr<const Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &matrix = Teuchos::null); 00232 00234 00236 00237 00239 magnitudeType getCondEst() const; 00240 00242 const Teuchos::RCP<const Teuchos::Comm<int> > & getComm() const; 00243 00245 Teuchos::RCP<const Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> > getMatrix() const; 00246 00248 double getComputeFlops() const; 00249 00251 double getApplyFlops() const; 00252 00254 int getNumInitialize() const; 00255 00257 int getNumCompute() const; 00258 00260 int getNumApply() const; 00261 00263 double getInitializeTime() const; 00264 00266 double getComputeTime() const; 00267 00269 double getApplyTime() const; 00270 00272 00274 00275 00277 std::string description() const; 00278 00280 void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const; 00281 00283 00284 private: 00285 00286 // @{ Internal methods 00287 00289 Relaxation(const Relaxation<MatrixType>& RHS); 00290 00292 Relaxation<MatrixType>& operator=(const Relaxation<MatrixType>& RHS); 00293 00295 void ApplyInverseJacobi( 00296 const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& X, 00297 Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& Y) const; 00298 00300 void ApplyInverseGS( 00301 const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& X, 00302 Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& Y) const; 00303 00304 void ApplyInverseGS_RowMatrix( 00305 const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& X, 00306 Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& Y) const; 00307 00308 void ApplyInverseGS_CrsMatrix( 00309 const MatrixType& A, 00310 const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& X, 00311 Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& Y) const; 00312 00314 void ApplyInverseSGS( 00315 const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& X, 00316 Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& Y) const; 00317 00318 void ApplyInverseSGS_RowMatrix( 00319 const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& X, 00320 Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& Y) const; 00321 00322 void ApplyInverseSGS_CrsMatrix( 00323 const MatrixType& A, 00324 const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& X, 00325 Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& Y) const; 00326 00328 00329 // @{ Internal data and parameters 00330 00332 const Teuchos::RCP<const Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> > A_; 00334 const Teuchos::RCP<const Teuchos::Comm<int> > Comm_; 00336 Teuchos::RCP<Teuchos::Time> Time_; 00338 Teuchos::RCP<const Tpetra::Import<LocalOrdinal,GlobalOrdinal,Node> > Importer_; 00340 mutable Teuchos::RCP<Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> > Diagonal_; 00342 int NumSweeps_; 00344 int PrecType_; 00346 Scalar MinDiagonalValue_; 00348 Scalar DampingFactor_; 00350 bool IsParallel_; 00352 bool ZeroStartingSolution_; 00354 bool DoBackwardGS_; 00356 bool DoL1Method_; 00358 magnitudeType L1Eta_; 00360 magnitudeType Condest_; 00362 bool IsInitialized_; 00364 bool IsComputed_; 00366 int NumInitialize_; 00368 int NumCompute_; 00370 mutable int NumApply_; 00372 double InitializeTime_; 00374 double ComputeTime_; 00376 mutable double ApplyTime_; 00378 double ComputeFlops_; 00380 mutable double ApplyFlops_; 00382 size_t NumMyRows_; 00384 global_size_t NumGlobalRows_; 00386 global_size_t NumGlobalNonzeros_; 00387 00389 00390 }; //class Relaxation 00391 00392 }//namespace Ifpack2 00393 00394 #endif // IFPACK2_RELAXATION_DECL_HPP 00395
1.7.6.1