16 #include <Teuchos_DefaultComm.hpp>
17 #include <Teuchos_RCP.hpp>
18 #include <Teuchos_CommHelpers.hpp>
28 int len,
int glen,
zgno_t *ids,
31 int nCoords,
int nWeights)
44 for (
int x=0; !fail && x < nCoords; x++){
53 for (
int i=0; !fail && i < len; i++, coordVal += 3){
55 if (idList[i] != ids[i])
58 if (!fail && vals[stride*i] != *coordVal)
63 for (
int w=0; !fail && w < nWeights; w++){
70 for (
int i=0; !fail && i < len; i++, weightVal++){
71 if (wgts[stride*i] != *weightVal)
80 int main(
int narg,
char *arg[])
82 Tpetra::ScopeGuard tscope(&narg, &arg);
83 Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
85 int rank = comm->getRank();
90 typedef Tpetra::MultiVector<zscalar_t, zlno_t, zgno_t, znode_t> mv_t;
91 RCP<UserInputForTests> uinput;
92 Teuchos::ParameterList params;
93 params.set(
"input file",
"simple");
94 params.set(
"file type",
"Chaco");
99 catch(std::exception &e){
108 coords = uinput->getUICoordinates();
110 catch(std::exception &e){
116 int numLocalIds = coords->getLocalLength();
117 int numGlobalIds = coords->getGlobalLength();
118 int coordDim = coords->getNumVectors();
119 ArrayView<const zgno_t> idList = coords->getMap()->getLocalElementList();
123 Array<zgno_t> myIds(numLocalIds);
124 zgno_t myFirstId = rank * numLocalIds;
127 Array<zscalar_t>
weights(numLocalIds*wdim);
128 for (
int i = 0; i < numLocalIds*wdim; i++) weights[i] =
zscalar_t(i);
130 zscalar_t *x_values= coords->getDataNonConst(0).getRawPtr();
135 y_values= coords->getDataNonConst(1).getRawPtr();
137 z_values= coords->getDataNonConst(2).getRawPtr();
140 Array<zscalar_t> xyz_values(3*numLocalIds);
142 for (
zlno_t i=0; i < numLocalIds; i++)
143 myIds[i] = myFirstId+i;
149 for (
int i=0, ii=0; i < numLocalIds; i++, ii += 3){
155 RCP<Zoltan2::BasicVectorAdapter<userTypes_t> > ia;
167 numLocalIds, myIds.getRawPtr(), x_values, y_values, z_values));
169 catch (std::exception &e){
176 myIds.getRawPtr(), xyz_values.getRawPtr(),
177 weights.getRawPtr(), ncoords, nweights);
192 numLocalIds, myIds.getRawPtr(),
193 x_values, y_values, z_values, 1, 1, 1,
194 true, weights.getRawPtr(), 1));
196 catch (std::exception &e){
203 myIds.getRawPtr(), xyz_values.getRawPtr(),
204 weights.getRawPtr(), ncoords, nweights);
216 std::vector<const zscalar_t *> values, weightValues;
217 std::vector<int> valueStrides, weightStrides;
219 values.push_back(x_values);
220 values.push_back(y_values);
221 values.push_back(z_values);
222 valueStrides.push_back(1);
223 valueStrides.push_back(1);
224 valueStrides.push_back(1);
228 numLocalIds, myIds.getRawPtr(), values, valueStrides,
229 weightValues, weightStrides));
231 catch (std::exception &e){
238 myIds.getRawPtr(), xyz_values.getRawPtr(),
239 weights.getRawPtr(), ncoords, nweights);
245 std::vector<int> emptyStrides;
249 numLocalIds, myIds.getRawPtr(), values, emptyStrides,
250 weightValues, emptyStrides));
252 catch (std::exception &e){
259 myIds.getRawPtr(), xyz_values.getRawPtr(),
260 weights.getRawPtr(), ncoords, nweights);
272 std::vector<const zscalar_t *> values, weightValues;
273 std::vector<int> valueStrides, weightStrides;
275 values.push_back(xyz_values.getRawPtr());
276 values.push_back(xyz_values.getRawPtr() + 1);
277 valueStrides.push_back(3);
278 valueStrides.push_back(3);
280 weightValues.push_back(weights.getRawPtr());
281 weightValues.push_back(weights.getRawPtr() + numLocalIds);
282 weightStrides.push_back(1);
283 weightStrides.push_back(1);
287 numLocalIds, myIds.getRawPtr(), values, valueStrides,
288 weightValues, weightStrides));
290 catch (std::exception &e){
297 myIds.getRawPtr(), xyz_values.getRawPtr(),
298 weights.getRawPtr(), ncoords, nweights);
304 std::vector<int> emptyStrides;
308 numLocalIds, myIds.getRawPtr(), values, valueStrides,
309 weightValues, emptyStrides));
311 catch (std::exception &e){
318 myIds.getRawPtr(), xyz_values.getRawPtr(),
319 weights.getRawPtr(), ncoords, nweights);
331 std::vector<const zscalar_t *> values, weightValues;
332 std::vector<int> valueStrides, weightStrides;
334 values.push_back(x_values);
335 valueStrides.push_back(1);
337 weightValues.push_back(weights.getRawPtr());
338 weightValues.push_back(weights.getRawPtr() + numLocalIds);
339 weightStrides.push_back(1);
340 weightStrides.push_back(1);
344 numLocalIds, myIds.getRawPtr(), values, valueStrides,
345 weightValues, weightStrides));
347 catch (std::exception &e){
354 myIds.getRawPtr(), xyz_values.getRawPtr(),
355 weights.getRawPtr(), ncoords, nweights);
361 std::cout <<
"PASS" << std::endl;
Zoltan2::BasicUserTypes< zscalar_t, zlno_t, zgno_t > userTypes_t
size_t getLocalNumIDs() const
Returns the number of objects on this process.
#define TEST_FAIL_AND_EXIT(comm, ok, s, code)
int main(int narg, char **arg)
common code used by tests
int getNumEntriesPerID() const
Return the number of vectors.
void getWeightsView(const scalar_t *&weights, int &stride, int idx) const
Provide pointer to a weight array with stride.
BasicVectorAdapter represents a vector (plus optional weights) supplied by the user as pointers to st...
Tpetra::Map::local_ordinal_type zlno_t
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
Provide a pointer to the elements of the specified vector.
Defines the BasicVectorAdapter class.
Tpetra::Map::global_ordinal_type zgno_t