Stratimikos Package Browser (Single Doxygen Collection)  Version of the Day
Stratimikos_DefaultLinearSolverBuilder.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Stratimikos: Thyra-based strategies for linear solvers
5 // Copyright (2006) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 #ifndef STRATIMIKOS_DEFAULT_LINEAR_SOLVER_BUILDING_BASE
43 #define STRATIMIKOS_DEFAULT_LINEAR_SOLVER_BUILDING_BASE
44 
46 #include "Thyra_LinearSolverBuilderBase.hpp"
50 
51 // Include these to make all of the helpful decls appear
52 #include "Thyra_EpetraThyraWrappers.hpp"
53 #include "Thyra_EpetraLinearOp.hpp"
54 #include "Thyra_LinearOpWithSolveFactoryHelpers.hpp"
55 #include "Thyra_LinearOpWithSolveBase.hpp"
56 #include "Thyra_PreconditionerFactoryHelpers.hpp"
57 #include "Thyra_DefaultScaledAdjointLinearOp.hpp"
58 #include "Thyra_DefaultPreconditioner.hpp"
59 #include "Thyra_MultiVectorStdOps.hpp"
60 #include "Thyra_VectorStdOps.hpp"
61 #include "Thyra_VectorBase.hpp"
62 
63 
64 namespace Teuchos { class CommandLineProcessor; }
65 
66 
67 namespace Stratimikos {
68 
69 
71 using Teuchos::RCP;
73 using Teuchos::Array;
78 
79 
109  : public Thyra::LinearSolverBuilderBase<double>
110 {
111 public:
112 
115 
124  const std::string &paramsXmlFileName = ""
125  ,const std::string &extraParamsXmlString = ""
126  ,const std::string &paramsUsedXmlOutFileName = ""
127  ,const std::string &paramsXmlFileNameOption = "linear-solver-params-file"
128  ,const std::string &extraParamsXmlStringOption = "extra-linear-solver-params"
129  ,const std::string &paramsUsedXmlOutFileNameOption = "linear-solver-params-used-file"
130  );
131 
134 
138  STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsXmlFileName);
139 
143  STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,extraParamsXmlString);
144 
148  STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsUsedXmlOutFileName);
149 
153  STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsXmlFileNameOption);
154 
158  STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,extraParamsXmlStringOption);
159 
163  STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsUsedXmlOutFileNameOption);
164 
166  void setLinearSolveStrategyFactory(
167  const RCP<const AbstractFactory<Thyra::LinearOpWithSolveFactoryBase<double> > >
168  &solveStrategyFactory,
169  const std::string &solveStrategyName,
170  const bool makeDefault = false
171  );
172 
174  void setDefaultLinearSolveStrategyFactoryName(
175  const std::string &solveStrategyName);
176 
178  void setPreconditioningStrategyFactory(
179  const RCP<const AbstractFactory<Thyra::PreconditionerFactoryBase<double> > >
180  &precStrategyFactory,
181  const std::string &precStrategyName,
182  const bool makeDefault = false
183  );
184 
186  void setDefaultPreconditioningStrategyFactoryName(
187  const std::string &precStrategyName);
188 
205  void setupCLP( Teuchos::CommandLineProcessor *clp );
206 
225  void readParameters( std::ostream *out );
226 
242  void writeParamsFile(
243  const Thyra::LinearOpWithSolveFactoryBase<double> &lowsFactory,
244  const std::string &outputXmlFileName = ""
245  ) const;
246 
250  std::string getLinearSolveStrategyName() const;
251 
255  std::string getPreconditionerStrategyName() const;
256 
258 
261 
263  void setParameterList(RCP<ParameterList> const& paramList);
265  RCP<ParameterList> getNonconstParameterList();
267  RCP<ParameterList> unsetParameterList();
269  RCP<const ParameterList> getParameterList() const;
271  RCP<const ParameterList> getValidParameters() const;
272 
274 
277 
280  createLinearSolveStrategy(
281  const std::string &linearSolveStrategyName
282  ) const;
285  createPreconditioningStrategy(
286  const std::string &preconditioningStrategyName
287  ) const;
288 
290 
291 private:
292 
293  // //////////////////////////////////////
294  // Private types
295 
300 
301  // //////////////////////////////////////
302  // Private data members
303 
307  std::string defaultLOWSF_;
308  Array<std::string> validPfNames_; // Contains "None" as the 0th entry!
310  std::string defaultPF_;
315 
316  // //////////////////////////////////////
317  // Private member functions
318 
319  void initializeDefaults();
320  void justInTimeInitialize() const;
321 
322 };
323 
324 
325 } // namespace Stratimikos
326 
327 
328 #endif // STRATIMIKOS_DEFAULT_LINEAR_SOLVER_BUILDING_BASE
RCP< const AbstractFactory< Thyra::LinearOpWithSolveFactoryBase< double > > > lowsf_fcty_t
RCP< const AbstractFactory< Thyra::PreconditionerFactoryBase< double > > > pf_fcty_t
Concrete subclass of Thyra::LinearSolverBuilderBase for creating LinearOpWithSolveFactoryBase objects...
RCP< const Teuchos::StringToIntegralParameterEntryValidator< int > > lowsfValidator_
#define STANDARD_MEMBER_COMPOSITION_MEMBERS(TYPE, NAME)
RCP< const Teuchos::StringToIntegralParameterEntryValidator< int > > pfValidator_