Teko  Version of the Day
 All Classes Files Functions Variables Pages
Teko_InverseFactory.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_InverseFactory_hpp__
11 #define __Teko_InverseFactory_hpp__
12 
13 // Teuchos includes
14 #include "Teuchos_RCP.hpp"
15 
16 // Thyra includes
17 #include "Thyra_LinearOpWithSolveFactoryBase.hpp"
18 #include "Thyra_PreconditionerFactoryBase.hpp"
19 
20 #include "Teko_Config.h"
21 #include "Teko_Utilities.hpp"
22 #include "Teko_PreconditionerState.hpp"
23 #include "Teko_RequestHandler.hpp"
24 #include "Teko_RequestHandlerContainer.hpp"
25 
26 namespace Teko {
27 
35  public:
36  virtual ~InverseFactory() {}
37 
47  virtual InverseLinearOp buildInverse(const LinearOp& linearOp) const = 0;
48 
61  virtual InverseLinearOp buildInverse(const LinearOp& linearOp,
62  const LinearOp& /* precOp */) const {
63  return buildInverse(linearOp);
64  }
65 
66 #if 0
67 
79  virtual InverseLinearOp buildInverse(const LinearOp & linearOp, const PreconditionerState & parentState) const
80  { return buildInverse(linearOp); }
81 
97  virtual InverseLinearOp buildInverse(const LinearOp & linearOp, const LinearOp & precOp, const PreconditionerState & parentState) const
98  { return buildInverse(linearOp,precOp); }
99 #endif
100 
112  virtual void rebuildInverse(const LinearOp& source, InverseLinearOp& dest) const = 0;
113 
126  virtual void rebuildInverse(const LinearOp& source, const LinearOp& /* precOp */,
127  InverseLinearOp& dest) const {
128  rebuildInverse(source, dest);
129  }
130 
139  virtual Teuchos::RCP<const Teuchos::ParameterList> getParameterList() const = 0;
140 
142  virtual std::string toString() const = 0;
143 
158  virtual Teuchos::RCP<Teuchos::ParameterList> getRequestedParameters() const {
159  return Teuchos::null;
160  }
161 
175  virtual bool updateRequestedParameters(const Teuchos::ParameterList& /* pl */) { return true; }
176 
178  void setRequestHandler(const Teuchos::RCP<RequestHandler>& rh) { callbackHandler_ = rh; }
179 
181  Teuchos::RCP<RequestHandler> getRequestHandler() const { return callbackHandler_; }
182 
183  protected:
185  Teuchos::RCP<RequestHandler> callbackHandler_;
186 };
187 
188 class StaticOpInverseFactory : public InverseFactory {
189  public:
191 
192 
201  StaticOpInverseFactory(const LinearOp inv) : inverse_(inv) {}
202 
204  StaticOpInverseFactory(const StaticOpInverseFactory& saFactory) : inverse_(saFactory.inverse_) {}
206 
207  virtual ~StaticOpInverseFactory() {}
208 
211 
223  virtual InverseLinearOp buildInverse(const LinearOp& /* linearOp */) const {
224  return Teuchos::rcp_const_cast<Thyra::LinearOpBase<double> >(this->inverse_);
225  }
226 
241  virtual void rebuildInverse(const LinearOp& /* source */, InverseLinearOp& /* dest */) const {}
242 
251  virtual Teuchos::RCP<const Teuchos::ParameterList> getParameterList() const {
252  return Teuchos::null;
253  }
254 
256  virtual std::string toString() const { return inverse_->description(); }
257 
258  protected:
259  Teko::LinearOp inverse_;
260 
261  private:
262  // hide me!
263  StaticOpInverseFactory();
264 };
265 
267 
268 
279 InverseLinearOp buildInverse(const InverseFactory& factory, const LinearOp& A);
280 
292 InverseLinearOp buildInverse(const InverseFactory& factory, const LinearOp& A,
293  const LinearOp& precOp);
294 
309 void rebuildInverse(const InverseFactory& factory, const LinearOp& A, InverseLinearOp& invA);
310 
326 void rebuildInverse(const InverseFactory& factory, const LinearOp& A, const LinearOp& precOp,
327  InverseLinearOp& invA);
328 
345 Teuchos::RCP<InverseFactory> invFactoryFromParamList(const Teuchos::ParameterList& list,
346  const std::string& type);
347 
361 Teuchos::RCP<const Teuchos::ParameterList> invFactoryValidParameters();
362 
364 
365 } // end namespace Teko
366 
367 #endif
void rebuildInverse(const InverseFactory &factory, const LinearOp &A, InverseLinearOp &invA)
Abstract class for building an inverse operator.
virtual InverseLinearOp buildInverse(const LinearOp &linearOp) const =0
Build an inverse operator.
Teuchos::RCP< RequestHandler > getRequestHandler() const
Get the request handler with pointers to the appropriate callbacks.
Teuchos::RCP< RequestHandler > callbackHandler_
For handling requests and send requests back to the user.
virtual Teuchos::RCP< Teuchos::ParameterList > getRequestedParameters() const
Request the additional parameters this preconditioner factory needs.
RCP< InverseFactory > invFactoryFromParamList(const Teuchos::ParameterList &list, const std::string &type)
Build an InverseFactory object from a ParameterList, as specified in Stratimikos. ...
virtual std::string toString() const =0
virtual Teuchos::RCP< const Teuchos::ParameterList > getParameterList() const =0
A function that permits inspection of the parameters used to create this object.
virtual InverseLinearOp buildInverse(const LinearOp &linearOp, const LinearOp &) const
Build a preconditioned inverse operator.
virtual bool updateRequestedParameters(const Teuchos::ParameterList &)
Update this object with the fields from a parameter list.
virtual void rebuildInverse(const LinearOp &source, const LinearOp &, InverseLinearOp &dest) const
Pass in an already constructed inverse operator. Update the inverse operator based on the new source ...
InverseLinearOp buildInverse(const InverseFactory &factory, const LinearOp &A)
Build an inverse operator using a factory and a linear operator.
void setRequestHandler(const Teuchos::RCP< RequestHandler > &rh)
Set the request handler with pointers to the appropriate callbacks.
An implementation of a state object preconditioners.
Teuchos::RCP< const Teuchos::ParameterList > invFactoryValidParameters()
Get a valid parameter list for the inverse factory class.
virtual void rebuildInverse(const LinearOp &source, InverseLinearOp &dest) const =0
Pass in an already constructed inverse operator. Update the inverse operator based on the new source ...