58#include <Teuchos_DefaultComm.hpp>
59#include <Teuchos_RCP.hpp>
60#include <Teuchos_Comm.hpp>
61#include <Teuchos_CommHelpers.hpp>
65using Teuchos::rcp_const_cast;
66using Teuchos::rcp_dynamic_cast;
72template<
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;
96template <
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.getLocalNumRows())
131 printGraph<offset_t>(comm, nvtx, vtxIds, offsets, edgeIds);
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->getLocalNumRows();
181 typedef adapter_t::part_t
part_t;
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>(
197 rcp_dynamic_cast<ztrowgraph_t>(tG));
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);
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);
258 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 TpetraRowGraphAdapter 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::RowGraph data.
size_t getLocalNumEdges() const
Returns the number of edges on this process.
size_t getLocalNumVertices() const
Returns the number of vertices on this process.
void getVertexIDsView(const gno_t *&ids) const
void getEdgesView(const offset_t *&offsets, const gno_t *&adjIds) const
static const std::string fail
SparseMatrixAdapter_t::part_t part_t