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>
139 auto cellIntegral_h = Kokkos::create_mirror_view ( cellIntegral_.get_static_view());
140 Kokkos::deep_copy(cellIntegral_h, cellIntegral_.get_static_view());
142 responseObj_->value += cellIntegral_h(i);
151 using Teuchos::rcp_dynamic_cast;
152 using Thyra::SpmdVectorBase;
155 TEUCHOS_ASSERT(scatterObj_!=Teuchos::null);
156 TEUCHOS_ASSERT(responseObj_->getGhostedVector()!=Teuchos::null);
158 RCP<ProductVectorBase<double> > prod_dgdx = Thyra::castOrCreateNonconstProductVectorBase(responseObj_->getGhostedVector());
160 std::vector<Teuchos::ArrayRCP<double> > local_dgdxs;
161 for(
int b=0;b<prod_dgdx->productSpace()->numBlocks();b++) {
163 Teuchos::ArrayRCP<double> local_dgdx;
164 RCP<SpmdVectorBase<double> > dgdx = rcp_dynamic_cast<SpmdVectorBase<double> >(prod_dgdx->getNonconstVectorBlock(b));
165 dgdx->getNonconstLocalData(ptrFromRef(local_dgdx));
167 TEUCHOS_ASSERT(!local_dgdx.is_null());
169 local_dgdxs.push_back(local_dgdx);
172 scatterObj_->scatterDerivative(cellIntegral_,d,this->wda,local_dgdxs);
175 #ifdef Panzer_BUILD_HESSIAN_SUPPORT 181 using Teuchos::rcp_dynamic_cast;
182 using Thyra::SpmdVectorBase;
185 TEUCHOS_ASSERT(scatterObj_!=Teuchos::null);
186 TEUCHOS_ASSERT(responseObj_->getGhostedVector()!=Teuchos::null);
188 RCP<ProductVectorBase<double> > prod_dgdx = Thyra::castOrCreateNonconstProductVectorBase(responseObj_->getGhostedVector());
190 std::vector<Teuchos::ArrayRCP<double> > local_dgdxs;
191 for(
int b=0;b<prod_dgdx->productSpace()->numBlocks();b++) {
193 Teuchos::ArrayRCP<double> local_dgdx;
194 RCP<SpmdVectorBase<double> > dgdx = rcp_dynamic_cast<SpmdVectorBase<double> >(prod_dgdx->getNonconstVectorBlock(b));
195 dgdx->getNonconstLocalData(ptrFromRef(local_dgdx));
197 TEUCHOS_ASSERT(!local_dgdx.is_null());
199 local_dgdxs.push_back(local_dgdx);
203 scatterObj_->scatterHessian(cellIntegral_,d,this->wda,local_dgdxs);
Teuchos::RCP< GlobalEvaluationDataContainer > gedc
int num_cells
DEPRECATED - use: numCells()
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