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,
72  bool rzn=false);
73  InvLSCStrategy(const Teuchos::RCP<InverseFactory> & factory,
74  LinearOp & mass,bool rzn=false);
75  InvLSCStrategy(const Teuchos::RCP<InverseFactory> & invFactF,
76  const Teuchos::RCP<InverseFactory> & invFactS,
77  bool rzn=false);
78  InvLSCStrategy(const Teuchos::RCP<InverseFactory> & invFactF,
79  const Teuchos::RCP<InverseFactory> & invFactS,
80  LinearOp & mass,bool rzn=false);
82 
83  virtual ~InvLSCStrategy() {}
84 
86 
87 
95  virtual void buildState(BlockedLinearOp & A,BlockPreconditionerState & state) const;
96 
105  virtual LinearOp getInvBQBt(const BlockedLinearOp & A,BlockPreconditionerState & state) const;
106 
115  virtual LinearOp getInvBHBt(const BlockedLinearOp & A,BlockPreconditionerState & state) const;
116 
125  virtual LinearOp getInvF(const BlockedLinearOp & A,BlockPreconditionerState & state) const;
126 
135  // virtual LinearOp getInvAlphaD(const BlockedLinearOp & A,BlockPreconditionerState & state) const;
136  virtual LinearOp getOuterStabilization(const BlockedLinearOp & A,BlockPreconditionerState & state) const;
137  virtual LinearOp getInnerStabilization(const BlockedLinearOp & /* A */,BlockPreconditionerState & /* state */) const
138  { return Teuchos::null; }
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)
174  { isSymmetric_ = isSymmetric; }
175 
177  virtual void initializeFromParameterList(const Teuchos::ParameterList & pl,
178  const InverseLibrary & invLib);
179 
181  virtual Teuchos::RCP<Teuchos::ParameterList> getRequestedParameters() const;
182 
184  virtual bool updateRequestedParameters(const Teuchos::ParameterList & pl);
186 
189  virtual void setPressureStabMatrix(const Teko::LinearOp & psm)
190  { userPresStabMat_ = psm; }
191 
193  virtual void initializeState(const BlockedLinearOp & A,LSCPrecondState * state) const;
194 
200  void computeInverses(const BlockedLinearOp & A,LSCPrecondState * state) const;
201 
202  // //! Initialize the state object using this blocked linear operator
203  // virtual void reinitializeState(const BlockedLinearOp & A,LSCPrecondState * state) const;
204 
206  virtual void setEigSolveParam(int sz) { eigSolveParam_ = sz; }
207 
209  virtual int getEigSolveParam() { return eigSolveParam_; }
210 
212  virtual void setUseFullLDU(bool val) { useFullLDU_ = val; }
213 
215  virtual void setRowZeroing(bool val) { rowZeroingNeeded_ = val; }
216 
218  virtual void setMassMatrix(const LinearOp & mass) { massMatrix_ = mass; }
219 
223  virtual void setHScaling(const LinearOp & hScaling) { hScaling_ = hScaling; }
224 
228  virtual void setHScaling(const MultiVector & hScaling)
229  { hScaling_ = buildDiagonal(hScaling,"H"); }
230 
234  virtual void setWScaling(const MultiVector & wScaling)
235  { wScaling_ = wScaling; }
236 
237 protected:
238  LinearOp massMatrix_;
239 
240  // how to invert the matrices
241  Teuchos::RCP<InverseFactory> invFactoryF_;
242  Teuchos::RCP<InverseFactory> invFactoryS_;
243 
244  // number of power iterations when computing spectral radius
245  int eigSolveParam_;
246 
247  // flags for handling various options
248  bool rowZeroingNeeded_;
249  bool useFullLDU_;
250  bool useMass_;
251  bool useLumping_;
252  bool useWScaling_;
253  DiagonalType scaleType_;
254  bool isSymmetric_;
255  bool assumeStable_;
256 
257  // operators requested, to be filled by user
258  LinearOp userPresStabMat_;
259  mutable LinearOp hScaling_;
260  MultiVector wScaling_;
261 
262 private:
264 };
265 
266 } // end namespace NS
267 } // end namespace Teko
268 
269 #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