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_GCRODR,
62  SOLVER_TYPE_RCG,
63  SOLVER_TYPE_MINRES
64  };
65 
66  inline std::istream& operator>>(
67  std::istream& is, EBelosSolverType& sType)
68  {
69  int intval;
70  is >> intval;
71  sType = (EBelosSolverType)intval;
72  return is;
73  }
74 
75 
83 template<class Scalar>
84 class BelosLinearOpWithSolveFactory : public LinearOpWithSolveFactoryBase<Scalar> {
85 public:
86 
92 
94 
97 
99  static const std::string SolverType_name;
101  static const std::string SolverType_default;
103  static const std::string SolverTypes_name;
105  static const std::string BlockGMRES_name;
107  static const std::string PseudoBlockGMRES_name;
109  static const std::string BlockCG_name;
111  static const std::string PseudoBlockCG_name;
113  static const std::string GCRODR_name;
115  static const std::string RCG_name;
117  static const std::string MINRES_name;
119  static const std::string ConvergenceTestFrequency_name;
120 
122 
125 
128 
131  const Teuchos::RCP<PreconditionerFactoryBase<Scalar> > &precFactory
132  );
133 
135 
139  bool acceptsPreconditionerFactory() const;
142  const Teuchos::RCP<PreconditionerFactoryBase<Scalar> > &precFactory
143  ,const std::string &precFactoryName
144  );
149  Teuchos::RCP<PreconditionerFactoryBase<Scalar> > *precFactory
150  ,std::string *precFactoryName
151  );
153  bool isCompatible( const LinearOpSourceBase<Scalar> &fwdOpSrc ) const;
157  void initializeOp(
158  const Teuchos::RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc
159  ,LinearOpWithSolveBase<Scalar> *Op
160  ,const ESupportSolveUse supportSolveUse
161  ) const;
164  const Teuchos::RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc
165  ,LinearOpWithSolveBase<Scalar> *Op
166  ) const;
168  void uninitializeOp(
169  LinearOpWithSolveBase<Scalar> *Op
170  ,Teuchos::RCP<const LinearOpSourceBase<Scalar> > *fwdOpSrc
171  ,Teuchos::RCP<const PreconditionerBase<Scalar> > *prec
172  ,Teuchos::RCP<const LinearOpSourceBase<Scalar> > *approxFwdOpSrc
173  ,ESupportSolveUse *supportSolveUse
174  ) const;
176  bool supportsPreconditionerInputType(const EPreconditionerInputType precOpType) const;
179  const Teuchos::RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc
180  ,const Teuchos::RCP<const PreconditionerBase<Scalar> > &prec
181  ,LinearOpWithSolveBase<Scalar> *Op
182  ,const ESupportSolveUse supportSolveUse
183  ) const;
186  const Teuchos::RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc
187  ,const Teuchos::RCP<const LinearOpSourceBase<Scalar> > &approxFwdOpSrc
188  ,LinearOpWithSolveBase<Scalar> *Op
189  ,const ESupportSolveUse supportSolveUse
190  ) const;
192 
195 
206 
208 
211 
213  std::string description() const;
214 
216 
217 private:
218 
219  // /////////////////////////
220  // Private types
221 
222 
223  // /////////////////////////
224  // Private data members
225 
227  std::string precFactoryName_;
230  EBelosSolverType solverType_;
232 
233  // /////////////////////////
234  // Private member functions
235 
237 
239 
240  void initializeOpImpl(
241  const Teuchos::RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc
242  ,const Teuchos::RCP<const LinearOpSourceBase<Scalar> > &approxFwdOpSrc
243  ,const Teuchos::RCP<const PreconditionerBase<Scalar> > &prec
244  ,const bool reusePrec
245  ,LinearOpWithSolveBase<Scalar> *Op
246  ,const ESupportSolveUse supportSolveUse
247  ) const;
248 
249 };
250 
252 
253 } // namespace Thyra
254 
255 #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()