Stratimikos Package Browser (Single Doxygen Collection)  Version of the Day
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 
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;
141  void setPreconditionerFactory(
142  const Teuchos::RCP<PreconditionerFactoryBase<Scalar> > &precFactory
143  ,const std::string &precFactoryName
144  );
146  Teuchos::RCP<PreconditionerFactoryBase<Scalar> > getPreconditionerFactory() const;
148  void unsetPreconditionerFactory(
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;
163  void initializeAndReuseOp(
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;
178  void initializePreconditionedOp(
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;
185  void initializeApproxPreconditionedOp(
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 
197  void setParameterList(Teuchos::RCP<Teuchos::ParameterList> const& paramList);
199  Teuchos::RCP<Teuchos::ParameterList> getNonconstParameterList();
201  Teuchos::RCP<Teuchos::ParameterList> unsetParameterList();
203  Teuchos::RCP<const Teuchos::ParameterList> getParameterList() const;
205  Teuchos::RCP<const Teuchos::ParameterList> getValidParameters() const;
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_;
232 
233  // /////////////////////////
234  // Private member functions
235 
236  static Teuchos::RCP<const Teuchos::ParameterList> generateAndGetValidParameters();
237 
238  void updateThisValidParamList();
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
std::istringstream & operator>>(std::istringstream &in, TwoDArray< T > &array)
LinearOpWithSolveFactoryBase subclass implemented in terms of Belos.
Teuchos::ScalarTraits< Scalar >::magnitudeType MagnitudeType
Teuchos::RCP< Teuchos::ParameterList > thisValidParamList_
Teuchos::RCP< PreconditionerFactoryBase< Scalar > > precFactory_
ValueTypeReductionOp< Ordinal, Packet > * createOp(const EReductionType reductType)