Teko Version of the Day
Teko_StratimikosFactory.hpp
00001 #ifndef __Teko_StratimikosFactory_hpp__
00002 #define __Teko_StratimikosFactory_hpp__
00003 
00004 #include <vector>
00005 
00006 #include "Thyra_PreconditionerFactoryBase.hpp"
00007 #include "Thyra_EpetraOperatorViewExtractorBase.hpp"
00008 #include "Teuchos_StandardCompositionMacros.hpp"
00009 
00010 #include "Teko_RequestHandler.hpp"
00011 #include "Teko_InverseLibrary.hpp"
00012 #include "Teko_InverseFactory.hpp"
00013 
00014 #include "Epetra_Operator.h"
00015 
00016 namespace Teko {
00017 
00022 class StratimikosFactory : public Thyra::PreconditionerFactoryBase<double> {
00023 public:
00024 
00027 
00029   StratimikosFactory();
00030 
00031   StratimikosFactory(const Teuchos::RCP<Teko::RequestHandler> & rh);
00032     
00041   STANDARD_COMPOSITION_MEMBERS(
00042     Thyra::EpetraOperatorViewExtractorBase, epetraFwdOpViewExtractor );
00043 
00045 
00048 
00050   bool isCompatible( const Thyra::LinearOpSourceBase<double> &fwdOp ) const;
00052   bool applySupportsConj(Thyra::EConj conj) const;
00054   bool applyTransposeSupportsConj(Thyra::EConj conj) const;
00056   Teuchos::RCP<Thyra::PreconditionerBase<double> > createPrec() const;
00058   void initializePrec(
00059     const Teuchos::RCP<const Thyra::LinearOpSourceBase<double> > &fwdOp,
00060     Thyra::PreconditionerBase<double> *prec,
00061     const Thyra::ESupportSolveUse supportSolveUse
00062     ) const;
00064   void uninitializePrec(
00065     Thyra::PreconditionerBase<double> *prec
00066     ,Teuchos::RCP<const Thyra::LinearOpSourceBase<double> > *fwdOp
00067     ,Thyra::ESupportSolveUse *supportSolveUse
00068     ) const;
00069 
00071 
00074 
00076   void setParameterList(
00077     Teuchos::RCP<Teuchos::ParameterList> const& paramList);
00079   Teuchos::RCP<Teuchos::ParameterList> getNonconstParameterList();
00081   Teuchos::RCP<Teuchos::ParameterList> unsetParameterList();
00083   Teuchos::RCP<const Teuchos::ParameterList> getParameterList() const;
00085   Teuchos::RCP<const Teuchos::ParameterList> getValidParameters() const;
00087 
00090 
00092   std::string description() const;
00093 
00094   // ToDo: Add an override of describe(...) to give more detail!
00095 
00097 
00100   void initializePrec_Thyra(
00101     const Teuchos::RCP<const Thyra::LinearOpSourceBase<double> > &fwdOp,
00102     Thyra::PreconditionerBase<double> *prec,
00103     const Thyra::ESupportSolveUse supportSolveUse
00104     ) const;
00105 
00108   void initializePrec_Epetra(
00109     const Teuchos::RCP<const Thyra::LinearOpSourceBase<double> > &fwdOp,
00110     Thyra::PreconditionerBase<double> *prec,
00111     const Thyra::ESupportSolveUse supportSolveUse
00112     ) const;
00113 
00116   void setRequestHandler(const Teuchos::RCP<Teko::RequestHandler> & rh)
00117   { reqHandler_ = rh; }
00118 
00121   Teuchos::RCP<Teko::RequestHandler> getRequestHandler() const 
00122   { return reqHandler_; }
00123 
00125   const std::vector<int> & getDecomposition() const
00126   { return decomp_; }
00127 
00128 private:
00129 
00142   Teuchos::RCP<Epetra_Operator> buildWrappedEpetraOperator(
00143                                                      const Teuchos::RCP<const Epetra_Operator> & Jac,
00144                                                      const Teuchos::RCP<Epetra_Operator> & wrapInput,
00145                                                      std::ostream & out) const;
00146 
00155   void buildStridedVectors(const Epetra_Operator & Jac,
00156                            const std::vector<int> & decomp,
00157                            std::vector<std::vector<int> > & vars) const;
00158 
00159   Teuchos::RCP<Teuchos::ParameterList> paramList_;
00160 
00161   mutable Teuchos::RCP<Teko::InverseLibrary> invLib_;
00162   mutable Teuchos::RCP<Teko::InverseFactory> invFactory_;
00163   Teuchos::RCP<Teko::RequestHandler> reqHandler_;
00164   mutable std::vector<int> decomp_;
00165 };
00166 
00167 void addTekoToStratimikosBuilder(Stratimikos::DefaultLinearSolverBuilder & builder,
00168                                const std::string & stratName="Teko");
00169 
00170 void addTekoToStratimikosBuilder(Stratimikos::DefaultLinearSolverBuilder & builder,
00171                                const Teuchos::RCP<Teko::RequestHandler> & rh,
00172                                const std::string & stratName="Teko");
00173 
00174 } // namespace Teko
00175 
00176 #endif 
 All Classes Files Functions Variables