Panzer Version of the Day
Loading...
Searching...
No Matches
Panzer_Response_Residual.cpp
Go to the documentation of this file.
2
5
6#include "Thyra_VectorSpaceBase.hpp"
7
8namespace panzer {
9
12
13Teuchos::RCP<Thyra::VectorBase<panzer::Traits::RealType> >
16{
17 using Teuchos::RCP;
18 using Teuchos::rcp_dynamic_cast;
19
21
22 // if already computed, uses that ghosted vector
23 if(ghostedResidual_!=Teuchos::null)
24 return ghostedResidual_;
25
26 // otherwise, allocate a new ghosted vector
27 RCP<LinearObjContainer> loc = linObjFactory_->buildGhostedLinearObjContainer();
28 linObjFactory_->initializeGhostedContainer(LinearObjContainer::F,*loc);
29
30 RCP<TOC> th_loc = rcp_dynamic_cast<TOC>(loc);
31 return th_loc->get_f_th();
32}
33
34Teuchos::RCP<Thyra::VectorBase<panzer::Traits::RealType> >
36getResidual() const
37{
38 return residual_;
39}
40
41void
44{
45 residual_ = res;
46}
47
48Teuchos::RCP<Thyra::VectorBase<panzer::Traits::RealType> >
51{
52 using Teuchos::RCP;
53 using Teuchos::rcp_dynamic_cast;
54
56
57 RCP<const ObjFactory> objFactory = rcp_dynamic_cast<const ObjFactory>(linObjFactory_);
58 return Thyra::createMember(objFactory->getThyraRangeSpace());
59}
60
63
64Teuchos::RCP<Thyra::LinearOpBase<panzer::Traits::RealType> >
67{
68 using Teuchos::RCP;
69 using Teuchos::rcp_dynamic_cast;
70
72
73 // if already computed, uses that ghosted vector
74 if(ghostedJacobian_!=Teuchos::null)
75 return ghostedJacobian_;
76
77 // otherwise, allocate a new ghosted vector
78 RCP<LinearObjContainer> loc = linObjFactory_->buildGhostedLinearObjContainer();
79 linObjFactory_->initializeGhostedContainer(LinearObjContainer::Mat,*loc);
80
81 RCP<TOC> th_loc = rcp_dynamic_cast<TOC>(loc);
82 return th_loc->get_A_th();
83}
84
85Teuchos::RCP<Thyra::LinearOpBase<panzer::Traits::RealType> >
87getJacobian() const
88{
89 return jacobian_;
90}
91
92void
95{
96 jacobian_ = jac;
97}
98
99Teuchos::RCP<Thyra::LinearOpBase<panzer::Traits::RealType> >
101allocateJacobian() const
102{
103 using Teuchos::RCP;
104 using Teuchos::rcp_dynamic_cast;
105
107
108 RCP<const ObjFactory> objFactory = rcp_dynamic_cast<const ObjFactory>(linObjFactory_);
109 return objFactory->getThyraMatrix();
110}
111
114
115#ifdef Panzer_BUILD_HESSIAN_SUPPORT
116
117Teuchos::RCP<Thyra::LinearOpBase<panzer::Traits::RealType> >
119getGhostedHessian() const
120{
121 using Teuchos::RCP;
122 using Teuchos::rcp_dynamic_cast;
123
125
126 // if already computed, uses that ghosted vector
127 if(ghostedHessian_!=Teuchos::null)
128 return ghostedHessian_;
129
130 // otherwise, allocate a new ghosted vector
131 RCP<LinearObjContainer> loc = linObjFactory_->buildGhostedLinearObjContainer();
132 linObjFactory_->initializeGhostedContainer(LinearObjContainer::Mat,*loc);
133
134 RCP<TOC> th_loc = rcp_dynamic_cast<TOC>(loc);
135 return th_loc->get_A_th();
136}
137
138Teuchos::RCP<Thyra::LinearOpBase<panzer::Traits::RealType> >
140getHessian() const
141{
142 return hessian_;
143}
144
145void
148{
149 hessian_ = jac;
150}
151
152Teuchos::RCP<Thyra::LinearOpBase<panzer::Traits::RealType> >
154allocateHessian() const
155{
156 using Teuchos::RCP;
157 using Teuchos::rcp_dynamic_cast;
158
160
161 RCP<const ObjFactory> objFactory = rcp_dynamic_cast<const ObjFactory>(linObjFactory_);
162 return objFactory->getThyraMatrix();
163}
164#endif
165
168
169} // end namespace panzer