Thyra_AztecOOLinearOpWithSolve.hpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
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>
00068 , virtual protected SingleRhsLinearOpBase<double>
00069 , virtual protected SingleScalarLinearOpWithSolveBase<double>
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 }
00304
00305 #endif // THYRA_AZTECOO_LINEAR_OP_WITH_SOLVE_HPP