51 #include <Teuchos_DefaultComm.hpp>
52 #include <Teuchos_RCP.hpp>
53 #include <Teuchos_CommHelpers.hpp>
63 int len,
int glen,
zgno_t *ids,
66 int nCoords,
int nWeights)
79 for (
int x=0; !fail && x < nCoords; x++){
88 for (
int i=0; !fail && i < len; i++, coordVal += 3){
90 if (idList[i] != ids[i])
93 if (!fail && vals[stride*i] != *coordVal)
98 for (
int w=0; !fail && w < nWeights; w++){
105 for (
int i=0; !fail && i < len; i++, weightVal++){
106 if (wgts[stride*i] != *weightVal)
115 int main(
int narg,
char *arg[])
117 Tpetra::ScopeGuard tscope(&narg, &arg);
118 Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
120 int rank = comm->getRank();
125 typedef Tpetra::MultiVector<zscalar_t, zlno_t, zgno_t, znode_t> mv_t;
126 RCP<UserInputForTests> uinput;
127 Teuchos::ParameterList params;
128 params.set(
"input file",
"simple");
129 params.set(
"file type",
"Chaco");
134 catch(std::exception &e){
143 coords = uinput->getUICoordinates();
145 catch(std::exception &e){
151 int numLocalIds = coords->getLocalLength();
152 int numGlobalIds = coords->getGlobalLength();
153 int coordDim = coords->getNumVectors();
154 ArrayView<const zgno_t>
idList = coords->getMap()->getNodeElementList();
158 Array<zgno_t> myIds(numLocalIds);
159 zgno_t myFirstId = rank * numLocalIds;
162 Array<zscalar_t>
weights(numLocalIds*wdim);
163 for (
int i = 0; i < numLocalIds*wdim; i++) weights[i] =
zscalar_t(i);
165 zscalar_t *x_values= coords->getDataNonConst(0).getRawPtr();
170 y_values= coords->getDataNonConst(1).getRawPtr();
172 z_values= coords->getDataNonConst(2).getRawPtr();
175 Array<zscalar_t> xyz_values(3*numLocalIds);
177 for (
zlno_t i=0; i < numLocalIds; i++)
178 myIds[i] = myFirstId+i;
184 for (
int i=0, ii=0; i < numLocalIds; i++, ii += 3){
190 RCP<Zoltan2::BasicVectorAdapter<userTypes_t> > ia;
202 numLocalIds, myIds.getRawPtr(), x_values, y_values, z_values));
204 catch (std::exception &e){
211 myIds.getRawPtr(), xyz_values.getRawPtr(),
212 weights.getRawPtr(), ncoords, nweights);
227 numLocalIds, myIds.getRawPtr(),
228 x_values, y_values, z_values, 1, 1, 1,
229 true, weights.getRawPtr(), 1));
231 catch (std::exception &e){
238 myIds.getRawPtr(), xyz_values.getRawPtr(),
239 weights.getRawPtr(), ncoords, nweights);
251 std::vector<const zscalar_t *> values, weightValues;
252 std::vector<int> valueStrides, weightStrides;
254 values.push_back(x_values);
255 values.push_back(y_values);
256 values.push_back(z_values);
257 valueStrides.push_back(1);
258 valueStrides.push_back(1);
259 valueStrides.push_back(1);
263 numLocalIds, myIds.getRawPtr(), values, valueStrides,
264 weightValues, weightStrides));
266 catch (std::exception &e){
273 myIds.getRawPtr(), xyz_values.getRawPtr(),
274 weights.getRawPtr(), ncoords, nweights);
280 std::vector<int> emptyStrides;
284 numLocalIds, myIds.getRawPtr(), values, emptyStrides,
285 weightValues, emptyStrides));
287 catch (std::exception &e){
294 myIds.getRawPtr(), xyz_values.getRawPtr(),
295 weights.getRawPtr(), ncoords, nweights);
307 std::vector<const zscalar_t *> values, weightValues;
308 std::vector<int> valueStrides, weightStrides;
310 values.push_back(xyz_values.getRawPtr());
311 values.push_back(xyz_values.getRawPtr() + 1);
312 valueStrides.push_back(3);
313 valueStrides.push_back(3);
315 weightValues.push_back(weights.getRawPtr());
316 weightValues.push_back(weights.getRawPtr() + numLocalIds);
317 weightStrides.push_back(1);
318 weightStrides.push_back(1);
322 numLocalIds, myIds.getRawPtr(), values, valueStrides,
323 weightValues, weightStrides));
325 catch (std::exception &e){
332 myIds.getRawPtr(), xyz_values.getRawPtr(),
333 weights.getRawPtr(), ncoords, nweights);
339 std::vector<int> emptyStrides;
343 numLocalIds, myIds.getRawPtr(), values, valueStrides,
344 weightValues, emptyStrides));
346 catch (std::exception &e){
353 myIds.getRawPtr(), xyz_values.getRawPtr(),
354 weights.getRawPtr(), ncoords, nweights);
366 std::vector<const zscalar_t *> values, weightValues;
367 std::vector<int> valueStrides, weightStrides;
369 values.push_back(x_values);
370 valueStrides.push_back(1);
372 weightValues.push_back(weights.getRawPtr());
373 weightValues.push_back(weights.getRawPtr() + numLocalIds);
374 weightStrides.push_back(1);
375 weightStrides.push_back(1);
379 numLocalIds, myIds.getRawPtr(), values, valueStrides,
380 weightValues, weightStrides));
382 catch (std::exception &e){
389 myIds.getRawPtr(), xyz_values.getRawPtr(),
390 weights.getRawPtr(), ncoords, nweights);
396 std::cout <<
"PASS" << std::endl;
size_t getLocalNumIDs() const
Returns the number of objects on this process.
int main(int narg, char *arg[])
#define TEST_FAIL_AND_EXIT(comm, ok, s, code)
common code used by tests
int getNumEntriesPerID() const
Return the number of vectors.
list idList
Match up parameters to validators.
void getWeightsView(const scalar_t *&weights, int &stride, int idx) const
BasicVectorAdapter represents a vector (plus optional weights) supplied by the user as pointers to st...
static const std::string fail
#define TEST_FAIL_AND_RETURN_VALUE(comm, ok, s, rc)
void getIDsView(const gno_t *&ids) const
Provide a pointer to this process' identifiers.
int getNumWeightsPerID() const
Returns the number of weights per object. Number of weights per object should be zero or greater...
void getEntriesView(const scalar_t *&entries, int &stride, int idx=0) const
Defines the BasicVectorAdapter class.