Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_ResponseMESupport_Default_impl.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Panzer: A partial differential equation assembly
4 // engine for strongly coupled complex multiphysics systems
5 //
6 // Copyright 2011 NTESS and the Panzer contributors.
7 // SPDX-License-Identifier: BSD-3-Clause
8 // *****************************************************************************
9 // @HEADER
10 
11 #ifndef __Panzer_ResponseMESupport_Default_impl_hpp__
12 #define __Panzer_ResponseMESupport_Default_impl_hpp__
13 
14 namespace panzer {
15 
16 #ifdef PANZER_HAVE_EPETRA_STACK
17 template <typename EvalT>
18 Epetra_Vector & ResponseMESupport_Default<EvalT>::
19 getEpetraVector() const
20 {
21  TEUCHOS_ASSERT(useEpetra());
22 
23  return *eVector_;
24 }
25 #endif
26 
27 template <typename EvalT>
28 Thyra::ArrayRCP<double> ResponseMESupport_Default<EvalT>::
30 {
31  TEUCHOS_ASSERT(useThyra());
32 
34  Teuchos::rcp_dynamic_cast<Thyra::SpmdVectorBase<double> >(tVector_,true)->getNonconstLocalData(Teuchos::outArg(data));
35 
36  return data;
37 }
38 
39 #ifdef PANZER_HAVE_EPETRA_STACK
40 template <typename EvalT>
42 getMap() const
43 {
44  TEUCHOS_TEST_FOR_EXCEPTION(useThyra_,std::logic_error,
45  "Reponse field \"" << this->getName() << "\" has previously been initialized as a "
46  "Thyra object, now trying to initalize as a Epetra! Error!");
47 
48  // lazily construct the map only as needed
49  if(map_==Teuchos::null) {
50  if(this->vectorIsDistributed())
51  map_ = Teuchos::rcp(new Epetra_Map(-1,(int) this->localSizeRequired(),0,eComm_));
52  else
53  map_ = Teuchos::rcp(new Epetra_LocalMap((int) this->localSizeRequired(),0,eComm_));
54  }
55 
56  return map_;
57 }
58 
59 template <typename EvalT>
62 {
63  TEUCHOS_TEST_FOR_EXCEPTION(useThyra_,std::logic_error,
64  "Reponse field \"" << this->getName() << "\" has previously been initialized as a "
65  "Thyra object, now trying to initalize as a Epetra! Error!");
66 
67  eVector_ = destVec;
68 
69  useEpetra_ = true;
70 }
71 #endif
72 
73 template <typename EvalT>
76 {
77  TEUCHOS_TEST_FOR_EXCEPTION(useEpetra_,std::logic_error,
78  "Reponse field \"" << this->getName() << "\" has previously been initialized as an "
79  "Epetra object, now trying to initalize as a Thyra object! Error!");
80 
81  // lazily build the space and return it
82  if(vSpace_==Teuchos::null) {
83  if(this->vectorIsDistributed())
84  vSpace_ = Thyra::defaultSpmdVectorSpace<double>(tComm_,this->localSizeRequired(),-1);
85  else
86  vSpace_ = Thyra::locallyReplicatedDefaultSpmdVectorSpace<double>(tComm_,this->localSizeRequired());
87  }
88 
89  return vSpace_;
90 }
91 
92 template <typename EvalT>
95 {
96  TEUCHOS_TEST_FOR_EXCEPTION(useEpetra_,std::logic_error,
97  "Reponse field \"" << this->getName() << "\" has previously been initialized as an "
98  "Epetra object, now trying to initalize as a Thyra object! Error!");
99 
100  tVector_ = destVec;
101 
102  useThyra_ = true;
103 }
104 
105 }
106 
107 #endif
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
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.
#define TEUCHOS_ASSERT(assertion_test)
void setVector(const Teuchos::RCP< Thyra::VectorBase< double > > &destVec)