Panzer  Version of the Day
Panzer_Response_Residual.hpp
Go to the documentation of this file.
1 #ifndef __Panzer_Response_Residual_hpp__
2 #define __Panzer_Response_Residual_hpp__
3 
4 #include <string>
5 
6 #include "Teuchos_RCP.hpp"
7 
8 #include "Thyra_VectorBase.hpp"
9 #include "Thyra_LinearOpBase.hpp"
10 
11 #include "Panzer_ResponseBase.hpp"
13 #include "Panzer_Traits.hpp"
14 
15 namespace panzer {
16 
21 template <typename EvalT>
23 public:
24  Response_Residual(const std::string & responseName,
25  const Teuchos::RCP<const panzer::LinearObjFactory<panzer::Traits> > & lof) :
26  ResponseBase(responseName) {}
27  virtual ~Response_Residual() {}
28  virtual void scatterResponse() {}
29  virtual void initializeResponse() {}
30 };
31 
38 template < >
40 private:
41  Teuchos::RCP<const panzer::LinearObjFactory<panzer::Traits> > linObjFactory_;
42 
43  Teuchos::RCP<Thyra::VectorBase<panzer::Traits::RealType> > residual_;
44  mutable Teuchos::RCP<Thyra::VectorBase<panzer::Traits::RealType> > ghostedResidual_;
45  // mutable because of lazy construction (as needed)
46 
47 public:
48  Response_Residual(const std::string & responseName,
49  const Teuchos::RCP<const panzer::LinearObjFactory<panzer::Traits> > & lof)
50  : ResponseBase(responseName)
51  , linObjFactory_(lof) {}
52  virtual ~Response_Residual() {}
53 
57  Teuchos::RCP<Thyra::VectorBase<panzer::Traits::RealType> > getGhostedResidual() const;
58 
62  Teuchos::RCP<Thyra::VectorBase<panzer::Traits::RealType> > getResidual() const;
63 
67  void setResidual(const Teuchos::RCP<Thyra::VectorBase<panzer::Traits::RealType> > & res);
68 
72  Teuchos::RCP<Thyra::VectorBase<panzer::Traits::RealType> > allocateResidualVector() const;
73 
74  // Functions inherited from ResponseBase
75  virtual void initializeResponse() {}
76  virtual void scatterResponse() {}
77 };
78 
85 template < >
87 private:
88  Teuchos::RCP<const panzer::LinearObjFactory<panzer::Traits> > linObjFactory_;
89 
90  Teuchos::RCP<Thyra::LinearOpBase<panzer::Traits::RealType> > jacobian_;
91  mutable Teuchos::RCP<Thyra::LinearOpBase<panzer::Traits::RealType> > ghostedJacobian_;
92  // mutable because of lazy construction (as needed)
93 
94 public:
95  Response_Residual(const std::string & responseName,
96  const Teuchos::RCP<const panzer::LinearObjFactory<panzer::Traits> > & lof)
97  : ResponseBase(responseName)
98  , linObjFactory_(lof) {}
99  virtual ~Response_Residual() {}
100 
104  Teuchos::RCP<Thyra::LinearOpBase<panzer::Traits::RealType> > getGhostedJacobian() const;
105 
109  Teuchos::RCP<Thyra::LinearOpBase<panzer::Traits::RealType> > getJacobian() const;
110 
114  void setJacobian(const Teuchos::RCP<Thyra::LinearOpBase<panzer::Traits::RealType> > & res);
115 
119  Teuchos::RCP<Thyra::LinearOpBase<panzer::Traits::RealType> > allocateJacobian() const;
120 
121  // Functions inherited from ResponseBase
122  virtual void initializeResponse() {}
123  virtual void scatterResponse() {}
124 };
125 
126 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
127 
133 template < >
134 class Response_Residual<panzer::Traits::Hessian> : public ResponseBase {
135 private:
136  Teuchos::RCP<const panzer::LinearObjFactory<panzer::Traits> > linObjFactory_;
137 
138  Teuchos::RCP<Thyra::LinearOpBase<panzer::Traits::RealType> > hessian_;
139  mutable Teuchos::RCP<Thyra::LinearOpBase<panzer::Traits::RealType> > ghostedHessian_;
140  // mutable because of lazy construction (as needed)
141 
142 public:
143  Response_Residual(const std::string & responseName,
144  const Teuchos::RCP<const panzer::LinearObjFactory<panzer::Traits> > & lof)
145  : ResponseBase(responseName)
146  , linObjFactory_(lof) {}
147  virtual ~Response_Residual() {}
148 
152  Teuchos::RCP<Thyra::LinearOpBase<panzer::Traits::RealType> > getGhostedHessian() const;
153 
157  Teuchos::RCP<Thyra::LinearOpBase<panzer::Traits::RealType> > getHessian() const;
158 
162  void setHessian(const Teuchos::RCP<Thyra::LinearOpBase<panzer::Traits::RealType> > & res);
163 
167  Teuchos::RCP<Thyra::LinearOpBase<panzer::Traits::RealType> > allocateHessian() const;
168 
169  // Functions inherited from ResponseBase
170  virtual void initializeResponse() {}
171  virtual void scatterResponse() {}
172 };
173 #endif
174 
175 }
176 
177 #endif
Response_Residual(const std::string &responseName, const Teuchos::RCP< const panzer::LinearObjFactory< panzer::Traits > > &lof)
Teuchos::RCP< const panzer::LinearObjFactory< panzer::Traits > > linObjFactory_
Response_Residual(const std::string &responseName, const Teuchos::RCP< const panzer::LinearObjFactory< panzer::Traits > > &lof)
Teuchos::RCP< Thyra::VectorBase< panzer::Traits::RealType > > residual_
Response_Residual(const std::string &responseName, const Teuchos::RCP< const panzer::LinearObjFactory< panzer::Traits > > &lof)
Teuchos::RCP< Thyra::VectorBase< panzer::Traits::RealType > > ghostedResidual_
virtual void scatterResponse()
Prepare the response for access by the user (do global communication)
virtual void scatterResponse()
Prepare the response for access by the user (do global communication)
virtual void scatterResponse()
Prepare the response for access by the user (do global communication)
Teuchos::RCP< Thyra::LinearOpBase< panzer::Traits::RealType > > ghostedJacobian_
Teuchos::RCP< const panzer::LinearObjFactory< panzer::Traits > > linObjFactory_
Teuchos::RCP< Thyra::LinearOpBase< panzer::Traits::RealType > > jacobian_