Ifpack2 Templated Preconditioning Package  Version 1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
Ifpack2_Details_Amesos2Wrapper_decl.hpp
Go to the documentation of this file.
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 
00050 
00051 #ifndef IFPACK2_DETAILS_AMESOS2WRAPPER_DECL_HPP
00052 #define IFPACK2_DETAILS_AMESOS2WRAPPER_DECL_HPP
00053 
00054 #include <Ifpack2_ConfigDefs.hpp>
00055 #include <Ifpack2_Preconditioner.hpp>
00056 #include <Ifpack2_Details_CanChangeMatrix.hpp>
00057 #include <Ifpack2_CondestType.hpp>
00058 
00059 #ifdef HAVE_IFPACK2_AMESOS2
00060 #include <Amesos2_config.h>
00061 #include <Amesos2.hpp>
00062 }
00063 
00064 using namespace Ifpack2;
00065 
00066 namespace Teuchos {
00067   // forward declaration
00068   class ParameterList;
00069 }
00070 
00071 namespace Ifpack2 {
00072 namespace Details {
00099 template<class MatrixType>
00100 class Amesos2Wrapper :
00101     virtual public ::Ifpack2::Preconditioner<typename MatrixType::scalar_type,
00102                                            typename MatrixType::local_ordinal_type,
00103                                            typename MatrixType::global_ordinal_type,
00104                                            typename MatrixType::node_type>,
00105     virtual public ::Ifpack2::Details::CanChangeMatrix<Tpetra::RowMatrix<typename MatrixType::scalar_type,
00106                                                                        typename MatrixType::local_ordinal_type,
00107                                                                        typename MatrixType::global_ordinal_type,
00108                                                                        typename MatrixType::node_type> >
00109 {
00110 public:
00112 
00113 
00115   typedef typename MatrixType::scalar_type scalar_type;
00116 
00118   TEUCHOS_DEPRECATED typedef typename MatrixType::scalar_type Scalar;
00119 
00120 
00122   typedef typename MatrixType::local_ordinal_type local_ordinal_type;
00123 
00125   TEUCHOS_DEPRECATED typedef typename MatrixType::local_ordinal_type LocalOrdinal;
00126 
00127 
00129   typedef typename MatrixType::global_ordinal_type global_ordinal_type;
00130 
00132   TEUCHOS_DEPRECATED typedef typename MatrixType::global_ordinal_type GlobalOrdinal;
00133 
00134 
00136   typedef typename MatrixType::node_type node_type;
00137 
00139   TEUCHOS_DEPRECATED typedef typename MatrixType::node_type Node;
00140 
00141 
00143   typedef typename ::Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitude_type;
00144 
00146   TEUCHOS_DEPRECATED typedef typename ::Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitudeType;
00147 
00149   typedef Tpetra::RowMatrix<scalar_type,
00150                             local_ordinal_type,
00151                             global_ordinal_type,
00152                             node_type> row_matrix_type;
00153 
00155   typedef Tpetra::Map<local_ordinal_type,
00156                       global_ordinal_type,
00157                       node_type> map_type;
00158 
00160   typedef Tpetra::CrsMatrix<scalar_type,
00161                             local_ordinal_type,
00162                             global_ordinal_type,
00163                             node_type> crs_matrix_type;
00165 
00166 
00167 
00173   explicit Amesos2Wrapper (const ::Teuchos::RCP<const row_matrix_type>& A);
00174 
00176   virtual ~Amesos2Wrapper();
00177 
00179 
00180 
00181 
00183   void setParameters (const ::Teuchos::ParameterList& params);
00184 
00197   void initialize ();
00198 
00200   inline bool isInitialized() const {
00201     return IsInitialized_;
00202   }
00203 
00215   void compute();
00216 
00218   inline bool isComputed() const {
00219     return IsComputed_;
00220   }
00221 
00223 
00224 
00225 
00248   virtual void
00249   setMatrix (const ::Teuchos::RCP<const row_matrix_type>& A);
00250 
00252 
00253 
00254 
00270   void
00271   apply (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
00272          Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
00273          ::Teuchos::ETransp mode = ::Teuchos::NO_TRANS,
00274          scalar_type alpha = ::Teuchos::ScalarTraits<scalar_type>::one(),
00275          scalar_type beta = ::Teuchos::ScalarTraits<scalar_type>::zero()) const;
00276 
00278   ::Teuchos::RCP<const map_type> getDomainMap () const;
00279 
00281   ::Teuchos::RCP<const map_type> getRangeMap () const;
00282 
00284   bool hasTransposeApply () const;
00285 
00287 
00288 
00289 
00299   virtual magnitude_type TEUCHOS_DEPRECATED
00300   computeCondEst (CondestType CT = Cheap,
00301                   local_ordinal_type MaxIters = 1550,
00302                   magnitude_type Tol = 1e-9,
00303                   const ::Teuchos::Ptr<const Tpetra::RowMatrix<scalar_type,local_ordinal_type,global_ordinal_type,node_type> >& Matrix_in = ::Teuchos::null);
00304 
00308   virtual magnitude_type TEUCHOS_DEPRECATED getCondEst () const {
00309     return Condest_;
00310   }
00311 
00313   ::Teuchos::RCP<const ::Teuchos::Comm<int> > getComm () const;
00314 
00316   ::Teuchos::RCP<const row_matrix_type> getMatrix () const;
00317 
00319   int getNumInitialize () const;
00320 
00322   int getNumCompute () const;
00323 
00325   int getNumApply () const;
00326 
00328   double getInitializeTime () const;
00329 
00331   double getComputeTime () const;
00332 
00334   double getApplyTime () const;
00335 
00337 
00338 
00339 
00341   std::string description () const;
00342 
00344   void
00345   describe (::Teuchos::FancyOStream &out,
00346             const ::Teuchos::EVerbosityLevel verbLevel =
00347             ::Teuchos::Describable::verbLevel_default) const;
00349 
00350 private:
00351   typedef ::Teuchos::ScalarTraits<scalar_type> STS;
00352   typedef ::Teuchos::ScalarTraits<magnitude_type> STM;
00353   typedef typename ::Teuchos::Array<local_ordinal_type>::size_type size_type;
00354 
00356   typedef Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type> MV;
00357 
00359   Amesos2Wrapper (const Amesos2Wrapper<MatrixType>& RHS);
00360 
00362   Amesos2Wrapper<MatrixType>& operator= (const Amesos2Wrapper<MatrixType>& RHS);
00363 
00365   ::Teuchos::RCP<Amesos2::Solver<crs_matrix_type, MV> > amesos2solver_;
00366 
00372   static ::Teuchos::RCP<const row_matrix_type>
00373   makeLocalFilter (const ::Teuchos::RCP<const row_matrix_type>& A);
00374 
00376   //Teuchos::RCP<const MatrixType> A_;
00377   ::Teuchos::RCP<const row_matrix_type> A_;
00378 
00387   ::Teuchos::RCP<const crs_matrix_type> A_local_crs_;
00388 
00390   // \name Parameters (set by setParameters())
00392 
00395   ::Teuchos::RCP<const ::Teuchos::ParameterList> parameterList_;
00396 
00398   // \name Other internal data
00400 
00402   magnitude_type Condest_;
00404   double InitializeTime_;
00406   double ComputeTime_;
00408   mutable double ApplyTime_;
00410   int NumInitialize_;
00412   int NumCompute_;
00414   mutable int NumApply_;
00416   bool IsInitialized_;
00418   bool IsComputed_;
00421   std::string SolverName_;
00423 }; // class Amesos2Wrapper
00424 
00425 } // namespace Details
00426 } // namespace Ifpack2
00427 
00428 #endif // HAVE_IFPACK2_AMESOS2
00429 
00430 #endif // IFPACK2_DETAILS_AMESOS2WRAPPER_DECL_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends