43#ifndef __Panzer_ResponseMESupport_Default_hpp__
44#define __Panzer_ResponseMESupport_Default_hpp__
46#include "Teuchos_DefaultMpiComm.hpp"
47#include "Teuchos_ArrayRCP.hpp"
48#include "Teuchos_RCP.hpp"
49#include "Teuchos_OpaqueWrapper.hpp"
53#include "Thyra_DefaultSpmdVectorSpace.hpp"
54#include "Thyra_SpmdVectorBase.hpp"
56#include "PanzerDiscFE_config.hpp"
57#ifdef PANZER_HAVE_EPETRA_STACK
58#include "Epetra_LocalMap.h"
59#include "Epetra_Map.h"
60#include "Thyra_EpetraThyraWrappers.hpp"
65template <
typename EvalT>
70#ifdef PANZER_HAVE_EPETRA_STACK
86#ifdef PANZER_HAVE_EPETRA_STACK
91 Teuchos::RCP<const Epetra_Map> getMap()
const;
96 void setVector(
const Teuchos::RCP<Epetra_Vector> & destVec);
103 Teuchos::RCP<const Thyra::VectorSpaceBase<double> >
getVectorSpace()
const;
115 Teuchos::RCP<Thyra::VectorBase<double> >
getVector()
const
120 Teuchos::RCP<const Teuchos::Comm<Thyra::Ordinal> >
getComm()
const {
return tComm_; }
128#ifdef PANZER_HAVE_EPETRA_STACK
147#ifdef PANZER_HAVE_EPETRA_STACK
149 mutable Teuchos::RCP<const Epetra_Map> map_;
150 Teuchos::RCP<Epetra_Vector> eVector_;
154 mutable Teuchos::RCP<const Thyra::VectorSpaceBase<double> >
vSpace_;
156 Teuchos::RCP<const Teuchos::Comm<Thyra::Ordinal> >
tComm_;
183 {
return derivative_; }
185#ifdef PANZER_HAVE_EPETRA_STACK
190 virtual Teuchos::RCP<Epetra_MultiVector> buildEpetraDerivative()
const
194 TEUCHOS_ASSERT(supportsDerivative());
196 if(eMap_==Teuchos::null)
197 eMap_ = Thyra::get_Epetra_Map(*getDerivativeVectorSpace(),Thyra::get_Epetra_Comm(*
tComm_));
205 virtual void setDerivative(
const Teuchos::RCP<Epetra_MultiVector> & derivative)
209 TEUCHOS_ASSERT(supportsDerivative());
210 TEUCHOS_ASSERT(eMap_!=Teuchos::null);
212 derivative_ = Thyra::create_MultiVector(derivative,getDerivativeVectorSpace());
224 TEUCHOS_ASSERT(supportsDerivative());
225 return Thyra::createMember(*getDerivativeVectorSpace());
235 TEUCHOS_ASSERT(supportsDerivative());
236 derivative_ = derivative;
241 Teuchos::RCP<const Teuchos::Comm<Thyra::Ordinal> >
getComm()
const {
return tComm_; }
245 {
return derivVecSpace_; }
249 { derivVecSpace_ = vs; }
256 Teuchos::RCP<const Teuchos::Comm<Thyra::Ordinal> >
tComm_;
258#ifdef PANZER_HAVE_EPETRA_STACK
259 mutable Teuchos::RCP<const Epetra_Map> eMap_;
272#ifdef PANZER_HAVE_EPETRA_STACK
288#ifdef PANZER_HAVE_EPETRA_STACK
293 Teuchos::RCP<const Epetra_Map> getMap()
const {
294 TEUCHOS_TEST_FOR_EXCEPTION(
useThyra_,std::logic_error,
295 "Reponse field \"" << this->
getName() <<
"\" has previously been initialized as a "
296 "Thyra object, now trying to initalize as a Epetra! Error!");
298 if(map_==Teuchos::null) {
310 void setVector(
const Teuchos::RCP<Epetra_MultiVector> & destVec) {
311 TEUCHOS_TEST_FOR_EXCEPTION(
useThyra_,std::logic_error,
312 "Reponse field \"" << this->
getName() <<
"\" has previously been initialized as a "
313 "Thyra object, now trying to initalize as a Epetra! Error!");
324 TEUCHOS_TEST_FOR_EXCEPTION(
useEpetra_,std::logic_error,
325 "Reponse field \"" << this->
getName() <<
"\" has previously been initialized as an "
326 "Epetra object, now trying to initalize as a Thyra object! Error!");
341 TEUCHOS_TEST_FOR_EXCEPTION(
useEpetra_,std::logic_error,
342 "Reponse field \"" << this->
getName() <<
"\" has previously been initialized as an "
343 "Epetra object, now trying to initalize as a Thyra object! Error!");
350 Teuchos::RCP<const Teuchos::Comm<Thyra::Ordinal> >
getComm()
const {
return tComm_; }
358#ifdef PANZER_HAVE_EPETRA_STACK
369 const int num_col =
tVector_->domain()->dim();
370 Thyra::ArrayRCP< Thyra::ArrayRCP<double> > data(num_col);
371 for (
int i=0; i<num_col; ++i)
372 Teuchos::rcp_dynamic_cast<Thyra::SpmdVectorBase<double> >(
tVector_->col(i),
true)->getNonconstLocalData(Teuchos::outArg(data[i]));
378#ifdef PANZER_HAVE_EPETRA_STACK
380 return eVector_->NumVectors();
393#ifdef PANZER_HAVE_EPETRA_STACK
395 mutable Teuchos::RCP<const Epetra_Map> map_;
396 Teuchos::RCP<Epetra_MultiVector> eVector_;
400 mutable Teuchos::RCP<const Thyra::VectorSpaceBase<double> >
vSpace_;
401 Teuchos::RCP<Thyra::MultiVectorBase<double> >
tVector_;
402 Teuchos::RCP<const Teuchos::Comm<Thyra::Ordinal> >
tComm_;
405#ifdef Panzer_BUILD_HESSIAN_SUPPORT
431 {
return derivative_; }
438 TEUCHOS_ASSERT(supportsDerivative());
439 return Thyra::createMember(*getDerivativeVectorSpace());
449 TEUCHOS_ASSERT(supportsDerivative());
450 derivative_ = derivative;
455 Teuchos::RCP<const Teuchos::Comm<Thyra::Ordinal> >
getComm()
const {
return tComm_; }
459 {
return derivVecSpace_; }
463 { derivVecSpace_ = vs; }
470 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)