75 RCP<const Comm<int> > comm = M.getComm();
76 int fail = 0, gfail=0;
81 if (M.getLocalNumRows()){
89 ArrayRCP<const zgno_t> colIds;
90 ArrayRCP<const offset_t> offsets;
99 if (nrows != M.getLocalNumRows())
105 printMatrix<offset_t>(comm, nrows, rowIds, offsets.getRawPtr(),
113 const zgno_t *colIds2=
nullptr;
116 ArrayRCP<const zgno_t> ccsRowIds;
117 ArrayRCP<const offset_t> ccsOffsets;
120 printMatrix<offset_t>(comm, nCols, colIds2, ccsOffsets.getRawPtr(),
128 Tpetra::ScopeGuard tscope(&narg, &arg);
129 Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
131 int rank = comm->getRank();
132 int fail = 0, gfail=0;
138 RCP<UserInputForTests> uinput;
139 Teuchos::ParameterList params;
140 params.set(
"input file",
"simple");
141 params.set(
"file type",
"Chaco");
146 catch(std::exception &e){
148 std::cout << e.what() << std::endl;
155 tM = uinput->getUITpetraCrsMatrix();
156 size_t nrows = tM->getLocalNumRows();
166 typedef adapter_t::part_t
part_t;
169 memset(p, 0,
sizeof(
part_t) * nrows);
170 ArrayRCP<part_t> solnParts(p, 0, nrows,
true);
172 soln_t solution(env, comm, nWeights);
173 solution.setParts(solnParts);
179 std::cout <<
"Input adapter for Tpetra::CrsMatrix" << std::endl;
181 RCP<const tmatrix_t> ctM = rcp_const_cast<const tmatrix_t>(tM);
182 RCP<Zoltan2::XpetraCrsMatrixAdapter<tmatrix_t> > tMInput;
188 catch (std::exception &e){
190 std::cout << e.what() << std::endl;
194 fail = verifyInputAdapter<tmatrix_t>(*tMInput, *tM);
201 tMInput->applyPartitioningSolution(*tM, mMigrate, solution);
202 newM = rcp(mMigrate);
204 catch (std::exception &e){
206 std::cout <<
"Error caught: " << e.what() << std::endl;
212 RCP<const tmatrix_t> cnewM = rcp_const_cast<const tmatrix_t>(newM);
213 RCP<Zoltan2::XpetraCrsMatrixAdapter<tmatrix_t> > newInput;
217 catch (std::exception &e){
219 std::cout << e.what() << std::endl;
225 "Input adapter for Tpetra::CrsMatrix migrated to proc 0" <<
228 fail = verifyInputAdapter<tmatrix_t>(*newInput, *newM);
243 std::cout <<
"Input adapter for Xpetra::CrsMatrix" << std::endl;
245 RCP<xmatrix_t> xM = uinput->getUIXpetraCrsMatrix();
246 RCP<const xmatrix_t> cxM = rcp_const_cast<const xmatrix_t>(xM);
247 RCP<Zoltan2::XpetraCrsMatrixAdapter<xmatrix_t> > xMInput;
253 catch (std::exception &e){
255 std::cout << e.what() << std::endl;
259 fail = verifyInputAdapter<xmatrix_t>(*xMInput, *tM);
266 xMInput->applyPartitioningSolution(*xM, mMigrate, solution);
268 catch (std::exception &e){
269 std::cout <<
"Error caught: " << e.what() << std::endl;
276 RCP<const xmatrix_t> cnewM(mMigrate);
277 RCP<Zoltan2::XpetraCrsMatrixAdapter<xmatrix_t> > newInput;
282 catch (std::exception &e){
284 std::cout << e.what() << std::endl;
290 "Input adapter for Xpetra::CrsMatrix migrated to proc 0" <<
293 fail = verifyInputAdapter<xmatrix_t>(*newInput, *newM);
303#ifdef HAVE_EPETRA_DATA_TYPES
306 typedef Epetra_CrsMatrix ematrix_t;
309 std::cout <<
"Input adapter for Epetra_CrsMatrix" << std::endl;
311 RCP<ematrix_t> eM = uinput->getUIEpetraCrsMatrix();
312 RCP<const ematrix_t> ceM = rcp_const_cast<const ematrix_t>(eM);
313 RCP<Zoltan2::XpetraCrsMatrixAdapter<ematrix_t> > eMInput;
315 bool goodAdapter =
true;
320 catch (std::exception &e){
321 if (std::is_same<znode_t, Xpetra::EpetraNode>::value) {
324 std::cout << e.what() << std::endl;
329 std::cout <<
"Node type is not supported by Xpetra's Epetra interface;"
330 <<
" Skipping this test." << std::endl;
331 std::cout <<
"FYI: Here's the exception message: " << std::endl
332 << e.what() << std::endl;
339 fail = verifyInputAdapter<ematrix_t>(*eMInput, *tM);
344 ematrix_t *mMigrate =NULL;
346 eMInput->applyPartitioningSolution(*eM, mMigrate, solution);
348 catch (std::exception &e){
349 std::cout <<
"Error caught: " << e.what() << std::endl;
356 RCP<const ematrix_t> cnewM(mMigrate,
true);
357 RCP<Zoltan2::XpetraCrsMatrixAdapter<ematrix_t> > newInput;
362 catch (std::exception &e){
364 std::cout << e.what() << std::endl;
370 "Input adapter for Epetra_CrsMatrix migrated to proc 0" <<
373 fail = verifyInputAdapter<ematrix_t>(*newInput, *newM);
389 std::cout <<
"PASS" << std::endl;