50 #ifndef _ZOLTAN2_XPETRAVECTORINPUT_HPP_
51 #define _ZOLTAN2_XPETRAVECTORINPUT_HPP_
58 #include <Xpetra_EpetraVector.hpp>
59 #include <Xpetra_TpetraVector.hpp>
83 template <
typename User>
87 #ifndef DOXYGEN_SHOULD_SKIP_THIS
96 typedef Xpetra::Vector<
98 typedef Xpetra::TpetraVector<
100 typedef Xpetra::EpetraVector xe_vector_t;
122 vector<const scalar_t *> &weights, vector<int> &weightStrides);
163 const scalar_t *&elements,
int &stride)
const
165 env_->localInputAssertion(__FILE__, __LINE__,
"invalid vector",
173 env_->localInputAssertion(__FILE__, __LINE__,
"invalid dimension",
178 weights_[dim].getStridedList(length, weights, stride);
183 template <
typename Adapter>
189 RCP<const User> invector_;
190 RCP<const x_vector_t> vector_;
191 RCP<const Xpetra::Map<lno_t, gno_t, node_t> > map_;
192 RCP<Environment> env_;
196 ArrayRCP<StridedData<lno_t, scalar_t> > weights_;
203 template <
typename User>
205 const RCP<const User> &invector,
206 vector<const scalar_t *> &weights, vector<int> &weightStrides):
207 invector_(invector), vector_(), map_(),
209 numWeights_(weights.size()), weights_()
214 map_ = vector_->getMap();
215 base_ = map_->getIndexBase();
217 size_t length = vector_->getLocalLength();
220 weights_ = arcp(
new input_t [numWeights_], 0, numWeights_,
true);
222 if (length > 0 && numWeights_ > 0){
224 for (
int w=0; w < numWeights_; w++){
225 if (weightStrides.size())
226 stride = weightStrides[w];
227 ArrayRCP<const scalar_t> wtArray(weights[w], 0, stride*length,
false);
228 weights_[w] =
input_t(wtArray, stride);
233 template <
typename User>
235 const scalar_t *&elements,
int &stride)
const
239 const x_vector_t *vec = vector_.get();
241 if (map_->lib() == Xpetra::UseTpetra){
242 const xt_vector_t *tvector =
dynamic_cast<const xt_vector_t *
>(vec);
244 if (tvector->getLocalLength() > 0){
246 ArrayRCP<const scalar_t> data = tvector->getData(0);
247 elements = data.get();
250 else if (map_->lib() == Xpetra::UseEpetra){
251 const xe_vector_t *evector =
dynamic_cast<const xe_vector_t *
>(vec);
253 if (evector->getLocalLength() > 0){
255 ArrayRCP<const double> data = evector->getData(0);
259 elements =
reinterpret_cast<const scalar_t *
>(data.get());
263 throw logic_error(
"invalid underlying lib");
266 ArrayView<const gid_t> gids = map_->getNodeElementList();
267 Ids = gids.getRawPtr();
269 return getLocalLength();
272 template <
typename User>
273 template <
typename Adapter>
275 const User &in, User *&out,
281 const gid_t *gids = solution.
getIdList();
283 ArrayRCP<gid_t> gidList = arcp(const_cast<gid_t *>(gids), 0, len,
false);
284 ArrayRCP<partId_t> partList = arcp(const_cast<partId_t *>(parts), 0, len,
287 ArrayRCP<lno_t> dummyIn;
288 ArrayRCP<gid_t> importList;
289 ArrayRCP<lno_t> dummyOut;
292 const RCP<const Comm<int> > comm = map_->getComm();
296 0, dummyIn, importList, dummyOut);
300 RCP<const User> inPtr = rcp(&in,
false);
301 lno_t localNumElts = numNewRows;
304 inPtr, localNumElts, importList.get());
306 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.