/usr/include/trilinos/Stratimikos_DefaultLinearSolverBuilder.hpp is in libtrilinos-stratimikos-dev 12.10.1-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 | // @HEADER
// ***********************************************************************
//
// Stratimikos: Thyra-based strategies for linear solvers
// Copyright (2006) Sandia Corporation
//
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
// license for use of this work by or on behalf of the U.S. Government.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
//
// ***********************************************************************
// @HEADER
#ifndef STRATIMIKOS_DEFAULT_LINEAR_SOLVER_BUILDING_BASE
#define STRATIMIKOS_DEFAULT_LINEAR_SOLVER_BUILDING_BASE
#include "Stratimikos_ConfigDefs.hpp"
#include "Thyra_LinearSolverBuilderBase.hpp"
#include "Teuchos_AbstractFactory.hpp"
#include "Teuchos_StandardMemberCompositionMacros.hpp"
#include "Teuchos_StandardParameterEntryValidators.hpp"
// Include these to make all of the helpful decls appear
#include "Thyra_EpetraThyraWrappers.hpp"
#include "Thyra_EpetraLinearOp.hpp"
#include "Thyra_LinearOpWithSolveFactoryHelpers.hpp"
#include "Thyra_LinearOpWithSolveBase.hpp"
#include "Thyra_PreconditionerFactoryHelpers.hpp"
#include "Thyra_DefaultScaledAdjointLinearOp.hpp"
#include "Thyra_DefaultPreconditioner.hpp"
#include "Thyra_MultiVectorStdOps.hpp"
#include "Thyra_VectorStdOps.hpp"
#include "Thyra_VectorBase.hpp"
namespace Teuchos { class CommandLineProcessor; }
namespace Stratimikos {
/** \brief . */
using Teuchos::RCP;
/** \brief . */
using Teuchos::Array;
/** \brief . */
using Teuchos::AbstractFactory;
/** \brief . */
using Teuchos::ParameterList;
/** \brief Concrete subclass of <tt>Thyra::LinearSolverBuilderBase</tt> for
* creating <tt>LinearOpWithSolveFactoryBase</tt> objects and
* <tt>PreconditionerFactoryBase</tt> object on demand for various Trilinos
* linear solver packages.
*
* For an example of how to use this class see
* <a href="simple__stratimikos__example_8cpp-example.html">simple_stratimikos_example.cpp</a></tt>.
*
* A hierarchical list of all valid parameters is given below:
*
* \htmlonly
* <iframe src="stratimikos.xml" width="100%" scrolling="no" frameborder="0"></iframe>
* <hr />
* \endhtmlonly
*/
/* (Old comments removed from Doxygen)
*
* The parameters this class accepts are shown below in different format:
* <ul>
* <li> \ref HumanReadableWithDocumentation "Human readable format (with documentation) for valid parameters accepted by this class"
* <li> \ref HumanReadableWithoutDocumentation "Human readable format (without documentation) for valid parameters accepted by this class"
* <li> \ref XmlFormat "XML format for valid parameters accepted by this class"
* </ul>
*
* <b>\anchor HumanReadableWithDocumentation Human readable format (with documentation) for valid parameters accepted by this class</b>
*
* <b>\anchor HumanReadableWithoutDocumentation Human readable format (without documentation) for valid parameters accepted by this class</b>
*
* \verbinclude simple_stratimikos_example.options.readable.out
*
* <b>\anchor XmlFormat XML format for valid parameters accepted by this class</b>
*
* \verbinclude simple_stratimikos_example.options.xml.out
*
*/
class DefaultLinearSolverBuilder
: public Thyra::LinearSolverBuilderBase<double>
{
public:
/** @name Constructors/Initializers/Accessors */
//@{
/** \brief Construct with default parameters.
*
* <b>Warning!</b> Do not change the defaults by passing then into this
* constructor. Instead, use the member functions to set them after
* <tt>*this</tt> is constructed. This will help to avoid problems with
* updates to the ordering of the arguments.
*/
DefaultLinearSolverBuilder(
const std::string ¶msXmlFileName = ""
,const std::string &extraParamsXmlString = ""
,const std::string ¶msUsedXmlOutFileName = ""
,const std::string ¶msXmlFileNameOption = "linear-solver-params-file"
,const std::string &extraParamsXmlStringOption = "extra-linear-solver-params"
,const std::string ¶msUsedXmlOutFileNameOption = "linear-solver-params-used-file"
);
/** \brief . */
~DefaultLinearSolverBuilder();
/** \brief The name an XML file that will be read to get XML parameters (if
* not "").
*/
STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsXmlFileName);
/** \brief An XML string that will be used to update the parameters (if not
* "").
*/
STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,extraParamsXmlString);
/** \brief The name of an XML file that will be written (if not "") for the
* parameters actually used.
*/
STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsUsedXmlOutFileName);
/** \brief The name of the option that will be added the the commandline
* processor that will set <tt>paramsXmlFileName()</tt> .
*/
STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsXmlFileNameOption);
/** \brief The name of the option that will be added the the commandline
* processor that will set <tt>extraParamsXmlString()</tt> .
*/
STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,extraParamsXmlStringOption);
/** \brief The name of the option that will be added the the commandline
* processor that will set <tt>paramsUsedXmlOutFileName()</tt> .
*/
STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsUsedXmlOutFileNameOption);
/** \brief Set a new linear solver strategy factory object. */
void setLinearSolveStrategyFactory(
const RCP<const AbstractFactory<Thyra::LinearOpWithSolveFactoryBase<double> > >
&solveStrategyFactory,
const std::string &solveStrategyName,
const bool makeDefault = false
);
/** \brief Set the default linear solver factory name. */
void setDefaultLinearSolveStrategyFactoryName(
const std::string &solveStrategyName);
/** \brief Set a new preconditioner strategy factory object. */
void setPreconditioningStrategyFactory(
const RCP<const AbstractFactory<Thyra::PreconditionerFactoryBase<double> > >
&precStrategyFactory,
const std::string &precStrategyName,
const bool makeDefault = false
);
/** \brief Set the default linear solver factory name. */
void setDefaultPreconditioningStrategyFactoryName(
const std::string &precStrategyName);
/** \brief Setup the command-line processor to read in the needed data to
* extra the parameters from.
*
* Command-line options with names <tt>this->paramsXmlFileNameOption()</tt>,
* <tt>this->extraParamsXmlStringOption()</tt>, and
* <tt>this->paramsUsedXmlOutFileNameOption()</tt> will be set if they are
* not empty.
*
* Then, when <tt>cpl->parse(...)</tt> is called, then the options set will
* be read into <tt>this->paramsXmlFileName()</tt>,
* <tt>this->extraParamsXmlString()</tt>, and
* <tt>this->paramsUsedXmlOutFileName()</tt>.
*
* After this function is called, <tt>this->readParameters()</tt> can be
* called to actually read in the parameters and fill the parameter list.
*/
void setupCLP( Teuchos::CommandLineProcessor *clp );
/** \brief Force the parameters to be read from a file and/or an extra XML
* string.
*
* First, if <tt>this->getParameterList().get()==NULL</tt> and new parameter
* list will be created.
*
* Second, if <tt>this->paramsXmlFileName()!=""</tt> then the file
* <tt>this->paramsXmlFileName()</tt> will be read to get XML parameters
* append/update those already in the parameter list.
*
* Third, if <tt>this->extraParamsXmlString()!=""</tt> then the XML string
* <tt>this->extraParamsXmlString()</tt> will be read and used to
* append/update the parameters already in the parameter list..
*
* <b>Postconditions:</b><ul>
* <li><tt>this->getParameterList().get()!=NULL</tt>
* </ul>
*/
void readParameters( std::ostream *out );
/** \brief Write the parameters list for a
* <tt>LinearOpWithSolveFactoryBase</tt> object to a file after the
* parameters are read in order to show defaults and create a new list for
* input the next time.
*
* If <tt>outputXmlFileName!=""</tt> then the parameter list with be written
* to the file <tt>outputXmlFileName</tt> in XML format. If
* <tt>outputXmlFileName==""</tt>, but
* <tt>this->paramsUsedXmlOutFileNameOption()!=""</tt> then the parameter
* list will be written to the file
* <tt>this->paramsUsedXmlOutFileNameOption()</tt>. If both
* <tt>outputXmlFileName==""</tt> and
* <tt>this->paramsUsedXmlOutFileNameOption()==""</tt> then no file is
* written.
*/
void writeParamsFile(
const Thyra::LinearOpWithSolveFactoryBase<double> &lowsFactory,
const std::string &outputXmlFileName = ""
) const;
/** \brief Get the name of the linear solver strategy that will be created
* on the next call to <tt>this->createLinearSolverStrategy()</tt>.
*/
std::string getLinearSolveStrategyName() const;
/** \brief Get the name of the preconditioner strategy that will be created
* on the next call to <tt>this->createPreconditioningStrategy()</tt>.
*/
std::string getPreconditionerStrategyName() const;
//@}
/** @name Overridden from ParameterListAcceptor */
//@{
/** \brief . */
void setParameterList(RCP<ParameterList> const& paramList);
/** \brief . */
RCP<ParameterList> getNonconstParameterList();
/** \brief . */
RCP<ParameterList> unsetParameterList();
/** \brief . */
RCP<const ParameterList> getParameterList() const;
/** \brief . */
RCP<const ParameterList> getValidParameters() const;
//@}
/** \name Overridden from LinearSolverBuilderBase. */
//@{
/** \brief . */
RCP<Thyra::LinearOpWithSolveFactoryBase<double> >
createLinearSolveStrategy(
const std::string &linearSolveStrategyName
) const;
/** \brief . */
RCP<Thyra::PreconditionerFactoryBase<double> >
createPreconditioningStrategy(
const std::string &preconditioningStrategyName
) const;
//@}
private:
// //////////////////////////////////////
// Private types
typedef RCP<const AbstractFactory<Thyra::LinearOpWithSolveFactoryBase<double> > >
lowsf_fcty_t;
typedef RCP<const AbstractFactory<Thyra::PreconditionerFactoryBase<double> > >
pf_fcty_t;
// //////////////////////////////////////
// Private data members
RCP<ParameterList> paramList_;
Array<std::string> validLowsfNames_;
Array<lowsf_fcty_t> lowsfArray_;
std::string defaultLOWSF_;
Array<std::string> validPfNames_; // Contains "None" as the 0th entry!
Array<pf_fcty_t> pfArray_;
std::string defaultPF_;
bool enableDelayedSolverConstruction_;
mutable RCP<const ParameterList> validParamList_;
mutable RCP<const Teuchos::StringToIntegralParameterEntryValidator<int> > lowsfValidator_;
mutable RCP<const Teuchos::StringToIntegralParameterEntryValidator<int> > pfValidator_;
// //////////////////////////////////////
// Private member functions
void initializeDefaults();
void justInTimeInitialize() const;
};
} // namespace Stratimikos
#endif // STRATIMIKOS_DEFAULT_LINEAR_SOLVER_BUILDING_BASE
|