23#include <Teuchos_DefaultComm.hpp>
24#include <Teuchos_RCP.hpp>
25#include <Teuchos_Comm.hpp>
26#include <Teuchos_CommHelpers.hpp>
30using Teuchos::rcp_const_cast;
33using Teuchos::ArrayView;
35typedef Tpetra::CrsGraph<zlno_t, zgno_t, znode_t>
tgraph_t;
36typedef Xpetra::CrsGraph<zlno_t, zgno_t, znode_t>
xgraph_t;
38template<
typename offset_t>
40 const zgno_t *vtxIds,
const offset_t *offsets,
const zgno_t *edgeIds)
42 int rank = comm->getRank();
43 int nprocs = comm->getSize();
45 for (
int p=0; p < nprocs; p++){
47 std::cout << rank <<
":" << std::endl;
48 for (
zlno_t i=0; i < nvtx; i++){
49 std::cout <<
" vertex " << vtxIds[i] <<
": ";
50 for (offset_t j=offsets[i]; j < offsets[i+1]; j++){
51 std::cout << edgeIds[j] <<
" ";
53 std::cout << std::endl;
62template <
typename User>
70 RCP<const Comm<int> > comm = graph.getComm();
71 int fail = 0, gfail=0;
83 const zgno_t *vtxIds=NULL, *edgeIds=NULL;
84 const offset_t *offsets=NULL;
93 if (nvtx != graph.getLocalNumRows())
110 Tpetra::ScopeGuard tscope(&narg, &arg);
111 Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
113 int rank = comm->getRank();
114 int fail = 0, gfail=0;
120 RCP<UserInputForTests> uinput;
121 Teuchos::ParameterList params;
122 params.set(
"input file",
"simple");
123 params.set(
"file type",
"Chaco");
128 catch(std::exception &e){
130 std::cout << e.what() << std::endl;
137 tG = uinput->getUITpetraCrsGraph();
138 size_t nvtx = tG->getLocalNumRows();
149 typedef adapter_t::part_t
part_t;
152 memset(p, 0,
sizeof(
part_t) * nvtx);
153 ArrayRCP<part_t> solnParts(p, 0, nvtx,
true);
155 soln_t solution(env, comm, nWeights);
156 solution.setParts(solnParts);
162 std::cout <<
"Input adapter for Tpetra::CrsGraph" << std::endl;
164 RCP<const tgraph_t> ctG = rcp_const_cast<const tgraph_t>(tG);
165 RCP<Zoltan2::XpetraCrsGraphAdapter<tgraph_t> > tGInput;
171 catch (std::exception &e){
173 std::cout << e.what() << std::endl;
184 tGInput->applyPartitioningSolution( *tG, mMigrate, solution);
185 newG = rcp(mMigrate);
187 catch (std::exception &e){
194 RCP<const tgraph_t> cnewG = rcp_const_cast<const tgraph_t>(newG);
195 RCP<Zoltan2::XpetraCrsGraphAdapter<tgraph_t> > newInput;
199 catch (std::exception &e){
201 std::cout << e.what() << std::endl;
207 "Input adapter for Tpetra::CrsGraph migrated to proc 0" <<
224 std::cout <<
"Input adapter for Xpetra::CrsGraph" << std::endl;
226 RCP<xgraph_t> xG = uinput->getUIXpetraCrsGraph();
227 RCP<const xgraph_t> cxG = rcp_const_cast<const xgraph_t>(xG);
228 RCP<Zoltan2::XpetraCrsGraphAdapter<xgraph_t> > xGInput;
234 catch (std::exception &e){
236 std::cout << e.what() << std::endl;
247 xGInput->applyPartitioningSolution( *xG, mMigrate, solution);
249 catch (std::exception &e){
256 RCP<const xgraph_t> cnewG(mMigrate);
257 RCP<Zoltan2::XpetraCrsGraphAdapter<xgraph_t> > newInput;
262 catch (std::exception &e){
264 std::cout << e.what() << std::endl;
270 "Input adapter for Xpetra::CrsGraph migrated to proc 0" <<
287 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)
Defines the PartitioningSolution class.
common code used by tests
Tpetra::Map ::local_ordinal_type zlno_t
Tpetra::Map ::global_ordinal_type zgno_t
Defines XpetraCrsGraphAdapter 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 Xpetra::CrsGraph data.
size_t getLocalNumEdges() const override
Returns the number of edges on this process.
size_t getLocalNumVertices() const override
Returns the number of vertices on this process.
void getEdgesView(const offset_t *&offsets, const gno_t *&adjIds) const override
void getVertexIDsView(const gno_t *&ids) const override
static const std::string fail
SparseMatrixAdapter_t::part_t part_t