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_EpetraThyraWrappers.hpp" 55 #include "Thyra_DefaultSpmdVectorSpace.hpp" 56 #include "Thyra_SpmdVectorBase.hpp" 58 #include "Epetra_LocalMap.h" 59 #include "Epetra_Map.h" 63 template <
typename EvalT>
84 Teuchos::RCP<const Epetra_Map>
getMap()
const;
89 void setVector(
const Teuchos::RCP<Epetra_Vector> & destVec);
95 Teuchos::RCP<const Thyra::VectorSpaceBase<double> >
getVectorSpace()
const;
107 Teuchos::RCP<Thyra::VectorBase<double> >
getVector()
const 112 Teuchos::RCP<const Teuchos::Comm<Thyra::Ordinal> >
getComm()
const {
return tComm_; }
138 mutable Teuchos::RCP<const Epetra_Map>
map_;
142 mutable Teuchos::RCP<const Thyra::VectorSpaceBase<double> >
vSpace_;
144 Teuchos::RCP<const Teuchos::Comm<Thyra::Ordinal> >
tComm_;
171 {
return derivative_; }
181 TEUCHOS_ASSERT(supportsDerivative());
183 if(eMap_==Teuchos::null)
184 eMap_ = Thyra::get_Epetra_Map(*getDerivativeVectorSpace(),Thyra::get_Epetra_Comm(*
tComm_));
192 virtual void setDerivative(
const Teuchos::RCP<Epetra_MultiVector> & derivative)
196 TEUCHOS_ASSERT(supportsDerivative());
197 TEUCHOS_ASSERT(eMap_!=Teuchos::null);
199 derivative_ = Thyra::create_MultiVector(derivative,getDerivativeVectorSpace());
210 TEUCHOS_ASSERT(supportsDerivative());
211 return Thyra::createMember(*getDerivativeVectorSpace());
221 TEUCHOS_ASSERT(supportsDerivative());
222 derivative_ = derivative;
227 Teuchos::RCP<const Teuchos::Comm<Thyra::Ordinal> >
getComm()
const {
return tComm_; }
231 {
return derivVecSpace_; }
235 { derivVecSpace_ = vs; }
242 Teuchos::RCP<const Teuchos::Comm<Thyra::Ordinal> >
tComm_;
244 mutable Teuchos::RCP<const Epetra_Map>
eMap_;
272 Teuchos::RCP<const Epetra_Map>
getMap()
const {
273 TEUCHOS_TEST_FOR_EXCEPTION(
useThyra_,std::logic_error,
274 "Reponse field \"" << this->
getName() <<
"\" has previously been initialized as a " 275 "Thyra object, now trying to initalize as a Epetra! Error!");
277 if(
map_==Teuchos::null) {
289 void setVector(
const Teuchos::RCP<Epetra_MultiVector> & destVec) {
290 TEUCHOS_TEST_FOR_EXCEPTION(
useThyra_,std::logic_error,
291 "Reponse field \"" << this->
getName() <<
"\" has previously been initialized as a " 292 "Thyra object, now trying to initalize as a Epetra! Error!");
302 TEUCHOS_TEST_FOR_EXCEPTION(
useEpetra_,std::logic_error,
303 "Reponse field \"" << this->
getName() <<
"\" has previously been initialized as an " 304 "Epetra object, now trying to initalize as a Thyra object! Error!");
319 TEUCHOS_TEST_FOR_EXCEPTION(
useEpetra_,std::logic_error,
320 "Reponse field \"" << this->
getName() <<
"\" has previously been initialized as an " 321 "Epetra object, now trying to initalize as a Thyra object! Error!");
328 Teuchos::RCP<const Teuchos::Comm<Thyra::Ordinal> >
getComm()
const {
return tComm_; }
345 const int num_col =
tVector_->domain()->dim();
346 Thyra::ArrayRCP< Thyra::ArrayRCP<double> > data(num_col);
347 for (
int i=0; i<num_col; ++i)
348 Teuchos::rcp_dynamic_cast<Thyra::SpmdVectorBase<double> >(
tVector_->col(i),
true)->getNonconstLocalData(Teuchos::outArg(data[i]));
368 mutable Teuchos::RCP<const Epetra_Map>
map_;
372 mutable Teuchos::RCP<const Thyra::VectorSpaceBase<double> >
vSpace_;
373 Teuchos::RCP<Thyra::MultiVectorBase<double> >
tVector_;
374 Teuchos::RCP<const Teuchos::Comm<Thyra::Ordinal> >
tComm_;
377 #ifdef Panzer_BUILD_HESSIAN_SUPPORT 403 {
return derivative_; }
410 TEUCHOS_ASSERT(supportsDerivative());
411 return Thyra::createMember(*getDerivativeVectorSpace());
421 TEUCHOS_ASSERT(supportsDerivative());
422 derivative_ = derivative;
427 Teuchos::RCP<const Teuchos::Comm<Thyra::Ordinal> >
getComm()
const {
return tComm_; }
431 {
return derivVecSpace_; }
435 { derivVecSpace_ = vs; }
442 Teuchos::RCP<const Teuchos::Comm<Thyra::Ordinal> >
tComm_;
Teuchos::RCP< Thyra::MultiVectorBase< double > > getDerivative() const
bool supportsDerivative() const
Does this response support derivative evaluation?
Teuchos::RCP< Thyra::VectorBase< double > > getVector() const
Access the response vector.
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< const Teuchos::Comm< Thyra::Ordinal > > getComm() const
Get the teuchos comm object.
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_
virtual void setDerivative(const Teuchos::RCP< Thyra::MultiVectorBase< double > > &derivative)
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?
Teuchos::RCP< Thyra::MultiVectorBase< double > > getThyraMultiVector() const
Access the thyra MultiVector.
ResponseMESupport_Default(const std::string &responseName, MPI_Comm comm, const Teuchos::RCP< const Thyra::VectorSpaceBase< double > > &derivVecSpace=Teuchos::null)
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 Thyra::VectorSpaceBase< double > > getDerivativeVectorSpace() const
Get the derivative vector space.
Teuchos::RCP< const Teuchos::Comm< Thyra::Ordinal > > tComm_
virtual Teuchos::RCP< Thyra::MultiVectorBase< double > > buildDerivative() const
Get the Epetra_Map for this response, map is constructed lazily.
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > derivVecSpace_
virtual ~ResponseMESupport_Default()
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > getVectorSpace() const
Get the vector space for this response, vector space is constructed lazily.
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.
panzer::Traits::Tangent EvalT
Thyra::ArrayRCP< double > getThyraVector() const
Access the thyra vector.
void setVector(const Teuchos::RCP< Epetra_Vector > &destVec)
void setVectorSpace(Teuchos::RCP< const Thyra::VectorSpaceBase< double > > vs)
set the vector space for this response
Teuchos::RCP< Epetra_MultiVector > eVector_
Teuchos::RCP< Thyra::VectorBase< double > > tVector_
std::string getName() const
virtual ~ResponseMESupport_Default()
Epetra_Vector & getEpetraVector() const
Access the epetra vector.
Thyra::ArrayRCP< Thyra::ArrayRCP< double > > getThyraMultiVector() const
Access the thyra vector.
Teuchos::RCP< Thyra::MultiVectorBase< double > > derivative_
Epetra_MultiVector & getEpetraMultiVector() const
Access the epetra vector.
Teuchos::RCP< const Teuchos::Comm< Thyra::Ordinal > > tComm_
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)
Teuchos::RCP< Thyra::MultiVectorBase< double > > getDerivative() const
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_