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;
69 using Teuchos::rcp_dynamic_cast;
71 using Teuchos::DefaultComm;
73 typedef Tpetra::CrsMatrix<zscalar_t, zlno_t, zgno_t, znode_t>
ztcrsmatrix_t;
74 typedef Tpetra::RowMatrix<zscalar_t, zlno_t, zgno_t, znode_t>
ztrowmatrix_t;
81 int rank = comm->getRank();
82 int nprocs = comm->getSize();
84 for (
int p=0; p < nprocs; p++){
86 std::cout << rank <<
":" << std::endl;
87 for (
zlno_t i=0; i < nrows; i++){
88 std::cout <<
" row " << rowIds[i] <<
": ";
89 for (
zlno_t j=offsets[i]; j < offsets[i+1]; j++){
90 std::cout << colIds[j] <<
" ";
92 std::cout << std::endl;
103 template <
typename User>
107 RCP<const Comm<int> > comm = M.getComm();
108 int fail = 0, gfail=0;
113 if (M.getNodeNumRows()){
120 const zgno_t *rowIds=NULL, *colIds=NULL;
121 const zlno_t *offsets=NULL;
130 if (nrows != M.getNodeNumRows())
146 int main(
int argc,
char *argv[])
148 Teuchos::GlobalMPISession session(&argc, &argv);
149 RCP<const Comm<int> > comm = DefaultComm<int>::getComm();
150 int rank = comm->getRank();
151 int fail = 0, gfail=0;
156 RCP<UserInputForTests> uinput;
163 catch(std::exception &e){
165 std::cout << e.what() << std::endl;
170 RCP<ztcrsmatrix_t> tM = uinput->getUITpetraCrsMatrix();
171 RCP<ztrowmatrix_t> trM = rcp_dynamic_cast<ztrowmatrix_t>(tM);
173 RCP<ztrowmatrix_t> newM;
175 size_t nrows = trM->getNodeNumRows();
185 typedef adapter_t::part_t part_t;
187 part_t *p =
new part_t [nrows];
188 memset(p, 0,
sizeof(part_t) * nrows);
189 ArrayRCP<part_t> solnParts(p, 0, nrows,
true);
191 soln_t solution(env, comm, nWeights);
192 solution.setParts(solnParts);
198 std::cout <<
"Input adapter for Tpetra::RowMatrix" << std::endl;
200 RCP<const ztrowmatrix_t> ctrM = rcp_const_cast<const ztrowmatrix_t>(
201 rcp_dynamic_cast<ztrowmatrix_t>(tM));
202 RCP<adapter_t> trMInput;
205 trMInput = rcp(
new adapter_t(ctrM));
207 catch (std::exception &e){
209 std::cout << e.what() << std::endl;
213 fail = verifyInputAdapter<ztrowmatrix_t>(*trMInput, *trM);
220 trMInput->applyPartitioningSolution(*trM, mMigrate, solution);
221 newM = rcp(mMigrate);
223 catch (std::exception &e){
225 cout <<
"Error caught: " << e.what() << endl;
231 RCP<const ztrowmatrix_t> cnewM =
232 rcp_const_cast<const ztrowmatrix_t>(newM);
233 RCP<adapter_t> newInput;
235 newInput = rcp(
new adapter_t(cnewM));
237 catch (std::exception &e){
239 std::cout << e.what() << std::endl;
245 "Input adapter for Tpetra::RowMatrix migrated to proc 0" <<
248 fail = verifyInputAdapter<ztrowmatrix_t>(*newInput, *newM);
262 std::cout <<
"PASS" << std::endl;
size_t getLocalNumColumns() const
Returns the number of columns on this process.
int globalFail(const RCP< const Comm< int > > &comm, int fail)
#define TEST_FAIL_AND_EXIT(comm, ok, s, code)
common code used by tests
Provides access for Zoltan2 to Tpetra::RowMatrix data.
size_t getLocalNumRows() const
Returns the number of rows on this process.
A PartitioningSolution is a solution to a partitioning problem.
Defines the TpetraRowMatrixAdapter class.
The user parameters, debug, timing and memory profiling output objects, and error checking methods.
static const std::string fail
void getCRSView(const lno_t *&offsets, const gno_t *&colIds) const
Sets pointers to this process' matrix entries using compressed sparse row (CRS) format....
void printFailureCode(const RCP< const Comm< int > > &comm, int fail)
void getRowIDsView(const gno_t *&rowIds) const
Sets pointer to this process' rows' global IDs.
std::string testDataFilePath(".")