50 #ifndef _ZOLTAN2_IDENTIFIERMODEL_HPP_ 51 #define _ZOLTAN2_IDENTIFIERMODEL_HPP_ 69 template <
typename Adapter>
74 #ifndef DOXYGEN_SHOULD_SKIP_THIS 75 typedef typename Adapter::scalar_t scalar_t;
76 typedef typename Adapter::gno_t gno_t;
77 typedef typename Adapter::lno_t lno_t;
89 const RCP<const Environment> &env,
90 const RCP<
const Comm<int> > &comm,
modelFlag_t &modelFlags);
99 return numGlobalIdentifiers_;
111 ArrayView<input_t> &wgts)
const 113 Ids = ArrayView<const gno_t>();
114 wgts = weights_.view(0, nUserWeights_);
117 Ids = ArrayView<const gno_t>(
118 reinterpret_cast<const gno_t*
>(gids_.getRawPtr()), n);
133 gno_t numGlobalIdentifiers_;
134 const RCP<const Environment> env_;
135 const RCP<const Comm<int> > comm_;
136 ArrayRCP<const gno_t> gids_;
138 ArrayRCP<input_t> weights_;
142 template <
typename Adapter>
144 const RCP<const Adapter> &ia,
145 const RCP<const Environment> &env,
146 const RCP<
const Comm<int> > &comm,
148 numGlobalIdentifiers_(), env_(env), comm_(comm),
149 gids_(), nUserWeights_(0), weights_()
152 size_t nLocalIds = ia->getLocalNumIDs();
153 gno_t lsum = nLocalIds;
154 reduceAll<int, gno_t>(*comm_, Teuchos::REDUCE_SUM, 1, &lsum,
155 &numGlobalIdentifiers_);
159 int tmp = ia->getNumWeightsPerID();
160 Teuchos::reduceAll<int, int>(*comm, Teuchos::REDUCE_MAX, 1,
161 &tmp, &nUserWeights_);
166 Array<const scalar_t *> wgts(nUserWeights_, (
const scalar_t *)NULL);
167 Array<int> wgtStrides(nUserWeights_, 0);
169 if (nUserWeights_ > 0){
170 input_t *w =
new input_t [nUserWeights_];
171 weights_ = arcp<input_t>(w, 0, nUserWeights_);
174 const gno_t *gids=NULL;
178 ia->getIDsView(gids);
179 for (
int idx=0; idx < nUserWeights_; idx++)
180 ia->getWeightsView(wgts[idx], wgtStrides[idx], idx);
185 gids_ = arcp(gids, 0, nLocalIds,
false);
187 if (nUserWeights_ > 0){
188 for (
int idx=0; idx < nUserWeights_; idx++){
189 ArrayRCP<const scalar_t> wgtArray(wgts[idx], 0,
190 nLocalIds*wgtStrides[idx],
false);
191 weights_[idx] = input_t(wgtArray, wgtStrides[idx]);
196 env_->memory(
"After construction of identifier model");
size_t getGlobalNumObjects() const
Return the global number of objects.
#define Z2_FORWARD_EXCEPTIONS
Forward an exception back through call stack.
Defines the Model interface.
size_t getLocalNumIdentifiers() const
size_t getLocalNumObjects() const
Return the local number of objects.
std::bitset< NUM_MODEL_FLAGS > modelFlag_t
global_size_t getGlobalNumIdentifiers() const
size_t getIdentifierList(ArrayView< const gno_t > &Ids, ArrayView< input_t > &wgts) const
The StridedData class manages lists of weights or coordinates.
The base class for all model classes.
IdentifierModel defines the interface for all identifier models.
IdentifierModel(const RCP< const Adapter > &ia, const RCP< const Environment > &env, const RCP< const Comm< int > > &comm, modelFlag_t &modelFlags)
Constructor.
This file defines the StridedData class.