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"
47 #include "Teuchos_AbstractFactory.hpp"
48 #include "Teuchos_StandardMemberCompositionMacros.hpp"
49 #include "Teuchos_StandardParameterEntryValidators.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;
75 using Teuchos::AbstractFactory;
77 using Teuchos::ParameterList;
78 
79 
96 /* (Old comments removed from Doxygen)
97  *
98  * The parameters this class accepts are shown below in different format:
99  * <ul>
100  * <li> \ref HumanReadableWithDocumentation "Human readable format (with documentation) for valid parameters accepted by this class"
101  * <li> \ref HumanReadableWithoutDocumentation "Human readable format (without documentation) for valid parameters accepted by this class"
102  * <li> \ref XmlFormat "XML format for valid parameters accepted by this class"
103  * </ul>
104  *
105  * <b>\anchor HumanReadableWithDocumentation Human readable format (with documentation) for valid parameters accepted by this class</b>
106  *
107  * <b>\anchor HumanReadableWithoutDocumentation Human readable format (without documentation) for valid parameters accepted by this class</b>
108  *
109  * \verbinclude simple_stratimikos_example.options.readable.out
110  *
111  * <b>\anchor XmlFormat XML format for valid parameters accepted by this class</b>
112  *
113  * \verbinclude simple_stratimikos_example.options.xml.out
114  *
115  */
117  : public Thyra::LinearSolverBuilderBase<double>
118 {
119 public:
120 
123 
132  const std::string &paramsXmlFileName = ""
133  ,const std::string &extraParamsXmlString = ""
134  ,const std::string &paramsUsedXmlOutFileName = ""
135  ,const std::string &paramsXmlFileNameOption = "linear-solver-params-file"
136  ,const std::string &extraParamsXmlStringOption = "extra-linear-solver-params"
137  ,const std::string &paramsUsedXmlOutFileNameOption = "linear-solver-params-used-file"
138  );
139 
142 
146  STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsXmlFileName);
147 
151  STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,extraParamsXmlString);
152 
156  STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsUsedXmlOutFileName);
157 
161  STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsXmlFileNameOption);
162 
166  STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,extraParamsXmlStringOption);
167 
171  STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsUsedXmlOutFileNameOption);
172 
175  const RCP<const AbstractFactory<Thyra::LinearOpWithSolveFactoryBase<double> > >
176  &solveStrategyFactory,
177  const std::string &solveStrategyName,
178  const bool makeDefault = false
179  );
180 
183  const std::string &solveStrategyName);
184 
187  const RCP<const AbstractFactory<Thyra::PreconditionerFactoryBase<double> > >
188  &precStrategyFactory,
189  const std::string &precStrategyName,
190  const bool makeDefault = false
191  );
192 
195  const std::string &precStrategyName);
196 
213  void setupCLP( Teuchos::CommandLineProcessor *clp );
214 
233  void readParameters( std::ostream *out );
234 
250  void writeParamsFile(
251  const Thyra::LinearOpWithSolveFactoryBase<double> &lowsFactory,
252  const std::string &outputXmlFileName = ""
253  ) const;
254 
258  std::string getLinearSolveStrategyName() const;
259 
263  std::string getPreconditionerStrategyName() const;
264 
266 
269 
271  void setParameterList(RCP<ParameterList> const& paramList);
273  RCP<ParameterList> getNonconstParameterList();
275  RCP<ParameterList> unsetParameterList();
277  RCP<const ParameterList> getParameterList() const;
279  RCP<const ParameterList> getValidParameters() const;
280 
282 
285 
287  RCP<Thyra::LinearOpWithSolveFactoryBase<double> >
289  const std::string &linearSolveStrategyName
290  ) const;
292  RCP<Thyra::PreconditionerFactoryBase<double> >
294  const std::string &preconditioningStrategyName
295  ) const;
296 
298 
299 private:
300 
301  // //////////////////////////////////////
302  // Private types
303 
304  typedef RCP<const AbstractFactory<Thyra::LinearOpWithSolveFactoryBase<double> > >
306  typedef RCP<const AbstractFactory<Thyra::PreconditionerFactoryBase<double> > >
308 
309  // //////////////////////////////////////
310  // Private data members
311 
312  RCP<ParameterList> paramList_;
313  Array<std::string> validLowsfNames_;
314  Array<lowsf_fcty_t> lowsfArray_;
315  std::string defaultLOWSF_;
316  Array<std::string> validPfNames_; // Contains "None" as the 0th entry!
317  Array<pf_fcty_t> pfArray_;
318  std::string defaultPF_;
320  mutable RCP<const ParameterList> validParamList_;
321  mutable RCP<const Teuchos::StringToIntegralParameterEntryValidator<int> > lowsfValidator_;
322  mutable RCP<const Teuchos::StringToIntegralParameterEntryValidator<int> > pfValidator_;
323 
324  // //////////////////////////////////////
325  // Private member functions
326 
327  void initializeDefaults();
328  void justInTimeInitialize() const;
329 
330 };
331 
332 
333 } // namespace Stratimikos
334 
335 
336 #endif // STRATIMIKOS_DEFAULT_LINEAR_SOLVER_BUILDING_BASE
RCP< Thyra::PreconditionerFactoryBase< double > > createPreconditioningStrategy(const std::string &preconditioningStrategyName) const
RCP< const AbstractFactory< Thyra::LinearOpWithSolveFactoryBase< double > > > lowsf_fcty_t
void setPreconditioningStrategyFactory(const RCP< const AbstractFactory< Thyra::PreconditionerFactoryBase< double > > > &precStrategyFactory, const std::string &precStrategyName, const bool makeDefault=false)
Set a new preconditioner strategy factory object.
STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string, paramsXmlFileName)
The name an XML file that will be read to get XML parameters (if not "").
void setupCLP(Teuchos::CommandLineProcessor *clp)
Setup the command-line processor to read in the needed data to extra the parameters from...
void setDefaultLinearSolveStrategyFactoryName(const std::string &solveStrategyName)
Set the default linear solver factory name.
RCP< const AbstractFactory< Thyra::PreconditionerFactoryBase< double > > > pf_fcty_t
RCP< Thyra::LinearOpWithSolveFactoryBase< double > > createLinearSolveStrategy(const std::string &linearSolveStrategyName) const
void setParameterList(RCP< ParameterList > const &paramList)
void readParameters(std::ostream *out)
Force the parameters to be read from a file and/or an extra XML string.
std::string getPreconditionerStrategyName() const
Get the name of the preconditioner strategy that will be created on the next call to this->createPrec...
Concrete subclass of Thyra::LinearSolverBuilderBase for creating LinearOpWithSolveFactoryBase objects...
RCP< const Teuchos::StringToIntegralParameterEntryValidator< int > > lowsfValidator_
RCP< const Teuchos::StringToIntegralParameterEntryValidator< int > > pfValidator_
void writeParamsFile(const Thyra::LinearOpWithSolveFactoryBase< double > &lowsFactory, const std::string &outputXmlFileName="") const
Write the parameters list for a LinearOpWithSolveFactoryBase object to a file after the parameters ar...
DefaultLinearSolverBuilder(const std::string &paramsXmlFileName="", const std::string &extraParamsXmlString="", const std::string &paramsUsedXmlOutFileName="", const std::string &paramsXmlFileNameOption="linear-solver-params-file", const std::string &extraParamsXmlStringOption="extra-linear-solver-params", const std::string &paramsUsedXmlOutFileNameOption="linear-solver-params-used-file")
Construct with default parameters.
void setLinearSolveStrategyFactory(const RCP< const AbstractFactory< Thyra::LinearOpWithSolveFactoryBase< double > > > &solveStrategyFactory, const std::string &solveStrategyName, const bool makeDefault=false)
Set a new linear solver strategy factory object.
std::string getLinearSolveStrategyName() const
Get the name of the linear solver strategy that will be created on the next call to this->createLinea...
void setDefaultPreconditioningStrategyFactoryName(const std::string &precStrategyName)
Set the default linear solver factory name.