1 #ifndef __Panzer_TpetraVector_ReadOnly_GlobalEvaluationData_impl_hpp__ 2 #define __Panzer_TpetraVector_ReadOnly_GlobalEvaluationData_impl_hpp__ 4 #include "Thyra_TpetraThyraWrappers.hpp" 10 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
16 "TpetraVector_ReadOnly_GED has been initialized, cannot call \"useConstantValues\"!");
22 globalFilteredPairs_.push_back(pair);
25 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
33 ghostedMap_ = ghostedMap;
40 ghostedSpace_ = Thyra::tpetraVectorSpace<ScalarT, LocalOrdinalT,
41 GlobalOrdinalT, NodeT>(ghostedMap_);
42 ownedSpace_ = Thyra::tpetraVectorSpace<ScalarT, LocalOrdinalT,
43 GlobalOrdinalT, NodeT>(ownedMap_);
48 filteredPairs_.resize(globalFilteredPairs_.size());
49 for(std::size_t i=0;i<globalFilteredPairs_.size();i++) {
50 std::vector<LocalOrdinalT>
lids;
51 const std::vector<GlobalOrdinalT> & gids = globalFilteredPairs_[i].first;
52 for(std::size_t j=0;j<gids.size();j++) {
53 LocalOrdinalT lid = ghostedMap->getLocalElement(gids[j]);
61 filteredPairs_[i].first =
lids;
62 filteredPairs_[i].second = globalFilteredPairs_[i].second;
65 isInitialized_ =
true;
68 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
74 "Owned vector has not been set, can't perform the halo exchange!");
81 ghostedVector_->doImport(*ownedVector_, *importer_, Tpetra::INSERT);
84 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
90 "TpetraVector_ReadOnly_GED has not been initialized, cannot call \"initializeData\"!");
92 ghostedVector_->putScalar(0.0);
94 typedef typename VectorType::dual_view_type::t_dev::memory_space DMS;
95 auto values_2d = ghostedVector_->template getLocalView<DMS>();
96 auto values = Kokkos::subview(values_2d, Kokkos::ALL (), 0);
99 for(std::size_t i=0;i<filteredPairs_.size();i++) {
100 const std::vector<int> &
lids = filteredPairs_[i].first;
101 double value = filteredPairs_[i].second;
102 for(std::size_t j=0;j<
lids.size();j++)
107 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
113 ownedVector_ = ownedVector;
116 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
125 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
133 return ghostedVector_;
136 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
142 typedef Thyra::TpetraOperatorVectorExtraction<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT> TOE;
144 ownedVector_ = TOE::getConstTpetraVector(ownedVector);
147 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
153 return (ownedVector_ == Teuchos::null) ? Teuchos::null :
154 Thyra::createConstVector(ownedVector_, ownedSpace_);
157 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
165 return Thyra::createVector(ghostedVector_,ghostedSpace_);
168 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
173 const std::string tab =
" ";
175 os << tab <<
"TpetraVector_ReadOnly_GlobalEvaluationData\n" 176 << tab <<
" init = " << isInitialized_ <<
"\n" 177 << tab <<
" owned = " << ownedVector_ <<
"\n" 178 << 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)
Kokkos::View< const LO **, PHX::Device > lids
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
std::vector< ScalarT > values
Teuchos::RCP< const VectorType > getOwnedVector_Tpetra() const
Get the owned vector (Tpetra version)
void print(std::ostream &os) const
Diagnostic function.
Teuchos::RCP< Thyra::VectorBase< double > > getGhostedVector() const
Get the ghosted vector (Thyra version)
Teuchos::RCP< VectorType > getGhostedVector_Tpetra() const
Get the ghosted vector (Tpetra version)
virtual void globalToGhost(int mem)
void setOwnedVector_Tpetra(const Teuchos::RCP< const VectorType > &ownedVector)
Set the owned vector (Tpetra version)
Teuchos::RCP< const Thyra::VectorBase< double > > getOwnedVector() const
Get the owned vector (Thyra version)
#define TEUCHOS_ASSERT(assertion_test)
std::pair< std::vector< GlobalOrdinalT >, double > FilteredGlobalPair
void initialize(const Teuchos::RCP< const ImportType > &importer, const Teuchos::RCP< const MapType > &ghostedMap, const Teuchos::RCP< const MapType > &ownedMap)