11 #ifndef __Panzer_Response_Functional_impl_hpp__
12 #define __Panzer_Response_Functional_impl_hpp__
14 #include "Teuchos_Comm.hpp"
15 #include "Teuchos_CommHelpers.hpp"
16 #include "Teuchos_dyn_cast.hpp"
18 #include "PanzerDiscFE_config.hpp"
19 #ifdef PANZER_HAVE_EPETRA_STACK
20 #include "Epetra_LocalMap.h"
23 #include "Sacado_Traits.hpp"
27 template <
typename EvalT>
31 double locValue = Sacado::scalarValue(value);
32 double glbValue = 0.0;
35 Teuchos::reduceAll(*this->getComm(),
Teuchos::REDUCE_SUM, static_cast<Thyra::Ordinal>(1), &locValue,&glbValue);
40 #ifdef PANZER_HAVE_EPETRA_STACK
41 if(this->useEpetra()) {
43 this->getEpetraVector()[0] = glbValue;
51 this->getThyraVector()[0] = glbValue;
59 using Teuchos::rcp_dynamic_cast;
64 if(dgdx_unique==Teuchos::null)
67 uniqueContainer_ = linObjFactory_->buildLinearObjContainer();
72 uniqueContainer_ = Teuchos::null;
75 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
80 using Teuchos::rcp_dynamic_cast;
85 if(dgdx_unique==Teuchos::null)
88 uniqueContainer_ = linObjFactory_->buildLinearObjContainer();
93 uniqueContainer_ = Teuchos::null;
101 const int n = value.size();
102 const int num_deriv = this->numDeriv();
109 Teuchos::reduceAll(*this->getComm(),
Teuchos::REDUCE_SUM, Thyra::Ordinal(1), &value.val(), &glbValue.val());
111 Teuchos::reduceAll(*this->getComm(),
Teuchos::REDUCE_SUM, Thyra::Ordinal(n), value.dx(), &glbValue.fastAccessDx(0));
116 #ifdef PANZER_HAVE_EPETRA_STACK
117 if(this->useEpetra()) {
120 for (
int i=0; i<num_deriv; ++i)
121 deriv[i][0] = glbValue.dx(i);
128 Thyra::ArrayRCP< Thyra::ArrayRCP<double> > deriv = this->getThyraMultiVector();
129 for (
int i=0; i<num_deriv; ++i)
130 deriv[i][0] = glbValue.dx(i);
135 template <
typename EvalT>
144 setDerivativeVectorSpace(soln_vs);
148 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
153 setDerivativeVectorSpace(soln_vs);
158 template <
typename EvalT>
167 linObjFactory_->adjustForDirichletConditions(Teuchos::dyn_cast<const LinearObjContainer>(localBCRows),
168 Teuchos::dyn_cast<const LinearObjContainer>(globalBCRows),
169 *ghostedContainer_,
true,
true);
172 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
178 linObjFactory_->adjustForDirichletConditions(Teuchos::dyn_cast<const LinearObjContainer>(localBCRows),
179 Teuchos::dyn_cast<const LinearObjContainer>(globalBCRows),
180 *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)