50 #ifndef _ZOLTAN2_XPETRAMULTIVECTORINPUT_HPP_
51 #define _ZOLTAN2_XPETRAMULTIVECTORINPUT_HPP_
58 #include <Xpetra_EpetraMultiVector.hpp>
59 #include <Xpetra_TpetraMultiVector.hpp>
80 template <
typename User>
84 #ifndef DOXYGEN_SHOULD_SKIP_THIS
93 typedef Xpetra::MultiVector<scalar_t, lno_t, gno_t, node_t> x_mvector_t;
94 typedef Xpetra::TpetraMultiVector<
96 typedef Xpetra::EpetraMultiVector xe_mvector_t;
119 vector<const scalar_t *> &weights, vector<int> &weightStrides);
164 const scalar_t *&elements,
int &stride)
const
166 return getVector(0, Ids, elements, stride);
169 size_t getVector(
int i,
const gid_t *&Ids,
170 const scalar_t *&elements,
int &stride)
const;
174 env_->localInputAssertion(__FILE__, __LINE__,
"invalid dimension",
179 weights_[dim].getStridedList(length, weights, stride);
184 template <
typename Adapter>
190 RCP<const User> invector_;
191 RCP<const x_mvector_t> vector_;
192 RCP<const Xpetra::Map<lno_t, gno_t, node_t> > map_;
193 RCP<Environment> env_;
197 ArrayRCP<StridedData<lno_t, scalar_t> > weights_;
204 template <
typename User>
206 const RCP<const User> &invector,
207 vector<const scalar_t *> &weights, vector<int> &weightStrides):
208 invector_(invector), vector_(), map_(),
210 numWeights_(weights.size()), weights_(weights.size())
215 map_ = vector_->getMap();
216 base_ = map_->getIndexBase();
218 size_t length = vector_->getLocalLength();
220 if (length > 0 && numWeights_ > 0){
222 for (
int w=0; w < numWeights_; w++){
223 if (weightStrides.size())
224 stride = weightStrides[w];
225 ArrayRCP<const scalar_t> wgtV(weights[w], 0, stride*length,
false);
226 weights_[w] =
input_t(wgtV, stride);
232 template <
typename User>
234 const RCP<const User> &invector):
235 invector_(invector), vector_(), map_(),
237 numWeights_(0), weights_()
240 map_ = vector_->getMap();
241 base_ = map_->getIndexBase();
244 template <
typename User>
246 int i,
const gid_t *&Ids,
const scalar_t *&elements,
int &stride)
const
250 if (map_->lib() == Xpetra::UseTpetra){
251 const xt_mvector_t *tvector =
252 dynamic_cast<const xt_mvector_t *
>(vector_.get());
254 if (tvector->getLocalLength() > 0){
255 ArrayRCP<const scalar_t> data = tvector->getData(i);
256 elements = data.get();
259 else if (map_->lib() == Xpetra::UseEpetra){
260 const xe_mvector_t *evector =
261 dynamic_cast<const xe_mvector_t *
>(vector_.get());
263 if (evector->getLocalLength() > 0){
264 ArrayRCP<const double> data = evector->getData(i);
268 elements =
reinterpret_cast<const scalar_t *
>(data.get());
272 throw logic_error(
"invalid underlying lib");
275 ArrayView<const gid_t> gids = map_->getNodeElementList();
276 Ids = gids.getRawPtr();
280 template <
typename User>
281 template <
typename Adapter>
283 const User &in, User *&out,
287 const gid_t *gids = solution.
getIdList();
289 ArrayRCP<gid_t> gidList = arcp(const_cast<gid_t *>(gids), 0, len,
false);
290 ArrayRCP<partId_t> partList = arcp(const_cast<partId_t *>(parts), 0, len,
292 ArrayRCP<lno_t> dummyIn;
293 ArrayRCP<gid_t> importList;
294 ArrayRCP<lno_t> dummyOut;
297 const RCP<const Comm<int> > comm = map_->getComm();
302 0, dummyIn, importList, dummyOut);
306 RCP<const User> inPtr = rcp(&in,
false);
307 lno_t localNumElts = numNewRows;
310 inPtr, localNumElts, importList.get());
312 out =
const_cast<User *
>(outPtr.get());
fast typical checks for valid arguments
#define Z2_FORWARD_EXCEPTIONS
Forward an exception back through call stack.
Zoltan2::StridedData< lno_t, scalar_t > input_t
zoltan2_partId_t partId_t
Traits of Xpetra classes, including migration method.
Zoltan2::BasicUserTypes< scalar_t, gno_t, lno_t, gno_t > user_t
size_t convertSolutionToImportList(int numExtra, ArrayRCP< Extra > &xtraInfo, ArrayRCP< typename Adapter::gid_t > &imports, ArrayRCP< Extra > &newXtraInfo) const
Create an import list from the export list.
const zoltan2_partId_t * getPartList() const
Returns the part list corresponding to the global ID list.
A PartitioningSolution is a solution to a partitioning problem.
The StridedData class manages lists of weights or coordinates.
static RCP< const User > doMigration(const RCP< const User > &from, lno_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...
static RCP< const User > convertToXpetra(const RCP< const User > &a)
Convert the object to its Xpetra wrapped version.
The user parameters, debug, timing and memory profiling output objects, and error checking methods...
const gid_t * getIdList() const
Returns the user's global ID list.
A gathering of useful namespace methods.
Kokkos::DefaultNode::DefaultNodeType node_t
This file defines the StridedData class.
size_t getLocalNumberOfIds() const
Returns the local number of Ids.