43 #ifndef __Panzer_Response_ExtremeValue_impl_hpp__ 44 #define __Panzer_Response_ExtremeValue_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;
68 Teuchos::reduceAll(*this->getComm(), Teuchos::REDUCE_MAX, static_cast<Thyra::Ordinal>(1), &locValue,&glbValue);
70 Teuchos::reduceAll(*this->getComm(), Teuchos::REDUCE_MIN, static_cast<Thyra::Ordinal>(1), &locValue,&glbValue);
74 #ifdef PANZER_HAVE_EPETRA_STACK 76 if(this->useEpetra()) {
78 this->getEpetraVector()[0] = glbValue;
84 TEUCHOS_ASSERT(this->useThyra());
86 this->getThyraVector()[0] = glbValue;
94 using Teuchos::rcp_dynamic_cast;
96 Teuchos::RCP<Thyra::MultiVectorBase<double> > dgdx_unique = getDerivative();
98 uniqueContainer_ = linObjFactory_->buildLinearObjContainer();
103 uniqueContainer_ = Teuchos::null;
106 #ifdef Panzer_BUILD_HESSIAN_SUPPORT 111 using Teuchos::rcp_dynamic_cast;
113 Teuchos::RCP<Thyra::MultiVectorBase<double> > dgdx_unique = getDerivative();
115 uniqueContainer_ = linObjFactory_->buildLinearObjContainer();
120 uniqueContainer_ = Teuchos::null;
128 const int n = value.size();
129 const int num_deriv = this->numDeriv();
130 TEUCHOS_ASSERT(n == 0 || n == num_deriv);
135 Teuchos::reduceAll(*this->getComm(), Teuchos::REDUCE_MAX, Thyra::Ordinal(1), &value.val(), &glbValue.val());
137 Teuchos::reduceAll(*this->getComm(), Teuchos::REDUCE_MIN, Thyra::Ordinal(1), &value.val(), &glbValue.val());
141 int locProc = value.val() == glbValue.val() ? this->getComm()->getRank() : this->getComm()->getSize();
143 Teuchos::reduceAll(*this->getComm(), Teuchos::REDUCE_MIN, Thyra::Ordinal(1), &locProc, &glbProc);
146 Teuchos::broadcast(*this->getComm(), glbProc, Thyra::Ordinal(n), &glbValue.fastAccessDx(0));
152 #ifdef PANZER_HAVE_EPETRA_STACK 153 if(this->useEpetra()) {
156 for (
int i=0; i<num_deriv; ++i)
157 deriv[i][0] = glbValue.dx(i);
163 TEUCHOS_ASSERT(this->useThyra());
164 Thyra::ArrayRCP< Thyra::ArrayRCP<double> > deriv = this->getThyraMultiVector();
165 for (
int i=0; i<num_deriv; ++i)
166 deriv[i][0] = glbValue.dx(i);
171 template <
typename EvalT>
180 setDerivativeVectorSpace(soln_vs);
183 #ifdef Panzer_BUILD_HESSIAN_SUPPORT 189 setDerivativeVectorSpace(soln_vs);
194 template <
typename EvalT>
203 linObjFactory_->adjustForDirichletConditions(Teuchos::dyn_cast<const LinearObjContainer>(localBCRows),
204 Teuchos::dyn_cast<const LinearObjContainer>(globalBCRows),
205 *ghostedContainer_,
true,
true);
208 #ifdef Panzer_BUILD_HESSIAN_SUPPORT 214 linObjFactory_->adjustForDirichletConditions(Teuchos::dyn_cast<const LinearObjContainer>(localBCRows),
215 Teuchos::dyn_cast<const LinearObjContainer>(globalBCRows),
216 *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)