|
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 00043 #ifndef IFPACK2_IDENTITY_SOLVER_DECL_HPP 00044 #define IFPACK2_IDENTITY_SOLVER_DECL_HPP 00045 00046 #include <Ifpack2_Preconditioner.hpp> 00047 #include <Ifpack2_Details_CanChangeMatrix.hpp> 00048 00049 00050 namespace Ifpack2 { 00051 00058 template<class MatrixType> 00059 class IdentitySolver : 00060 virtual public Ifpack2::Preconditioner<typename MatrixType::scalar_type, 00061 typename MatrixType::local_ordinal_type, 00062 typename MatrixType::global_ordinal_type, 00063 typename MatrixType::node_type>, 00064 virtual public Ifpack2::Details::CanChangeMatrix<Tpetra::RowMatrix<typename MatrixType::scalar_type, 00065 typename MatrixType::local_ordinal_type, 00066 typename MatrixType::global_ordinal_type, 00067 typename MatrixType::node_type> > 00068 { 00069 public: 00071 typedef typename MatrixType::scalar_type scalar_type; 00073 typedef typename MatrixType::local_ordinal_type local_ordinal_type; 00075 typedef typename MatrixType::global_ordinal_type global_ordinal_type; 00077 typedef typename MatrixType::node_type node_type; 00078 00080 typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitude_type; 00082 typedef Tpetra::Map<local_ordinal_type, global_ordinal_type, node_type> map_type; 00084 typedef Tpetra::RowMatrix<scalar_type, local_ordinal_type, 00085 global_ordinal_type, node_type> row_matrix_type; 00086 00088 IdentitySolver (const Teuchos::RCP<const row_matrix_type>& A); 00089 00091 virtual ~IdentitySolver(); 00092 00096 void setParameters (const Teuchos::ParameterList& params); 00097 00099 void initialize(); 00100 00102 inline bool isInitialized() const { 00103 return(isInitialized_); 00104 } 00105 00107 void compute(); 00108 00110 inline bool isComputed() const { 00111 return(isComputed_); 00112 } 00113 00115 00116 00123 void 00124 apply (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X, 00125 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y, 00126 Teuchos::ETransp mode = Teuchos::NO_TRANS, 00127 scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(), 00128 scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero()) const; 00129 00131 Teuchos::RCP<const map_type> getDomainMap () const; 00132 00134 Teuchos::RCP<const map_type> getRangeMap () const; 00135 00140 void 00141 applyMat (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X, 00142 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y, 00143 Teuchos::ETransp mode = Teuchos::NO_TRANS) const; 00144 00146 00147 00148 00158 virtual magnitude_type TEUCHOS_DEPRECATED 00159 computeCondEst (CondestType CT = Cheap, 00160 local_ordinal_type MaxIters = 1550, 00161 magnitude_type Tol = 1e-9, 00162 const Teuchos::Ptr<const Tpetra::RowMatrix<scalar_type,local_ordinal_type,global_ordinal_type,node_type> > &matrix = Teuchos::null); 00163 00165 00166 00167 00171 virtual magnitude_type TEUCHOS_DEPRECATED getCondEst() const { 00172 return condEst_; 00173 } 00174 00176 Teuchos::RCP<const Teuchos::Comm<int> > getComm () const; 00177 00179 Teuchos::RCP<const row_matrix_type> getMatrix () const { 00180 return matrix_; 00181 } 00182 00184 double getComputeFlops() const; 00185 00187 double getApplyFlops() const; 00188 00190 int getNumInitialize() const; 00191 00193 int getNumCompute() const; 00194 00196 int getNumApply() const; 00197 00199 double getInitializeTime() const; 00200 00202 double getComputeTime() const; 00203 00205 double getApplyTime() const; 00206 00208 00209 00210 00212 std::string description() const; 00213 00215 void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const; 00216 00221 virtual void setMatrix (const Teuchos::RCP<const row_matrix_type>& A); 00222 00224 00225 private: 00227 typedef Tpetra::Export<local_ordinal_type, global_ordinal_type, node_type> export_type; 00228 00229 Teuchos::RCP<const row_matrix_type> matrix_; 00230 00238 Teuchos::RCP<const export_type> export_; 00239 00240 bool isInitialized_; 00241 bool isComputed_; 00242 00243 mutable int numInitialize_; 00244 mutable int numCompute_; 00245 mutable int numApply_; 00246 00247 double initializeTime_; 00248 double computeTime_; 00249 double applyTime_; 00250 00251 magnitude_type condEst_; 00252 }; 00253 00254 }//namespace Ifpack2 00255 00256 #endif
1.7.6.1