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 "Epetra_LocalMap.h"
52 #include "Sacado_Traits.hpp"
56 template <
typename EvalT>
60 double locValue = Sacado::ScalarValue<ScalarT>::eval(value);
61 double glbValue = 0.0;
64 Teuchos::reduceAll(*this->getComm(),
Teuchos::REDUCE_SUM, static_cast<Thyra::Ordinal>(1), &locValue,&glbValue);
69 if(this->useEpetra()) {
71 this->getEpetraVector()[0] = glbValue;
77 this->getThyraVector()[0] = glbValue;
85 using Teuchos::rcp_dynamic_cast;
90 if(dgdx_unique==Teuchos::null)
93 uniqueContainer_ = linObjFactory_->buildLinearObjContainer();
98 uniqueContainer_ = Teuchos::null;
101 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
106 using Teuchos::rcp_dynamic_cast;
111 if(dgdx_unique==Teuchos::null)
114 uniqueContainer_ = linObjFactory_->buildLinearObjContainer();
119 uniqueContainer_ = Teuchos::null;
127 const int n = value.size();
128 const int num_deriv = this->numDeriv();
135 Teuchos::reduceAll(*this->getComm(),
Teuchos::REDUCE_SUM, Thyra::Ordinal(1), &value.val(), &glbValue.val());
137 Teuchos::reduceAll(*this->getComm(),
Teuchos::REDUCE_SUM, Thyra::Ordinal(n), value.dx(), &glbValue.fastAccessDx(0));
142 if(this->useEpetra()) {
145 for (
int i=0; i<num_deriv; ++i)
146 deriv[i][0] = glbValue.dx(i);
151 Thyra::ArrayRCP< Thyra::ArrayRCP<double> > deriv = this->getThyraMultiVector();
152 for (
int i=0; i<num_deriv; ++i)
153 deriv[i][0] = glbValue.dx(i);
158 template <
typename EvalT>
167 setDerivativeVectorSpace(soln_vs);
171 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
176 setDerivativeVectorSpace(soln_vs);
181 template <
typename EvalT>
190 linObjFactory_->adjustForDirichletConditions(Teuchos::dyn_cast<const LinearObjContainer>(localBCRows),
191 Teuchos::dyn_cast<const LinearObjContainer>(globalBCRows),
192 *ghostedContainer_,
true,
true);
195 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
201 linObjFactory_->adjustForDirichletConditions(Teuchos::dyn_cast<const LinearObjContainer>(localBCRows),
202 Teuchos::dyn_cast<const LinearObjContainer>(globalBCRows),
203 *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.
#define TEUCHOS_ASSERT(assertion_test)
void adjustForDirichletConditions(const GlobalEvaluationData &localBCRows, const GlobalEvaluationData &globalBCRows)