11#ifndef __Panzer_Response_Probe_impl_hpp__
12#define __Panzer_Response_Probe_impl_hpp__
15#include "Teuchos_Comm.hpp"
16#include "Teuchos_CommHelpers.hpp"
17#include "Teuchos_dyn_cast.hpp"
19#include "PanzerDiscFE_config.hpp"
20#ifdef PANZER_HAVE_EPETRA_STACK
21#include "Epetra_LocalMap.h"
24#include "Sacado_Traits.hpp"
25#include "Thyra_VectorStdOps.hpp"
29template <
typename EvalT>
47 if constexpr (std::is_same<EvalT,panzer::Traits::Jacobian>::value) {
53template <
typename EvalT>
63template <
typename EvalT>
67 double glbValue = Sacado::scalarValue(
value);
72 Teuchos::reduceAll(*this->
getComm(), Teuchos::REDUCE_MIN, Thyra::Ordinal(1), &locProc, &glbProc);
74 TEUCHOS_ASSERT(glbProc < this->
getComm()->getSize());
77 Teuchos::broadcast(*this->
getComm(), glbProc, Thyra::Ordinal(1), &glbValue);
82#ifdef PANZER_HAVE_EPETRA_STACK
85 this->getEpetraVector()[0] = glbValue;
101 using Teuchos::rcp_dynamic_cast;
111 Teuchos::reduceAll(*this->
getComm(), Teuchos::REDUCE_MIN, Thyra::Ordinal(1), &locProc, &glbProc);
112 TEUCHOS_ASSERT(glbProc < this->
getComm()->getSize());
114 if (this->
getComm()->getRank() != glbProc) {
116 Thyra::assign(ghosted->get_x_th().ptr(),0.0);
119 Teuchos::RCP<Thyra::MultiVectorBase<double> > dgdx_unique = getDerivative();
122 Teuchos::rcp_dynamic_cast<ThyraObjContainer<double> >(
uniqueContainer_)->set_x_th(dgdx_unique->col(0));
129#ifdef Panzer_BUILD_HESSIAN_SUPPORT
134 using Teuchos::rcp_dynamic_cast;
136 Teuchos::RCP<Thyra::MultiVectorBase<double> > dgdx_unique = getDerivative();
139 Teuchos::rcp_dynamic_cast<ThyraObjContainer<double> >(
uniqueContainer_)->set_x_th(dgdx_unique->col(0));
152 if (!this->hasTargetVector())
155 const int n =
value.size();
156 const int num_deriv = this->numDeriv();
157 TEUCHOS_ASSERT(n == 0 || n == num_deriv);
159 value.resize(num_deriv);
165 Teuchos::reduceAll(*this->
getComm(), Teuchos::REDUCE_MIN, Thyra::Ordinal(1), &locProc, &glbProc);
167 TEUCHOS_ASSERT(glbProc < this->
getComm()->getSize());
170 Teuchos::broadcast(*this->
getComm(), glbProc, Thyra::Ordinal(num_deriv), &
value.fastAccessDx(0));
174#ifdef PANZER_HAVE_EPETRA_STACK
177 Epetra_MultiVector& deriv = this->getEpetraMultiVector();
178 for (
int i=0; i<num_deriv; ++i)
179 deriv[i][0] =
value.dx(i);
187 for (
int i=0; i<num_deriv; ++i) {
188 deriv[i][0] =
value.dx(i);
194template <
typename EvalT>
203 setDerivativeVectorSpace(soln_vs);
206#ifdef Panzer_BUILD_HESSIAN_SUPPORT
212 setDerivativeVectorSpace(soln_vs);
217template <
typename EvalT>
226 linObjFactory_->adjustForDirichletConditions(Teuchos::dyn_cast<const LinearObjContainer>(localBCRows),
227 Teuchos::dyn_cast<const LinearObjContainer>(globalBCRows),
231#ifdef Panzer_BUILD_HESSIAN_SUPPORT
237 linObjFactory_->adjustForDirichletConditions(Teuchos::dyn_cast<const LinearObjContainer>(localBCRows),
238 Teuchos::dyn_cast<const LinearObjContainer>(globalBCRows),
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_
Teuchos::RCP< LinearObjContainer > uniqueContainer_
void adjustForDirichletConditions(const GlobalEvaluationData &localBCRows, const GlobalEvaluationData &globalBCRows)
virtual void scatterResponse()
This simply does global summation, then shoves the result into a vector.
Teuchos::RCP< const Teuchos::Comm< Thyra::Ordinal > > getComm() const
Get the teuchos comm object.
bool useEpetra() const
Is Epetra the right vector.
Teuchos::RCP< Thyra::MultiVectorBase< double > > getThyraMultiVector() const
Access the thyra MultiVector.
Thyra::ArrayRCP< double > getThyraVector() const
Access the thyra vector.
bool useThyra() const
Is Thyra the right vector.
ResponseMESupport_Default(const std::string &responseName, MPI_Comm comm)