Teko  Version of the Day
 All Classes Files Functions Variables Pages
Teko_PreconditionerState.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_PreconditionerState_hpp__
48 #define __Teko_PreconditionerState_hpp__
49 
50 #include "Teuchos_ParameterListAcceptor.hpp"
51 
52 // Thyra includes
53 // #include "Thyra_SolveSupportTypes.hpp"
54 
55 // Teko includes
56 #include "Teko_Utilities.hpp"
57 
58 namespace Teko {
59 
71 class PreconditionerState : public Teuchos::ParameterListAcceptor {
72 public:
74 
77  : paramList_(Teuchos::rcp(new Teuchos::ParameterList(*src.paramList_))),
79  inverses_(src.inverses_),
82 
84 
85 
87  void setParameterList(const Teuchos::RCP<Teuchos::ParameterList> & paramList);
88 
90  Teuchos::RCP<Teuchos::ParameterList> getNonconstParameterList();
91 
93  Teuchos::RCP<Teuchos::ParameterList> unsetParameterList();
94 
96 
100  virtual bool isInitialized() const
101  { return isInitialized_; }
102 
105  virtual void setInitialized(bool init=true)
106  { isInitialized_ = init; }
107 
109  virtual void setSourceVector(const Teko::MultiVector & srcVec)
110  { srcVector_ = srcVec; }
111 
113  virtual const Teko::MultiVector getSourceVector() const
114  { return srcVector_; }
115 
117  virtual void addInverse(const std::string & name,const Teko::InverseLinearOp & ilo)
118  { inverses_[name] = ilo; }
119 
121  virtual Teko::InverseLinearOp getInverse(const std::string & name) const
122  { std::map<std::string,Teko::InverseLinearOp>::const_iterator itr;
123  itr = inverses_.find(name);
124  if(itr==inverses_.end()) return Teuchos::null;
125  return itr->second; }
126 
128  virtual void addLinearOp(const std::string & name,const Teko::LinearOp & lo)
129  { linearOps_[name] = lo; }
130 
132  virtual Teko::LinearOp getLinearOp(const std::string & name)
133  { return linearOps_[name]; }
134 
136  virtual void addModifiableOp(const std::string & name,const Teko::ModifiableLinearOp & mlo)
137  { modifiableOp_[name] = mlo; }
138 
140  virtual Teko::ModifiableLinearOp &
141  getModifiableOp(const std::string & name)
142  { std::map<std::string,Teko::ModifiableLinearOp>::iterator itr;
143  itr = modifiableOp_.find(name);
144  if(itr==modifiableOp_.end())
145  return modifiableOp_[name];
146  return itr->second; }
147 
149  virtual void merge(const PreconditionerState & ps,int position=-1);
150 
152  unsigned int getTag() const;
153 
155  void setTag(unsigned int tag);
156 
157 protected:
159  Teuchos::RCP<Teuchos::ParameterList> paramList_;
160 
162  Teko::MultiVector srcVector_;
163 
165  std::map<std::string,Teko::InverseLinearOp> inverses_;
166  std::map<std::string,Teko::ModifiableLinearOp> modifiableOp_;
167  std::map<std::string,Teko::LinearOp> linearOps_;
168 
171 
172  unsigned int tag_;
173 };
174 
175 } // end namespace Teko
176 
177 #endif
Teuchos::RCP< Teuchos::ParameterList > paramList_
for ParameterListAcceptor
virtual Teko::InverseLinearOp getInverse(const std::string &name) const
Get a named inverse from the state object.
virtual void setSourceVector(const Teko::MultiVector &srcVec)
Set the vector associated with this operator (think nonlinear system)
virtual void addLinearOp(const std::string &name, const Teko::LinearOp &lo)
Add a named operator to the state object.
bool isInitialized_
Stores the initialization state.
virtual const Teko::MultiVector getSourceVector() const
Set the vector associated with this operator (think nonlinear system)
Teuchos::RCP< Teuchos::ParameterList > getNonconstParameterList()
Get the parameter list that was set using setParameterList().
virtual void merge(const PreconditionerState &ps, int position=-1)
Merge internal storage of another PreconditionerState object into this one.
std::map< std::string, Teko::InverseLinearOp > inverses_
Store a map of inverse linear operators.
virtual Teko::LinearOp getLinearOp(const std::string &name)
Add a named operator to the state object.
virtual void addInverse(const std::string &name, const Teko::InverseLinearOp &ilo)
Add a named inverse to the state object.
void setTag(unsigned int tag)
Set the tag for this operator.
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > &paramList)
Set parameters from a parameter list and return with default values.
virtual void addModifiableOp(const std::string &name, const Teko::ModifiableLinearOp &mlo)
Add a named operator to the state object.
An implementation of a state object preconditioners.
Teko::MultiVector srcVector_
Store a source vector.
virtual void setInitialized(bool init=true)
unsigned int getTag() const
Get the tag for this operator.
virtual Teko::ModifiableLinearOp & getModifiableOp(const std::string &name)
Add a named operator to the state object.
Teuchos::RCP< Teuchos::ParameterList > unsetParameterList()
Unset the parameter list that was set using setParameterList().