Teko  Version of the Day
 All Classes Files Functions Variables Pages
Teko_PreconditionerState.hpp
1 // @HEADER
2 // *****************************************************************************
3 // Teko: A package for block and physics based preconditioning
4 //
5 // Copyright 2010 NTESS and the Teko contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef __Teko_PreconditionerState_hpp__
11 #define __Teko_PreconditionerState_hpp__
12 
13 #include "Teuchos_ParameterListAcceptor.hpp"
14 
15 // Thyra includes
16 // #include "Thyra_SolveSupportTypes.hpp"
17 
18 // Teko includes
19 #include "Teko_Utilities.hpp"
20 
21 namespace Teko {
22 
34 class PreconditionerState : public Teuchos::ParameterListAcceptor {
35  public:
37 
40  : paramList_(Teuchos::rcp(new Teuchos::ParameterList(*src.paramList_))),
42  inverses_(src.inverses_),
45 
47 
48 
50  void setParameterList(const Teuchos::RCP<Teuchos::ParameterList>& paramList);
51 
53  Teuchos::RCP<Teuchos::ParameterList> getNonconstParameterList();
54 
56  Teuchos::RCP<Teuchos::ParameterList> unsetParameterList();
57 
59 
63  virtual bool isInitialized() const { return isInitialized_; }
64 
67  virtual void setInitialized(bool init = true) { isInitialized_ = init; }
68 
70  virtual void setSourceVector(const Teko::MultiVector& srcVec) { srcVector_ = srcVec; }
71 
73  virtual const Teko::MultiVector getSourceVector() const { return srcVector_; }
74 
76  virtual void addInverse(const std::string& name, const Teko::InverseLinearOp& ilo) {
77  inverses_[name] = ilo;
78  }
79 
81  virtual Teko::InverseLinearOp getInverse(const std::string& name) const {
82  std::map<std::string, Teko::InverseLinearOp>::const_iterator itr;
83  itr = inverses_.find(name);
84  if (itr == inverses_.end()) return Teuchos::null;
85  return itr->second;
86  }
87 
89  virtual void addLinearOp(const std::string& name, const Teko::LinearOp& lo) {
90  linearOps_[name] = lo;
91  }
92 
94  virtual Teko::LinearOp getLinearOp(const std::string& name) { return linearOps_[name]; }
95 
97  virtual void addModifiableOp(const std::string& name, const Teko::ModifiableLinearOp& mlo) {
98  modifiableOp_[name] = mlo;
99  }
100 
102  virtual Teko::ModifiableLinearOp& getModifiableOp(const std::string& name) {
103  std::map<std::string, Teko::ModifiableLinearOp>::iterator itr;
104  itr = modifiableOp_.find(name);
105  if (itr == modifiableOp_.end()) return modifiableOp_[name];
106  return itr->second;
107  }
108 
110  virtual void merge(const PreconditionerState& ps, int position = -1);
111 
113  unsigned int getTag() const;
114 
116  void setTag(unsigned int tag);
117 
118  protected:
120  Teuchos::RCP<Teuchos::ParameterList> paramList_;
121 
123  Teko::MultiVector srcVector_;
124 
126  std::map<std::string, Teko::InverseLinearOp> inverses_;
127  std::map<std::string, Teko::ModifiableLinearOp> modifiableOp_;
128  std::map<std::string, Teko::LinearOp> linearOps_;
129 
132 
133  unsigned int tag_;
134 };
135 
136 } // end namespace Teko
137 
138 #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().