Panzer Version of the Day
Loading...
Searching...
No Matches
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
14namespace panzer {
15
16#ifdef PANZER_HAVE_EPETRA_STACK
17template <typename EvalT>
18Epetra_Vector & ResponseMESupport_Default<EvalT>::
19getEpetraVector() const
20{
21 TEUCHOS_ASSERT(useEpetra());
22
23 return *eVector_;
24}
25#endif
26
27template <typename EvalT>
29getThyraVector() const
30{
31 TEUCHOS_ASSERT(useThyra());
32
33 Teuchos::ArrayRCP<double> data;
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
40template <typename EvalT>
41Teuchos::RCP<const Epetra_Map> ResponseMESupport_Default<EvalT>::
42getMap() 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
59template <typename EvalT>
61setVector(const Teuchos::RCP<Epetra_Vector> & destVec)
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
73template <typename EvalT>
74Teuchos::RCP<const Thyra::VectorSpaceBase<double> > ResponseMESupport_Default<EvalT>::
75getVectorSpace() const
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
92template <typename EvalT>
94setVector(const Teuchos::RCP<Thyra::VectorBase<double> > & destVec)
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
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.