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_;
137 ArrayRCP<const gno_t> gidsConst_;
139 ArrayRCP<input_t> weights_;
143 template <
typename Adapter>
145 const RCP<const Adapter> &ia,
146 const RCP<const Environment> &env,
147 const RCP<
const Comm<int> > &comm,
149 numGlobalIdentifiers_(), env_(env), comm_(comm),
150 gids_(), gidsConst_(), nUserWeights_(0), weights_()
153 size_t nLocalIds = ia->getLocalNumIDs();
154 gno_t lsum = nLocalIds;
155 reduceAll<int, gno_t>(*comm_, Teuchos::REDUCE_SUM, 1, &lsum,
156 &numGlobalIdentifiers_);
160 int tmp = ia->getNumWeightsPerID();
161 Teuchos::reduceAll<int, int>(*comm, Teuchos::REDUCE_MAX, 1,
162 &tmp, &nUserWeights_);
167 Array<const scalar_t *> wgts(nUserWeights_, (
const scalar_t *)NULL);
168 Array<int> wgtStrides(nUserWeights_, 0);
170 if (nUserWeights_ > 0){
171 input_t *w =
new input_t [nUserWeights_];
172 weights_ = arcp<input_t>(w, 0, nUserWeights_);
175 const gno_t *gids=NULL;
179 ia->getIDsView(gids);
180 for (
int idx=0; idx < nUserWeights_; idx++)
181 ia->getWeightsView(wgts[idx], wgtStrides[idx], idx);
186 gids_ = arcp(gids, 0, nLocalIds,
false);
188 if (nUserWeights_ > 0){
189 for (
int idx=0; idx < nUserWeights_; idx++){
190 ArrayRCP<const scalar_t> wgtArray(wgts[idx], 0,
191 nLocalIds*wgtStrides[idx],
false);
192 weights_[idx] = input_t(wgtArray, wgtStrides[idx]);
197 gidsConst_ = arcp_const_cast<
const gno_t>(gids_);
199 env_->memory(
"After construction of identifier model");
#define Z2_FORWARD_EXCEPTIONS
Forward an exception back through call stack.
Defines the Model interface.
std::bitset< NUM_MODEL_FLAGS > modelFlag_t
The StridedData class manages lists of weights or coordinates.
size_t getLocalNumObjects() const
Return the local number of objects.
The base class for all model classes.
size_t getLocalNumIdentifiers() const
IdentifierModel defines the interface for all identifier models.
size_t getGlobalNumObjects() const
Return the global number of objects.
global_size_t getGlobalNumIdentifiers() const
size_t getIdentifierList(ArrayView< const gno_t > &Ids, ArrayView< input_t > &wgts) const
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.