1 #ifndef __Panzer_Response_ExtremeValue_impl_hpp__ 2 #define __Panzer_Response_ExtremeValue_impl_hpp__ 4 #include "Teuchos_Comm.hpp" 5 #include "Teuchos_CommHelpers.hpp" 6 #include "Teuchos_dyn_cast.hpp" 8 #include "Epetra_LocalMap.h" 10 #include "Sacado_Traits.hpp" 14 template <
typename EvalT>
18 double locValue = Sacado::ScalarValue<ScalarT>::eval(
value);
19 double glbValue = 0.0;
23 Teuchos::reduceAll(*this->getComm(), Teuchos::REDUCE_MAX, static_cast<Thyra::Ordinal>(1), &locValue,&glbValue);
25 Teuchos::reduceAll(*this->getComm(), Teuchos::REDUCE_MIN, static_cast<Thyra::Ordinal>(1), &locValue,&glbValue);
30 if(this->useEpetra()) {
32 this->getEpetraVector()[0] = glbValue;
36 TEUCHOS_ASSERT(this->useThyra());
38 this->getThyraVector()[0] = glbValue;
46 using Teuchos::rcp_dynamic_cast;
48 Teuchos::RCP<Thyra::MultiVectorBase<double> > dgdx_unique = getDerivative();
50 uniqueContainer_ = linObjFactory_->buildLinearObjContainer();
55 uniqueContainer_ = Teuchos::null;
58 #ifdef Panzer_BUILD_HESSIAN_SUPPORT 63 using Teuchos::rcp_dynamic_cast;
65 Teuchos::RCP<Thyra::MultiVectorBase<double> > dgdx_unique = getDerivative();
67 uniqueContainer_ = linObjFactory_->buildLinearObjContainer();
72 uniqueContainer_ = Teuchos::null;
80 const int n =
value.size();
81 const int num_deriv = this->numDeriv();
82 TEUCHOS_ASSERT(n == 0 || n == num_deriv);
87 Teuchos::reduceAll(*this->getComm(), Teuchos::REDUCE_MAX, Thyra::Ordinal(1), &
value.val(), &glbValue.val());
89 Teuchos::reduceAll(*this->getComm(), Teuchos::REDUCE_MIN, Thyra::Ordinal(1), &
value.val(), &glbValue.val());
93 int locProc =
value.val() == glbValue.val() ? this->getComm()->getRank() : this->getComm()->getSize();
95 Teuchos::reduceAll(*this->getComm(), Teuchos::REDUCE_MIN, Thyra::Ordinal(1), &locProc, &glbProc);
98 Teuchos::broadcast(*this->getComm(), glbProc, Thyra::Ordinal(n), &glbValue.fastAccessDx(0));
104 if(this->useEpetra()) {
106 Epetra_MultiVector& deriv = this->getEpetraMultiVector();
107 for (
int i=0; i<num_deriv; ++i)
108 deriv[i][0] = glbValue.dx(i);
112 TEUCHOS_ASSERT(this->useThyra());
113 Thyra::ArrayRCP< Thyra::ArrayRCP<double> > deriv = this->getThyraMultiVector();
114 for (
int i=0; i<num_deriv; ++i)
115 deriv[i][0] = glbValue.dx(i);
120 template <
typename EvalT>
129 setDerivativeVectorSpace(soln_vs);
132 #ifdef Panzer_BUILD_HESSIAN_SUPPORT 138 setDerivativeVectorSpace(soln_vs);
143 template <
typename EvalT>
152 linObjFactory_->adjustForDirichletConditions(Teuchos::dyn_cast<const LinearObjContainer>(localBCRows),
153 Teuchos::dyn_cast<const LinearObjContainer>(globalBCRows),
154 *ghostedContainer_,
true,
true);
157 #ifdef Panzer_BUILD_HESSIAN_SUPPORT 163 linObjFactory_->adjustForDirichletConditions(Teuchos::dyn_cast<const LinearObjContainer>(localBCRows),
164 Teuchos::dyn_cast<const LinearObjContainer>(globalBCRows),
165 *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)