1 #ifndef __Panzer_ResponseMESupport_Default_hpp__ 2 #define __Panzer_ResponseMESupport_Default_hpp__ 4 #include "Teuchos_DefaultMpiComm.hpp" 5 #include "Teuchos_ArrayRCP.hpp" 6 #include "Teuchos_RCP.hpp" 7 #include "Teuchos_OpaqueWrapper.hpp" 11 #include "Thyra_EpetraThyraWrappers.hpp" 13 #include "Thyra_DefaultSpmdVectorSpace.hpp" 14 #include "Thyra_SpmdVectorBase.hpp" 16 #include "Epetra_LocalMap.h" 17 #include "Epetra_Map.h" 21 template <
typename EvalT>
27 tComm_ = Teuchos::rcp(
new Teuchos::MpiComm<Thyra::Ordinal>(Teuchos::opaqueWrapper(
comm)));
42 Teuchos::RCP<const Epetra_Map>
getMap()
const;
47 void setVector(
const Teuchos::RCP<Epetra_Vector> & destVec);
53 Teuchos::RCP<const Thyra::VectorSpaceBase<double> >
getVectorSpace()
const;
62 Teuchos::RCP<const Teuchos::Comm<Thyra::Ordinal> >
getComm()
const {
return tComm_; }
84 mutable Teuchos::RCP<const Epetra_Map>
map_;
88 mutable Teuchos::RCP<const Thyra::VectorSpaceBase<double> >
vSpace_;
89 Teuchos::RCP<Thyra::VectorBase<double> >
tVector_;
90 Teuchos::RCP<const Teuchos::Comm<Thyra::Ordinal> >
tComm_;
100 {
tComm_ = Teuchos::rcp(
new Teuchos::MpiComm<Thyra::Ordinal>(Teuchos::opaqueWrapper(
comm))); }
117 {
return derivative_; }
127 TEUCHOS_ASSERT(supportsDerivative());
129 if(eMap_==Teuchos::null)
130 eMap_ = Thyra::get_Epetra_Map(*getDerivativeVectorSpace(),Thyra::get_Epetra_Comm(*
tComm_));
132 return Teuchos::rcp(
new Epetra_Vector(*eMap_));
138 virtual void setDerivative(
const Teuchos::RCP<Epetra_MultiVector> & derivative)
142 TEUCHOS_ASSERT(supportsDerivative());
143 TEUCHOS_ASSERT(eMap_!=Teuchos::null);
145 derivative_ = Thyra::create_MultiVector(derivative,getDerivativeVectorSpace());
156 TEUCHOS_ASSERT(supportsDerivative());
157 return Thyra::createMember(*getDerivativeVectorSpace());
167 TEUCHOS_ASSERT(supportsDerivative());
168 derivative_ = derivative;
173 Teuchos::RCP<const Teuchos::Comm<Thyra::Ordinal> >
getComm()
const {
return tComm_; }
177 {
return derivVecSpace_; }
181 { derivVecSpace_ = vs; }
188 Teuchos::RCP<const Teuchos::Comm<Thyra::Ordinal> >
tComm_;
190 mutable Teuchos::RCP<const Epetra_Map>
eMap_;
203 tComm_ = Teuchos::rcp(
new Teuchos::MpiComm<Thyra::Ordinal>(Teuchos::opaqueWrapper(
comm)));
218 Teuchos::RCP<const Epetra_Map>
getMap()
const {
219 TEUCHOS_TEST_FOR_EXCEPTION(
useThyra_,std::logic_error,
220 "Reponse field \"" << this->
getName() <<
"\" has previously been initialized as a " 221 "Thyra object, now trying to initalize as a Epetra! Error!");
223 if(
map_==Teuchos::null) {
235 void setVector(
const Teuchos::RCP<Epetra_MultiVector> & destVec) {
236 TEUCHOS_TEST_FOR_EXCEPTION(
useThyra_,std::logic_error,
237 "Reponse field \"" << this->
getName() <<
"\" has previously been initialized as a " 238 "Thyra object, now trying to initalize as a Epetra! Error!");
248 TEUCHOS_TEST_FOR_EXCEPTION(
useEpetra_,std::logic_error,
249 "Reponse field \"" << this->
getName() <<
"\" has previously been initialized as an " 250 "Epetra object, now trying to initalize as a Thyra object! Error!");
265 TEUCHOS_TEST_FOR_EXCEPTION(
useEpetra_,std::logic_error,
266 "Reponse field \"" << this->
getName() <<
"\" has previously been initialized as an " 267 "Epetra object, now trying to initalize as a Thyra object! Error!");
274 Teuchos::RCP<const Teuchos::Comm<Thyra::Ordinal> >
getComm()
const {
return tComm_; }
291 const int num_col =
tVector_->domain()->dim();
292 Thyra::ArrayRCP< Thyra::ArrayRCP<double> > data(num_col);
293 for (
int i=0; i<num_col; ++i)
294 Teuchos::rcp_dynamic_cast<Thyra::SpmdVectorBase<double> >(
tVector_->col(i),
true)->getNonconstLocalData(Teuchos::outArg(data[i]));
314 mutable Teuchos::RCP<const Epetra_Map>
map_;
318 mutable Teuchos::RCP<const Thyra::VectorSpaceBase<double> >
vSpace_;
319 Teuchos::RCP<Thyra::MultiVectorBase<double> >
tVector_;
320 Teuchos::RCP<const Teuchos::Comm<Thyra::Ordinal> >
tComm_;
323 #ifdef Panzer_BUILD_HESSIAN_SUPPORT 332 {
tComm_ = Teuchos::rcp(
new Teuchos::MpiComm<Thyra::Ordinal>(Teuchos::opaqueWrapper(
comm))); }
343 bool supportsDerivative()
const {
return getDerivativeVectorSpace()!=Teuchos::null; }
348 Teuchos::RCP<Thyra::MultiVectorBase<double> > getDerivative()
const 349 {
return derivative_; }
352 virtual Teuchos::RCP<Thyra::MultiVectorBase<double> > buildDerivative()
const 356 TEUCHOS_ASSERT(supportsDerivative());
357 return Thyra::createMember(*getDerivativeVectorSpace());
367 TEUCHOS_ASSERT(supportsDerivative());
368 derivative_ = derivative;
373 Teuchos::RCP<const Teuchos::Comm<Thyra::Ordinal> >
getComm()
const {
return tComm_; }
376 Teuchos::RCP<const Thyra::VectorSpaceBase<double> > getDerivativeVectorSpace()
const 377 {
return derivVecSpace_; }
381 { derivVecSpace_ = vs; }
388 Teuchos::RCP<const Teuchos::Comm<Thyra::Ordinal> >
tComm_;
389 Teuchos::RCP<const Thyra::VectorSpaceBase<double> > derivVecSpace_;
391 Teuchos::RCP<Thyra::MultiVectorBase<double> > derivative_;
Teuchos::RCP< Thyra::MultiVectorBase< double > > getDerivative() const
virtual void setDerivative(const Teuchos::RCP< Thyra::MultiVectorBase< double > > &derivative)
virtual ~ResponseMESupport_Default()
ResponseMESupport_Default(const std::string &responseName, MPI_Comm comm)
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > vSpace_
virtual void setDerivative(const Teuchos::RCP< Epetra_MultiVector > &derivative)
Teuchos::RCP< Epetra_Vector > eVector_
bool useThyra() const
Is Thyra the right vector.
void setDerivativeVectorSpace(const Teuchos::RCP< const Thyra::VectorSpaceBase< double > > &vs)
Set the derivative vector space.
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > vSpace_
Teuchos::RCP< const Epetra_Map > getMap() const
Get the Epetra_Map for this response, map is constructed lazily.
Teuchos::RCP< const Teuchos::Comm< Thyra::Ordinal > > tComm_
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > derivVecSpace_
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > getDerivativeVectorSpace() const
Get the derivative vector space.
bool useEpetra() const
Is Epetra the right vector.
ResponseMESupport_Default()
Teuchos::RCP< Thyra::MultiVectorBase< double > > tVector_
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > getVectorSpace() const
Get the vector space for this response, vector space is constructed lazily.
bool useEpetra() const
Is Epetra the right vector.
virtual Teuchos::RCP< Thyra::MultiVectorBase< double > > buildDerivative() const
Get the Epetra_Map for this response, map is constructed lazily.
bool supportsDerivative() const
Does this response support derivative evaluation?
void setVector(const Teuchos::RCP< Thyra::MultiVectorBase< double > > &destVec)
virtual ~ResponseMESupport_Default()
Teuchos::RCP< const Teuchos::Comm< Thyra::Ordinal > > getComm() const
Get the teuchos comm object.
Teuchos::RCP< const Teuchos::Comm< Thyra::Ordinal > > getComm() const
Get the teuchos comm object.
Teuchos::RCP< const Teuchos::Comm< Thyra::Ordinal > > getComm() const
Get the teuchos comm object.
Teuchos::RCP< const Epetra_Map > eMap_
int numDeriv() const
Return the number of columns in the multivector.
Teuchos::RCP< const Teuchos::Comm< Thyra::Ordinal > > tComm_
Teuchos::RCP< const Epetra_Map > map_
Teuchos::RCP< const Teuchos::Comm< Thyra::Ordinal > > tComm_
virtual ~ResponseMESupport_Default()
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > getVectorSpace() const
Get the vector space for this response, vector space is constructed lazily.
virtual std::size_t localSizeRequired() const =0
What is the number of values you need locally.
panzer::Traits::Tangent EvalT
Thyra::ArrayRCP< double > getThyraVector() const
Access the thyra vector.
void setVector(const Teuchos::RCP< Epetra_Vector > &destVec)
Teuchos::RCP< Epetra_MultiVector > eVector_
Teuchos::RCP< Thyra::VectorBase< double > > tVector_
std::string getName() const
Epetra_Vector & getEpetraVector() const
Access the epetra vector.
Teuchos::RCP< const Teuchos::Comm< int > > comm
Thyra::ArrayRCP< Thyra::ArrayRCP< double > > getThyraMultiVector() const
Access the thyra vector.
Epetra_MultiVector & getEpetraMultiVector() const
Access the epetra vector.
void setVector(const Teuchos::RCP< Epetra_MultiVector > &destVec)
Teuchos::RCP< const Epetra_Map > getMap() const
Get the Epetra_Map for this response, map is constructed lazily.
bool useThyra() const
Is Thyra the right vector.
ResponseMESupport_Default(const std::string &responseName, MPI_Comm comm, const Teuchos::RCP< const Thyra::VectorSpaceBase< double > > &derivVecSpace=Teuchos::null)
virtual bool vectorIsDistributed() const =0
Is the vector distributed (or replicated)
ResponseMESupport_Default(const std::string &responseName, MPI_Comm comm)
virtual Teuchos::RCP< Epetra_MultiVector > buildEpetraDerivative() const
Get the Epetra_Map for this response, map is constructed lazily.
Teuchos::RCP< Thyra::MultiVectorBase< double > > derivative_
Teuchos::RCP< const Epetra_Map > map_