Stratimikos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_BelosLinearOpWithSolveFactory_decl.hpp
Go to the documentation of this file.
1 /*
2 // @HEADER
3 // ***********************************************************************
4 //
5 // Stratimikos: Thyra-based strategies for linear solvers
6 // Copyright (2006) Sandia Corporation
7 //
8 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
9 // license for use of this work by or on behalf of the U.S. Government.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
39 //
40 // ***********************************************************************
41 // @HEADER
42 */
43 
44 
45 #ifndef THYRA_BELOS_LINEAR_OP_WITH_SOLVE_FACTORY_DECL_HPP
46 #define THYRA_BELOS_LINEAR_OP_WITH_SOLVE_FACTORY_DECL_HPP
47 
48 #include "Thyra_LinearOpWithSolveFactoryBase.hpp"
51 
52 
53 namespace Teuchos { class ParameterList; }
54 
55 
56 namespace Thyra {
57 
58 
60 enum EBelosSolverType {
61  SOLVER_TYPE_BLOCK_GMRES,
62  SOLVER_TYPE_PSEUDO_BLOCK_GMRES,
63  SOLVER_TYPE_BLOCK_CG,
64  SOLVER_TYPE_PSEUDO_BLOCK_CG,
65  SOLVER_TYPE_PSEUDO_BLOCK_STOCHASTIC_CG,
66  SOLVER_TYPE_GCRODR,
67  SOLVER_TYPE_RCG,
68  SOLVER_TYPE_MINRES,
69  SOLVER_TYPE_TFQMR,
70  SOLVER_TYPE_BICGSTAB,
71  SOLVER_TYPE_FIXEDPOINT,
72  SOLVER_TYPE_TPETRA_GMRES,
73  SOLVER_TYPE_TPETRA_GMRES_PIPELINE,
74  SOLVER_TYPE_TPETRA_GMRES_SINGLE_REDUCE,
75  SOLVER_TYPE_TPETRA_GMRES_SSTEP
76 };
77 
78 
80 inline std::istream& operator>>(
81  std::istream& is, EBelosSolverType& sType)
82 {
83  int intval;
84  is >> intval;
85  sType = (EBelosSolverType)intval;
86  return is;
87 }
88 
89 
97 template<class Scalar>
98 class BelosLinearOpWithSolveFactory : public LinearOpWithSolveFactoryBase<Scalar> {
99 public:
100 
106 
108 
111 
113  static const std::string SolverType_name;
115  static const std::string SolverType_default;
117  static const std::string SolverTypes_name;
119  static const std::string BlockGMRES_name;
121  static const std::string PseudoBlockGMRES_name;
123  static const std::string BlockCG_name;
125  static const std::string PseudoBlockCG_name;
127  static const std::string PseudoBlockStochasticCG_name;
129  static const std::string GCRODR_name;
131  static const std::string RCG_name;
133  static const std::string MINRES_name;
135  static const std::string TFQMR_name;
137  static const std::string BiCGStab_name;
139  static const std::string FixedPoint_name;
141  static const std::string TpetraGmres_name;
143  static const std::string TpetraGmresPipeline_name;
145  static const std::string TpetraGmresSingleReduce_name;
147  static const std::string TpetraGmresSstep_name;
149  static const std::string ConvergenceTestFrequency_name;
150 
152 
155 
158 
161  const Teuchos::RCP<PreconditionerFactoryBase<Scalar> > &precFactory
162  );
163 
165 
169  bool acceptsPreconditionerFactory() const;
172  const Teuchos::RCP<PreconditionerFactoryBase<Scalar> > &precFactory
173  ,const std::string &precFactoryName
174  );
179  Teuchos::RCP<PreconditionerFactoryBase<Scalar> > *precFactory
180  ,std::string *precFactoryName
181  );
183  bool isCompatible( const LinearOpSourceBase<Scalar> &fwdOpSrc ) const;
187  void initializeOp(
188  const Teuchos::RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc
189  ,LinearOpWithSolveBase<Scalar> *Op
190  ,const ESupportSolveUse supportSolveUse
191  ) const;
194  const Teuchos::RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc
195  ,LinearOpWithSolveBase<Scalar> *Op
196  ) const;
198  void uninitializeOp(
199  LinearOpWithSolveBase<Scalar> *Op
200  ,Teuchos::RCP<const LinearOpSourceBase<Scalar> > *fwdOpSrc
201  ,Teuchos::RCP<const PreconditionerBase<Scalar> > *prec
202  ,Teuchos::RCP<const LinearOpSourceBase<Scalar> > *approxFwdOpSrc
203  ,ESupportSolveUse *supportSolveUse
204  ) const;
206  bool supportsPreconditionerInputType(const EPreconditionerInputType precOpType) const;
209  const Teuchos::RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc
210  ,const Teuchos::RCP<const PreconditionerBase<Scalar> > &prec
211  ,LinearOpWithSolveBase<Scalar> *Op
212  ,const ESupportSolveUse supportSolveUse
213  ) const;
216  const Teuchos::RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc
217  ,const Teuchos::RCP<const LinearOpSourceBase<Scalar> > &approxFwdOpSrc
218  ,LinearOpWithSolveBase<Scalar> *Op
219  ,const ESupportSolveUse supportSolveUse
220  ) const;
222 
225 
236 
238 
241 
243  std::string description() const;
244 
246 
247 private:
248 
249  // /////////////////////////
250  // Private types
251 
252 
253  // /////////////////////////
254  // Private data members
255 
257  std::string precFactoryName_;
260  EBelosSolverType solverType_;
262 
263  // /////////////////////////
264  // Private member functions
265 
267 
269 
270  void initializeOpImpl(
271  const Teuchos::RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc
272  ,const Teuchos::RCP<const LinearOpSourceBase<Scalar> > &approxFwdOpSrc
273  ,const Teuchos::RCP<const PreconditionerBase<Scalar> > &prec
274  ,const bool reusePrec
275  ,LinearOpWithSolveBase<Scalar> *Op
276  ,const ESupportSolveUse supportSolveUse
277  ) const;
278 
279 };
280 
282 
283 } // namespace Thyra
284 
285 #endif // THYRA_BELOS_LINEAR_OP_WITH_SOLVE_FACTORY_DECL_HPP
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
void uninitializeOp(LinearOpWithSolveBase< Scalar > *Op, Teuchos::RCP< const LinearOpSourceBase< Scalar > > *fwdOpSrc, Teuchos::RCP< const PreconditionerBase< Scalar > > *prec, Teuchos::RCP< const LinearOpSourceBase< Scalar > > *approxFwdOpSrc, ESupportSolveUse *supportSolveUse) const
void initializeAndReuseOp(const Teuchos::RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, LinearOpWithSolveBase< Scalar > *Op) const
static Teuchos::RCP< const Teuchos::ParameterList > generateAndGetValidParameters()
void unsetPreconditionerFactory(Teuchos::RCP< PreconditionerFactoryBase< Scalar > > *precFactory, std::string *precFactoryName)
void setParameterList(Teuchos::RCP< Teuchos::ParameterList > const &paramList)
bool isCompatible(const LinearOpSourceBase< Scalar > &fwdOpSrc) const
std::istringstream & operator>>(std::istringstream &in, TwoDArray< T > &array)
Teuchos::RCP< Teuchos::ParameterList > getNonconstParameterList()
void initializeOp(const Teuchos::RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, LinearOpWithSolveBase< Scalar > *Op, const ESupportSolveUse supportSolveUse) const
void setPreconditionerFactory(const Teuchos::RCP< PreconditionerFactoryBase< Scalar > > &precFactory, const std::string &precFactoryName)
LinearOpWithSolveFactoryBase subclass implemented in terms of Belos.
bool supportsPreconditionerInputType(const EPreconditionerInputType precOpType) const
Teuchos::ScalarTraits< Scalar >::magnitudeType MagnitudeType
Teuchos::RCP< const Teuchos::ParameterList > getParameterList() const
Teuchos::RCP< PreconditionerFactoryBase< Scalar > > getPreconditionerFactory() const
Teuchos::RCP< Teuchos::ParameterList > thisValidParamList_
void initializeApproxPreconditionedOp(const Teuchos::RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, const Teuchos::RCP< const LinearOpSourceBase< Scalar > > &approxFwdOpSrc, LinearOpWithSolveBase< Scalar > *Op, const ESupportSolveUse supportSolveUse) const
void initializePreconditionedOp(const Teuchos::RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, const Teuchos::RCP< const PreconditionerBase< Scalar > > &prec, LinearOpWithSolveBase< Scalar > *Op, const ESupportSolveUse supportSolveUse) const
Teuchos::RCP< LinearOpWithSolveBase< Scalar > > createOp() const
BelosLinearOpWithSolveFactory()
Construct without preconditioner factory.
Teuchos::RCP< PreconditionerFactoryBase< Scalar > > precFactory_
void initializeOpImpl(const Teuchos::RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, const Teuchos::RCP< const LinearOpSourceBase< Scalar > > &approxFwdOpSrc, const Teuchos::RCP< const PreconditionerBase< Scalar > > &prec, const bool reusePrec, LinearOpWithSolveBase< Scalar > *Op, const ESupportSolveUse supportSolveUse) const
Teuchos::RCP< Teuchos::ParameterList > unsetParameterList()