43 #ifndef __Panzer_Response_Functional_impl_hpp__ 44 #define __Panzer_Response_Functional_impl_hpp__ 46 #include "Teuchos_Comm.hpp" 47 #include "Teuchos_CommHelpers.hpp" 48 #include "Teuchos_dyn_cast.hpp" 50 #include "PanzerDiscFE_config.hpp" 51 #ifdef PANZER_HAVE_EPETRA_STACK 52 #include "Epetra_LocalMap.h" 55 #include "Sacado_Traits.hpp" 59 template <
typename EvalT>
63 double locValue = Sacado::scalarValue(value);
64 double glbValue = 0.0;
67 Teuchos::reduceAll(*this->getComm(), Teuchos::REDUCE_SUM, static_cast<Thyra::Ordinal>(1), &locValue,&glbValue);
72 #ifdef PANZER_HAVE_EPETRA_STACK 73 if(this->useEpetra()) {
75 this->getEpetraVector()[0] = glbValue;
81 TEUCHOS_ASSERT(this->useThyra());
83 this->getThyraVector()[0] = glbValue;
91 using Teuchos::rcp_dynamic_cast;
93 Teuchos::RCP<Thyra::MultiVectorBase<double> > dgdx_unique = getDerivative();
96 if(dgdx_unique==Teuchos::null)
99 uniqueContainer_ = linObjFactory_->buildLinearObjContainer();
104 uniqueContainer_ = Teuchos::null;
107 #ifdef Panzer_BUILD_HESSIAN_SUPPORT 112 using Teuchos::rcp_dynamic_cast;
114 Teuchos::RCP<Thyra::MultiVectorBase<double> > dgdx_unique = getDerivative();
117 if(dgdx_unique==Teuchos::null)
120 uniqueContainer_ = linObjFactory_->buildLinearObjContainer();
125 uniqueContainer_ = Teuchos::null;
133 const int n = value.size();
134 const int num_deriv = this->numDeriv();
135 TEUCHOS_ASSERT(n == 0 || n == num_deriv);
141 Teuchos::reduceAll(*this->getComm(), Teuchos::REDUCE_SUM, Thyra::Ordinal(1), &value.val(), &glbValue.val());
143 Teuchos::reduceAll(*this->getComm(), Teuchos::REDUCE_SUM, Thyra::Ordinal(n), value.dx(), &glbValue.fastAccessDx(0));
148 #ifdef PANZER_HAVE_EPETRA_STACK 149 if(this->useEpetra()) {
152 for (
int i=0; i<num_deriv; ++i)
153 deriv[i][0] = glbValue.dx(i);
159 TEUCHOS_ASSERT(this->useThyra());
160 Thyra::ArrayRCP< Thyra::ArrayRCP<double> > deriv = this->getThyraMultiVector();
161 for (
int i=0; i<num_deriv; ++i)
162 deriv[i][0] = glbValue.dx(i);
167 template <
typename EvalT>
176 setDerivativeVectorSpace(soln_vs);
180 #ifdef Panzer_BUILD_HESSIAN_SUPPORT 185 setDerivativeVectorSpace(soln_vs);
190 template <
typename EvalT>
199 linObjFactory_->adjustForDirichletConditions(Teuchos::dyn_cast<const LinearObjContainer>(localBCRows),
200 Teuchos::dyn_cast<const LinearObjContainer>(globalBCRows),
201 *ghostedContainer_,
true,
true);
204 #ifdef Panzer_BUILD_HESSIAN_SUPPORT 210 linObjFactory_->adjustForDirichletConditions(Teuchos::dyn_cast<const LinearObjContainer>(localBCRows),
211 Teuchos::dyn_cast<const LinearObjContainer>(globalBCRows),
212 *ghostedContainer_,
true,
true);
virtual void scatterResponse()
This simply does global summation, then shoves the result into a vector.
void setSolnVectorSpace(const Teuchos::RCP< const Thyra::VectorSpaceBase< double > > &soln_vs)
Set solution vector space.
void adjustForDirichletConditions(const GlobalEvaluationData &localBCRows, const GlobalEvaluationData &globalBCRows)