1 #ifndef __Panzer_Response_Probe_impl_hpp__ 2 #define __Panzer_Response_Probe_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>
19 have_probe(false), linObjFactory_(linObjFact)
34 template <
typename EvalT>
41 if(ghostedContainer_!=Teuchos::null) ghostedContainer_->initialize();
44 template <
typename EvalT>
48 double glbValue = Sacado::ScalarValue<ScalarT>::eval(
value);
51 int locProc = have_probe ? this->getComm()->getRank() : this->getComm()->getSize();
53 Teuchos::reduceAll(*this->getComm(), Teuchos::REDUCE_MIN, Thyra::Ordinal(1), &locProc, &glbProc);
55 TEUCHOS_ASSERT(glbProc < this->getComm()->getSize());
58 Teuchos::broadcast(*this->getComm(), glbProc, Thyra::Ordinal(1), &glbValue);
63 if(this->useEpetra()) {
65 this->getEpetraVector()[0] = glbValue;
69 TEUCHOS_ASSERT(this->useThyra());
71 this->getThyraVector()[0] = glbValue;
79 using Teuchos::rcp_dynamic_cast;
81 Teuchos::RCP<Thyra::MultiVectorBase<double> > dgdx_unique = getDerivative();
83 uniqueContainer_ = linObjFactory_->buildLinearObjContainer();
88 uniqueContainer_ = Teuchos::null;
91 #ifdef Panzer_BUILD_HESSIAN_SUPPORT 96 using Teuchos::rcp_dynamic_cast;
98 Teuchos::RCP<Thyra::MultiVectorBase<double> > dgdx_unique = getDerivative();
100 uniqueContainer_ = linObjFactory_->buildLinearObjContainer();
105 uniqueContainer_ = Teuchos::null;
113 const int n =
value.size();
114 const int num_deriv = this->numDeriv();
115 TEUCHOS_ASSERT(n == 0 || n == num_deriv);
117 value.resize(num_deriv);
121 int locProc = have_probe ? this->getComm()->getRank() : this->getComm()->getSize();
123 Teuchos::reduceAll(*this->getComm(), Teuchos::REDUCE_MIN, Thyra::Ordinal(1), &locProc, &glbProc);
125 TEUCHOS_ASSERT(glbProc < this->getComm()->getSize());
128 Teuchos::broadcast(*this->getComm(), glbProc, Thyra::Ordinal(num_deriv), &
value.fastAccessDx(0));
132 if(this->useEpetra()) {
134 Epetra_MultiVector& deriv = this->getEpetraMultiVector();
135 for (
int i=0; i<num_deriv; ++i)
136 deriv[i][0] =
value.dx(i);
140 TEUCHOS_ASSERT(this->useThyra());
141 Thyra::ArrayRCP< Thyra::ArrayRCP<double> > deriv = this->getThyraMultiVector();
142 for (
int i=0; i<num_deriv; ++i)
143 deriv[i][0] =
value.dx(i);
148 template <
typename EvalT>
157 setDerivativeVectorSpace(soln_vs);
160 #ifdef Panzer_BUILD_HESSIAN_SUPPORT 166 setDerivativeVectorSpace(soln_vs);
171 template <
typename EvalT>
180 linObjFactory_->adjustForDirichletConditions(Teuchos::dyn_cast<const LinearObjContainer>(localBCRows),
181 Teuchos::dyn_cast<const LinearObjContainer>(globalBCRows),
182 *ghostedContainer_,
true,
true);
185 #ifdef Panzer_BUILD_HESSIAN_SUPPORT 191 linObjFactory_->adjustForDirichletConditions(Teuchos::dyn_cast<const LinearObjContainer>(localBCRows),
192 Teuchos::dyn_cast<const LinearObjContainer>(globalBCRows),
193 *ghostedContainer_,
true,
true);
virtual void scatterResponse()
This simply does global summation, then shoves the result into a vector.
Teuchos::RCP< LinearObjContainer > ghostedContainer_
Teuchos::RCP< const panzer::LinearObjFactory< panzer::Traits > > linObjFactory_
void adjustForDirichletConditions(const GlobalEvaluationData &localBCRows, const GlobalEvaluationData &globalBCRows)
Teuchos::RCP< const panzer::ThyraObjFactory< double > > thyraObjFactory_
Teuchos::RCP< const Teuchos::Comm< int > > comm
void setSolnVectorSpace(const Teuchos::RCP< const Thyra::VectorSpaceBase< double > > &soln_vs)
Set solution vector space.
virtual void initializeResponse()