59 #include <Teuchos_GlobalMPISession.hpp>
60 #include <Teuchos_DefaultComm.hpp>
61 #include <Teuchos_RCP.hpp>
62 #include <Teuchos_Comm.hpp>
63 #include <Teuchos_CommHelpers.hpp>
68 using Teuchos::rcp_const_cast;
70 using Teuchos::DefaultComm;
73 typedef Tpetra::CrsMatrix<scalar_t, lno_t, gno_t, node_t>
tmatrix_t;
74 typedef Xpetra::CrsMatrix<scalar_t, lno_t, gno_t, node_t>
xmatrix_t;
80 int rank = comm->getRank();
81 int nprocs = comm->getSize();
83 for (
int p=0; p < nprocs; p++){
85 std::cout << rank <<
":" << std::endl;
86 for (
lno_t i=0; i < nrows; i++){
87 std::cout <<
" row " << rowIds[i] <<
": ";
88 for (
lno_t j=offsets[i]; j < offsets[i+1]; j++){
89 std::cout << colIds[j] <<
" ";
91 std::cout << std::endl;
100 template <
typename User>
104 RCP<const Comm<int> > comm = M.getComm();
105 int fail = 0, gfail=0;
110 if (M.getNodeNumRows()){
117 const gno_t *rowIds=NULL, *colIds=NULL;
118 const lno_t *offsets=NULL;
125 if (nrows != M.getNodeNumRows())
134 if (!fail) fail = 10;
140 int main(
int argc,
char *argv[])
142 Teuchos::GlobalMPISession session(&argc, &argv);
143 RCP<const Comm<int> > comm = DefaultComm<int>::getComm();
144 int rank = comm->getRank();
145 int fail = 0, gfail=0;
150 RCP<uinput_t> uinput;
157 catch(std::exception &e){
164 tM = uinput->getTpetraCrsMatrix();
165 size_t nrows = tM->getNodeNumRows();
166 Teuchos::ArrayView<const gno_t> rowGids =
167 tM->getRowMap()->getNodeElementList();
176 ArrayRCP<const gno_t> gidArray = arcpFromArrayView(rowGids);
177 RCP<const idmap_t> idMap = rcp(
new idmap_t(env, comm, gidArray));
184 ArrayRCP<zoltan2_partId_t> solnParts(p, 0, nrows,
true);
188 soln_t solution(env, comm, idMap, weightDim);
189 solution.setParts(gidArray, solnParts,
false);
194 RCP<const tmatrix_t> ctM = rcp_const_cast<
const tmatrix_t>(tM);
195 RCP<Zoltan2::XpetraCrsMatrixInput<tmatrix_t> > tMInput;
201 catch (std::exception &e){
203 string(
"XpetraCrsMatrixInput ")+e.what(), 1);
207 std::cout <<
"Input adapter for Tpetra::CrsMatrix" << std::endl;
209 fail = verifyInputAdapter<tmatrix_t>(*tMInput, *tM);
216 tMInput->applyPartitioningSolution(*tM, mMigrate, solution);
217 newM = rcp(mMigrate);
219 catch (std::exception &e){
221 cout <<
"Error caught: " << e.what() << endl;
227 RCP<const tmatrix_t> cnewM = rcp_const_cast<
const tmatrix_t>(newM);
228 RCP<Zoltan2::XpetraCrsMatrixInput<tmatrix_t> > newInput;
232 catch (std::exception &e){
234 string(
"XpetraCrsMatrixInput 2 ")+e.what(), 1);
239 "Input adapter for Tpetra::CrsMatrix migrated to proc 0" <<
242 fail = verifyInputAdapter<tmatrix_t>(*newInput, *newM);
243 if (fail) fail += 100;
255 RCP<xmatrix_t> xM = uinput->getXpetraCrsMatrix();
256 RCP<const xmatrix_t> cxM = rcp_const_cast<
const xmatrix_t>(xM);
257 RCP<Zoltan2::XpetraCrsMatrixInput<xmatrix_t> > xMInput;
263 catch (std::exception &e){
265 string(
"XpetraCrsMatrixInput 3 ")+e.what(), 1);
269 std::cout <<
"Input adapter for Xpetra::CrsMatrix" << std::endl;
271 fail = verifyInputAdapter<xmatrix_t>(*xMInput, *tM);
278 xMInput->applyPartitioningSolution(*xM, mMigrate, solution);
280 catch (std::exception &e){
281 cout <<
"Error caught: " << e.what() << endl;
288 RCP<const xmatrix_t> cnewM(mMigrate);
289 RCP<Zoltan2::XpetraCrsMatrixInput<xmatrix_t> > newInput;
294 catch (std::exception &e){
296 string(
"XpetraCrsMatrixInput 4 ")+e.what(), 1);
301 "Input adapter for Xpetra::CrsMatrix migrated to proc 0" <<
304 fail = verifyInputAdapter<xmatrix_t>(*newInput, *newM);
305 if (fail) fail += 100;
314 #ifdef HAVE_EPETRA_DATA_TYPES
318 RCP<ematrix_t> eM = uinput->getEpetraCrsMatrix();
319 RCP<const ematrix_t> ceM = rcp_const_cast<
const ematrix_t>(eM);
320 RCP<Zoltan2::XpetraCrsMatrixInput<ematrix_t> > eMInput;
326 catch (std::exception &e){
328 string(
"XpetraCrsMatrixInput 5 ")+e.what(), 1);
332 std::cout <<
"Input adapter for Epetra_CrsMatrix" << std::endl;
334 fail = verifyInputAdapter<ematrix_t>(*eMInput, *tM);
341 eMInput->applyPartitioningSolution(*eM, mMigrate, solution);
343 catch (std::exception &e){
344 cout <<
"Error caught: " << e.what() << endl;
351 RCP<const ematrix_t> cnewM(mMigrate,
true);
352 RCP<Zoltan2::XpetraCrsMatrixInput<ematrix_t> > newInput;
357 catch (std::exception &e){
359 string(
"XpetraCrsMatrixInput 6 ")+e.what(), 1);
364 "Input adapter for Epetra_CrsMatrix migrated to proc 0" <<
367 fail = verifyInputAdapter<ematrix_t>(*newInput, *newM);
368 if (fail) fail += 100;
382 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)
common code used by tests
int main(int argc, char *argv[])
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(".")