102 RCP<const Comm<int> > comm = M.getComm();
103 int fail = 0, gfail=0;
105 if (!
fail && ia.getLocalNumRows() != M.getLocalNumRows())
108 if (M.getLocalNumRows()){
109 if (!
fail && ia.getLocalNumColumns() != M.getLocalNumCols())
115 const zgno_t *rowIds=NULL;
116 ArrayRCP<const zgno_t> colIds;
117 ArrayRCP<const offset_t> offsets;
122 nrows = ia.getLocalNumRows();
123 ia.getRowIDsView(rowIds);
124 ia.getCRSView(offsets, colIds);
126 if (nrows != M.getLocalNumRows())
132 printMatrix<offset_t>(comm, nrows, rowIds, offsets.getRawPtr(), colIds.getRawPtr());
143 Tpetra::ScopeGuard tscope(&narg, &arg);
144 Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
146 int rank = comm->getRank();
147 int fail = 0, gfail=0;
153 RCP<UserInputForTests> uinput;
154 Teuchos::ParameterList params;
155 params.set(
"input file",
"simple");
156 params.set(
"file type",
"Chaco");
161 catch(std::exception &e){
163 std::cout << e.what() << std::endl;
170 tM = uinput->getUITpetraCrsMatrix();
171 size_t nrows = tM->getLocalNumRows();
181 typedef adapter_t::part_t
part_t;
184 memset(p, 0,
sizeof(
part_t) * nrows);
185 ArrayRCP<part_t> solnParts(p, 0, nrows,
true);
187 soln_t solution(env, comm, nWeights);
188 solution.setParts(solnParts);
194 std::cout <<
"Input adapter for Tpetra::CrsMatrix" << std::endl;
196 RCP<const tmatrix_t> ctM = rcp_const_cast<const tmatrix_t>(tM);
197 RCP<Zoltan2::XpetraCrsMatrixAdapter<tmatrix_t> > tMInput;
203 catch (std::exception &e){
205 std::cout << e.what() << 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 std::cout <<
"Error caught: " << e.what() << std::endl;
227 RCP<const tmatrix_t> cnewM = rcp_const_cast<const tmatrix_t>(newM);
228 RCP<Zoltan2::XpetraCrsMatrixAdapter<tmatrix_t> > newInput;
232 catch (std::exception &e){
234 std::cout << e.what() << std::endl;
240 "Input adapter for Tpetra::CrsMatrix migrated to proc 0" <<
243 fail = verifyInputAdapter<tmatrix_t>(*newInput, *newM);
257 std::cout <<
"Input adapter for Xpetra::CrsMatrix" << std::endl;
259 RCP<xmatrix_t> xM = uinput->getUIXpetraCrsMatrix();
260 RCP<const xmatrix_t> cxM = rcp_const_cast<const xmatrix_t>(xM);
261 RCP<Zoltan2::XpetraCrsMatrixAdapter<xmatrix_t> > xMInput;
267 catch (std::exception &e){
269 std::cout << e.what() << std::endl;
273 fail = verifyInputAdapter<xmatrix_t>(*xMInput, *tM);
280 xMInput->applyPartitioningSolution(*xM, mMigrate, solution);
282 catch (std::exception &e){
283 std::cout <<
"Error caught: " << e.what() << std::endl;
290 RCP<const xmatrix_t> cnewM(mMigrate);
291 RCP<Zoltan2::XpetraCrsMatrixAdapter<xmatrix_t> > newInput;
296 catch (std::exception &e){
298 std::cout << e.what() << std::endl;
304 "Input adapter for Xpetra::CrsMatrix migrated to proc 0" <<
307 fail = verifyInputAdapter<xmatrix_t>(*newInput, *newM);
317#ifdef HAVE_EPETRA_DATA_TYPES
320 typedef Epetra_CrsMatrix ematrix_t;
323 std::cout <<
"Input adapter for Epetra_CrsMatrix" << std::endl;
325 RCP<ematrix_t> eM = uinput->getUIEpetraCrsMatrix();
326 RCP<const ematrix_t> ceM = rcp_const_cast<const ematrix_t>(eM);
327 RCP<Zoltan2::XpetraCrsMatrixAdapter<ematrix_t> > eMInput;
329 bool goodAdapter =
true;
334 catch (std::exception &e){
335 if (std::is_same<znode_t, Xpetra::EpetraNode>::value) {
338 std::cout << e.what() << std::endl;
343 std::cout <<
"Node type is not supported by Xpetra's Epetra interface;"
344 <<
" Skipping this test." << std::endl;
345 std::cout <<
"FYI: Here's the exception message: " << std::endl
346 << e.what() << std::endl;
353 fail = verifyInputAdapter<ematrix_t>(*eMInput, *tM);
358 ematrix_t *mMigrate =NULL;
360 eMInput->applyPartitioningSolution(*eM, mMigrate, solution);
362 catch (std::exception &e){
363 std::cout <<
"Error caught: " << e.what() << std::endl;
370 RCP<const ematrix_t> cnewM(mMigrate,
true);
371 RCP<Zoltan2::XpetraCrsMatrixAdapter<ematrix_t> > newInput;
376 catch (std::exception &e){
378 std::cout << e.what() << std::endl;
384 "Input adapter for Epetra_CrsMatrix migrated to proc 0" <<
387 fail = verifyInputAdapter<ematrix_t>(*newInput, *newM);
403 std::cout <<
"PASS" << std::endl;