Teko  Version of the Day
 All Classes Files Functions Variables Pages
Teko_StratimikosFactory.hpp
1 // @HEADER
2 // *****************************************************************************
3 // Teko: A package for block and physics based preconditioning
4 //
5 // Copyright 2010 NTESS and the Teko contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef __Teko_StratimikosFactory_hpp__
11 #define __Teko_StratimikosFactory_hpp__
12 
13 #include <vector>
14 
15 #include "Thyra_PreconditionerFactoryBase.hpp"
16 #include "Teuchos_StandardCompositionMacros.hpp"
17 
18 #include "Teko_RequestHandler.hpp"
19 #include "Teko_InverseLibrary.hpp"
20 #include "Teko_InverseFactory.hpp"
21 
22 #ifdef TEKO_HAVE_EPETRA
23 #include "Thyra_EpetraOperatorViewExtractorBase.hpp"
24 #include "Epetra_Operator.h"
25 #endif
26 
27 namespace Teko {
28 
33 class StratimikosFactory : public Thyra::PreconditionerFactoryBase<double> {
34  public:
37 
40 
41  StratimikosFactory(const Teuchos::RCP<Teko::RequestHandler> &rh);
42  StratimikosFactory(const Teuchos::RCP<Stratimikos::DefaultLinearSolverBuilder> &builder,
43  const Teuchos::RCP<Teko::RequestHandler> &rh);
44 
45 #ifdef TEKO_HAVE_EPETRA
46 
54  STANDARD_COMPOSITION_MEMBERS(Thyra::EpetraOperatorViewExtractorBase, epetraFwdOpViewExtractor);
55 #endif
56 
58 
61 
63  bool isCompatible(const Thyra::LinearOpSourceBase<double> &fwdOp) const;
65  bool applySupportsConj(Thyra::EConj conj) const;
67  bool applyTransposeSupportsConj(Thyra::EConj conj) const;
69  Teuchos::RCP<Thyra::PreconditionerBase<double> > createPrec() const;
71  void initializePrec(const Teuchos::RCP<const Thyra::LinearOpSourceBase<double> > &fwdOp,
72  Thyra::PreconditionerBase<double> *prec,
73  const Thyra::ESupportSolveUse supportSolveUse) const;
75  void uninitializePrec(Thyra::PreconditionerBase<double> *prec,
76  Teuchos::RCP<const Thyra::LinearOpSourceBase<double> > *fwdOp,
77  Thyra::ESupportSolveUse *supportSolveUse) const;
78 
80 
83 
85  void setParameterList(Teuchos::RCP<Teuchos::ParameterList> const &paramList);
87  Teuchos::RCP<Teuchos::ParameterList> getNonconstParameterList();
89  Teuchos::RCP<Teuchos::ParameterList> unsetParameterList();
91  Teuchos::RCP<const Teuchos::ParameterList> getParameterList() const;
93  Teuchos::RCP<const Teuchos::ParameterList> getValidParameters() const;
95 
98 
100  std::string description() const;
101 
102  // ToDo: Add an override of describe(...) to give more detail!
103 
105 
108  void initializePrec_Thyra(const Teuchos::RCP<const Thyra::LinearOpSourceBase<double> > &fwdOp,
109  Thyra::PreconditionerBase<double> *prec,
110  const Thyra::ESupportSolveUse supportSolveUse) const;
111 
112 #ifdef TEKO_HAVE_EPETRA
113 
115  void initializePrec_Epetra(const Teuchos::RCP<const Thyra::LinearOpSourceBase<double> > &fwdOp,
116  Thyra::PreconditionerBase<double> *prec,
117  const Thyra::ESupportSolveUse supportSolveUse) const;
118 #endif
119 
122  void setRequestHandler(const Teuchos::RCP<Teko::RequestHandler> &rh) { reqHandler_ = rh; }
123 
126  Teuchos::RCP<Teko::RequestHandler> getRequestHandler() const { return reqHandler_; }
127 
129  const std::vector<int> &getDecomposition() const { return decomp_; }
130 
131  private:
132 #ifdef TEKO_HAVE_EPETRA
133 
145  Teuchos::RCP<Epetra_Operator> buildWrappedEpetraOperator(
146  const Teuchos::RCP<const Epetra_Operator> &Jac,
147  const Teuchos::RCP<Epetra_Operator> &wrapInput, std::ostream &out) const;
148 
157  void buildStridedVectors(const Epetra_Operator &Jac, const std::vector<int> &decomp,
158  std::vector<std::vector<int> > &vars) const;
159 #endif // TEKO_HAVE_EPETRA
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>
168  builder_; // builder to use for default solvers
169 };
170 
178 void addTekoToStratimikosBuilder(Stratimikos::DefaultLinearSolverBuilder &builder,
179  const std::string &stratName = "Teko");
180 
188 void addTekoToStratimikosBuilder(Stratimikos::DefaultLinearSolverBuilder &builder,
189  const Teuchos::RCP<Teko::RequestHandler> &rh,
190  const std::string &stratName = "Teko");
191 
192 } // namespace Teko
193 
194 #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.
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 setParameterList(Teuchos::RCP< Teuchos::ParameterList > const &paramList)
Teuchos::RCP< Teko::RequestHandler > getRequestHandler() const