59#include <Teuchos_DefaultComm.hpp>
60#include <Teuchos_RCP.hpp>
61#include <Teuchos_Comm.hpp>
62#include <Teuchos_CommHelpers.hpp>
66using Teuchos::rcp_const_cast;
67using Teuchos::rcp_dynamic_cast;
70typedef Tpetra::CrsMatrix<zscalar_t, zlno_t, zgno_t, znode_t>
ztcrsmatrix_t;
71typedef Tpetra::RowMatrix<zscalar_t, zlno_t, zgno_t, znode_t>
ztrowmatrix_t;
75template<
typename offset_t>
77 const zgno_t *rowIds,
const offset_t *offsets,
const zgno_t *colIds)
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 (
zlno_t i=0; i < nrows; i++){
86 std::cout <<
" row " << rowIds[i] <<
": ";
87 for (offset_t j=offsets[i]; j < offsets[i+1]; j++){
88 std::cout << colIds[j] <<
" ";
90 std::cout << std::endl;
101template <
typename User>
107 RCP<const Comm<int> > comm = M.getComm();
108 int fail = 0, gfail=0;
110 if (!
fail && ia.getLocalNumRows() != M.getLocalNumRows())
113 if (M.getLocalNumRows()){
114 if (!
fail && ia.getLocalNumColumns() != M.getLocalNumCols())
120 const zgno_t *rowIds=NULL;
121 ArrayRCP<const zgno_t> colIds;
122 ArrayRCP<const offset_t> offsets;
127 nrows = ia.getLocalNumRows();
128 ia.getRowIDsView(rowIds);
129 ia.getCRSView(offsets, colIds);
131 if (nrows != M.getLocalNumRows())
137 printMatrix<offset_t>(comm, nrows, rowIds, offsets.getRawPtr(), colIds.getRawPtr());
149 Tpetra::ScopeGuard tscope(&narg, &arg);
150 Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
152 int rank = comm->getRank();
153 int fail = 0, gfail=0;
158 RCP<UserInputForTests> uinput;
159 Teuchos::ParameterList params;
160 params.set(
"input file",
"simple");
161 params.set(
"file type",
"Chaco");
166 catch(std::exception &e){
168 std::cout << e.what() << std::endl;
173 RCP<ztcrsmatrix_t> tM = uinput->getUITpetraCrsMatrix();
174 RCP<ztrowmatrix_t> trM = rcp_dynamic_cast<ztrowmatrix_t>(tM);
176 RCP<ztrowmatrix_t> newM;
178 size_t nrows = trM->getLocalNumRows();
188 typedef adapter_t::part_t
part_t;
191 memset(p, 0,
sizeof(
part_t) * nrows);
192 ArrayRCP<part_t> solnParts(p, 0, nrows,
true);
194 soln_t solution(env, comm, nWeights);
195 solution.setParts(solnParts);
201 std::cout <<
"Input adapter for Tpetra::RowMatrix" << std::endl;
203 RCP<const ztrowmatrix_t> ctrM = rcp_const_cast<const ztrowmatrix_t>(
204 rcp_dynamic_cast<ztrowmatrix_t>(tM));
205 RCP<adapter_t> trMInput;
208 trMInput = rcp(
new adapter_t(ctrM));
210 catch (std::exception &e){
212 std::cout << e.what() << std::endl;
216 fail = verifyInputAdapter<ztrowmatrix_t>(*trMInput, *trM);
223 trMInput->applyPartitioningSolution(*trM, mMigrate, solution);
224 newM = rcp(mMigrate);
226 catch (std::exception &e){
228 std::cout <<
"Error caught: " << e.what() << std::endl;
234 RCP<const ztrowmatrix_t> cnewM =
235 rcp_const_cast<const ztrowmatrix_t>(newM);
236 RCP<adapter_t> newInput;
238 newInput = rcp(
new adapter_t(cnewM));
240 catch (std::exception &e){
242 std::cout << e.what() << std::endl;
248 "Input adapter for Tpetra::RowMatrix migrated to proc 0" <<
251 fail = verifyInputAdapter<ztrowmatrix_t>(*newInput, *newM);
265 std::cout <<
"PASS" << std::endl;
int globalFail(const Comm< int > &comm, int fail)
void printFailureCode(const Comm< int > &comm, int fail)
#define TEST_FAIL_AND_EXIT(comm, ok, s, code)
common code used by tests
Tpetra::Map ::local_ordinal_type zlno_t
Tpetra::Map ::global_ordinal_type zgno_t
Defines the TpetraRowMatrixAdapter class.
The user parameters, debug, timing and memory profiling output objects, and error checking methods.
A PartitioningSolution is a solution to a partitioning problem.
Provides access for Zoltan2 to Tpetra::RowMatrix data.
static const std::string fail
SparseMatrixAdapter_t::part_t part_t