22#include "Thyra_DefaultProductVector.hpp"
23#include "Thyra_DefaultProductVectorSpace.hpp"
24#include "Thyra_VectorBase.hpp"
35 : isInitialized_(false)
62 const std::vector<Teuchos::RCP<ReadOnlyVector_GlobalEvaluationData>>&
67 initialize(ghostedSpace, ownedSpace, gedBlocks);
80 const std::vector<Teuchos::RCP<ReadOnlyVector_GlobalEvaluationData>>&
83 using std::logic_error;
85 using Teuchos::rcp_dynamic_cast;
89 for (
size_t i(0); i < gedBlocks.size(); ++i)
91 logic_error,
"BlockedVector_ReadOnly_GlobalEvaluationData::" \
92 "initialize: GED block " << i <<
" is not initialized.")
95 rcp_dynamic_cast<const DefaultProductVectorSpace<double>>(ghostedSpace);
96 TEUCHOS_TEST_FOR_EXCEPTION(
ghostedSpace_.is_null(), logic_error,
97 "BlockedVector_ReadOnly_GlobalEvaluationData::initialize(): Ghosted " \
98 "space must be a Thyra::DefaultProductVectorSpace");
112 using std::logic_error;
115 "BlockedVector_ReadOnly_GlobalEvaluationData has not been " \
116 "initialized; cannot call \"globalToGhost()\"!");
130 using std::logic_error;
133 "BlockedVector_ReadOnly_GlobalEvaluationData has not been " \
134 "initialized; cannot call \"initializeData()\"!");
149 using std::logic_error;
153 using Thyra::castOrCreateProductVectorBase;
156 RCP<const ProductVectorBase<double>> blocks =
158 TEUCHOS_TEST_FOR_EXCEPTION(blocks->productSpace()->numBlocks() !=
160 "BlockedVector_ReadOnly_GlobalEvaluationData owned vector has the " \
161 "wrong number of blocks!");
171 Teuchos::RCP<const Thyra::VectorBase<double>>
183 Teuchos::RCP<Thyra::VectorBase<double>>
187 using std::logic_error;
190 using Teuchos::arrayViewFromVector;
192 using Thyra::defaultProductVector;
195 "BlockedVector_ReadOnly_GlobalEvaluationData has not been " \
196 "initialized; cannot call \"getGhostedVector()\"!");
197 vector<RCP<VectorBase<double>>> blocks;
199 blocks.push_back(
gedBlocks_[i]->getGhostedVector());
200 const vector<RCP<VectorBase<double>>>& constBlocks = blocks;
202 arrayViewFromVector(constBlocks));
This class encapsulates the needs of a gather operation to do a halo exchange for blocked vectors.
virtual Teuchos::RCP< Thyra::VectorBase< double > > getGhostedVector() const
Get the ghosted vector.
bool isInitialized_
A flag indicating whether or not the object has been initialized.
virtual void initializeData()
Initialize internal data for communication.
void initialize(const Teuchos::RCP< const Thyra::VectorSpaceBase< double > > &ghostedSpace, const Teuchos::RCP< const Thyra::VectorSpaceBase< double > > &ownedSpace, const std::vector< Teuchos::RCP< ReadOnlyVector_GlobalEvaluationData > > &gedBlocks)
Initialize this object using the sub-GlobalEvaluationData objects.
Teuchos::RCP< const Thyra::VectorBase< double > > ownedVector_
The owned vector.
Teuchos::RCP< const Thyra::DefaultProductVectorSpace< double > > ghostedSpace_
The vector space corresponding to the ghosted vector.
std::vector< Teuchos::RCP< ReadOnlyVector_GlobalEvaluationData > > gedBlocks_
A vector of the GlobalEvaluationData blocks.
virtual bool isInitialized() const
Is this object initialized?
virtual void globalToGhost(int mem)
Communicate the owned data to the ghosted vector.
virtual void setOwnedVector(const Teuchos::RCP< const Thyra::VectorBase< double > > &ownedVector)
Set the owned vector.
virtual Teuchos::RCP< const Thyra::VectorBase< double > > getOwnedVector() const
Get the owned vector.
BlockedVector_ReadOnly_GlobalEvaluationData()
Default Constructor.