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>
68 const RCP<
const Comm<int> > &comm,
69 bool nodeZeroHasAll,
bool printInfo)
71 int fail = 0, gfail = 0;
74 std::cout <<
"Test: " << fname << std::endl;
75 std::cout <<
"Num Weights: " << nWeights;
76 std::cout <<
" proc 0 has all: " << nodeZeroHasAll;
77 std::cout << std::endl;
84 typedef Tpetra::MultiVector<zscalar_t, zlno_t, zgno_t, znode_t> mv_t;
86 RCP<UserInputForTests> uinput;
91 catch(std::exception &e){
100 coords = uinput->getUICoordinates();
102 catch(std::exception &e){
108 int coordDim = coords->getNumVectors();
112 const zscalar_t *x=NULL, *y=NULL, *z=NULL;
114 x = coords->getData(0).getRawPtr();
116 y = coords->getData(1).getRawPtr();
118 z = coords->getData(2).getRawPtr();
123 int nLocalIds = coords->getLocalLength();
124 ArrayView<const zgno_t>
idList = coords->getMap()->getNodeElementList();
128 if (comm->getRank() > 0){
133 nGlobalIds = nLocalIds;
135 Teuchos::broadcast<int, int>(*comm, 0, &nGlobalIds);
138 nGlobalIds = coords->getGlobalLength();
141 Array<ArrayRCP<const zscalar_t> > coordWeights(nWeights);
144 for (
int wdim=0; wdim < nWeights; wdim++){
146 for (
int i=0; i < nLocalIds; i++){
147 w[i] = ((i%2) + 1) + wdim;
149 coordWeights[wdim] = Teuchos::arcp(w, 0, nLocalIds);
165 ia = rcp(
new ia_t(nLocalIds, idList.getRawPtr(), x, y, z));
167 catch(std::exception &e){
172 std::vector<const zscalar_t *> values,
weights;
173 std::vector<int> valueStrides, weightStrides;
180 for (
int wdim=0; wdim < nWeights; wdim++){
181 weights.push_back(coordWeights[wdim].getRawPtr());
185 ia = rcp(
new ia_t(nLocalIds, idList.getRawPtr(),
186 values, valueStrides,
weights, weightStrides));
188 catch(std::exception &e){
193 RCP<const base_ia_t> base_ia = Teuchos::rcp_dynamic_cast<
const base_ia_t>(ia);
202 typedef std::bitset<Zoltan2::NUM_MODEL_FLAGS> modelFlags_t;
204 modelFlags_t modelFlags;
211 model = rcp(
new model_t(base_ia, env, comm, modelFlags));
213 catch (std::exception &e){
221 if (model->getCoordinateDim() != coordDim)
224 if (!fail && model->getLocalNumCoordinates() != size_t(nLocalIds))
227 if (!fail && model->getGlobalNumCoordinates() != size_t(nGlobalIds))
230 if (!fail && model->getNumWeightsPerCoordinate() != nWeights)
238 ArrayView<const zgno_t> gids;
239 ArrayView<input_t> xyz;
240 ArrayView<input_t> wgts;
242 model->getCoordinates(gids, xyz, wgts);
244 if (!fail && gids.size() != nLocalIds)
247 for (
int i=0; !fail && i < nLocalIds; i++){
248 if (gids[i] != idList[i])
252 if (!fail && wgts.size() != nWeights)
257 for (
int dim=0; !fail && dim < coordDim; dim++){
258 for (
int i=0; !fail && i < nLocalIds; i++){
259 if (xyz[dim][i] != vals[dim][i])
264 for (
int wdim=0; !fail && wdim < nWeights; wdim++){
265 for (
int i=0; !fail && i < nLocalIds; i++){
266 if (wgts[wdim][i] != coordWeights[wdim][i])
277 int main(
int narg,
char *arg[])
279 Tpetra::ScopeGuard tscope(&narg, &arg);
280 Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
282 int rank = comm->getRank();
283 string fname(
"simple");
297 if (rank==0) std::cout <<
"PASS" << std::endl;
void printFailureCode(const Comm< int > &comm, int fail)
void testCoordinateModel(std::string &fname, int nWeights, const RCP< const Comm< int > > &comm, bool nodeZeroHasAll, bool printInfo)
int main(int narg, char *arg[])
#define TEST_FAIL_AND_EXIT(comm, ok, s, code)
common code used by tests
list idList
Match up parameters to validators.
This class provides geometric coordinates with optional weights to the Zoltan2 algorithm.
VectorAdapter defines the interface for vector input.
The StridedData class manages lists of weights or coordinates.
BasicVectorAdapter represents a vector (plus optional weights) supplied by the user as pointers to st...
The user parameters, debug, timing and memory profiling output objects, and error checking methods...
static const std::string fail
int globalFail(const Comm< int > &comm, int fail)
Defines the CoordinateModel classes.
Defines the BasicVectorAdapter class.
std::string testDataFilePath(".")