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;
158 catch(std::exception &e){
160 std::cout << e.what() << std::endl;
165 RCP<ztcrsgraph_t> tG = uinput->getUITpetraCrsGraph();
166 RCP<ztrowgraph_t> trG = rcp_dynamic_cast<
ztrowgraph_t>(tG);
168 RCP<ztrowgraph_t> newG;
170 size_t nvtx = tG->getNodeNumRows();
182 part_t *p =
new part_t [nvtx];
183 memset(p, 0,
sizeof(part_t) * nvtx);
184 ArrayRCP<part_t> solnParts(p, 0, nvtx,
true);
186 soln_t solution(env, comm, nWeights);
187 solution.setParts(solnParts);
193 std::cout <<
"Input adapter for Tpetra::RowGraph" << std::endl;
195 RCP<const ztrowgraph_t> ctrG = rcp_const_cast<
const ztrowgraph_t>(
198 RCP<adapter_t> trGInput;
201 trGInput = rcp(
new adapter_t(ctrG));
203 catch (std::exception &e){
205 std::cout << e.what() << std::endl;
209 fail = verifyInputAdapter<ztrowgraph_t>(*trGInput, *trG);
214 ztrowgraph_t *mMigrate = NULL;
216 trGInput->applyPartitioningSolution( *trG, mMigrate, solution);
217 newG = rcp(mMigrate);
219 catch (std::exception &e){
226 RCP<const ztrowgraph_t> cnewG =
227 rcp_const_cast<
const ztrowgraph_t>(newG);
228 RCP<adapter_t> newInput;
230 newInput = rcp(
new adapter_t(cnewG));
232 catch (std::exception &e){
234 std::cout << e.what() << std::endl;
240 "Input adapter for Tpetra::RowGraph migrated to proc 0" <<
243 fail = verifyInputAdapter<ztrowgraph_t>(*newInput, *newG);
244 if (fail) fail += 100;
257 std::cout <<
"PASS" << std::endl;
int globalFail(const RCP< const Comm< int > > &comm, int fail)
void getEdgesView(const offset_t *&offsets, const gno_t *&adjIds) const
size_t getLocalNumEdges() const
Returns the number of edges on this process.
Defines TpetraRowGraphAdapter class.
#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.
The user parameters, debug, timing and memory profiling output objects, and error checking methods...
static const std::string fail
void printFailureCode(const RCP< const Comm< int > > &comm, int fail)
size_t getLocalNumVertices() const
Returns the number of vertices on this process.
void getVertexIDsView(const gno_t *&ids) const
Sets pointers to this process' graph entries.
Provides access for Zoltan2 to Tpetra::RowGraph data.
std::string testDataFilePath(".")