11 #ifndef __Panzer_TpetraVector_ReadOnly_GlobalEvaluationData_impl_hpp__
12 #define __Panzer_TpetraVector_ReadOnly_GlobalEvaluationData_impl_hpp__
14 #include "Thyra_TpetraThyraWrappers.hpp"
20 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
26 "TpetraVector_ReadOnly_GED has been initialized, cannot call \"useConstantValues\"!");
32 globalFilteredPairs_.push_back(pair);
35 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
43 ghostedMap_ = ghostedMap;
50 ghostedSpace_ = Thyra::tpetraVectorSpace<ScalarT, LocalOrdinalT,
51 GlobalOrdinalT, NodeT>(ghostedMap_);
52 ownedSpace_ = Thyra::tpetraVectorSpace<ScalarT, LocalOrdinalT,
53 GlobalOrdinalT, NodeT>(ownedMap_);
58 filteredPairs_.resize(globalFilteredPairs_.size());
59 for(std::size_t i=0;i<globalFilteredPairs_.size();i++) {
60 std::vector<LocalOrdinalT>
lids;
61 const std::vector<GlobalOrdinalT> & gids = globalFilteredPairs_[i].first;
62 for(std::size_t j=0;j<gids.size();j++) {
63 LocalOrdinalT lid = ghostedMap->getLocalElement(gids[j]);
71 filteredPairs_[i].first =
lids;
72 filteredPairs_[i].second = globalFilteredPairs_[i].second;
75 isInitialized_ =
true;
78 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
84 "Owned vector has not been set, can't perform the halo exchange!");
91 ghostedVector_->doImport(*ownedVector_, *importer_, Tpetra::INSERT);
92 PHX::ExecSpace().fence();
95 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
101 "TpetraVector_ReadOnly_GED has not been initialized, cannot call \"initializeData\"!");
103 ghostedVector_->putScalar(0.0);
104 PHX::ExecSpace().fence();
106 auto values = ghostedVector_->getLocalViewHost(Tpetra::Access::OverwriteAll);
109 for(std::size_t i=0;i<filteredPairs_.size();i++) {
110 const std::vector<int> &
lids = filteredPairs_[i].first;
111 double value = filteredPairs_[i].second;
112 for(std::size_t j=0;j<lids.size();j++)
113 values(lids[j], 0) = value;
117 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
123 ownedVector_ = ownedVector;
126 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
135 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
143 return ghostedVector_;
146 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
152 typedef Thyra::TpetraOperatorVectorExtraction<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT> TOE;
154 ownedVector_ = TOE::getConstTpetraVector(ownedVector);
157 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
163 return (ownedVector_ == Teuchos::null) ? Teuchos::null :
164 Thyra::createConstVector(ownedVector_, ownedSpace_);
167 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
175 return Thyra::createVector(ghostedVector_,ghostedSpace_);
178 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
183 const std::string tab =
" ";
185 os << tab <<
"TpetraVector_ReadOnly_GlobalEvaluationData\n"
186 << tab <<
" init = " << isInitialized_ <<
"\n"
187 << tab <<
" owned = " << ownedVector_ <<
"\n"
188 << tab <<
" ghosted = " << ghostedVector_ <<
"\n";
Tpetra::Vector< ScalarT, LocalOrdinalT, GlobalOrdinalT, NodeT > VectorType
virtual void initializeData()
Clear out the ghosted vector.
void setOwnedVector(const Teuchos::RCP< const Thyra::VectorBase< double > > &ownedVector)
Set the owned vector (Thyra version)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void useConstantValues(const std::vector< GlobalOrdinalT > &indices, double value)
void print(std::ostream &os) const
Diagnostic function.
Teuchos::RCP< const Thyra::VectorBase< double > > getOwnedVector() const
Get the owned vector (Thyra version)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
virtual void globalToGhost(int mem)
void setOwnedVector_Tpetra(const Teuchos::RCP< const VectorType > &ownedVector)
Set the owned vector (Tpetra version)
Teuchos::RCP< const VectorType > getOwnedVector_Tpetra() const
Get the owned vector (Tpetra version)
Teuchos::RCP< VectorType > getGhostedVector_Tpetra() const
Get the ghosted vector (Tpetra version)
#define TEUCHOS_ASSERT(assertion_test)
std::pair< std::vector< GlobalOrdinalT >, double > FilteredGlobalPair
Teuchos::RCP< Thyra::VectorBase< double > > getGhostedVector() const
Get the ghosted vector (Thyra version)
Kokkos::View< const LO **, Kokkos::LayoutRight, PHX::Device > lids
void initialize(const Teuchos::RCP< const ImportType > &importer, const Teuchos::RCP< const MapType > &ghostedMap, const Teuchos::RCP< const MapType > &ownedMap)