Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_Response_Residual.cpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Panzer: A partial differential equation assembly
4 // engine for strongly coupled complex multiphysics systems
5 //
6 // Copyright 2011 NTESS and the Panzer contributors.
7 // SPDX-License-Identifier: BSD-3-Clause
8 // *****************************************************************************
9 // @HEADER
10 
12 
15 
16 #include "Thyra_VectorSpaceBase.hpp"
17 
18 namespace panzer {
19 
22 
26 {
27  using Teuchos::RCP;
28  using Teuchos::rcp_dynamic_cast;
29 
31 
32  // if already computed, uses that ghosted vector
33  if(ghostedResidual_!=Teuchos::null)
34  return ghostedResidual_;
35 
36  // otherwise, allocate a new ghosted vector
37  RCP<LinearObjContainer> loc = linObjFactory_->buildGhostedLinearObjContainer();
38  linObjFactory_->initializeGhostedContainer(LinearObjContainer::F,*loc);
39 
40  RCP<TOC> th_loc = rcp_dynamic_cast<TOC>(loc);
41  return th_loc->get_f_th();
42 }
43 
46 getResidual() const
47 {
48  return residual_;
49 }
50 
51 void
54 {
55  residual_ = res;
56 }
57 
61 {
62  using Teuchos::RCP;
63  using Teuchos::rcp_dynamic_cast;
64 
66 
67  RCP<const ObjFactory> objFactory = rcp_dynamic_cast<const ObjFactory>(linObjFactory_);
68  return Thyra::createMember(objFactory->getThyraRangeSpace());
69 }
70 
73 
77 {
78  using Teuchos::RCP;
79  using Teuchos::rcp_dynamic_cast;
80 
82 
83  // if already computed, uses that ghosted vector
84  if(ghostedJacobian_!=Teuchos::null)
85  return ghostedJacobian_;
86 
87  // otherwise, allocate a new ghosted vector
88  RCP<LinearObjContainer> loc = linObjFactory_->buildGhostedLinearObjContainer();
89  linObjFactory_->initializeGhostedContainer(LinearObjContainer::Mat,*loc);
90 
91  RCP<TOC> th_loc = rcp_dynamic_cast<TOC>(loc);
92  return th_loc->get_A_th();
93 }
94 
97 getJacobian() const
98 {
99  return jacobian_;
100 }
101 
102 void
105 {
106  jacobian_ = jac;
107 }
108 
112 {
113  using Teuchos::RCP;
114  using Teuchos::rcp_dynamic_cast;
115 
117 
118  RCP<const ObjFactory> objFactory = rcp_dynamic_cast<const ObjFactory>(linObjFactory_);
119  return objFactory->getThyraMatrix();
120 }
121 
124 
125 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
126 
130 {
131  using Teuchos::RCP;
132  using Teuchos::rcp_dynamic_cast;
133 
135 
136  // if already computed, uses that ghosted vector
137  if(ghostedHessian_!=Teuchos::null)
138  return ghostedHessian_;
139 
140  // otherwise, allocate a new ghosted vector
141  RCP<LinearObjContainer> loc = linObjFactory_->buildGhostedLinearObjContainer();
142  linObjFactory_->initializeGhostedContainer(LinearObjContainer::Mat,*loc);
143 
144  RCP<TOC> th_loc = rcp_dynamic_cast<TOC>(loc);
145  return th_loc->get_A_th();
146 }
147 
150 getHessian() const
151 {
152  return hessian_;
153 }
154 
155 void
158 {
159  hessian_ = jac;
160 }
161 
165 {
166  using Teuchos::RCP;
167  using Teuchos::rcp_dynamic_cast;
168 
170 
171  RCP<const ObjFactory> objFactory = rcp_dynamic_cast<const ObjFactory>(linObjFactory_);
172  return objFactory->getThyraMatrix();
173 }
174 #endif
175 
178 
179 } // end namespace panzer
Teuchos::RCP< Thyra::VectorBase< panzer::Traits::RealType > > getGhostedResidual() const