Thyra_AztecOOLinearOpWithSolve.hpp

00001 /*@HEADER
00002 // ***********************************************************************
00003 // 
00004 //        AztecOO: An Object-Oriented Aztec Linear Solver Package 
00005 //                 Copyright (2002) 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 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //  
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00025 // 
00026 // ***********************************************************************
00027 //@HEADER
00028 */
00029 
00030 #ifndef THYRA_AZTECOO_LINEAR_OP_WITH_SOLVE_HPP
00031 #define THYRA_AZTECOO_LINEAR_OP_WITH_SOLVE_HPP
00032 
00033 #include "Thyra_SingleScalarLinearOpWithSolveBase.hpp"
00034 #include "Thyra_LinearOpSourceBase.hpp"
00035 #include "Thyra_SingleRhsLinearOpBase.hpp"
00036 #include "Thyra_EpetraLinearOp.hpp"
00037 #include "Thyra_PreconditionerBase.hpp"
00038 #include "Teuchos_StandardMemberCompositionMacros.hpp"
00039 #include "AztecOO.h"
00040 
00041 
00042 namespace Thyra {
00043 
00044 
00066 class AztecOOLinearOpWithSolve
00067   : virtual public LinearOpWithSolveBase<double>                  // Public interface
00068   , virtual protected SingleRhsLinearOpBase<double>               // Implementation detail
00069   , virtual protected SingleScalarLinearOpWithSolveBase<double>   // Implementation detail
00070 {
00071 public:
00072 
00075 
00082    AztecOOLinearOpWithSolve(
00083      const int fwdDefaultMaxIterations = 400,
00084      const double fwdDefaultTol = 1e-6,
00085      const int adjDefaultMaxIterations = 400,
00086      const double adjDefaultTol = 1e-6,
00087      const bool outputEveryRhs = false
00088      );
00089 
00091   STANDARD_MEMBER_COMPOSITION_MEMBERS( int, fwdDefaultMaxIterations );
00093    STANDARD_MEMBER_COMPOSITION_MEMBERS( double, fwdDefaultTol );
00095   STANDARD_MEMBER_COMPOSITION_MEMBERS( int, adjDefaultMaxIterations );
00097    STANDARD_MEMBER_COMPOSITION_MEMBERS( double, adjDefaultTol );
00099    STANDARD_MEMBER_COMPOSITION_MEMBERS( bool, outputEveryRhs );
00100 
00177   void initialize(
00178     const Teuchos::RCP<const LinearOpBase<double> > &fwdOp,
00179     const Teuchos::RCP<const LinearOpSourceBase<double> > &fwdOpSrc,
00180     const Teuchos::RCP<const PreconditionerBase<double> > &prec,
00181     const bool isExternalPrec,
00182     const Teuchos::RCP<const LinearOpSourceBase<double> > &approxFwdOpSrc,
00183     const Teuchos::RCP<AztecOO> &aztecFwdSolver,
00184     const bool allowInexactFwdSolve = false,
00185     const Teuchos::RCP<AztecOO> &aztecAdjSolver = Teuchos::null,
00186     const bool allowInexactAdjSolve = false,
00187     const double aztecSolverScalar = 1.0
00188     );
00189   
00193   Teuchos::RCP<const LinearOpSourceBase<double> > extract_fwdOpSrc();
00194 
00197   Teuchos::RCP<const PreconditionerBase<double> > extract_prec();
00198 
00201   bool isExternalPrec() const;
00202 
00203 
00207   Teuchos::RCP<const LinearOpSourceBase<double> > extract_approxFwdOpSrc();
00208   
00210   void uninitialize(
00211     Teuchos::RCP<const LinearOpBase<double> > *fwdOp = NULL,
00212     Teuchos::RCP<const LinearOpSourceBase<double> > *fwdOpSrc = NULL,
00213     Teuchos::RCP<const PreconditionerBase<double> > *prec = NULL,
00214     bool *isExternalPrec = NULL,
00215     Teuchos::RCP<const LinearOpSourceBase<double> > *approxFwdOpSrc = NULL,
00216     Teuchos::RCP<AztecOO> *aztecFwdSolver = NULL,
00217     bool *allowInexactFwdSolve = NULL,
00218     Teuchos::RCP<AztecOO> *aztecAdjSolver = NULL,
00219     bool *allowInexactAdjSolve = NULL,
00220     double *aztecSolverScalar = NULL
00221     );
00222 
00224 
00228   Teuchos::RCP< const VectorSpaceBase<double> > range() const;
00230   Teuchos::RCP< const VectorSpaceBase<double> > domain() const;
00232   Teuchos::RCP<const LinearOpBase<double> > clone() const;
00234 
00238   std::string description() const;
00240   void describe(
00241     Teuchos::FancyOStream &out,
00242     const Teuchos::EVerbosityLevel verbLevel
00243     ) const;
00245 
00246 protected:
00247 
00251   bool opSupported(ETransp M_trans) const;
00253 
00257   void apply(
00258     const ETransp M_trans,
00259     const VectorBase<double> &x,
00260     VectorBase<double> *y,
00261     const double alpha,
00262     const double beta
00263     ) const;
00265 
00269   bool solveSupportsTrans(ETransp M_trans) const;
00271   bool solveSupportsSolveMeasureType(
00272     ETransp M_trans, const SolveMeasureType& solveMeasureType
00273     ) const;
00275   void solve(
00276     const ETransp M_trans,
00277     const MultiVectorBase<double> &B,
00278     MultiVectorBase<double> *X,
00279     const int numBlocks,
00280     const BlockSolveCriteria<double> blockSolveCriteria[],
00281     SolveStatus<double> blockSolveStatus[]
00282     ) const;
00284   
00285 private:
00286   
00287   Teuchos::RCP<const LinearOpBase<double> > fwdOp_;
00288   Teuchos::RCP<const LinearOpSourceBase<double> > fwdOpSrc_;
00289   Teuchos::RCP<const PreconditionerBase<double> > prec_;
00290   bool isExternalPrec_;
00291   Teuchos::RCP<const LinearOpSourceBase<double> > approxFwdOpSrc_;
00292   Teuchos::RCP<AztecOO> aztecFwdSolver_;
00293   bool allowInexactFwdSolve_;
00294   Teuchos::RCP<AztecOO> aztecAdjSolver_;
00295   bool allowInexactAdjSolve_;
00296   double aztecSolverScalar_;
00297   
00298   void assertInitialized() const;
00299 
00300 };
00301 
00302 
00303 } // namespace Thyra
00304 
00305 #endif  // THYRA_AZTECOO_LINEAR_OP_WITH_SOLVE_HPP

Generated on Wed Jul 22 13:20:35 2009 for Stratimikos by doxygen 1.5.8