43 #ifndef __Panzer_TpetraVector_ReadOnly_GlobalEvaluationData_impl_hpp__
44 #define __Panzer_TpetraVector_ReadOnly_GlobalEvaluationData_impl_hpp__
46 #include "Thyra_TpetraThyraWrappers.hpp"
52 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
58 "TpetraVector_ReadOnly_GED has been initialized, cannot call \"useConstantValues\"!");
64 globalFilteredPairs_.push_back(pair);
67 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
75 ghostedMap_ = ghostedMap;
82 ghostedSpace_ = Thyra::tpetraVectorSpace<ScalarT, LocalOrdinalT,
83 GlobalOrdinalT, NodeT>(ghostedMap_);
84 ownedSpace_ = Thyra::tpetraVectorSpace<ScalarT, LocalOrdinalT,
85 GlobalOrdinalT, NodeT>(ownedMap_);
90 filteredPairs_.resize(globalFilteredPairs_.size());
91 for(std::size_t i=0;i<globalFilteredPairs_.size();i++) {
92 std::vector<LocalOrdinalT>
lids;
93 const std::vector<GlobalOrdinalT> & gids = globalFilteredPairs_[i].first;
94 for(std::size_t j=0;j<gids.size();j++) {
95 LocalOrdinalT lid = ghostedMap->getLocalElement(gids[j]);
103 filteredPairs_[i].first =
lids;
104 filteredPairs_[i].second = globalFilteredPairs_[i].second;
107 isInitialized_ =
true;
110 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
116 "Owned vector has not been set, can't perform the halo exchange!");
123 ghostedVector_->doImport(*ownedVector_, *importer_, Tpetra::INSERT);
124 PHX::ExecSpace().fence();
127 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
133 "TpetraVector_ReadOnly_GED has not been initialized, cannot call \"initializeData\"!");
135 ghostedVector_->putScalar(0.0);
136 PHX::ExecSpace().fence();
138 typedef typename VectorType::dual_view_type::t_dev::memory_space DMS;
139 auto values = ghostedVector_->getLocalViewHost(Tpetra::Access::OverwriteAll);
142 for(std::size_t i=0;i<filteredPairs_.size();i++) {
143 const std::vector<int> &
lids = filteredPairs_[i].first;
144 double value = filteredPairs_[i].second;
145 for(std::size_t j=0;j<lids.size();j++)
146 values(lids[j], 0) = value;
150 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
156 ownedVector_ = ownedVector;
159 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
168 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
176 return ghostedVector_;
179 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
185 typedef Thyra::TpetraOperatorVectorExtraction<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT> TOE;
187 ownedVector_ = TOE::getConstTpetraVector(ownedVector);
190 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
196 return (ownedVector_ == Teuchos::null) ? Teuchos::null :
197 Thyra::createConstVector(ownedVector_, ownedSpace_);
200 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
208 return Thyra::createVector(ghostedVector_,ghostedSpace_);
211 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
216 const std::string tab =
" ";
218 os << tab <<
"TpetraVector_ReadOnly_GlobalEvaluationData\n"
219 << tab <<
" init = " << isInitialized_ <<
"\n"
220 << tab <<
" owned = " << ownedVector_ <<
"\n"
221 << 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)