50 #ifndef _ZOLTAN2_XPETRAMULTIVECTORADAPTER_HPP_ 51 #define _ZOLTAN2_XPETRAMULTIVECTORADAPTER_HPP_ 58 #include <Xpetra_EpetraMultiVector.hpp> 59 #include <Xpetra_TpetraMultiVector.hpp> 80 template <
typename User>
84 #ifndef DOXYGEN_SHOULD_SKIP_THIS 92 typedef User userCoord_t;
94 typedef Xpetra::MultiVector<scalar_t, lno_t, gno_t, node_t> x_mvector_t;
95 typedef Xpetra::TpetraMultiVector<
97 typedef Xpetra::EpetraMultiVector xe_mvector_t;
120 std::vector<const scalar_t *> &weights, std::vector<int> &weightStrides);
138 ids = map_->getNodeElementList().getRawPtr();
145 env_->localInputAssertion(__FILE__, __LINE__,
"invalid weight index",
148 weights_[idx].getStridedList(length, weights, stride);
157 void getEntriesView(
const scalar_t *&elements,
int &stride,
int idx=0)
const;
159 template <
typename Adapter>
163 template <
typename Adapter>
169 RCP<const User> invector_;
170 RCP<const x_mvector_t> vector_;
171 RCP<const Xpetra::Map<lno_t, gno_t, node_t> > map_;
172 RCP<Environment> env_;
176 ArrayRCP<StridedData<lno_t, scalar_t> > weights_;
183 template <
typename User>
185 const RCP<const User> &invector,
186 std::vector<const scalar_t *> &weights, std::vector<int> &weightStrides):
187 invector_(invector), vector_(), map_(),
189 numWeights_(weights.size()), weights_(weights.size())
193 RCP<x_mvector_t> tmp =
195 vector_ = rcp_const_cast<
const x_mvector_t>(tmp);
196 map_ = vector_->getMap();
197 base_ = map_->getIndexBase();
199 size_t length = vector_->getLocalLength();
201 if (length > 0 && numWeights_ > 0){
203 for (
int w=0; w < numWeights_; w++){
204 if (weightStrides.size())
205 stride = weightStrides[w];
206 ArrayRCP<const scalar_t> wgtV(weights[w], 0, stride*length,
false);
207 weights_[w] = input_t(wgtV, stride);
214 template <
typename User>
216 const RCP<const User> &invector):
217 invector_(invector), vector_(), map_(),
219 numWeights_(0), weights_()
221 RCP<x_mvector_t> tmp =
223 vector_ = rcp_const_cast<
const x_mvector_t>(tmp);
224 map_ = vector_->getMap();
225 base_ = map_->getIndexBase();
229 template <
typename User>
231 const scalar_t *&elements,
int &stride,
int idx)
const 236 if (map_->lib() == Xpetra::UseTpetra){
237 const xt_mvector_t *tvector =
238 dynamic_cast<const xt_mvector_t *
>(vector_.get());
240 vecsize = tvector->getLocalLength();
242 ArrayRCP<const scalar_t> data = tvector->getData(idx);
243 elements = data.get();
246 else if (map_->lib() == Xpetra::UseEpetra){
247 const xe_mvector_t *evector =
248 dynamic_cast<const xe_mvector_t *
>(vector_.get());
250 vecsize = evector->getLocalLength();
252 ArrayRCP<const double> data = evector->getData(idx);
256 elements =
reinterpret_cast<const scalar_t *
>(data.get());
260 throw std::logic_error(
"invalid underlying lib");
265 template <
typename User>
266 template <
typename Adapter>
268 const User &in, User *&out,
273 ArrayRCP<gno_t> importList;
277 (solution,
this, importList);
283 importList.getRawPtr());
289 template <
typename User>
290 template <
typename Adapter>
292 const User &in, RCP<User> &out,
297 ArrayRCP<gno_t> importList;
301 (solution,
this, importList);
307 importList.getRawPtr());
InputTraits< User >::scalar_t scalar_t
Helper functions for Partitioning Problems.
fast typical checks for valid arguments
#define Z2_FORWARD_EXCEPTIONS
Forward an exception back through call stack.
InputTraits< User >::gno_t gno_t
XpetraMultiVectorAdapter(const RCP< const User > &invector, std::vector< const scalar_t * > &weights, std::vector< int > &weightStrides)
Constructor.
Defines the VectorAdapter interface.
static RCP< User > doMigration(const User &from, size_t numLocalRows, const gno_t *myNewRows)
Migrate the object Given a user object and a new row distribution, create and return a new user objec...
Traits of Xpetra classes, including migration method.
static RCP< User > convertToXpetra(const RCP< User > &a)
Convert the object to its Xpetra wrapped version.
size_t getImportList(const PartitioningSolution< SolutionAdapter > &solution, const DataAdapter *const data, ArrayRCP< typename DataAdapter::gno_t > &imports)
From a PartitioningSolution, get a list of IDs to be imported. Assumes part numbers in PartitioningSo...
int getNumEntriesPerID() const
Return the number of vectors (typically one).
A PartitioningSolution is a solution to a partitioning problem.
void applyPartitioningSolution(const User &in, User *&out, const PartitioningSolution< Adapter > &solution) const
VectorAdapter defines the interface for vector input.
The StridedData class manages lists of weights or coordinates.
~XpetraMultiVectorAdapter()
Destructor.
void getEntriesView(const scalar_t *&elements, int &stride, int idx=0) const
Provide a pointer to the elements of the specified vector.
InputTraits< User >::part_t part_t
The user parameters, debug, timing and memory profiling output objects, and error checking methods...
int getNumWeightsPerID() const
Returns the number of weights per object. Number of weights per object should be zero or greater...
An adapter for Xpetra::MultiVector.
void getIDsView(const gno_t *&ids) const
size_t getLocalNumIDs() const
Returns the number of objects on this process.
void getWeightsView(const scalar_t *&weights, int &stride, int idx) const
Provide pointer to a weight array with stride.
This file defines the StridedData class.