Stratimikos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Stratimikos_LinearSolverBuilder_decl.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Stratimikos: Thyra-based strategies for linear solvers
4 //
5 // Copyright 2006 NTESS and the Stratimikos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef STRATIMIKOS_LINEAR_SOLVER_BUILDING_BASE
11 #define STRATIMIKOS_LINEAR_SOLVER_BUILDING_BASE
12 
14 #include "Thyra_LinearSolverBuilderBase.hpp"
18 
19 // Include these to make all of the helpful decls appear
20 #ifdef HAVE_STRATIMIKOS_THYRAEPETRAADAPTERS
22 #include "Thyra_EpetraLinearOp.hpp"
23 #endif
24 #include "Thyra_LinearOpWithSolveFactoryHelpers.hpp"
25 #include "Thyra_LinearOpWithSolveBase.hpp"
26 #include "Thyra_PreconditionerFactoryHelpers.hpp"
27 #include "Thyra_DefaultScaledAdjointLinearOp.hpp"
28 #include "Thyra_DefaultPreconditioner.hpp"
29 #include "Thyra_MultiVectorStdOps.hpp"
30 #include "Thyra_VectorStdOps.hpp"
31 #include "Thyra_VectorBase.hpp"
32 
33 
34 namespace Teuchos { class CommandLineProcessor; }
35 
36 
37 namespace Stratimikos {
38 
39 
41 using Teuchos::RCP;
43 using Teuchos::Array;
48 
49 
66 /* (Old comments removed from Doxygen)
67  *
68  * The parameters this class accepts are shown below in different format:
69  * <ul>
70  * <li> \ref HumanReadableWithDocumentation "Human readable format (with documentation) for valid parameters accepted by this class"
71  * <li> \ref HumanReadableWithoutDocumentation "Human readable format (without documentation) for valid parameters accepted by this class"
72  * <li> \ref XmlFormat "XML format for valid parameters accepted by this class"
73  * </ul>
74  *
75  * <b>\anchor HumanReadableWithDocumentation Human readable format (with documentation) for valid parameters accepted by this class</b>
76  *
77  * <b>\anchor HumanReadableWithoutDocumentation Human readable format (without documentation) for valid parameters accepted by this class</b>
78  *
79  * \verbinclude simple_stratimikos_example.options.readable.out
80  *
81  * <b>\anchor XmlFormat XML format for valid parameters accepted by this class</b>
82  *
83  * \verbinclude simple_stratimikos_example.options.xml.out
84  *
85  */
86 template <class Scalar = double>
88  : public Thyra::LinearSolverBuilderBase<Scalar>
89 {
90 public:
91 
94 
103  const std::string &paramsXmlFileName = "",
104  const std::string &extraParamsXmlString = "",
105  const std::string &paramsUsedXmlOutFileName = "",
106  const std::string &paramsXmlFileNameOption = "linear-solver-params-file",
107  const std::string &extraParamsXmlStringOption = "extra-linear-solver-params",
108  const std::string &paramsUsedXmlOutFileNameOption = "linear-solver-params-used-file",
109  const bool &replaceDuplicateFactories = true
110  );
111 
114 
118  STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsXmlFileName);
119 
123  STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,extraParamsXmlString);
124 
128  STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsUsedXmlOutFileName);
129 
133  STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsXmlFileNameOption);
134 
138  STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,extraParamsXmlStringOption);
139 
143  STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsUsedXmlOutFileNameOption);
144 
148  STANDARD_MEMBER_COMPOSITION_MEMBERS(bool,replaceDuplicateFactories);
149 
152  const RCP<const AbstractFactory<Thyra::LinearOpWithSolveFactoryBase<Scalar> > >
153  &solveStrategyFactory,
154  const std::string &solveStrategyName,
155  const bool makeDefault = false
156  );
157 
160  const std::string &solveStrategyName);
161 
164  const RCP<const AbstractFactory<Thyra::PreconditionerFactoryBase<Scalar> > >
165  &precStrategyFactory,
166  const std::string &precStrategyName,
167  const bool makeDefault = false
168  );
169 
172  const std::string &precStrategyName);
173 
191 
210  void readParameters( std::ostream *out );
211 
227  void writeParamsFile(
228  const Thyra::LinearOpWithSolveFactoryBase<Scalar> &lowsFactory,
229  const std::string &outputXmlFileName = ""
230  ) const;
231 
235  std::string getLinearSolveStrategyName() const;
236 
240  std::string getPreconditionerStrategyName() const;
241 
243 
246 
248  void setParameterList(RCP<ParameterList> const& paramList);
257 
259 
262 
266  const std::string &linearSolveStrategyName
267  ) const;
271  const std::string &preconditioningStrategyName
272  ) const;
273 
275 
276 private:
277 
278  // //////////////////////////////////////
279  // Private types
280 
285 
286  // //////////////////////////////////////
287  // Private data members
288 
292  std::string defaultLOWSF_;
293  Array<std::string> validPfNames_; // Contains "None" as the 0th entry!
295  std::string defaultPF_;
300 
301  // //////////////////////////////////////
302  // Private member functions
303 
304  void initializeDefaults();
305  void justInTimeInitialize() const;
306 
307  int getAndAssertExistingFactoryNameIdx(const std::string &setFunctionName,
308  const Teuchos::ArrayView<std::string> namesArray, const std::string &name) const;
309 
310 };
311 
312 
313 namespace LinearSolverBuilderHelpers {
314 
315 
324  const Teuchos::ArrayView<std::string> namesArray, const std::string &name);
325 
326 
327 } // namespace LinearSolverBuilderHelpers
328 
329 
330 } // namespace Stratimikos
331 
332 
333 #endif // STRATIMIKOS_LINEAR_SOLVER_BUILDING_BASE
RCP< const ParameterList > getParameterList() const
STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string, paramsXmlFileName)
The name an XML file that will be read to get XML parameters (if not &quot;&quot;).
LinearSolverBuilder(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", const bool &replaceDuplicateFactories=true)
Construct with default parameters.
void setLinearSolveStrategyFactory(const RCP< const AbstractFactory< Thyra::LinearOpWithSolveFactoryBase< Scalar > > > &solveStrategyFactory, const std::string &solveStrategyName, const bool makeDefault=false)
Set a new linear solver strategy factory object.
void setDefaultLinearSolveStrategyFactoryName(const std::string &solveStrategyName)
Set the default linear solver factory name.
RCP< Thyra::PreconditionerFactoryBase< Scalar > > createPreconditioningStrategy(const std::string &preconditioningStrategyName) const
RCP< const Teuchos::StringToIntegralParameterEntryValidator< int > > lowsfValidator_
std::string getPreconditionerStrategyName() const
Get the name of the preconditioner strategy that will be created on the next call to this-&gt;createPrec...
RCP< const Teuchos::StringToIntegralParameterEntryValidator< int > > pfValidator_
void readParameters(std::ostream *out)
Force the parameters to be read from a file and/or an extra XML string.
void setPreconditioningStrategyFactory(const RCP< const AbstractFactory< Thyra::PreconditionerFactoryBase< Scalar > > > &precStrategyFactory, const std::string &precStrategyName, const bool makeDefault=false)
Set a new preconditioner strategy factory object.
void setParameterList(RCP< ParameterList > const &paramList)
std::string getLinearSolveStrategyName() const
Get the name of the linear solver strategy that will be created on the next call to this-&gt;createLinea...
RCP< Thyra::LinearOpWithSolveFactoryBase< Scalar > > createLinearSolveStrategy(const std::string &linearSolveStrategyName) const
int getAndAssertExistingFactoryNameIdx(const std::string &setFunctionName, const Teuchos::ArrayView< std::string > namesArray, const std::string &name) const
Concrete subclass of Thyra::LinearSolverBuilderBase for creating Thyra::LinearOpWithSolveFactoryBase ...
RCP< const AbstractFactory< Thyra::LinearOpWithSolveFactoryBase< Scalar > > > lowsf_fcty_t
void setDefaultPreconditioningStrategyFactoryName(const std::string &precStrategyName)
Set the default linear solver factory name.
RCP< const AbstractFactory< Thyra::PreconditionerFactoryBase< Scalar > > > pf_fcty_t
int existingNameIndex(const Teuchos::ArrayView< std::string > namesArray, const std::string &name)
Return the index of a name in an array of names.
void writeParamsFile(const Thyra::LinearOpWithSolveFactoryBase< Scalar > &lowsFactory, const std::string &outputXmlFileName="") const
Write the parameters list for a LinearOpWithSolveFactoryBase object to a file after the parameters ar...
void setupCLP(Teuchos::CommandLineProcessor *clp)
Setup the command-line processor to read in the needed data to extra the parameters from...
RCP< const ParameterList > getValidParameters() const