Stratimikos Version of the Day
Loading...
Searching...
No Matches
Stratimikos_LinearSolverBuilder_decl.hpp
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
13#include "Stratimikos_ConfigDefs.hpp"
14#include "Thyra_LinearSolverBuilderBase.hpp"
15#include "Teuchos_AbstractFactory.hpp"
16#include "Teuchos_StandardMemberCompositionMacros.hpp"
17#include "Teuchos_StandardParameterEntryValidators.hpp"
18
19// Include these to make all of the helpful decls appear
20#include "Thyra_LinearOpWithSolveFactoryHelpers.hpp"
21#include "Thyra_LinearOpWithSolveBase.hpp"
22#include "Thyra_PreconditionerFactoryHelpers.hpp"
23#include "Thyra_DefaultScaledAdjointLinearOp.hpp"
24#include "Thyra_DefaultPreconditioner.hpp"
25#include "Thyra_MultiVectorStdOps.hpp"
26#include "Thyra_VectorStdOps.hpp"
27#include "Thyra_VectorBase.hpp"
28
29
30namespace Teuchos { class CommandLineProcessor; }
31
32
33namespace Stratimikos {
34
35
37using Teuchos::RCP;
39using Teuchos::Array;
41using Teuchos::AbstractFactory;
43using Teuchos::ParameterList;
44
45
62/* (Old comments removed from Doxygen)
63 *
64 * The parameters this class accepts are shown below in different format:
65 * <ul>
66 * <li> \ref HumanReadableWithDocumentation "Human readable format (with documentation) for valid parameters accepted by this class"
67 * <li> \ref HumanReadableWithoutDocumentation "Human readable format (without documentation) for valid parameters accepted by this class"
68 * <li> \ref XmlFormat "XML format for valid parameters accepted by this class"
69 * </ul>
70 *
71 * <b>\anchor HumanReadableWithDocumentation Human readable format (with documentation) for valid parameters accepted by this class</b>
72 *
73 * <b>\anchor HumanReadableWithoutDocumentation Human readable format (without documentation) for valid parameters accepted by this class</b>
74 *
75 * \verbinclude simple_stratimikos_example.options.readable.out
76 *
77 * <b>\anchor XmlFormat XML format for valid parameters accepted by this class</b>
78 *
79 * \verbinclude simple_stratimikos_example.options.xml.out
80 *
81 */
82template <class Scalar = double>
84 : public Thyra::LinearSolverBuilderBase<Scalar>
85{
86public:
87
90
99 const std::string &paramsXmlFileName = "",
100 const std::string &extraParamsXmlString = "",
101 const std::string &paramsUsedXmlOutFileName = "",
102 const std::string &paramsXmlFileNameOption = "linear-solver-params-file",
103 const std::string &extraParamsXmlStringOption = "extra-linear-solver-params",
104 const std::string &paramsUsedXmlOutFileNameOption = "linear-solver-params-used-file",
105 const bool &replaceDuplicateFactories = true
106 );
107
110
114 STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsXmlFileName);
115
119 STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,extraParamsXmlString);
120
124 STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsUsedXmlOutFileName);
125
129 STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsXmlFileNameOption);
130
134 STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,extraParamsXmlStringOption);
135
139 STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsUsedXmlOutFileNameOption);
140
144 STANDARD_MEMBER_COMPOSITION_MEMBERS(bool,replaceDuplicateFactories);
145
148 const RCP<const AbstractFactory<Thyra::LinearOpWithSolveFactoryBase<Scalar> > >
149 &solveStrategyFactory,
150 const std::string &solveStrategyName,
151 const bool makeDefault = false
152 );
153
156 const std::string &solveStrategyName);
157
160 const RCP<const AbstractFactory<Thyra::PreconditionerFactoryBase<Scalar> > >
161 &precStrategyFactory,
162 const std::string &precStrategyName,
163 const bool makeDefault = false
164 );
165
168 const std::string &precStrategyName);
169
186 void setupCLP( Teuchos::CommandLineProcessor *clp );
187
206 void readParameters( std::ostream *out );
207
223 void writeParamsFile(
224 const Thyra::LinearOpWithSolveFactoryBase<Scalar> &lowsFactory,
225 const std::string &outputXmlFileName = ""
226 ) const;
227
231 std::string getLinearSolveStrategyName() const;
232
236 std::string getPreconditionerStrategyName() const;
237
239
242
244 void setParameterList(RCP<ParameterList> const& paramList);
246 RCP<ParameterList> getNonconstParameterList();
248 RCP<ParameterList> unsetParameterList();
250 RCP<const ParameterList> getParameterList() const;
252 RCP<const ParameterList> getValidParameters() const;
253
255
258
260 RCP<Thyra::LinearOpWithSolveFactoryBase<Scalar> >
262 const std::string &linearSolveStrategyName
263 ) const;
265 RCP<Thyra::PreconditionerFactoryBase<Scalar> >
267 const std::string &preconditioningStrategyName
268 ) const;
269
271
272private:
273
274 // //////////////////////////////////////
275 // Private types
276
277 typedef RCP<const AbstractFactory<Thyra::LinearOpWithSolveFactoryBase<Scalar> > >
278 lowsf_fcty_t;
279 typedef RCP<const AbstractFactory<Thyra::PreconditionerFactoryBase<Scalar> > >
280 pf_fcty_t;
281
282 // //////////////////////////////////////
283 // Private data members
284
285 RCP<ParameterList> paramList_;
286 Array<std::string> validLowsfNames_;
287 Array<lowsf_fcty_t> lowsfArray_;
288 std::string defaultLOWSF_;
289 Array<std::string> validPfNames_; // Contains "None" as the 0th entry!
290 Array<pf_fcty_t> pfArray_;
291 std::string defaultPF_;
292 bool enableDelayedSolverConstruction_;
293 mutable RCP<const ParameterList> validParamList_;
294 mutable RCP<const Teuchos::StringToIntegralParameterEntryValidator<int> > lowsfValidator_;
295 mutable RCP<const Teuchos::StringToIntegralParameterEntryValidator<int> > pfValidator_;
296
297 // //////////////////////////////////////
298 // Private member functions
299
300 void initializeDefaults();
301 void justInTimeInitialize() const;
302
303 int getAndAssertExistingFactoryNameIdx(const std::string &setFunctionName,
304 const Teuchos::ArrayView<std::string> namesArray, const std::string &name) const;
305
306};
307
308
309namespace LinearSolverBuilderHelpers {
310
311
319int existingNameIndex(
320 const Teuchos::ArrayView<std::string> namesArray, const std::string &name);
321
322
323} // namespace LinearSolverBuilderHelpers
324
325
326} // namespace Stratimikos
327
328
329#endif // STRATIMIKOS_LINEAR_SOLVER_BUILDING_BASE
Concrete subclass of Thyra::LinearSolverBuilderBase for creating Thyra::LinearOpWithSolveFactoryBase ...
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.
RCP< Thyra::PreconditionerFactoryBase< Scalar > > createPreconditioningStrategy(const std::string &preconditioningStrategyName) const
STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string, extraParamsXmlString)
An XML string that will be used to update the parameters (if not "").
RCP< const ParameterList > getParameterList() const
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.
STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string, extraParamsXmlStringOption)
The name of the option that will be added the the commandline processor that will set extraParamsXmlS...
STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string, paramsXmlFileNameOption)
The name of the option that will be added the the commandline processor that will set paramsXmlFileNa...
RCP< const ParameterList > getValidParameters() const
STANDARD_MEMBER_COMPOSITION_MEMBERS(bool, replaceDuplicateFactories)
Determines if duplicate registered factories are replaced or if an exception is thrown.
STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string, paramsUsedXmlOutFileName)
The name of an XML file that will be written (if not "") for the parameters actually used.
RCP< Thyra::LinearOpWithSolveFactoryBase< Scalar > > createLinearSolveStrategy(const std::string &linearSolveStrategyName) const
std::string getPreconditionerStrategyName() const
Get the name of the preconditioner strategy that will be created on the next call to this->createPrec...
void setParameterList(RCP< ParameterList > const &paramList)
void setDefaultLinearSolveStrategyFactoryName(const std::string &solveStrategyName)
Set the default linear solver factory name.
void setupCLP(Teuchos::CommandLineProcessor *clp)
Setup the command-line processor to read in the needed data to extra the parameters from.
void readParameters(std::ostream *out)
Force the parameters to be read from a file and/or an extra XML string.
STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string, paramsUsedXmlOutFileNameOption)
The name of the option that will be added the the commandline processor that will set paramsUsedXmlOu...
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 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...
STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string, paramsXmlFileName)
The name an XML file that will be read to get XML parameters (if not "").

Generated for Stratimikos by doxygen 1.9.8