43#ifndef __Panzer_Response_Probe_impl_hpp__
44#define __Panzer_Response_Probe_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"
59template <
typename EvalT>
64 have_probe(false), linObjFactory_(linObjFact)
79template <
typename EvalT>
86 if(ghostedContainer_!=Teuchos::null) ghostedContainer_->initialize();
89template <
typename EvalT>
93 double glbValue = Sacado::scalarValue(value);
96 int locProc = have_probe ? this->getComm()->getRank() : this->getComm()->getSize();
98 Teuchos::reduceAll(*this->getComm(), Teuchos::REDUCE_MIN, Thyra::Ordinal(1), &locProc, &glbProc);
100 TEUCHOS_ASSERT(glbProc < this->getComm()->getSize());
103 Teuchos::broadcast(*this->getComm(), glbProc, Thyra::Ordinal(1), &glbValue);
108#ifdef PANZER_HAVE_EPETRA_STACK
109 if(this->useEpetra()) {
111 this->getEpetraVector()[0] = glbValue;
117 TEUCHOS_ASSERT(this->useThyra());
119 this->getThyraVector()[0] = glbValue;
127 using Teuchos::rcp_dynamic_cast;
129 Teuchos::RCP<Thyra::MultiVectorBase<double> > dgdx_unique = getDerivative();
131 uniqueContainer_ = linObjFactory_->buildLinearObjContainer();
132 Teuchos::rcp_dynamic_cast<ThyraObjContainer<double> >(uniqueContainer_)->set_x_th(dgdx_unique->col(0));
136 uniqueContainer_ = Teuchos::null;
139#ifdef Panzer_BUILD_HESSIAN_SUPPORT
144 using Teuchos::rcp_dynamic_cast;
146 Teuchos::RCP<Thyra::MultiVectorBase<double> > dgdx_unique = getDerivative();
148 uniqueContainer_ = linObjFactory_->buildLinearObjContainer();
149 Teuchos::rcp_dynamic_cast<ThyraObjContainer<double> >(uniqueContainer_)->set_x_th(dgdx_unique->col(0));
153 uniqueContainer_ = Teuchos::null;
161 const int n = value.size();
162 const int num_deriv = this->numDeriv();
163 TEUCHOS_ASSERT(n == 0 || n == num_deriv);
165 value.resize(num_deriv);
169 int locProc = have_probe ? this->getComm()->getRank() : this->getComm()->getSize();
171 Teuchos::reduceAll(*this->getComm(), Teuchos::REDUCE_MIN, Thyra::Ordinal(1), &locProc, &glbProc);
173 TEUCHOS_ASSERT(glbProc < this->getComm()->getSize());
176 Teuchos::broadcast(*this->getComm(), glbProc, Thyra::Ordinal(num_deriv), &value.fastAccessDx(0));
180#ifdef PANZER_HAVE_EPETRA_STACK
181 if(this->useEpetra()) {
184 for (
int i=0; i<num_deriv; ++i)
185 deriv[i][0] = value.dx(i);
191 TEUCHOS_ASSERT(this->useThyra());
192 Thyra::ArrayRCP< Thyra::ArrayRCP<double> > deriv = this->getThyraMultiVector();
193 for (
int i=0; i<num_deriv; ++i)
194 deriv[i][0] = value.dx(i);
199template <
typename EvalT>
208 setDerivativeVectorSpace(soln_vs);
211#ifdef Panzer_BUILD_HESSIAN_SUPPORT
217 setDerivativeVectorSpace(soln_vs);
222template <
typename EvalT>
231 linObjFactory_->adjustForDirichletConditions(Teuchos::dyn_cast<const LinearObjContainer>(localBCRows),
232 Teuchos::dyn_cast<const LinearObjContainer>(globalBCRows),
233 *ghostedContainer_,
true,
true);
236#ifdef Panzer_BUILD_HESSIAN_SUPPORT
242 linObjFactory_->adjustForDirichletConditions(Teuchos::dyn_cast<const LinearObjContainer>(localBCRows),
243 Teuchos::dyn_cast<const LinearObjContainer>(globalBCRows),
244 *ghostedContainer_,
true,
true);
Teuchos::RCP< const panzer::ThyraObjFactory< double > > thyraObjFactory_
Teuchos::RCP< LinearObjContainer > ghostedContainer_
virtual void initializeResponse()
void setSolnVectorSpace(const Teuchos::RCP< const Thyra::VectorSpaceBase< double > > &soln_vs)
Set solution vector space.
Teuchos::RCP< const panzer::LinearObjFactory< panzer::Traits > > linObjFactory_
void adjustForDirichletConditions(const GlobalEvaluationData &localBCRows, const GlobalEvaluationData &globalBCRows)
virtual void scatterResponse()
This simply does global summation, then shoves the result into a vector.