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 "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;
65 Teuchos::reduceAll(*this->getComm(),
Teuchos::REDUCE_MAX, static_cast<Thyra::Ordinal>(1), &locValue,&glbValue);
67 Teuchos::reduceAll(*this->getComm(),
Teuchos::REDUCE_MIN, static_cast<Thyra::Ordinal>(1), &locValue,&glbValue);
72 if(this->useEpetra()) {
74 this->getEpetraVector()[0] = glbValue;
80 this->getThyraVector()[0] = glbValue;
88 using Teuchos::rcp_dynamic_cast;
92 uniqueContainer_ = linObjFactory_->buildLinearObjContainer();
97 uniqueContainer_ = Teuchos::null;
100 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
105 using Teuchos::rcp_dynamic_cast;
109 uniqueContainer_ = linObjFactory_->buildLinearObjContainer();
114 uniqueContainer_ = Teuchos::null;
122 const int n = value.size();
123 const int num_deriv = this->numDeriv();
129 Teuchos::reduceAll(*this->getComm(),
Teuchos::REDUCE_MAX, Thyra::Ordinal(1), &value.val(), &glbValue.val());
131 Teuchos::reduceAll(*this->getComm(),
Teuchos::REDUCE_MIN, Thyra::Ordinal(1), &value.val(), &glbValue.val());
135 int locProc = value.val() == glbValue.val() ? this->getComm()->getRank() : this->getComm()->getSize();
137 Teuchos::reduceAll(*this->getComm(),
Teuchos::REDUCE_MIN, Thyra::Ordinal(1), &locProc, &glbProc);
140 Teuchos::broadcast(*this->getComm(), glbProc, Thyra::Ordinal(n), &glbValue.fastAccessDx(0));
146 if(this->useEpetra()) {
149 for (
int i=0; i<num_deriv; ++i)
150 deriv[i][0] = glbValue.dx(i);
155 Thyra::ArrayRCP< Thyra::ArrayRCP<double> > deriv = this->getThyraMultiVector();
156 for (
int i=0; i<num_deriv; ++i)
157 deriv[i][0] = glbValue.dx(i);
162 template <
typename EvalT>
171 setDerivativeVectorSpace(soln_vs);
174 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
180 setDerivativeVectorSpace(soln_vs);
185 template <
typename EvalT>
194 linObjFactory_->adjustForDirichletConditions(Teuchos::dyn_cast<const LinearObjContainer>(localBCRows),
195 Teuchos::dyn_cast<const LinearObjContainer>(globalBCRows),
196 *ghostedContainer_,
true,
true);
199 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
205 linObjFactory_->adjustForDirichletConditions(Teuchos::dyn_cast<const LinearObjContainer>(localBCRows),
206 Teuchos::dyn_cast<const LinearObjContainer>(globalBCRows),
207 *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)
#define TEUCHOS_ASSERT(assertion_test)