Teko  Version of the Day
 All Classes Files Functions Variables Pages
Teko_InvLSCStrategy.hpp
1 /*
2 // @HEADER
3 //
4 // ***********************************************************************
5 //
6 // Teko: A package for block and physics based preconditioning
7 // Copyright 2010 Sandia Corporation
8 //
9 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
10 // the U.S. Government retains certain rights in this software.
11 //
12 // Redistribution and use in source and binary forms, with or without
13 // modification, are permitted provided that the following conditions are
14 // met:
15 //
16 // 1. Redistributions of source code must retain the above copyright
17 // notice, this list of conditions and the following disclaimer.
18 //
19 // 2. Redistributions in binary form must reproduce the above copyright
20 // notice, this list of conditions and the following disclaimer in the
21 // documentation and/or other materials provided with the distribution.
22 //
23 // 3. Neither the name of the Corporation nor the names of the
24 // contributors may be used to endorse or promote products derived from
25 // this software without specific prior written permission.
26 //
27 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
28 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
31 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
32 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
33 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
34 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
35 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
36 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
37 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 //
39 // Questions? Contact Eric C. Cyr (eccyr@sandia.gov)
40 //
41 // ***********************************************************************
42 //
43 // @HEADER
44 
45 */
46 
47 #ifndef __Teko_InvLSCStrategy_hpp__
48 #define __Teko_InvLSCStrategy_hpp__
49 
50 #include "Teko_LSCStrategy.hpp"
51 
52 namespace Teko {
53 namespace NS {
54 
55 class LSCPrecondState; // forward declration
56 
66 class InvLSCStrategy : public LSCStrategy {
67  public:
69 
71  InvLSCStrategy(const Teuchos::RCP<InverseFactory> &factory, bool rzn = false);
72  InvLSCStrategy(const Teuchos::RCP<InverseFactory> &factory, LinearOp &mass, bool rzn = false);
73  InvLSCStrategy(const Teuchos::RCP<InverseFactory> &invFactF,
74  const Teuchos::RCP<InverseFactory> &invFactS, bool rzn = false);
75  InvLSCStrategy(const Teuchos::RCP<InverseFactory> &invFactF,
76  const Teuchos::RCP<InverseFactory> &invFactS, LinearOp &mass, bool rzn = false);
78 
79  virtual ~InvLSCStrategy() {}
80 
82 
83 
91  virtual void buildState(BlockedLinearOp &A, BlockPreconditionerState &state) const;
92 
101  virtual LinearOp getInvBQBt(const BlockedLinearOp &A, BlockPreconditionerState &state) const;
102 
111  virtual LinearOp getInvBHBt(const BlockedLinearOp &A, BlockPreconditionerState &state) const;
112 
121  virtual LinearOp getInvF(const BlockedLinearOp &A, BlockPreconditionerState &state) const;
122 
131  // virtual LinearOp getInvAlphaD(const BlockedLinearOp & A,BlockPreconditionerState & state)
132  // const;
133  virtual LinearOp getOuterStabilization(const BlockedLinearOp &A,
134  BlockPreconditionerState &state) const;
135  virtual LinearOp getInnerStabilization(const BlockedLinearOp & /* A */,
136  BlockPreconditionerState & /* state */) const {
137  return Teuchos::null;
138  }
139 
148  virtual LinearOp getInvMass(const BlockedLinearOp &A, BlockPreconditionerState &state) const;
149 
158  virtual LinearOp getHScaling(const BlockedLinearOp &A, BlockPreconditionerState &state) const;
159 
166  virtual bool useFullLDU() const { return useFullLDU_; }
167 
173  virtual void setSymmetric(bool isSymmetric) { isSymmetric_ = isSymmetric; }
174 
176  virtual void initializeFromParameterList(const Teuchos::ParameterList &pl,
177  const InverseLibrary &invLib);
178 
180  virtual Teuchos::RCP<Teuchos::ParameterList> getRequestedParameters() const;
181 
183  virtual bool updateRequestedParameters(const Teuchos::ParameterList &pl);
185 
188  virtual void setPressureStabMatrix(const Teko::LinearOp &psm) { userPresStabMat_ = psm; }
189 
191  virtual void initializeState(const BlockedLinearOp &A, LSCPrecondState *state) const;
192 
198  void computeInverses(const BlockedLinearOp &A, LSCPrecondState *state) const;
199 
200  // //! Initialize the state object using this blocked linear operator
201  // virtual void reinitializeState(const BlockedLinearOp & A,LSCPrecondState * state) const;
202 
204  virtual void setEigSolveParam(int sz) { eigSolveParam_ = sz; }
205 
207  virtual int getEigSolveParam() { return eigSolveParam_; }
208 
210  virtual void setUseFullLDU(bool val) { useFullLDU_ = val; }
211 
213  virtual void setRowZeroing(bool val) { rowZeroingNeeded_ = val; }
214 
216  virtual void setMassMatrix(const LinearOp &mass) { massMatrix_ = mass; }
217 
221  virtual void setHScaling(const LinearOp &hScaling) { hScaling_ = hScaling; }
222 
226  virtual void setHScaling(const MultiVector &hScaling) {
227  hScaling_ = buildDiagonal(hScaling, "H");
228  }
229 
233  virtual void setWScaling(const MultiVector &wScaling) { wScaling_ = wScaling; }
234 
235  protected:
236  LinearOp massMatrix_;
237 
238  // how to invert the matrices
239  Teuchos::RCP<InverseFactory> invFactoryF_;
240  Teuchos::RCP<InverseFactory> invFactoryS_;
241 
242  // number of power iterations when computing spectral radius
243  int eigSolveParam_;
244 
245  // flags for handling various options
246  bool rowZeroingNeeded_;
247  bool useFullLDU_;
248  bool useMass_;
249  bool useLumping_;
250  bool useWScaling_;
251  DiagonalType scaleType_;
252  bool isSymmetric_;
253  bool assumeStable_;
254 
255  // operators requested, to be filled by user
256  LinearOp userPresStabMat_;
257  mutable LinearOp hScaling_;
258  MultiVector wScaling_;
259 
260  private:
262 };
263 
264 } // end namespace NS
265 } // end namespace Teko
266 
267 #endif
virtual LinearOp getInvF(const BlockedLinearOp &A, BlockPreconditionerState &state) const
virtual void setUseFullLDU(bool val)
Set to true to use the Full LDU decomposition, false otherwise.
virtual LinearOp getInnerStabilization(const BlockedLinearOp &, BlockPreconditionerState &) const
virtual void setRowZeroing(bool val)
Set to true to zero the rows of F when computing the spectral radius.
virtual Teuchos::RCP< Teuchos::ParameterList > getRequestedParameters() const
For assiting in construction of the preconditioner.
virtual LinearOp getOuterStabilization(const BlockedLinearOp &A, BlockPreconditionerState &state) const
virtual void setHScaling(const LinearOp &hScaling)
virtual LinearOp getHScaling(const BlockedLinearOp &A, BlockPreconditionerState &state) const
virtual LinearOp getInvBHBt(const BlockedLinearOp &A, BlockPreconditionerState &state) const
An implementation of a state object for block preconditioners.
virtual void setEigSolveParam(int sz)
Set the number of power series iterations to use when finding the spectral radius.
virtual void buildState(BlockedLinearOp &A, BlockPreconditionerState &state) const
Functions inherited from LSCStrategy.
virtual void initializeState(const BlockedLinearOp &A, LSCPrecondState *state) const
Initialize the state object using this blocked linear operator.
A strategy that takes a single inverse factory and uses that for all inverses. If no mass matrix is p...
virtual LinearOp getInvMass(const BlockedLinearOp &A, BlockPreconditionerState &state) const
void computeInverses(const BlockedLinearOp &A, LSCPrecondState *state) const
Preconditioner state for the LSC factory.
virtual bool updateRequestedParameters(const Teuchos::ParameterList &pl)
For assiting in construction of the preconditioner.
Strategy for driving LSCPreconditionerFactory.
virtual void initializeFromParameterList(const Teuchos::ParameterList &pl, const InverseLibrary &invLib)
Initialize from a parameter list.
virtual void setMassMatrix(const LinearOp &mass)
set the mass matrix to use in computing the scaling
virtual void setHScaling(const MultiVector &hScaling)
virtual int getEigSolveParam()
Return the number of power series iterations to use when finding the spectral radius.
virtual bool useFullLDU() const
virtual void setPressureStabMatrix(const Teko::LinearOp &psm)
virtual void setSymmetric(bool isSymmetric)
virtual void setWScaling(const MultiVector &wScaling)
virtual LinearOp getInvBQBt(const BlockedLinearOp &A, BlockPreconditionerState &state) const