43 #ifndef PANZER_RESPONSE_SCATTER_EVALUATOR_FUNCTIONAL_IMPL_HPP 44 #define PANZER_RESPONSE_SCATTER_EVALUATOR_FUNCTIONAL_IMPL_HPP 49 #include "PanzerDiscFE_config.hpp" 51 #include "Phalanx_Evaluator_Macros.hpp" 52 #include "Phalanx_MDField.hpp" 53 #include "Phalanx_DataLayout_MDALayout.hpp" 59 #include "Thyra_DefaultProductVector.hpp" 60 #include "Thyra_SpmdVectorBase.hpp" 61 #include "Thyra_ProductVectorBase.hpp" 63 #include "Teuchos_ArrayRCP.hpp" 70 template<
typename EvalT,
typename Traits>
74 const Teuchos::RCP<FunctionalScatterBase> & functionalScatter)
76 , scatterObj_(functionalScatter)
84 RCP<PHX::DataLayout> dl_dummy = rcp(
new PHX::MDALayout<panzer::Dummy>(0));
89 RCP<PHX::DataLayout> dl_cell = rcp(
new PHX::MDALayout<panzer::Cell>(cd.
numCells()));
90 cellIntegral_ = PHX::MDField<const ScalarT,panzer::Cell>(name,dl_cell);
93 std::string n =
"Functional Response Scatter: " + name;
97 template<
typename EvalT,
typename Traits>
100 const std::string & responseName,
102 const Teuchos::RCP<FunctionalScatterBase> & functionalScatter)
103 : responseName_(responseName)
104 , scatterObj_(functionalScatter)
112 RCP<PHX::DataLayout> dl_dummy = rcp(
new PHX::MDALayout<panzer::Dummy>(0));
117 RCP<PHX::DataLayout> dl_cell = rcp(
new PHX::MDALayout<panzer::Cell>(cd.
numCells()));
118 cellIntegral_ = PHX::MDField<const ScalarT,panzer::Cell>(integrandName,dl_cell);
121 std::string n =
"Functional Response Scatter: " + responseName;
125 template<
typename EvalT,
typename Traits>
135 template<
typename EvalT,
typename Traits>
140 responseObj_->value += cellIntegral_(i);
149 using Teuchos::rcp_dynamic_cast;
150 using Thyra::SpmdVectorBase;
153 TEUCHOS_ASSERT(scatterObj_!=Teuchos::null);
154 TEUCHOS_ASSERT(responseObj_->getGhostedVector()!=Teuchos::null);
156 RCP<ProductVectorBase<double> > prod_dgdx = Thyra::castOrCreateNonconstProductVectorBase(responseObj_->getGhostedVector());
158 std::vector<Teuchos::ArrayRCP<double> > local_dgdxs;
159 for(
int b=0;b<prod_dgdx->productSpace()->numBlocks();b++) {
161 Teuchos::ArrayRCP<double> local_dgdx;
162 RCP<SpmdVectorBase<double> > dgdx = rcp_dynamic_cast<SpmdVectorBase<double> >(prod_dgdx->getNonconstVectorBlock(b));
163 dgdx->getNonconstLocalData(ptrFromRef(local_dgdx));
165 TEUCHOS_ASSERT(!local_dgdx.is_null());
167 local_dgdxs.push_back(local_dgdx);
170 scatterObj_->scatterDerivative(cellIntegral_,d,this->wda,local_dgdxs);
173 #ifdef Panzer_BUILD_HESSIAN_SUPPORT 179 using Teuchos::rcp_dynamic_cast;
180 using Thyra::SpmdVectorBase;
183 TEUCHOS_ASSERT(scatterObj_!=Teuchos::null);
184 TEUCHOS_ASSERT(responseObj_->getGhostedVector()!=Teuchos::null);
186 RCP<ProductVectorBase<double> > prod_dgdx = Thyra::castOrCreateNonconstProductVectorBase(responseObj_->getGhostedVector());
188 std::vector<Teuchos::ArrayRCP<double> > local_dgdxs;
189 for(
int b=0;b<prod_dgdx->productSpace()->numBlocks();b++) {
191 Teuchos::ArrayRCP<double> local_dgdx;
192 RCP<SpmdVectorBase<double> > dgdx = rcp_dynamic_cast<SpmdVectorBase<double> >(prod_dgdx->getNonconstVectorBlock(b));
193 dgdx->getNonconstLocalData(ptrFromRef(local_dgdx));
195 TEUCHOS_ASSERT(!local_dgdx.is_null());
197 local_dgdxs.push_back(local_dgdx);
201 scatterObj_->scatterHessian(cellIntegral_,d,this->wda,local_dgdxs);
Teuchos::RCP< GlobalEvaluationDataContainer > gedc
ResponseScatterEvaluator_Functional(const std::string &name, const CellData &cd, const Teuchos::RCP< FunctionalScatterBase > &functionalScatter)
A constructor with concrete arguments instead of a parameter list.
static std::string buildLookupName(const std::string &responseName)
void preEvaluate(typename Traits::PreEvalData d)
PHX::MDField< const ScalarT, panzer::Cell > cellIntegral_
Data for determining cell topology and dimensionality.
void evaluateFields(typename Traits::EvalData d)
Teuchos::RCP< PHX::FieldTag > scatterHolder_
std::size_t numCells() const