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 { return isInitialized_; }
101 
104  virtual void setInitialized(bool init = true) { isInitialized_ = init; }
105 
107  virtual void setSourceVector(const Teko::MultiVector& srcVec) { srcVector_ = srcVec; }
108 
110  virtual const Teko::MultiVector getSourceVector() const { return srcVector_; }
111 
113  virtual void addInverse(const std::string& name, const Teko::InverseLinearOp& ilo) {
114  inverses_[name] = ilo;
115  }
116 
118  virtual Teko::InverseLinearOp getInverse(const std::string& name) const {
119  std::map<std::string, Teko::InverseLinearOp>::const_iterator itr;
120  itr = inverses_.find(name);
121  if (itr == inverses_.end()) return Teuchos::null;
122  return itr->second;
123  }
124 
126  virtual void addLinearOp(const std::string& name, const Teko::LinearOp& lo) {
127  linearOps_[name] = lo;
128  }
129 
131  virtual Teko::LinearOp getLinearOp(const std::string& name) { return linearOps_[name]; }
132 
134  virtual void addModifiableOp(const std::string& name, const Teko::ModifiableLinearOp& mlo) {
135  modifiableOp_[name] = mlo;
136  }
137 
139  virtual Teko::ModifiableLinearOp& getModifiableOp(const std::string& name) {
140  std::map<std::string, Teko::ModifiableLinearOp>::iterator itr;
141  itr = modifiableOp_.find(name);
142  if (itr == modifiableOp_.end()) return modifiableOp_[name];
143  return itr->second;
144  }
145 
147  virtual void merge(const PreconditionerState& ps, int position = -1);
148 
150  unsigned int getTag() const;
151 
153  void setTag(unsigned int tag);
154 
155  protected:
157  Teuchos::RCP<Teuchos::ParameterList> paramList_;
158 
160  Teko::MultiVector srcVector_;
161 
163  std::map<std::string, Teko::InverseLinearOp> inverses_;
164  std::map<std::string, Teko::ModifiableLinearOp> modifiableOp_;
165  std::map<std::string, Teko::LinearOp> linearOps_;
166 
169 
170  unsigned int tag_;
171 };
172 
173 } // end namespace Teko
174 
175 #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)
std::map< std::string, Teko::InverseLinearOp > inverses_
Store a map of inverse linear operators.
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.
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().