Panzer  Version of the Day
Panzer_ResponseMESupport_Default_impl.hpp
Go to the documentation of this file.
1 #ifndef __Panzer_ResponseMESupport_Default_impl_hpp__
2 #define __Panzer_ResponseMESupport_Default_impl_hpp__
3 
4 namespace panzer {
5 
6 template <typename EvalT>
9 {
10  TEUCHOS_ASSERT(useEpetra());
11 
12  return *eVector_;
13 }
14 
15 template <typename EvalT>
16 Thyra::ArrayRCP<double> ResponseMESupport_Default<EvalT>::
18 {
19  TEUCHOS_ASSERT(useThyra());
20 
21  Teuchos::ArrayRCP<double> data;
22  Teuchos::rcp_dynamic_cast<Thyra::SpmdVectorBase<double> >(tVector_,true)->getNonconstLocalData(Teuchos::outArg(data));
23 
24  return data;
25 }
26 
27 template <typename EvalT>
28 Teuchos::RCP<const Epetra_Map> ResponseMESupport_Default<EvalT>::
29 getMap() const
30 {
31  TEUCHOS_TEST_FOR_EXCEPTION(useThyra_,std::logic_error,
32  "Reponse field \"" << this->getName() << "\" has previously been initialized as a "
33  "Thyra object, now trying to initalize as a Epetra! Error!");
34 
35  // lazily construct the map only as needed
36  if(map_==Teuchos::null) {
37  if(this->vectorIsDistributed())
38  map_ = Teuchos::rcp(new Epetra_Map(-1,(int) this->localSizeRequired(),0,eComm_));
39  else
40  map_ = Teuchos::rcp(new Epetra_LocalMap((int) this->localSizeRequired(),0,eComm_));
41  }
42 
43  return map_;
44 }
45 
46 template <typename EvalT>
48 setVector(const Teuchos::RCP<Epetra_Vector> & destVec)
49 {
50  TEUCHOS_TEST_FOR_EXCEPTION(useThyra_,std::logic_error,
51  "Reponse field \"" << this->getName() << "\" has previously been initialized as a "
52  "Thyra object, now trying to initalize as a Epetra! Error!");
53 
54  eVector_ = destVec;
55 
56  useEpetra_ = true;
57 }
58 
59 template <typename EvalT>
60 Teuchos::RCP<const Thyra::VectorSpaceBase<double> > ResponseMESupport_Default<EvalT>::
62 {
63  TEUCHOS_TEST_FOR_EXCEPTION(useEpetra_,std::logic_error,
64  "Reponse field \"" << this->getName() << "\" has previously been initialized as an "
65  "Epetra object, now trying to initalize as a Thyra object! Error!");
66 
67  // lazily build the space and return it
68  if(vSpace_==Teuchos::null) {
69  if(this->vectorIsDistributed())
70  vSpace_ = Thyra::defaultSpmdVectorSpace<double>(tComm_,this->localSizeRequired(),-1);
71  else
72  vSpace_ = Thyra::locallyReplicatedDefaultSpmdVectorSpace<double>(tComm_,this->localSizeRequired());
73  }
74 
75  return vSpace_;
76 }
77 
78 template <typename EvalT>
80 setVector(const Teuchos::RCP<Thyra::VectorBase<double> > & destVec)
81 {
82  TEUCHOS_TEST_FOR_EXCEPTION(useEpetra_,std::logic_error,
83  "Reponse field \"" << this->getName() << "\" has previously been initialized as an "
84  "Epetra object, now trying to initalize as a Thyra object! Error!");
85 
86  tVector_ = destVec;
87 
88  useThyra_ = true;
89 }
90 
91 }
92 
93 #endif
Teuchos::RCP< const Epetra_Map > getMap() const
Get the Epetra_Map for this response, map is constructed lazily.
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > getVectorSpace() const
Get the vector space for this response, vector space is constructed lazily.
Thyra::ArrayRCP< double > getThyraVector() const
Access the thyra vector.
void setVector(const Teuchos::RCP< Epetra_Vector > &destVec)
Epetra_Vector & getEpetraVector() const
Access the epetra vector.