Teko  Version of the Day
 All Classes Files Functions Variables Pages
Teko_StratimikosFactory.hpp
1 #ifndef __Teko_StratimikosFactory_hpp__
2 #define __Teko_StratimikosFactory_hpp__
3 
4 #include <vector>
5 
6 #include "Thyra_PreconditionerFactoryBase.hpp"
7 #include "Thyra_EpetraOperatorViewExtractorBase.hpp"
8 #include "Teuchos_StandardCompositionMacros.hpp"
9 
10 #include "Teko_RequestHandler.hpp"
11 #include "Teko_InverseLibrary.hpp"
12 #include "Teko_InverseFactory.hpp"
13 
14 #include "Epetra_Operator.h"
15 
16 namespace Teko {
17 
22 class StratimikosFactory : public Thyra::PreconditionerFactoryBase<double> {
23 public:
24 
27 
30 
31  StratimikosFactory(const Teuchos::RCP<Teko::RequestHandler> & rh);
32  StratimikosFactory(const Teuchos::RCP<Stratimikos::DefaultLinearSolverBuilder> & builder,
33  const Teuchos::RCP<Teko::RequestHandler> & rh);
34 
44  Thyra::EpetraOperatorViewExtractorBase, epetraFwdOpViewExtractor );
45 
47 
50 
52  bool isCompatible( const Thyra::LinearOpSourceBase<double> &fwdOp ) const;
54  bool applySupportsConj(Thyra::EConj conj) const;
56  bool applyTransposeSupportsConj(Thyra::EConj conj) const;
58  Teuchos::RCP<Thyra::PreconditionerBase<double> > createPrec() const;
60  void initializePrec(
61  const Teuchos::RCP<const Thyra::LinearOpSourceBase<double> > &fwdOp,
62  Thyra::PreconditionerBase<double> *prec,
63  const Thyra::ESupportSolveUse supportSolveUse
64  ) const;
66  void uninitializePrec(
67  Thyra::PreconditionerBase<double> *prec
68  ,Teuchos::RCP<const Thyra::LinearOpSourceBase<double> > *fwdOp
69  ,Thyra::ESupportSolveUse *supportSolveUse
70  ) const;
71 
73 
76 
78  void setParameterList(
79  Teuchos::RCP<Teuchos::ParameterList> const& paramList);
81  Teuchos::RCP<Teuchos::ParameterList> getNonconstParameterList();
83  Teuchos::RCP<Teuchos::ParameterList> unsetParameterList();
85  Teuchos::RCP<const Teuchos::ParameterList> getParameterList() const;
87  Teuchos::RCP<const Teuchos::ParameterList> getValidParameters() const;
89 
92 
94  std::string description() const;
95 
96  // ToDo: Add an override of describe(...) to give more detail!
97 
99 
103  const Teuchos::RCP<const Thyra::LinearOpSourceBase<double> > &fwdOp,
104  Thyra::PreconditionerBase<double> *prec,
105  const Thyra::ESupportSolveUse supportSolveUse
106  ) const;
107 
111  const Teuchos::RCP<const Thyra::LinearOpSourceBase<double> > &fwdOp,
112  Thyra::PreconditionerBase<double> *prec,
113  const Thyra::ESupportSolveUse supportSolveUse
114  ) const;
115 
118  void setRequestHandler(const Teuchos::RCP<Teko::RequestHandler> & rh)
119  { reqHandler_ = rh; }
120 
123  Teuchos::RCP<Teko::RequestHandler> getRequestHandler() const
124  { return reqHandler_; }
125 
127  const std::vector<int> & getDecomposition() const
128  { return decomp_; }
129 
130 private:
131 
144  Teuchos::RCP<Epetra_Operator> buildWrappedEpetraOperator(
145  const Teuchos::RCP<const Epetra_Operator> & Jac,
146  const Teuchos::RCP<Epetra_Operator> & wrapInput,
147  std::ostream & out) const;
148 
157  void buildStridedVectors(const Epetra_Operator & Jac,
158  const std::vector<int> & decomp,
159  std::vector<std::vector<int> > & vars) const;
160 
161  Teuchos::RCP<Teuchos::ParameterList> paramList_;
162 
163  mutable Teuchos::RCP<Teko::InverseLibrary> invLib_;
164  mutable Teuchos::RCP<Teko::InverseFactory> invFactory_;
165  Teuchos::RCP<Teko::RequestHandler> reqHandler_;
166  mutable std::vector<int> decomp_;
167  Teuchos::RCP<Stratimikos::DefaultLinearSolverBuilder> builder_; // builder to use for default solvers
168 };
169 
177 void addTekoToStratimikosBuilder(Stratimikos::DefaultLinearSolverBuilder & builder,
178  const std::string & stratName="Teko");
179 
187 void addTekoToStratimikosBuilder(Stratimikos::DefaultLinearSolverBuilder & builder,
188  const Teuchos::RCP<Teko::RequestHandler> & rh,
189  const std::string & stratName="Teko");
190 
191 } // namespace Teko
192 
193 #endif
bool applySupportsConj(Thyra::EConj conj) const
Teuchos::RCP< Teuchos::ParameterList > unsetParameterList()
void setRequestHandler(const Teuchos::RCP< Teko::RequestHandler > &rh)
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
void initializePrec(const Teuchos::RCP< const Thyra::LinearOpSourceBase< double > > &fwdOp, Thyra::PreconditionerBase< double > *prec, const Thyra::ESupportSolveUse supportSolveUse) const
void uninitializePrec(Thyra::PreconditionerBase< double > *prec, Teuchos::RCP< const Thyra::LinearOpSourceBase< double > > *fwdOp, Thyra::ESupportSolveUse *supportSolveUse) const
const std::vector< int > & getDecomposition() const
Get the decomposition vector in use by this factory.
STANDARD_COMPOSITION_MEMBERS(Thyra::EpetraOperatorViewExtractorBase, epetraFwdOpViewExtractor)
Set the strategy object used to extract an Epetra_Operator view of an input forward operator...
bool applyTransposeSupportsConj(Thyra::EConj conj) const
Teuchos::RCP< const Teuchos::ParameterList > getParameterList() const
Teuchos::RCP< Teuchos::ParameterList > getNonconstParameterList()
void initializePrec_Thyra(const Teuchos::RCP< const Thyra::LinearOpSourceBase< double > > &fwdOp, Thyra::PreconditionerBase< double > *prec, const Thyra::ESupportSolveUse supportSolveUse) const
bool isCompatible(const Thyra::LinearOpSourceBase< double > &fwdOp) const
Teuchos::RCP< Thyra::PreconditionerBase< double > > createPrec() const
Concrete preconditioner factory subclass based on ML.
void initializePrec_Epetra(const Teuchos::RCP< const Thyra::LinearOpSourceBase< double > > &fwdOp, Thyra::PreconditionerBase< double > *prec, const Thyra::ESupportSolveUse supportSolveUse) const
void setParameterList(Teuchos::RCP< Teuchos::ParameterList > const &paramList)
Teuchos::RCP< Teko::RequestHandler > getRequestHandler() const