Stratimikos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Thyra_BelosLinearOpWithSolveFactory_decl.hpp
Go to the documentation of this file.
00001 /*
00002 // @HEADER
00003 // ***********************************************************************
00004 // 
00005 //         Stratimikos: Thyra-based strategies for linear solvers
00006 //                Copyright (2006) Sandia Corporation
00007 // 
00008 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00009 // license for use of this work by or on behalf of the U.S. Government.
00010 // 
00011 // Redistribution and use in source and binary forms, with or without
00012 // modification, are permitted provided that the following conditions are
00013 // met:
00014 //
00015 // 1. Redistributions of source code must retain the above copyright
00016 // notice, this list of conditions and the following disclaimer.
00017 //
00018 // 2. Redistributions in binary form must reproduce the above copyright
00019 // notice, this list of conditions and the following disclaimer in the
00020 // documentation and/or other materials provided with the distribution.
00021 //
00022 // 3. Neither the name of the Corporation nor the names of the
00023 // contributors may be used to endorse or promote products derived from
00024 // this software without specific prior written permission.
00025 //
00026 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00027 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00029 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00030 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00031 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00032 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00033 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00034 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00035 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00036 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00037 //
00038 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 
00039 // 
00040 // ***********************************************************************
00041 // @HEADER
00042 */
00043 
00044 
00045 #ifndef THYRA_BELOS_LINEAR_OP_WITH_SOLVE_FACTORY_DECL_HPP
00046 #define THYRA_BELOS_LINEAR_OP_WITH_SOLVE_FACTORY_DECL_HPP
00047 
00048 #include "Thyra_LinearOpWithSolveFactoryBase.hpp"
00049 #include "Teuchos_StandardMemberCompositionMacros.hpp"
00050 #include "Teuchos_StandardCompositionMacros.hpp"
00051 
00052 namespace Teuchos { class ParameterList; }
00053 
00054 namespace Thyra {
00055 
00056   enum EBelosSolverType {
00057     SOLVER_TYPE_BLOCK_GMRES,
00058     SOLVER_TYPE_PSEUDO_BLOCK_GMRES,
00059     SOLVER_TYPE_BLOCK_CG,
00060     SOLVER_TYPE_PSEUDO_BLOCK_CG,
00061     SOLVER_TYPE_PSEUDO_BLOCK_STOCHASTIC_CG,
00062     SOLVER_TYPE_GCRODR,
00063     SOLVER_TYPE_RCG,
00064     SOLVER_TYPE_MINRES,
00065     SOLVER_TYPE_TFQMR
00066   };
00067 
00068   inline std::istream& operator>>(
00069     std::istream& is, EBelosSolverType& sType)
00070   {
00071     int intval;
00072     is >> intval;
00073     sType = (EBelosSolverType)intval;
00074     return is;
00075   }
00076 
00077 
00085 template<class Scalar>
00086 class BelosLinearOpWithSolveFactory : public LinearOpWithSolveFactoryBase<Scalar> {
00087 public:
00088 
00093   typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType  MagnitudeType;
00094 
00096 
00099 
00101   static const std::string  SolverType_name;
00103   static const std::string  SolverType_default;
00105   static const std::string  SolverTypes_name;
00107   static const std::string  BlockGMRES_name;
00109   static const std::string  PseudoBlockGMRES_name;
00111   static const std::string  BlockCG_name;
00113   static const std::string  PseudoBlockCG_name;
00115   static const std::string  PseudoBlockStochasticCG_name;
00117   static const std::string  GCRODR_name;
00119   static const std::string  RCG_name;
00121   static const std::string  MINRES_name;
00123   static const std::string  TFQMR_name;
00125   static const std::string  ConvergenceTestFrequency_name;
00126 
00128 
00131 
00133   BelosLinearOpWithSolveFactory();
00134 
00136   BelosLinearOpWithSolveFactory(
00137     const Teuchos::RCP<PreconditionerFactoryBase<Scalar> >      &precFactory
00138     );
00139 
00141 
00145   bool acceptsPreconditionerFactory() const;
00147   void setPreconditionerFactory(
00148     const Teuchos::RCP<PreconditionerFactoryBase<Scalar> >      &precFactory
00149     ,const std::string                                          &precFactoryName
00150     );
00152   Teuchos::RCP<PreconditionerFactoryBase<Scalar> > getPreconditionerFactory() const;
00154   void unsetPreconditionerFactory(
00155     Teuchos::RCP<PreconditionerFactoryBase<Scalar> >            *precFactory
00156     ,std::string                                                *precFactoryName
00157     );
00159   bool isCompatible( const LinearOpSourceBase<Scalar> &fwdOpSrc ) const;
00161   Teuchos::RCP<LinearOpWithSolveBase<Scalar> > createOp() const;
00163   void initializeOp(
00164     const Teuchos::RCP<const LinearOpSourceBase<Scalar> >       &fwdOpSrc
00165     ,LinearOpWithSolveBase<Scalar>                              *Op
00166     ,const ESupportSolveUse                                     supportSolveUse
00167     ) const;
00169   void initializeAndReuseOp(
00170     const Teuchos::RCP<const LinearOpSourceBase<Scalar> >       &fwdOpSrc
00171     ,LinearOpWithSolveBase<Scalar>                              *Op
00172     ) const;
00174   void uninitializeOp(
00175     LinearOpWithSolveBase<Scalar>                               *Op
00176     ,Teuchos::RCP<const LinearOpSourceBase<Scalar> >            *fwdOpSrc
00177     ,Teuchos::RCP<const PreconditionerBase<Scalar> >            *prec
00178     ,Teuchos::RCP<const LinearOpSourceBase<Scalar> >            *approxFwdOpSrc
00179     ,ESupportSolveUse                                           *supportSolveUse
00180     ) const;
00182   bool supportsPreconditionerInputType(const EPreconditionerInputType precOpType) const;
00184   void initializePreconditionedOp(
00185     const Teuchos::RCP<const LinearOpSourceBase<Scalar> >       &fwdOpSrc
00186     ,const Teuchos::RCP<const PreconditionerBase<Scalar> >      &prec
00187     ,LinearOpWithSolveBase<Scalar>                              *Op
00188     ,const ESupportSolveUse                                     supportSolveUse
00189     ) const;
00191   void initializeApproxPreconditionedOp(
00192     const Teuchos::RCP<const LinearOpSourceBase<Scalar> >       &fwdOpSrc
00193     ,const Teuchos::RCP<const LinearOpSourceBase<Scalar> >      &approxFwdOpSrc
00194     ,LinearOpWithSolveBase<Scalar>                              *Op
00195     ,const ESupportSolveUse                                     supportSolveUse
00196     ) const;
00198 
00201 
00203   void setParameterList(Teuchos::RCP<Teuchos::ParameterList> const& paramList);
00205   Teuchos::RCP<Teuchos::ParameterList> getNonconstParameterList();
00207   Teuchos::RCP<Teuchos::ParameterList> unsetParameterList();
00209   Teuchos::RCP<const Teuchos::ParameterList> getParameterList() const;
00211   Teuchos::RCP<const Teuchos::ParameterList> getValidParameters() const;
00212 
00214 
00217 
00219   std::string description() const;
00220 
00222 
00223 private:
00224 
00225   // /////////////////////////
00226   // Private types
00227 
00228 
00229   // /////////////////////////
00230   // Private data members
00231 
00232   Teuchos::RCP<PreconditionerFactoryBase<Scalar> >  precFactory_;
00233   std::string                                       precFactoryName_;
00234   Teuchos::RCP<Teuchos::ParameterList>              thisValidParamList_;
00235   Teuchos::RCP<Teuchos::ParameterList>              paramList_;
00236   EBelosSolverType solverType_;
00237   int convergenceTestFrequency_;
00238 
00239   // /////////////////////////
00240   // Private member functions
00241 
00242   static Teuchos::RCP<const Teuchos::ParameterList> generateAndGetValidParameters();
00243 
00244   void updateThisValidParamList();
00245 
00246   void initializeOpImpl(
00247     const Teuchos::RCP<const LinearOpSourceBase<Scalar> >       &fwdOpSrc
00248     ,const Teuchos::RCP<const LinearOpSourceBase<Scalar> >      &approxFwdOpSrc
00249     ,const Teuchos::RCP<const PreconditionerBase<Scalar> >      &prec
00250     ,const bool                                                 reusePrec
00251     ,LinearOpWithSolveBase<Scalar>                              *Op
00252     ,const ESupportSolveUse                                     supportSolveUse
00253     ) const;
00254 
00255 };
00256 
00258 
00259 } // namespace Thyra
00260 
00261 #endif // THYRA_BELOS_LINEAR_OP_WITH_SOLVE_FACTORY_DECL_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines