23 #include <Teuchos_DefaultComm.hpp>
24 #include <Teuchos_RCP.hpp>
25 #include <Teuchos_Comm.hpp>
26 #include <Teuchos_CommHelpers.hpp>
30 using Teuchos::rcp_const_cast;
31 using Teuchos::rcp_dynamic_cast;
37 template<
typename offset_t>
39 const zgno_t *vtxIds,
const offset_t *offsets,
const zgno_t *edgeIds)
41 int rank = comm->getRank();
42 int nprocs = comm->getSize();
44 for (
int p=0; p < nprocs; p++){
46 std::cout << rank <<
":" << std::endl;
47 for (
zlno_t i=0; i < nvtx; i++){
48 std::cout <<
" vertex " << vtxIds[i] <<
": ";
49 for (offset_t j=offsets[i]; j < offsets[i+1]; j++){
50 std::cout << edgeIds[j] <<
" ";
52 std::cout << std::endl;
61 template <
typename User>
67 auto comm = graph.getComm();
68 int fail = 0, gfail=0;
80 const zgno_t *vtxIds=NULL, *edgeIds=NULL;
81 const offset_t *offsets=NULL;
90 if (nvtx != graph.getLocalNumRows())
96 printGraph<offset_t>(comm, nvtx, vtxIds, offsets, edgeIds);
105 int main(
int narg,
char *arg[])
107 Tpetra::ScopeGuard tscope(&narg, &arg);
108 Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
110 int rank = comm->getRank();
111 int fail = 0, gfail=0;
116 RCP<UserInputForTests> uinput;
117 Teuchos::ParameterList params;
118 params.set(
"input file",
"simple");
119 params.set(
"file type",
"Chaco");
124 catch(std::exception &e){
126 std::cout << e.what() << std::endl;
131 auto tG = uinput->getUITpetraCrsGraph();
134 RCP<ztrowgraph_t> newG;
136 size_t nvtx = tG->getLocalNumRows();
148 part_t *p =
new part_t [nvtx];
149 memset(p, 0,
sizeof(part_t) * nvtx);
150 ArrayRCP<part_t> solnParts(p, 0, nvtx,
true);
152 soln_t solution(env, comm, nWeights);
153 solution.setParts(solnParts);
159 std::cout <<
"Input adapter for Tpetra::RowGraph" << std::endl;
161 RCP<const ztrowgraph_t> ctrG = rcp_const_cast<
const ztrowgraph_t>(
164 RCP<adapter_t> trGInput;
167 trGInput = rcp(
new adapter_t(ctrG));
169 catch (std::exception &e){
171 std::cout << e.what() << std::endl;
175 fail = verifyInputAdapter<ztrowgraph_t>(*trGInput, *trG);
180 ztrowgraph_t *mMigrate = NULL;
182 trGInput->applyPartitioningSolution( *trG, mMigrate, solution);
183 newG = rcp(mMigrate);
185 catch (std::exception &e){
192 auto cnewG = rcp_const_cast<
const ztrowgraph_t>(newG);
193 RCP<adapter_t> newInput;
195 newInput = rcp(
new adapter_t(cnewG));
197 catch (std::exception &e){
199 std::cout << e.what() << std::endl;
205 "Input adapter for Tpetra::RowGraph migrated to proc 0" <<
208 fail = verifyInputAdapter<ztrowgraph_t>(*newInput, *newG);
209 if (fail) fail += 100;
222 std::cout <<
"PASS" << std::endl;
void printFailureCode(const Comm< int > &comm, int fail)
void getVertexIDsView(const gno_t *&ids) const override
Sets pointers to this process' graph entries.
void getEdgesView(const offset_t *&offsets, const gno_t *&adjIds) const override
Gets adjacency lists for all vertices in a compressed sparse row (CSR) format.
Defines TpetraRowGraphAdapter class.
#define TEST_FAIL_AND_EXIT(comm, ok, s, code)
size_t getLocalNumVertices() const override
Returns the number of vertices on this process.
int main(int narg, char **arg)
common code used by tests
SparseMatrixAdapter_t::part_t part_t
A PartitioningSolution is a solution to a partitioning problem.
size_t getLocalNumEdges() const override
Returns the number of edges on this process.
The user parameters, debug, timing and memory profiling output objects, and error checking methods...
Tpetra::Map::local_ordinal_type zlno_t
static const std::string fail
int globalFail(const Comm< int > &comm, int fail)
Tpetra::Map::global_ordinal_type zgno_t
Provides access for Zoltan2 to Tpetra::RowGraph data.