Stratimikos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Thyra_BelosLinearOpWithSolve_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_DECL_HPP
00046 #define THYRA_BELOS_LINEAR_OP_WITH_SOLVE_DECL_HPP
00047 
00048 #include "Thyra_LinearOpWithSolveBase.hpp"
00049 #include "Thyra_LinearOpSourceBase.hpp"
00050 #include "BelosSolverManager.hpp"
00051 #include "BelosThyraAdapter.hpp"
00052 #include "Teuchos_StandardMemberCompositionMacros.hpp"
00053 
00054 
00055 namespace Thyra {
00056 
00057 
00065 template<class Scalar>
00066 class BelosLinearOpWithSolve : virtual public LinearOpWithSolveBase<Scalar>
00067 {
00068 public:
00069 
00072 
00074   typedef MultiVectorBase<Scalar>    MV_t;
00076   typedef LinearOpBase<Scalar>       LO_t;
00077 
00079 
00082 
00084   BelosLinearOpWithSolve();
00085 
00125   void initialize(
00126     const RCP<Belos::LinearProblem<Scalar,MV_t,LO_t> > &lp,
00127     const RCP<Teuchos::ParameterList> &solverPL,
00128     const RCP<Belos::SolverManager<Scalar,MV_t,LO_t> > &iterativeSolver,
00129     const RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc,
00130     const RCP<const PreconditionerBase<Scalar> > &prec,
00131     const bool isExternalPrec,
00132     const RCP<const LinearOpSourceBase<Scalar> > &approxFwdOpSrc,
00133     const ESupportSolveUse &supportSolveUse,
00134     const int convergenceTestFrequency
00135     );
00136 
00138   RCP<const LinearOpSourceBase<Scalar> > extract_fwdOpSrc();
00139 
00141   RCP<const PreconditionerBase<Scalar> > extract_prec();
00142 
00144   bool isExternalPrec() const;
00145 
00147   RCP<const LinearOpSourceBase<Scalar> > extract_approxFwdOpSrc();
00148 
00150   ESupportSolveUse supportSolveUse() const;
00151 
00156   void uninitialize(
00157     RCP<Belos::LinearProblem<Scalar,MV_t,LO_t> > *lp = NULL,
00158     RCP<Teuchos::ParameterList> *solverPL = NULL,
00159     RCP<Belos::SolverManager<Scalar,MV_t,LO_t> > *iterativeSolver = NULL,
00160     RCP<const LinearOpSourceBase<Scalar> > *fwdOpSrc = NULL,
00161     RCP<const PreconditionerBase<Scalar> > *prec = NULL,
00162     bool *isExternalPrec = NULL,
00163     RCP<const LinearOpSourceBase<Scalar> > *approxFwdOpSrc = NULL,
00164     ESupportSolveUse *supportSolveUse = NULL
00165     );
00166 
00168 
00172   RCP< const VectorSpaceBase<Scalar> > range() const;
00174   RCP< const VectorSpaceBase<Scalar> > domain() const;
00176   RCP<const LinearOpBase<Scalar> > clone() const;
00178 
00182   std::string description() const;
00184   void describe(
00185     Teuchos::FancyOStream &out,
00186     const Teuchos::EVerbosityLevel verbLevel
00187     ) const;
00189 
00192 
00194   void setParameterList(RCP<Teuchos::ParameterList> const& paramList);
00196   RCP<Teuchos::ParameterList> getNonconstParameterList();
00198   RCP<Teuchos::ParameterList> unsetParameterList();
00200   RCP<const Teuchos::ParameterList> getParameterList() const;
00202   RCP<const Teuchos::ParameterList> getValidParameters() const;
00203 
00205 
00206 protected:
00207 
00211   virtual bool opSupportedImpl(EOpTransp M_trans) const;
00213   virtual void applyImpl(
00214     const EOpTransp M_trans,
00215     const MultiVectorBase<Scalar> &X,
00216     const Ptr<MultiVectorBase<Scalar> > &Y,
00217     const Scalar alpha,
00218     const Scalar beta
00219     ) const;
00221 
00225   virtual bool solveSupportsImpl(EOpTransp M_trans) const;
00227   virtual bool solveSupportsNewImpl(EOpTransp transp,
00228     const Ptr<const SolveCriteria<Scalar> > solveCriteria) const;
00230   virtual bool solveSupportsSolveMeasureTypeImpl(
00231     EOpTransp M_trans, const SolveMeasureType& solveMeasureType
00232     ) const;
00234   virtual SolveStatus<Scalar> solveImpl(
00235     const EOpTransp transp,
00236     const MultiVectorBase<Scalar> &B,
00237     const Ptr<MultiVectorBase<Scalar> > &X,
00238     const Ptr<const SolveCriteria<Scalar> > solveCriteria
00239     ) const;
00241   
00242 private:
00243   
00244   // ///////////////////////////////
00245   // Private data members
00246 
00247 
00248   RCP<Belos::LinearProblem<Scalar,MV_t,LO_t> > lp_;
00249   RCP<Teuchos::ParameterList> solverPL_;
00250   RCP<Belos::SolverManager<Scalar,MV_t,LO_t> > iterativeSolver_;
00251   int convergenceTestFrequency_;
00252 
00253   RCP<const LinearOpSourceBase<Scalar> > fwdOpSrc_;
00254   RCP<const PreconditionerBase<Scalar> > prec_;
00255   bool isExternalPrec_;
00256   RCP<const LinearOpSourceBase<Scalar> > approxFwdOpSrc_;
00257   ESupportSolveUse supportSolveUse_;
00258 
00259   typename Teuchos::ScalarTraits<Scalar>::magnitudeType defaultTol_;
00260                                                      
00261   void assertInitialized() const;
00262   
00263 };
00264 
00265 
00266 } // namespace Thyra
00267 
00268 
00269 #endif  // THYRA_BELOS_LINEAR_OP_WITH_SOLVE_DECL_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines