|
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 // Redistribution and use in source and binary forms, with or without 00011 // modification, are permitted provided that the following conditions are 00012 // met: 00013 // 00014 // 1. Redistributions of source code must retain the above copyright 00015 // notice, this list of conditions and the following disclaimer. 00016 // 00017 // 2. Redistributions in binary form must reproduce the above copyright 00018 // notice, this list of conditions and the following disclaimer in the 00019 // documentation and/or other materials provided with the distribution. 00020 // 00021 // 3. Neither the name of the Corporation nor the names of the 00022 // contributors may be used to endorse or promote products derived from 00023 // this software without specific prior written permission. 00024 // 00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY 00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE 00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00036 // 00037 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00038 // 00039 // *********************************************************************** 00040 //@HEADER 00041 */ 00042 00046 00047 #ifndef IFPACK2_KRYLOV_DECL_HPP 00048 #define IFPACK2_KRYLOV_DECL_HPP 00049 00050 #include "Ifpack2_ConfigDefs.hpp" 00051 #include "Ifpack2_Preconditioner.hpp" 00052 #include "Ifpack2_Condest.hpp" 00053 #include "Ifpack2_Heap.hpp" 00054 #include "Ifpack2_Parameters.hpp" 00055 #include "Ifpack2_Relaxation.hpp" 00056 #include "Ifpack2_ILUT.hpp" 00057 #include "Ifpack2_RILUK.hpp" 00058 #include "Ifpack2_Chebyshev.hpp" 00059 #include "Ifpack2_Details_CanChangeMatrix.hpp" 00060 00061 #include <BelosConfigDefs.hpp> 00062 #include <BelosSolverManager.hpp> 00063 #include <BelosTpetraAdapter.hpp> 00064 #include <BelosBlockGmresSolMgr.hpp> 00065 #include <BelosBlockCGSolMgr.hpp> 00066 00067 #include <Teuchos_Assert.hpp> 00068 #include <Teuchos_RCP.hpp> 00069 #include <Teuchos_Time.hpp> 00070 #include <Teuchos_TypeNameTraits.hpp> 00071 #include <Teuchos_ScalarTraits.hpp> 00072 00073 #include <iostream> 00074 #include <string> 00075 #include <sstream> 00076 #include <cmath> 00077 00078 namespace Teuchos { 00079 class ParameterList; // forward declaration 00080 } 00081 00082 namespace Ifpack2 { 00083 00094 template <typename ScalarType> 00095 struct BelosScalarType { 00096 typedef ScalarType type; 00097 }; 00098 00107 template<class MatrixType> 00108 class Krylov : 00109 virtual public Ifpack2::Preconditioner<typename MatrixType::scalar_type, 00110 typename MatrixType::local_ordinal_type, 00111 typename MatrixType::global_ordinal_type, 00112 typename MatrixType::node_type>, 00113 virtual public Ifpack2::Details::CanChangeMatrix<Tpetra::RowMatrix<typename MatrixType::scalar_type, 00114 typename MatrixType::local_ordinal_type, 00115 typename MatrixType::global_ordinal_type, 00116 typename MatrixType::node_type> > 00117 { 00118 public: 00119 // \name Public typedefs 00121 00123 typedef typename MatrixType::scalar_type scalar_type; 00124 00126 typedef typename BelosScalarType<scalar_type>::type belos_scalar_type; 00127 00129 TEUCHOS_DEPRECATED typedef typename MatrixType::scalar_type Scalar; 00130 00131 00133 typedef typename MatrixType::local_ordinal_type local_ordinal_type; 00134 00136 TEUCHOS_DEPRECATED typedef typename MatrixType::local_ordinal_type LocalOrdinal; 00137 00138 00140 typedef typename MatrixType::global_ordinal_type global_ordinal_type; 00141 00143 TEUCHOS_DEPRECATED typedef typename MatrixType::global_ordinal_type GlobalOrdinal; 00144 00145 00147 typedef typename MatrixType::node_type node_type; 00148 00150 TEUCHOS_DEPRECATED typedef typename MatrixType::node_type Node; 00151 00152 00154 typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitude_type; 00155 00157 TEUCHOS_DEPRECATED typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitudeType; 00158 00160 typedef Tpetra::RowMatrix<scalar_type, 00161 local_ordinal_type, 00162 global_ordinal_type, 00163 node_type> row_matrix_type; 00164 00166 typedef Ifpack2::Preconditioner<scalar_type, 00167 local_ordinal_type, 00168 global_ordinal_type, 00169 node_type> prec_type; 00170 00172 // \name Constructors and Destructors 00174 00176 explicit Krylov (const Teuchos::RCP<const row_matrix_type>& A); 00177 00179 virtual ~Krylov (); 00180 00182 00183 00184 00199 void setParameters (const Teuchos::ParameterList& params); 00200 00202 void initialize (); 00203 00205 inline bool isInitialized () const { 00206 return IsInitialized_; 00207 } 00208 00210 void compute (); 00211 00213 inline bool isComputed() const { 00214 return IsComputed_; 00215 } 00216 00218 00219 00220 00243 virtual void setMatrix (const Teuchos::RCP<const row_matrix_type>& A); 00244 00246 00247 00248 00250 void 00251 apply (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X, 00252 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y, 00253 Teuchos::ETransp mode = Teuchos::NO_TRANS, 00254 scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(), 00255 scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero()) const; 00256 00258 Teuchos::RCP<const Tpetra::Map<local_ordinal_type,global_ordinal_type,node_type> > getDomainMap() const; 00259 00261 Teuchos::RCP<const Tpetra::Map<local_ordinal_type,global_ordinal_type,node_type> > getRangeMap() const; 00262 00264 bool hasTransposeApply() const; 00265 00269 virtual magnitude_type TEUCHOS_DEPRECATED getCondEst() const { 00270 return Condest_; 00271 } 00272 00274 00275 00276 00278 Teuchos::RCP<const Teuchos::Comm<int> > getComm() const; 00279 00281 Teuchos::RCP<const Tpetra::RowMatrix<scalar_type,local_ordinal_type,global_ordinal_type,node_type> > getMatrix() const; 00282 00284 int getNumInitialize() const; 00285 00287 int getNumCompute() const; 00288 00290 int getNumApply() const; 00291 00293 double getInitializeTime() const; 00294 00296 double getComputeTime() const; 00297 00299 double getApplyTime() const; 00300 00310 virtual magnitude_type TEUCHOS_DEPRECATED 00311 computeCondEst (CondestType CT = Cheap, 00312 local_ordinal_type MaxIters = 1550, 00313 magnitude_type Tol = 1e-9, 00314 const Teuchos::Ptr<const Tpetra::RowMatrix<scalar_type,local_ordinal_type,global_ordinal_type,node_type> > &Matrix_in = Teuchos::null); 00315 00317 00318 00320 std::string description() const; 00321 00323 void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const; 00324 00326 00327 private: 00328 typedef Teuchos::ScalarTraits<scalar_type> STS; 00329 typedef Teuchos::ScalarTraits<magnitude_type> STM; 00330 00332 Krylov (const Krylov<MatrixType>& RHS); 00333 00335 Krylov<MatrixType>& operator= (const Krylov<MatrixType>& RHS); 00336 00341 Teuchos::RCP<const row_matrix_type> A_; 00342 00344 00348 std::string iterationType_; 00349 00351 int numIters_; 00352 00354 magnitude_type resTol_; 00355 00357 int BlockSize_; 00358 00360 bool ZeroStartingSolution_; 00361 00363 // 1 for relaxation 00364 // 2 for ILUT 00365 // 3 for RILUK 00366 // 4 for Chebyshev 00367 int PreconditionerType_; 00368 00373 Teuchos::ParameterList precParams_; 00374 00376 magnitude_type Condest_; 00378 bool IsInitialized_; 00380 bool IsComputed_; 00382 int NumInitialize_; 00384 int NumCompute_; 00386 mutable int NumApply_; 00388 double InitializeTime_; 00390 double ComputeTime_; 00392 mutable double ApplyTime_; 00393 00395 Teuchos::RCP<Belos::LinearProblem<belos_scalar_type, 00396 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>, 00397 Tpetra::Operator<scalar_type,local_ordinal_type,global_ordinal_type,node_type> > > belosProblem_; 00398 00400 Teuchos::RCP<Belos::SolverManager<belos_scalar_type, 00401 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>, 00402 Tpetra::Operator<scalar_type,local_ordinal_type,global_ordinal_type,node_type> > > belosSolver_; 00403 00405 Teuchos::RCP<prec_type> ifpack2_prec_; 00406 }; 00407 00408 } // namespace Ifpack2 00409 00410 #endif // IFPACK2_KRYLOV_DECL_HPP
1.7.6.1