58 #include <Teuchos_GlobalMPISession.hpp> 59 #include <Teuchos_DefaultComm.hpp> 60 #include <Teuchos_RCP.hpp> 61 #include <Teuchos_Comm.hpp> 62 #include <Teuchos_CommHelpers.hpp> 67 using Teuchos::rcp_const_cast;
69 using Teuchos::DefaultComm;
72 typedef Tpetra::Vector<scalar_t, lno_t, gno_t, node_t>
tvector_t;
73 typedef Xpetra::Vector<scalar_t, lno_t, gno_t, node_t>
xvector_t;
79 int rank = comm->getRank();
80 int nprocs = comm->getSize();
82 for (
int p=0; p < nprocs; p++){
84 std::cout << rank <<
":" << std::endl;
85 for (
lno_t i=0; i < vlen; i++){
86 std::cout <<
" " << vtxIds[i] <<
": " << vals[i] << std::endl;
95 template <
typename User>
100 RCP<const Comm<int> > comm = vector.getMap()->getComm();
101 int fail = 0, gfail=0;
115 const gno_t *vtxIds=NULL;
119 size_t nvals = ia.
getVector(vtxIds, vals, stride);
121 if (nvals != vector.getLocalLength())
123 if (!fail && stride != 1)
137 for (
int w=0; !fail && w < wdim; w++){
140 if (nvals != vector.getLocalLength())
142 if (!fail && stride != strides[w])
145 for (
size_t v=0; !fail && v < nvals; v++){
146 if (wgt[v*stride] != weights[w][v*stride])
157 int main(
int argc,
char *argv[])
159 Teuchos::GlobalMPISession session(&argc, &argv);
160 RCP<const Comm<int> > comm = DefaultComm<int>::getComm();
161 int rank = comm->getRank();
162 int fail = 0, gfail=0;
167 RCP<uinput_t> uinput;
173 catch(std::exception &e){
180 tV = uinput->getTpetraVector();
181 size_t vlen = tV->getLocalLength();
182 Teuchos::ArrayView<const gno_t> rowGids = tV->getMap()->getNodeElementList();
191 ArrayRCP<const gno_t> gidArray = arcpFromArrayView(rowGids);
192 RCP<const idmap_t> idMap = rcp(
new idmap_t(env, comm, gidArray));
198 ArrayRCP<zoltan2_partId_t> solnParts(p, 0, vlen,
true);
200 std::vector<const scalar_t *> emptyWeights;
201 std::vector<int> emptyStrides;
205 env, comm, idMap, weightDim);
206 solution.
setParts(gidArray, solnParts,
true);
211 RCP<const tvector_t> ctV = rcp_const_cast<
const tvector_t>(tV);
212 RCP<adapter_t> tVInput;
217 emptyWeights, emptyStrides));
219 catch (std::exception &e){
221 string(
"XpetraVectorInput ")+e.what(), 1);
225 std::cout << tVInput->inputAdapterName() <<
", constructed with ";
226 std::cout <<
"Tpetra::Vector" << std::endl;
229 fail = verifyInputAdapter<tvector_t>(*tVInput, *tV, 0, NULL, NULL);
236 tVInput->applyPartitioningSolution(*tV, vMigrate, solution);
237 newV = rcp(vMigrate);
239 catch (std::exception &e){
246 RCP<const tvector_t> cnewV = rcp_const_cast<
const tvector_t>(newV);
247 RCP<Zoltan2::XpetraVectorInput<tvector_t> > newInput;
250 emptyWeights, emptyStrides));
252 catch (std::exception &e){
254 string(
"XpetraVectorInput 2 ")+e.what(), 1);
258 std::cout << tVInput->inputAdapterName() <<
", constructed with ";
259 std::cout <<
"Tpetra::Vector migrated to proc 0" << std::endl;
261 fail = verifyInputAdapter<tvector_t>(*newInput, *newV, 0, NULL, NULL);
262 if (fail) fail += 100;
274 RCP<xvector_t> xV = uinput->getXpetraVector();
275 RCP<const xvector_t> cxV = rcp_const_cast<
const xvector_t>(xV);
276 RCP<Zoltan2::XpetraVectorInput<xvector_t> > xVInput;
281 emptyWeights, emptyStrides));
283 catch (std::exception &e){
285 string(
"XpetraVectorInput 3 ")+e.what(), 1);
289 std::cout << xVInput->inputAdapterName() <<
", constructed with ";
290 std::cout <<
"Xpetra::Vector" << std::endl;
292 fail = verifyInputAdapter<xvector_t>(*xVInput, *tV, 0, NULL, NULL);
299 xVInput->applyPartitioningSolution(*xV, vMigrate, solution);
301 catch (std::exception &e){
308 RCP<const xvector_t> cnewV(vMigrate);
309 RCP<Zoltan2::XpetraVectorInput<xvector_t> > newInput;
313 emptyWeights, emptyStrides));
315 catch (std::exception &e){
317 string(
"XpetraVectorInput 4 ")+e.what(), 1);
321 std::cout << xVInput->inputAdapterName() <<
", constructed with ";
322 std::cout <<
"Xpetra::Vector migrated to proc 0" << std::endl;
324 fail = verifyInputAdapter<xvector_t>(*newInput, *newV, 0, NULL, NULL);
325 if (fail) fail += 100;
334 #ifdef HAVE_EPETRA_DATA_TYPES 338 RCP<evector_t> eV = uinput->getEpetraVector();
339 RCP<const evector_t> ceV = rcp_const_cast<
const evector_t>(eV);
340 RCP<Zoltan2::XpetraVectorInput<evector_t> > eVInput;
345 emptyWeights, emptyStrides));
347 catch (std::exception &e){
349 string(
"XpetraVectorInput 5 ")+e.what(), 1);
353 std::cout << eVInput->inputAdapterName() <<
", constructed with ";
354 std::cout <<
"Epetra_Vector" << std::endl;
356 fail = verifyInputAdapter<evector_t>(*eVInput, *tV, 0, NULL, NULL);
363 eVInput->applyPartitioningSolution(*eV, vMigrate, solution);
365 catch (std::exception &e){
372 RCP<const evector_t> cnewV(vMigrate,
true);
373 RCP<Zoltan2::XpetraVectorInput<evector_t> > newInput;
377 emptyWeights, emptyStrides));
379 catch (std::exception &e){
381 string(
"XpetraVectorInput 6 ")+e.what(), 1);
385 std::cout << eVInput->inputAdapterName() <<
", constructed with ";
386 std::cout <<
"Epetra_Vector migrated to proc 0" << std::endl;
388 fail = verifyInputAdapter<evector_t>(*newInput, *newV, 0, NULL, NULL);
389 if (fail) fail += 100;
403 std::cout <<
"PASS" << std::endl;
An IdentifierMap manages a global space of object identifiers.
int globalFail(const RCP< const Comm< int > > &comm, int fail)
#define TEST_FAIL_AND_EXIT(comm, ok, s, code)
void setParts(ArrayRCP< const gno_t > &gnoList, ArrayRCP< partId_t > &partList, bool dataDidNotMove)
The algorithm uses setParts to set the solution.
common code used by tests
int zoltan2_partId_t
a data type for part IDs
A PartitioningSolution is a solution to a partitioning problem.
The user parameters, debug, timing and memory profiling output objects, and error checking methods...
void printFailureCode(const RCP< const Comm< int > > &comm, int fail)
std::string testDataFilePath(".")