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 namespace Teuchos { class ParameterList; }
53 
54 namespace Thyra {
55 
56  enum EBelosSolverType {
57  SOLVER_TYPE_BLOCK_GMRES,
58  SOLVER_TYPE_PSEUDO_BLOCK_GMRES,
59  SOLVER_TYPE_BLOCK_CG,
60  SOLVER_TYPE_PSEUDO_BLOCK_CG,
61  SOLVER_TYPE_PSEUDO_BLOCK_STOCHASTIC_CG,
62  SOLVER_TYPE_GCRODR,
63  SOLVER_TYPE_RCG,
64  SOLVER_TYPE_MINRES,
65  SOLVER_TYPE_TFQMR
66  };
67 
68  inline std::istream& operator>>(
69  std::istream& is, EBelosSolverType& sType)
70  {
71  int intval;
72  is >> intval;
73  sType = (EBelosSolverType)intval;
74  return is;
75  }
76 
77 
85 template<class Scalar>
86 class BelosLinearOpWithSolveFactory : public LinearOpWithSolveFactoryBase<Scalar> {
87 public:
88 
94 
96 
99 
101  static const std::string SolverType_name;
103  static const std::string SolverType_default;
105  static const std::string SolverTypes_name;
107  static const std::string BlockGMRES_name;
109  static const std::string PseudoBlockGMRES_name;
111  static const std::string BlockCG_name;
113  static const std::string PseudoBlockCG_name;
115  static const std::string PseudoBlockStochasticCG_name;
117  static const std::string GCRODR_name;
119  static const std::string RCG_name;
121  static const std::string MINRES_name;
123  static const std::string TFQMR_name;
125  static const std::string ConvergenceTestFrequency_name;
126 
128 
131 
134 
137  const Teuchos::RCP<PreconditionerFactoryBase<Scalar> > &precFactory
138  );
139 
141 
145  bool acceptsPreconditionerFactory() const;
148  const Teuchos::RCP<PreconditionerFactoryBase<Scalar> > &precFactory
149  ,const std::string &precFactoryName
150  );
155  Teuchos::RCP<PreconditionerFactoryBase<Scalar> > *precFactory
156  ,std::string *precFactoryName
157  );
159  bool isCompatible( const LinearOpSourceBase<Scalar> &fwdOpSrc ) const;
163  void initializeOp(
164  const Teuchos::RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc
165  ,LinearOpWithSolveBase<Scalar> *Op
166  ,const ESupportSolveUse supportSolveUse
167  ) const;
170  const Teuchos::RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc
171  ,LinearOpWithSolveBase<Scalar> *Op
172  ) const;
174  void uninitializeOp(
175  LinearOpWithSolveBase<Scalar> *Op
176  ,Teuchos::RCP<const LinearOpSourceBase<Scalar> > *fwdOpSrc
177  ,Teuchos::RCP<const PreconditionerBase<Scalar> > *prec
178  ,Teuchos::RCP<const LinearOpSourceBase<Scalar> > *approxFwdOpSrc
179  ,ESupportSolveUse *supportSolveUse
180  ) const;
182  bool supportsPreconditionerInputType(const EPreconditionerInputType precOpType) const;
185  const Teuchos::RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc
186  ,const Teuchos::RCP<const PreconditionerBase<Scalar> > &prec
187  ,LinearOpWithSolveBase<Scalar> *Op
188  ,const ESupportSolveUse supportSolveUse
189  ) const;
192  const Teuchos::RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc
193  ,const Teuchos::RCP<const LinearOpSourceBase<Scalar> > &approxFwdOpSrc
194  ,LinearOpWithSolveBase<Scalar> *Op
195  ,const ESupportSolveUse supportSolveUse
196  ) const;
198 
201 
212 
214 
217 
219  std::string description() const;
220 
222 
223 private:
224 
225  // /////////////////////////
226  // Private types
227 
228 
229  // /////////////////////////
230  // Private data members
231 
233  std::string precFactoryName_;
236  EBelosSolverType solverType_;
238 
239  // /////////////////////////
240  // Private member functions
241 
243 
245 
246  void initializeOpImpl(
247  const Teuchos::RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc
248  ,const Teuchos::RCP<const LinearOpSourceBase<Scalar> > &approxFwdOpSrc
249  ,const Teuchos::RCP<const PreconditionerBase<Scalar> > &prec
250  ,const bool reusePrec
251  ,LinearOpWithSolveBase<Scalar> *Op
252  ,const ESupportSolveUse supportSolveUse
253  ) const;
254 
255 };
256 
258 
259 } // namespace Thyra
260 
261 #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()