11 #ifndef __Panzer_Response_ExtremeValue_impl_hpp__
12 #define __Panzer_Response_ExtremeValue_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;
36 Teuchos::reduceAll(*this->getComm(),
Teuchos::REDUCE_MAX, static_cast<Thyra::Ordinal>(1), &locValue,&glbValue);
38 Teuchos::reduceAll(*this->getComm(),
Teuchos::REDUCE_MIN, static_cast<Thyra::Ordinal>(1), &locValue,&glbValue);
42 #ifdef PANZER_HAVE_EPETRA_STACK
44 if(this->useEpetra()) {
46 this->getEpetraVector()[0] = glbValue;
54 this->getThyraVector()[0] = glbValue;
62 using Teuchos::rcp_dynamic_cast;
66 uniqueContainer_ = linObjFactory_->buildLinearObjContainer();
71 uniqueContainer_ = Teuchos::null;
74 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
79 using Teuchos::rcp_dynamic_cast;
83 uniqueContainer_ = linObjFactory_->buildLinearObjContainer();
88 uniqueContainer_ = Teuchos::null;
96 const int n = value.size();
97 const int num_deriv = this->numDeriv();
103 Teuchos::reduceAll(*this->getComm(),
Teuchos::REDUCE_MAX, Thyra::Ordinal(1), &value.val(), &glbValue.val());
105 Teuchos::reduceAll(*this->getComm(),
Teuchos::REDUCE_MIN, Thyra::Ordinal(1), &value.val(), &glbValue.val());
109 int locProc = value.val() == glbValue.val() ? this->getComm()->getRank() : this->getComm()->getSize();
111 Teuchos::reduceAll(*this->getComm(),
Teuchos::REDUCE_MIN, Thyra::Ordinal(1), &locProc, &glbProc);
114 Teuchos::broadcast(*this->getComm(), glbProc, Thyra::Ordinal(n), &glbValue.fastAccessDx(0));
120 #ifdef PANZER_HAVE_EPETRA_STACK
121 if(this->useEpetra()) {
124 for (
int i=0; i<num_deriv; ++i)
125 deriv[i][0] = glbValue.dx(i);
132 Thyra::ArrayRCP< Thyra::ArrayRCP<double> > deriv = this->getThyraMultiVector();
133 for (
int i=0; i<num_deriv; ++i)
134 deriv[i][0] = glbValue.dx(i);
139 template <
typename EvalT>
148 setDerivativeVectorSpace(soln_vs);
151 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
157 setDerivativeVectorSpace(soln_vs);
162 template <
typename EvalT>
171 linObjFactory_->adjustForDirichletConditions(Teuchos::dyn_cast<const LinearObjContainer>(localBCRows),
172 Teuchos::dyn_cast<const LinearObjContainer>(globalBCRows),
173 *ghostedContainer_,
true,
true);
176 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
182 linObjFactory_->adjustForDirichletConditions(Teuchos::dyn_cast<const LinearObjContainer>(localBCRows),
183 Teuchos::dyn_cast<const LinearObjContainer>(globalBCRows),
184 *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)