11#ifndef __Panzer_ResponseMESupport_Default_hpp__
12#define __Panzer_ResponseMESupport_Default_hpp__
14#include "Teuchos_DefaultMpiComm.hpp"
15#include "Teuchos_ArrayRCP.hpp"
16#include "Teuchos_RCP.hpp"
17#include "Teuchos_OpaqueWrapper.hpp"
21#include "Thyra_DefaultSpmdVectorSpace.hpp"
22#include "Thyra_SpmdVectorBase.hpp"
24#include "PanzerDiscFE_config.hpp"
25#ifdef PANZER_HAVE_EPETRA_STACK
26#include "Epetra_LocalMap.h"
27#include "Epetra_Map.h"
28#include "Thyra_EpetraThyraWrappers.hpp"
33template <
typename EvalT>
38#ifdef PANZER_HAVE_EPETRA_STACK
54#ifdef PANZER_HAVE_EPETRA_STACK
59 Teuchos::RCP<const Epetra_Map> getMap()
const;
64 void setVector(
const Teuchos::RCP<Epetra_Vector> & destVec);
71 Teuchos::RCP<const Thyra::VectorSpaceBase<double> >
getVectorSpace()
const;
83 Teuchos::RCP<Thyra::VectorBase<double> >
getVector()
const
88 Teuchos::RCP<const Teuchos::Comm<Thyra::Ordinal> >
getComm()
const {
return tComm_; }
96#ifdef PANZER_HAVE_EPETRA_STACK
98 Epetra_Vector & getEpetraVector()
const;
115#ifdef PANZER_HAVE_EPETRA_STACK
116 Epetra_MpiComm eComm_;
117 mutable Teuchos::RCP<const Epetra_Map> map_;
118 Teuchos::RCP<Epetra_Vector> eVector_;
122 mutable Teuchos::RCP<const Thyra::VectorSpaceBase<double> >
vSpace_;
124 Teuchos::RCP<const Teuchos::Comm<Thyra::Ordinal> >
tComm_;
151 {
return derivative_; }
153#ifdef PANZER_HAVE_EPETRA_STACK
158 virtual Teuchos::RCP<Epetra_MultiVector> buildEpetraDerivative()
const
162 TEUCHOS_ASSERT(supportsDerivative());
164 if(eMap_==Teuchos::null)
165 eMap_ = Thyra::get_Epetra_Map(*getDerivativeVectorSpace(),Thyra::get_Epetra_Comm(*
tComm_));
167 return Teuchos::rcp(
new Epetra_Vector(*eMap_));
173 virtual void setDerivative(
const Teuchos::RCP<Epetra_MultiVector> & derivative)
177 TEUCHOS_ASSERT(supportsDerivative());
178 TEUCHOS_ASSERT(eMap_!=Teuchos::null);
180 derivative_ = Thyra::create_MultiVector(derivative,getDerivativeVectorSpace());
192 TEUCHOS_ASSERT(supportsDerivative());
193 return Thyra::createMember(*getDerivativeVectorSpace());
203 TEUCHOS_ASSERT(supportsDerivative());
204 derivative_ = derivative;
209 Teuchos::RCP<const Teuchos::Comm<Thyra::Ordinal> >
getComm()
const {
return tComm_; }
213 {
return derivVecSpace_; }
217 { derivVecSpace_ = vs; }
224 Teuchos::RCP<const Teuchos::Comm<Thyra::Ordinal> >
tComm_;
226#ifdef PANZER_HAVE_EPETRA_STACK
227 mutable Teuchos::RCP<const Epetra_Map> eMap_;
240#ifdef PANZER_HAVE_EPETRA_STACK
256#ifdef PANZER_HAVE_EPETRA_STACK
261 Teuchos::RCP<const Epetra_Map> getMap()
const {
262 TEUCHOS_TEST_FOR_EXCEPTION(
useThyra_,std::logic_error,
263 "Reponse field \"" << this->
getName() <<
"\" has previously been initialized as a "
264 "Thyra object, now trying to initalize as a Epetra! Error!");
266 if(map_==Teuchos::null) {
268 map_ = Teuchos::rcp(
new Epetra_Map(-1,(
int) this->
localSizeRequired(),0,eComm_));
270 map_ = Teuchos::rcp(
new Epetra_LocalMap((
int) this->
localSizeRequired(),0,eComm_));
278 void setVector(
const Teuchos::RCP<Epetra_MultiVector> & destVec) {
279 TEUCHOS_TEST_FOR_EXCEPTION(
useThyra_,std::logic_error,
280 "Reponse field \"" << this->
getName() <<
"\" has previously been initialized as a "
281 "Thyra object, now trying to initalize as a Epetra! Error!");
292 TEUCHOS_TEST_FOR_EXCEPTION(
useEpetra_,std::logic_error,
293 "Reponse field \"" << this->
getName() <<
"\" has previously been initialized as an "
294 "Epetra object, now trying to initalize as a Thyra object! Error!");
309 TEUCHOS_TEST_FOR_EXCEPTION(
useEpetra_,std::logic_error,
310 "Reponse field \"" << this->
getName() <<
"\" has previously been initialized as an "
311 "Epetra object, now trying to initalize as a Thyra object! Error!");
318 Teuchos::RCP<const Teuchos::Comm<Thyra::Ordinal> >
getComm()
const {
return tComm_; }
326#ifdef PANZER_HAVE_EPETRA_STACK
328 Epetra_MultiVector & getEpetraMultiVector()
const {
337 const int num_col =
tVector_->domain()->dim();
338 Thyra::ArrayRCP< Thyra::ArrayRCP<double> > data(num_col);
339 for (
int i=0; i<num_col; ++i)
340 Teuchos::rcp_dynamic_cast<Thyra::SpmdVectorBase<double> >(
tVector_->col(i),
true)->getNonconstLocalData(Teuchos::outArg(data[i]));
346#ifdef PANZER_HAVE_EPETRA_STACK
348 return eVector_->NumVectors();
361#ifdef PANZER_HAVE_EPETRA_STACK
362 Epetra_MpiComm eComm_;
363 mutable Teuchos::RCP<const Epetra_Map> map_;
364 Teuchos::RCP<Epetra_MultiVector> eVector_;
368 mutable Teuchos::RCP<const Thyra::VectorSpaceBase<double> >
vSpace_;
369 Teuchos::RCP<Thyra::MultiVectorBase<double> >
tVector_;
370 Teuchos::RCP<const Teuchos::Comm<Thyra::Ordinal> >
tComm_;
373#ifdef Panzer_BUILD_HESSIAN_SUPPORT
399 {
return derivative_; }
406 TEUCHOS_ASSERT(supportsDerivative());
407 return Thyra::createMember(*getDerivativeVectorSpace());
417 TEUCHOS_ASSERT(supportsDerivative());
418 derivative_ = derivative;
423 Teuchos::RCP<const Teuchos::Comm<Thyra::Ordinal> >
getComm()
const {
return tComm_; }
427 {
return derivVecSpace_; }
431 { derivVecSpace_ = vs; }
438 Teuchos::RCP<const Teuchos::Comm<Thyra::Ordinal> >
tComm_;
std::string getName() const
virtual void setDerivative(const Teuchos::RCP< Thyra::MultiVectorBase< double > > &derivative)
ResponseMESupport_Default()
Teuchos::RCP< Thyra::MultiVectorBase< double > > derivative_
bool supportsDerivative() const
Does this response support derivative evaluation?
Teuchos::RCP< Thyra::MultiVectorBase< double > > getDerivative() const
virtual bool vectorIsDistributed() const =0
Is the vector distributed (or replicated). For derivative assembly this must be false!
virtual Teuchos::RCP< Thyra::MultiVectorBase< double > > buildDerivative() const
Get the Epetra_Map for this response, map is constructed lazily.
virtual ~ResponseMESupport_Default()
Teuchos::RCP< const Teuchos::Comm< Thyra::Ordinal > > getComm() const
Get the teuchos comm object.
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > derivVecSpace_
void setDerivativeVectorSpace(const Teuchos::RCP< const Thyra::VectorSpaceBase< double > > &vs)
Set the derivative vector space.
virtual std::size_t localSizeRequired() const =0
What is the number of values you need locally.
ResponseMESupport_Default(const ResponseMESupport_Default< panzer::Traits::Hessian > &)
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > getDerivativeVectorSpace() const
Get the derivative vector space.
Teuchos::RCP< const Teuchos::Comm< Thyra::Ordinal > > tComm_
ResponseMESupport_Default(const std::string &responseName, MPI_Comm comm, const Teuchos::RCP< const Thyra::VectorSpaceBase< double > > &derivVecSpace=Teuchos::null)
Teuchos::RCP< const Teuchos::Comm< Thyra::Ordinal > > getComm() const
Get the teuchos comm object.
Teuchos::RCP< Thyra::MultiVectorBase< double > > getDerivative() const
virtual Teuchos::RCP< Thyra::MultiVectorBase< double > > buildDerivative() const
Get the Epetra_Map for this response, map is constructed lazily.
ResponseMESupport_Default()
void setDerivativeVectorSpace(const Teuchos::RCP< const Thyra::VectorSpaceBase< double > > &vs)
Set the derivative vector space.
ResponseMESupport_Default(const ResponseMESupport_Default< panzer::Traits::Jacobian > &)
ResponseMESupport_Default(const std::string &responseName, MPI_Comm comm, const Teuchos::RCP< const Thyra::VectorSpaceBase< double > > &derivVecSpace=Teuchos::null)
virtual ~ResponseMESupport_Default()
Teuchos::RCP< const Teuchos::Comm< Thyra::Ordinal > > tComm_
virtual bool vectorIsDistributed() const =0
Is the vector distributed (or replicated). For derivative assembly this must be false!
bool supportsDerivative() const
Does this response support derivative evaluation?
Teuchos::RCP< Thyra::MultiVectorBase< double > > derivative_
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > derivVecSpace_
virtual std::size_t localSizeRequired() const =0
What is the number of values you need locally.
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > getDerivativeVectorSpace() const
Get the derivative vector space.
virtual void setDerivative(const Teuchos::RCP< Thyra::MultiVectorBase< double > > &derivative)
virtual ~ResponseMESupport_Default()
void setVector(const Teuchos::RCP< Thyra::MultiVectorBase< double > > &destVec)
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > getVectorSpace() const
Get the vector space for this response, vector space is constructed lazily.
Teuchos::RCP< Thyra::MultiVectorBase< double > > tVector_
virtual std::size_t localSizeRequired() const =0
What is the number of values you need locally.
Teuchos::RCP< const Teuchos::Comm< Thyra::Ordinal > > getComm() const
Get the teuchos comm object.
int numDeriv() const
Return the number of columns in the multivector.
Teuchos::RCP< const Teuchos::Comm< Thyra::Ordinal > > tComm_
bool useThyra() const
Is Thyra the right vector.
ResponseMESupport_Default()
virtual bool vectorIsDistributed() const =0
Is the vector distributed (or replicated)
Thyra::ArrayRCP< Thyra::ArrayRCP< double > > getThyraMultiVector() const
Access the thyra vector.
bool useEpetra() const
Is Epetra the right vector.
panzer::Traits::Tangent EvalT
ResponseMESupport_Default(const std::string &responseName, MPI_Comm comm)
ResponseMESupport_Default(const ResponseMESupport_Default< EvalT > &)
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > vSpace_
Teuchos::RCP< Thyra::VectorBase< double > > tVector_
void setVectorSpace(Teuchos::RCP< const Thyra::VectorSpaceBase< double > > vs)
set the vector space for this response
Teuchos::RCP< const Teuchos::Comm< Thyra::Ordinal > > getComm() const
Get the teuchos comm object.
bool useEpetra() const
Is Epetra the right vector.
ResponseMESupport_Default()
Teuchos::RCP< const Teuchos::Comm< Thyra::Ordinal > > tComm_
Teuchos::RCP< Thyra::MultiVectorBase< double > > getThyraMultiVector() const
Access the thyra MultiVector.
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > vSpace_
ResponseMESupport_Default(const ResponseMESupport_Default< EvalT > &)
virtual bool vectorIsDistributed() const =0
Is the vector distributed (or replicated)
virtual std::size_t localSizeRequired() const =0
What is the number of values you need locally.
void setVector(const Teuchos::RCP< Thyra::VectorBase< double > > &destVec)
Thyra::ArrayRCP< double > getThyraVector() const
Access the thyra vector.
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > getVectorSpace() const
Get the vector space for this response, vector space is constructed lazily.
Teuchos::RCP< Thyra::VectorBase< double > > getVector() const
Access the response vector.
bool useThyra() const
Is Thyra the right vector.
virtual ~ResponseMESupport_Default()
ResponseMESupport_Default(const std::string &responseName, MPI_Comm comm)
Evaluation type for computing second derivatives, using HessianType as the scalar type....
Evaluation type for computing the residual and its Jacobian, using FadType as the scalar type.
Evaluation type for computing directional derivatives (e.g. parameter sensitivities),...
Panzer's specialization of the Phalanx traits class.