58 #include <Teuchos_DefaultComm.hpp>
59 #include <Teuchos_RCP.hpp>
60 #include <Teuchos_Comm.hpp>
61 #include <Teuchos_CommHelpers.hpp>
65 using Teuchos::rcp_const_cast;
66 using Teuchos::rcp_dynamic_cast;
72 template<
typename offset_t>
74 const zgno_t *vtxIds,
const offset_t *offsets,
const zgno_t *edgeIds)
76 int rank = comm->getRank();
77 int nprocs = comm->getSize();
79 for (
int p=0; p < nprocs; p++){
81 std::cout << rank <<
":" << std::endl;
82 for (
zlno_t i=0; i < nvtx; i++){
83 std::cout <<
" vertex " << vtxIds[i] <<
": ";
84 for (offset_t j=offsets[i]; j < offsets[i+1]; j++){
85 std::cout << edgeIds[j] <<
" ";
87 std::cout << std::endl;
96 template <
typename User>
102 RCP<const Comm<int> > comm = graph.getComm();
103 int fail = 0, gfail=0;
115 const zgno_t *vtxIds=NULL, *edgeIds=NULL;
116 const offset_t *offsets=NULL;
125 if (nvtx != graph.getNodeNumRows())
131 printGraph<offset_t>(comm, nvtx, vtxIds, offsets, edgeIds);
134 if (!fail) fail = 10;
140 int main(
int narg,
char *arg[])
142 Tpetra::ScopeGuard tscope(&narg, &arg);
143 Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
145 int rank = comm->getRank();
146 int fail = 0, gfail=0;
151 RCP<UserInputForTests> uinput;
152 Teuchos::ParameterList params;
153 params.set(
"input file",
"simple");
154 params.set(
"file type",
"Chaco");
159 catch(std::exception &e){
161 std::cout << e.what() << std::endl;
166 RCP<ztcrsgraph_t> tG = uinput->getUITpetraCrsGraph();
167 RCP<ztrowgraph_t> trG = rcp_dynamic_cast<
ztrowgraph_t>(tG);
169 RCP<ztrowgraph_t> newG;
171 size_t nvtx = tG->getNodeNumRows();
183 part_t *p =
new part_t [nvtx];
184 memset(p, 0,
sizeof(part_t) * nvtx);
185 ArrayRCP<part_t> solnParts(p, 0, nvtx,
true);
187 soln_t solution(env, comm, nWeights);
188 solution.setParts(solnParts);
194 std::cout <<
"Input adapter for Tpetra::RowGraph" << std::endl;
196 RCP<const ztrowgraph_t> ctrG = rcp_const_cast<
const ztrowgraph_t>(
199 RCP<adapter_t> trGInput;
202 trGInput = rcp(
new adapter_t(ctrG));
204 catch (std::exception &e){
206 std::cout << e.what() << std::endl;
210 fail = verifyInputAdapter<ztrowgraph_t>(*trGInput, *trG);
215 ztrowgraph_t *mMigrate = NULL;
217 trGInput->applyPartitioningSolution( *trG, mMigrate, solution);
218 newG = rcp(mMigrate);
220 catch (std::exception &e){
227 RCP<const ztrowgraph_t> cnewG =
228 rcp_const_cast<
const ztrowgraph_t>(newG);
229 RCP<adapter_t> newInput;
231 newInput = rcp(
new adapter_t(cnewG));
233 catch (std::exception &e){
235 std::cout << e.what() << std::endl;
241 "Input adapter for Tpetra::RowGraph migrated to proc 0" <<
244 fail = verifyInputAdapter<ztrowgraph_t>(*newInput, *newG);
245 if (fail) fail += 100;
258 std::cout <<
"PASS" << std::endl;
void printFailureCode(const Comm< int > &comm, int fail)
size_t getLocalNumVertices() const
Returns the number of vertices on this process.
size_t getLocalNumEdges() const
Returns the number of edges on this process.
Defines TpetraRowGraphAdapter class.
int main(int narg, char *arg[])
#define TEST_FAIL_AND_EXIT(comm, ok, s, code)
common code used by tests
SparseMatrixAdapter_t::part_t part_t
A PartitioningSolution is a solution to a partitioning problem.
void getVertexIDsView(const gno_t *&ids) const
Sets pointers to this process' graph entries.
The user parameters, debug, timing and memory profiling output objects, and error checking methods...
static const std::string fail
int globalFail(const Comm< int > &comm, int fail)
void getEdgesView(const offset_t *&offsets, const gno_t *&adjIds) const
Provides access for Zoltan2 to Tpetra::RowGraph data.