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#ifdef HAVE_STRATIMIKOS_THYRAEPETRAADAPTERS
21#include "Thyra_EpetraThyraWrappers.hpp"
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
34namespace Teuchos { class CommandLineProcessor; }
35
36
37namespace Stratimikos {
38
39
41using Teuchos::RCP;
43using Teuchos::Array;
45using Teuchos::AbstractFactory;
47using Teuchos::ParameterList;
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 */
86template <class Scalar = double>
88 : public Thyra::LinearSolverBuilderBase<Scalar>
89{
90public:
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
190 void setupCLP( Teuchos::CommandLineProcessor *clp );
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);
250 RCP<ParameterList> getNonconstParameterList();
252 RCP<ParameterList> unsetParameterList();
254 RCP<const ParameterList> getParameterList() const;
256 RCP<const ParameterList> getValidParameters() const;
257
259
262
264 RCP<Thyra::LinearOpWithSolveFactoryBase<Scalar> >
266 const std::string &linearSolveStrategyName
267 ) const;
269 RCP<Thyra::PreconditionerFactoryBase<Scalar> >
271 const std::string &preconditioningStrategyName
272 ) const;
273
275
276private:
277
278 // //////////////////////////////////////
279 // Private types
280
281 typedef RCP<const AbstractFactory<Thyra::LinearOpWithSolveFactoryBase<Scalar> > >
282 lowsf_fcty_t;
283 typedef RCP<const AbstractFactory<Thyra::PreconditionerFactoryBase<Scalar> > >
284 pf_fcty_t;
285
286 // //////////////////////////////////////
287 // Private data members
288
289 RCP<ParameterList> paramList_;
290 Array<std::string> validLowsfNames_;
291 Array<lowsf_fcty_t> lowsfArray_;
292 std::string defaultLOWSF_;
293 Array<std::string> validPfNames_; // Contains "None" as the 0th entry!
294 Array<pf_fcty_t> pfArray_;
295 std::string defaultPF_;
296 bool enableDelayedSolverConstruction_;
297 mutable RCP<const ParameterList> validParamList_;
298 mutable RCP<const Teuchos::StringToIntegralParameterEntryValidator<int> > lowsfValidator_;
299 mutable RCP<const Teuchos::StringToIntegralParameterEntryValidator<int> > pfValidator_;
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
313namespace LinearSolverBuilderHelpers {
314
315
323int existingNameIndex(
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
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