/usr/include/trilinos/Teko_LU2x2PreconditionerFactory.hpp is in libtrilinos-teko-dev 12.12.1-5.
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 | /*
// @HEADER
//
// ***********************************************************************
//
// Teko: A package for block and physics based preconditioning
// Copyright 2010 Sandia Corporation
//
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
// the U.S. Government retains certain rights in this software.
//
// 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 Eric C. Cyr (eccyr@sandia.gov)
//
// ***********************************************************************
//
// @HEADER
*/
#ifndef __Teko_LU2x2PreconditionerFactory_hpp__
#define __Teko_LU2x2PreconditionerFactory_hpp__
#include "Teuchos_RCP.hpp"
#include "Teko_BlockPreconditionerFactory.hpp"
#include "Teko_LU2x2Strategy.hpp"
namespace Teko {
/** \brief Construct a preconditioner using a LDU dcomposition of a block
* 2x2 matrix.
*
* This produces a preconditioner using the block-LDU decomposition of
* the matrix. The general assumption made is that the matrix is 2x2
* and the block factorization can be constructed (i.e. assumptions about
* the invertability of some blocks). The pattern used, and the one you
* should follow if you want to use this software is
*
* \f$
* A = \left[
* \begin{array}{cc}
* A_{00} & A_{01} \\
* A_{10} & A_{11}
* \end{array}
* \right]
* = \left[
* \begin{array}{cc}
* I & 0 \\
* A_{10} A_{00}^{-1} & I
* \end{array}
* \right]
* \left[
* \begin{array}{cc}
* A_{00} & 0 \\
* 0 & -S
* \end{array}
* \right]
* \left[
* \begin{array}{cc}
* I & A_{00}^{-1} A_{01} \\
* 0 & I
* \end{array}
* \right]
* \f$
*
* where the Schur complement is \f$ S=-A_{11}+A_{10} A_{00}^{-1} A_{01} \f$ .
*
* To use an LDU approximation 2 evaluations of \f$ A_{00}^{-1} \f$ and a single
* evalution of \f$ S^{-1} \f$ are needed. For increased flexibility both
* evaluations of \f$A_{00}^{-1}\f$ can be specified independently.
* For righthand side vector \f$[f, g]^T\f$ and solution vector \f$[u,v]^T\f$
* the two inverses (\f$A\f$-hat and \f$A\f$-tilde) are needed to evaluate
*
* \f$\hat{A}_{00} u^* = f\f$,
*
* \f$\tilde{A}_{00} v = A_{01} v\f$
*
* where \f$u^*\f$ is an intermediate step.
*
* In order to facilate using this class in a nonlinear solve (or for a
* time-dependent problem) the additional abstraction of a ``Strategy''
* has been added. This strategy, abstractly represented as the LU2x2Strategy,
* provides the \f$A_{00}^{-1}\f$ and \f$S^{-1}\f$ operators. Typical usage for this class
* is to build a LU2x2Strategy and pass it into the primary constructor.
* Additional constructors are provided both for convenience and to ease
* adoption. Underneath the hood all these constructors do is invoke the
* corresponding strategy object.
*
* For example, assume that you have the particularly nice case that
* your approximations of \f$A_{00}^{-1}\f$ and \f$S^{-1}\f$ are independent of the source
* operator. Then, one way to instantiate a LU2x2PreconditionerFactory
* is
<code>
RCP<LinearOpBase<double> > invA00 = buildInvA00(...);\n
RCP<LinearOpBase<double> > invS = buildInvS(...);\n
RCP<LU2x2PreconditionerFactory> precFact = rcp(new LU2x2PreconditionerFactory(invA00,invS));
</code>
* Now using the strategy constructor, an entirely equivalent factory
* object can be constructed by
<code>
RCP<LinearOpBase<double> > invA00 = buildInvA00(...);\n
RCP<LinearOpBase<double> > invS = buildInvS(...);\n
RCP<LU2x2Strateghy> precStrat = rcp(new StaticLU2x2Strategy(invA00,invS));\n
RCP<LU2x2PreconditionerFactory> precFact = rcp(new LU2x2PreconditionerFactory(precStrat));
</code>
* Notice that the StaticLU2x2Strategy takes the same objects
* as the original constructor, it acts as an intermediary to tell the
* LU2x2PreconditionerFactory what those operators are.
**/
class LU2x2PreconditionerFactory : public BlockPreconditionerFactory {
public:
//! @name Constructors.
//@{
/** @brief Build a simple static LU2x2 preconditioner */
LU2x2PreconditionerFactory(LinearOp & invA00,LinearOp & invS);
/** @brief Build a simple static LU2x2 preconditioner */
LU2x2PreconditionerFactory(LinearOp & hatInvA00,LinearOp & tildeInvA00,LinearOp & invS);
/** @brief Constructor that permits the most generality in building \f$A_{00}^{-1}\f$ and
* \f$S^{-1}\f$.
*
* Constructor that permits the most generality in building \f$A_{00}^{-1}\f$ and \f$S^{-1}\f$.
*
* @param[in] strategy Strategy object that takes a 2x2 block matrix and
* and constructs the \f$A_{00}^{-1}\f$ and \f$S^{-1}\f$ objects.
*/
LU2x2PreconditionerFactory(const Teuchos::RCP<LU2x2Strategy> & strategy);
/** \brief Default constructor for use with AutoClone
*
* Default constructor for use with AutoClone
*/
LU2x2PreconditionerFactory();
//@}
/** \brief Create the LU 2x2 preconditioner operator.
*
* This method breaks apart the BlockLinearOp and builds a block
* LU preconditioner. This will require two applications of the inverse
* of the (0,0) block and one application of the inverse Schur complement.
*/
LinearOp buildPreconditionerOperator(BlockedLinearOp & blo,BlockPreconditionerState & state) const;
/** \brief This function builds the internals of the preconditioner factory
* from a parameter list.
*
* This function builds the internals of the preconditioner factory
* from a parameter list. Furthermore, it allows a preconditioner factory
* developer to easily add a factory to the build system. This function
* is required for building a preconditioner from a parameter list.
*
* \param[in] settings Parmaeter list to use as the internal settings
*
* \note The default implementation does nothing.
*/
virtual void initializeFromParameterList(const Teuchos::ParameterList & settings);
/** \brief Request the additional parameters this preconditioner factory
* needs.
*
* Request the additonal parameters needed by this preconditioner factory.
* The parameter list will have a set of fields that can be filled with
* the requested values. These fields include all requirements, even those
* of the sub-solvers if there are any. Once correctly filled the object
* can be updated by calling the updateRequestedParameters with the filled
* parameter list.
*
* \returns A parameter list with the requested parameters.
*
* \note The default implementation returns Teuchos::null.
*/
virtual Teuchos::RCP<Teuchos::ParameterList> getRequestedParameters() const;
/** \brief Update this object with the fields from a parameter list.
*
* Update the requested fields using a parameter list. This method is
* expected to pair with the getRequestedParameters method (i.e. the fields
* requested are going to be update using this method).
*
* \param[in] pl Parameter list containing the requested parameters.
*
* \returns If the method succeeded (found all its required parameters) this
* method returns true, otherwise it returns false.
*
* \note The default implementation returns true (it does nothing!).
*/
virtual bool updateRequestedParameters(const Teuchos::ParameterList & pl);
/** \brief Determine the type of inverse operator to build.
*
* Determine the type of inverse operator to build. If true
* use the full LDU decomposition. If false only the upper
* triangular solve should be used. Motivation for doing this
* can be found in Murphy, Golub and Wathen, SISC 2000.
*
* \returns A boolean indicating the type of inverse operator
* to use.
*
* \note Default behavior for this class is to return true.
*/
virtual bool useFullLDU() const { return useFullLDU_; }
/** \brief Set the type of inverse operation to use.
*
* Set the type of inverse operator to use. If true
* use the full LDU decomposition. If false only the upper
* triangular solve should be used. Motivation for doing this
* can be found in Murphy, Golub and Wathen, SISC 2000.
*
* \param[in] value Boolean indicating type of inverse operator
* to build.
*/
virtual void setFullLDU(bool value)
{ useFullLDU_ = value; }
protected:
using Teko::BlockPreconditionerFactory::buildPreconditionerOperator;
//! some members
Teuchos::RCP<LU2x2Strategy> invOpsStrategy_;
/** If true, use full LDU decomposition, otherwise
* use the Golub & Wathen style upper block. This is
* true by default.
*/
bool useFullLDU_;
public:
/** \brief Builder function for creating strategies.
*
* Builder function for creating strategies.
*
* \param[in] name String name of strategy to build
* \param[in] settings Parameter list describing the parameters for the
* strategy to build
* \param[in] invLib Inverse library for the strategy to use.
*
* \returns If the name is associated with a strategy
* a pointer is returned, otherwise Teuchos::null is returned.
*/
static RCP<LU2x2Strategy>
buildStrategy(const std::string & name,
const Teuchos::ParameterList & settings,
const RCP<const InverseLibrary> & invLib,
const RCP<RequestHandler> & rh);
/** \brief Add a strategy to the builder. This is done using the
* clone pattern.
*
* Add a strategy to the builder. This is done using the
* clone pattern. If your class does not support the Cloneable interface then
* you can use the AutoClone class to construct your object.
*
* \note If this method is called twice with the same string, the latter clone pointer
* will be used.
*
* \param[in] name String to associate with this object
* \param[in] clone Pointer to Cloneable object
*/
static void addStrategy(const std::string & name,const RCP<Cloneable> & clone);
private:
//! for creating the strategy objects
static CloneFactory<LU2x2Strategy> strategyBuilder_;
//! This is where the default objects are put into the strategyBuilder_
static void initializeStrategyBuilder();
};
} // end namespace Teko
#endif
|