Stratimikos Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
Stratimikos_LinearSolverBuilder_decl.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_LINEAR_SOLVER_BUILDING_BASE
43#define STRATIMIKOS_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#ifdef HAVE_STRATIMIKOS_THYRAEPETRAADAPTERS
53#include "Thyra_EpetraThyraWrappers.hpp"
54#include "Thyra_EpetraLinearOp.hpp"
55#endif
56#include "Thyra_LinearOpWithSolveFactoryHelpers.hpp"
57#include "Thyra_LinearOpWithSolveBase.hpp"
58#include "Thyra_PreconditionerFactoryHelpers.hpp"
59#include "Thyra_DefaultScaledAdjointLinearOp.hpp"
60#include "Thyra_DefaultPreconditioner.hpp"
61#include "Thyra_MultiVectorStdOps.hpp"
62#include "Thyra_VectorStdOps.hpp"
63#include "Thyra_VectorBase.hpp"
64
65
66namespace Teuchos { class CommandLineProcessor; }
67
68
69namespace Stratimikos {
70
71
73using Teuchos::RCP;
75using Teuchos::Array;
77using Teuchos::AbstractFactory;
79using Teuchos::ParameterList;
80
81
98/* (Old comments removed from Doxygen)
99 *
100 * The parameters this class accepts are shown below in different format:
101 * <ul>
102 * <li> \ref HumanReadableWithDocumentation "Human readable format (with documentation) for valid parameters accepted by this class"
103 * <li> \ref HumanReadableWithoutDocumentation "Human readable format (without documentation) for valid parameters accepted by this class"
104 * <li> \ref XmlFormat "XML format for valid parameters accepted by this class"
105 * </ul>
106 *
107 * <b>\anchor HumanReadableWithDocumentation Human readable format (with documentation) for valid parameters accepted by this class</b>
108 *
109 * <b>\anchor HumanReadableWithoutDocumentation Human readable format (without documentation) for valid parameters accepted by this class</b>
110 *
111 * \verbinclude simple_stratimikos_example.options.readable.out
112 *
113 * <b>\anchor XmlFormat XML format for valid parameters accepted by this class</b>
114 *
115 * \verbinclude simple_stratimikos_example.options.xml.out
116 *
117 */
118template <class Scalar = double>
120 : public Thyra::LinearSolverBuilderBase<Scalar>
121{
122public:
123
126
135 const std::string &paramsXmlFileName = ""
136 ,const std::string &extraParamsXmlString = ""
137 ,const std::string &paramsUsedXmlOutFileName = ""
138 ,const std::string &paramsXmlFileNameOption = "linear-solver-params-file"
139 ,const std::string &extraParamsXmlStringOption = "extra-linear-solver-params"
140 ,const std::string &paramsUsedXmlOutFileNameOption = "linear-solver-params-used-file"
141 );
142
145
149 STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsXmlFileName);
150
154 STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,extraParamsXmlString);
155
159 STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsUsedXmlOutFileName);
160
164 STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsXmlFileNameOption);
165
169 STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,extraParamsXmlStringOption);
170
174 STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsUsedXmlOutFileNameOption);
175
178 const RCP<const AbstractFactory<Thyra::LinearOpWithSolveFactoryBase<Scalar> > >
179 &solveStrategyFactory,
180 const std::string &solveStrategyName,
181 const bool makeDefault = false
182 );
183
186 const std::string &solveStrategyName);
187
190 const RCP<const AbstractFactory<Thyra::PreconditionerFactoryBase<Scalar> > >
191 &precStrategyFactory,
192 const std::string &precStrategyName,
193 const bool makeDefault = false
194 );
195
198 const std::string &precStrategyName);
199
216 void setupCLP( Teuchos::CommandLineProcessor *clp );
217
236 void readParameters( std::ostream *out );
237
253 void writeParamsFile(
254 const Thyra::LinearOpWithSolveFactoryBase<Scalar> &lowsFactory,
255 const std::string &outputXmlFileName = ""
256 ) const;
257
261 std::string getLinearSolveStrategyName() const;
262
266 std::string getPreconditionerStrategyName() const;
267
269
272
274 void setParameterList(RCP<ParameterList> const& paramList);
276 RCP<ParameterList> getNonconstParameterList();
278 RCP<ParameterList> unsetParameterList();
280 RCP<const ParameterList> getParameterList() const;
282 RCP<const ParameterList> getValidParameters() const;
283
285
288
290 RCP<Thyra::LinearOpWithSolveFactoryBase<Scalar> >
292 const std::string &linearSolveStrategyName
293 ) const;
295 RCP<Thyra::PreconditionerFactoryBase<Scalar> >
297 const std::string &preconditioningStrategyName
298 ) const;
299
301
302private:
303
304 // //////////////////////////////////////
305 // Private types
306
307 typedef RCP<const AbstractFactory<Thyra::LinearOpWithSolveFactoryBase<Scalar> > >
309 typedef RCP<const AbstractFactory<Thyra::PreconditionerFactoryBase<Scalar> > >
311
312 // //////////////////////////////////////
313 // Private data members
314
315 RCP<ParameterList> paramList_;
316 Array<std::string> validLowsfNames_;
317 Array<lowsf_fcty_t> lowsfArray_;
318 std::string defaultLOWSF_;
319 Array<std::string> validPfNames_; // Contains "None" as the 0th entry!
320 Array<pf_fcty_t> pfArray_;
321 std::string defaultPF_;
323 mutable RCP<const ParameterList> validParamList_;
324 mutable RCP<const Teuchos::StringToIntegralParameterEntryValidator<int> > lowsfValidator_;
325 mutable RCP<const Teuchos::StringToIntegralParameterEntryValidator<int> > pfValidator_;
326
327 // //////////////////////////////////////
328 // Private member functions
329
330 void initializeDefaults();
331 void justInTimeInitialize() const;
332
333};
334
335
336} // namespace Stratimikos
337
338
339#endif // STRATIMIKOS_LINEAR_SOLVER_BUILDING_BASE
Concrete subclass of Thyra::LinearSolverBuilderBase for creating LinearOpWithSolveFactoryBase objects...
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 Teuchos::StringToIntegralParameterEntryValidator< int > > lowsfValidator_
RCP< const ParameterList > getParameterList() const
RCP< const AbstractFactory< Thyra::LinearOpWithSolveFactoryBase< Scalar > > > lowsf_fcty_t
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
RCP< const AbstractFactory< Thyra::PreconditionerFactoryBase< Scalar > > > pf_fcty_t
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)
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")
Construct with default parameters.
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 "").
RCP< const Teuchos::StringToIntegralParameterEntryValidator< int > > pfValidator_