56 #include <Teuchos_Comm.hpp> 57 #include <Teuchos_CommHelpers.hpp> 58 #include <Teuchos_DefaultComm.hpp> 59 #include <Teuchos_ArrayView.hpp> 60 #include <Teuchos_OrdinalTraits.hpp> 62 #include <Tpetra_CrsMatrix.hpp> 67 using Teuchos::DefaultComm;
72 const RCP<
const Comm<int> > &comm,
bool consecutiveIds,
73 bool nodeZeroHasAll,
bool printInfo)
75 int fail = 0, gfail = 0;
78 cout <<
"Test: " << fname << endl;
79 cout <<
"Weight dim: " << weightDim;
80 cout <<
" want consec ids: " << consecutiveIds;
81 cout <<
" proc 0 has all: " << nodeZeroHasAll;
89 typedef Tpetra::MultiVector<scalar_t, lno_t, gno_t, node_t> mv_t;
91 RCP<UserInputForTests> uinput;
96 catch(std::exception &e){
105 coords = uinput->getCoordinates();
107 catch(std::exception &e){
113 int coordDim = coords->getNumVectors();
117 const scalar_t *x=NULL, *y=NULL, *z=NULL;
119 x = coords->getData(0).getRawPtr();
121 y = coords->getData(1).getRawPtr();
123 z = coords->getData(2).getRawPtr();
128 int nLocalIds = coords->getLocalLength();
129 ArrayView<const gno_t>
idList = coords->getMap()->getNodeElementList();
133 if (comm->getRank() > 0){
138 nGlobalIds = nLocalIds;
140 Teuchos::broadcast<int, int>(*comm, 0, &nGlobalIds);
143 nGlobalIds = coords->getGlobalLength();
146 Array<ArrayRCP<const scalar_t> > coordWeights(weightDim);
149 for (
int wdim=0; wdim < weightDim; wdim++){
151 for (
int i=0; i < nLocalIds; i++){
152 w[i] = ((i%2) + 1) + wdim;
154 coordWeights[wdim] = Teuchos::arcp(w, 0, nLocalIds);
170 ia = rcp(
new ia_t(nLocalIds, idList.getRawPtr(), x, y, z));
172 catch(std::exception &e){
177 std::vector<const scalar_t *> values, weights;
178 std::vector<int> valueStrides, weightStrides;
185 for (
int wdim=0; wdim < weightDim; wdim++){
186 weights.push_back(coordWeights[wdim].getRawPtr());
190 ia = rcp(
new ia_t(nLocalIds, idList.getRawPtr(),
191 values, valueStrides, weights, weightStrides));
193 catch(std::exception &e){
198 RCP<base_ia_t> base_ia = Teuchos::rcp_implicit_cast<base_ia_t>(ia);
207 typedef std::bitset<Zoltan2::NUM_MODEL_FLAGS> modelFlags_t;
209 modelFlags_t modelFlags;
219 model = rcp(
new model_t(base_ia.getRawPtr(), env, comm, modelFlags));
221 catch (std::exception &e){
229 if (model->getCoordinateDim() != coordDim)
232 if (!fail && model->getLocalNumCoordinates() != size_t(nLocalIds))
235 if (!fail && model->getGlobalNumCoordinates() != size_t(nGlobalIds))
238 if (!fail && model->getCoordinateWeightDim() != weightDim)
246 ArrayView<const gno_t> gids;
247 ArrayView<input_t> xyz;
248 ArrayView<input_t> wgts;
250 model->getCoordinates(gids, xyz, wgts);
252 if (!fail && gids.size() != nLocalIds)
255 for (
int i=0; !fail && i < nLocalIds; i++){
256 if (gids[i] != idList[i])
260 if (!fail && wgts.size() != weightDim)
265 for (
int dim=0; !fail && dim < coordDim; dim++){
266 for (
int i=0; !fail && i < nLocalIds; i++){
267 if (xyz[dim][i] != vals[dim][i])
272 for (
int wdim=0; !fail && wdim < weightDim; wdim++){
273 for (
int i=0; !fail && i < nLocalIds; i++){
274 if (wgts[wdim][i] != coordWeights[wdim][i])
279 if (!fail && consecutiveIds){
281 gids.getRawPtr(), nLocalIds);
293 int main(
int argc,
char *argv[])
295 Teuchos::GlobalMPISession session(&argc, &argv);
296 Teuchos::RCP<const Teuchos::Comm<int> > comm =
297 Teuchos::DefaultComm<int>::getComm();
299 int rank = comm->getRank();
300 string fname(
"simple");
301 bool wishConsecutiveIds =
true;
319 if (rank==0) cout <<
"PASS" << endl;
int globalFail(const RCP< const Comm< int > > &comm, int fail)
Zoltan2::StridedData< lno_t, scalar_t > input_t
algorithm requires consecutive ids
#define TEST_FAIL_AND_EXIT(comm, ok, s, code)
common code used by tests
void testCoordinateModel(std::string &fname, int weightDim, const RCP< const Comm< int > > &comm, bool consecutiveIds, bool nodeZeroHasAll, bool printInfo)
list idList
Match up parameters to validators.
This class provides geometric coordinates with optional weights to the Zoltan2 algorithm.
The StridedData class manages lists of weights or coordinates.
The user parameters, debug, timing and memory profiling output objects, and error checking methods...
static bool areConsecutive(const T *val, size_t n)
Determine if the values are locally increasing consecutive.
void printFailureCode(const RCP< const Comm< int > > &comm, int fail)
int main(int argc, char *argv[])
Defines the CoordinateModel classes.
std::string testDataFilePath(".")