58 #include <Teuchos_GlobalMPISession.hpp> 59 #include <Teuchos_DefaultComm.hpp> 60 #include <Teuchos_RCP.hpp> 61 #include <Teuchos_Comm.hpp> 62 #include <Teuchos_CommHelpers.hpp> 67 using Teuchos::rcp_const_cast;
68 using Teuchos::rcp_dynamic_cast;
70 using Teuchos::DefaultComm;
78 int rank = comm->getRank();
79 int nprocs = comm->getSize();
81 for (
int p=0; p < nprocs; p++){
83 std::cout << rank <<
":" << std::endl;
84 for (
zlno_t i=0; i < nvtx; i++){
85 std::cout <<
" vertex " << vtxIds[i] <<
": ";
86 for (
zlno_t j=offsets[i]; j < offsets[i+1]; j++){
87 std::cout << edgeIds[j] <<
" ";
89 std::cout << std::endl;
98 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 zlno_t *offsets=NULL;
125 if (nvtx != graph.getNodeNumRows())
131 printGraph(comm, nvtx, vtxIds, offsets, edgeIds);
140 int main(
int argc,
char *argv[])
142 Teuchos::GlobalMPISession session(&argc, &argv);
143 RCP<const Comm<int> > comm = DefaultComm<int>::getComm();
144 int rank = comm->getRank();
145 int fail = 0, gfail=0;
150 RCP<UserInputForTests> uinput;
157 catch(std::exception &e){
159 std::cout << e.what() << std::endl;
164 RCP<ztcrsgraph_t> tG = uinput->getUITpetraCrsGraph();
165 RCP<ztrowgraph_t> trG = rcp_dynamic_cast<
ztrowgraph_t>(tG);
167 RCP<ztrowgraph_t> newG;
169 size_t nvtx = tG->getNodeNumRows();
179 typedef adapter_t::part_t part_t;
181 part_t *p =
new part_t [nvtx];
182 memset(p, 0,
sizeof(part_t) * nvtx);
183 ArrayRCP<part_t> solnParts(p, 0, nvtx,
true);
185 soln_t solution(env, comm, nWeights);
186 solution.setParts(solnParts);
192 std::cout <<
"Input adapter for Tpetra::RowGraph" << std::endl;
194 RCP<const ztrowgraph_t> ctrG = rcp_const_cast<
const ztrowgraph_t>(
197 RCP<adapter_t> trGInput;
200 trGInput = rcp(
new adapter_t(ctrG));
202 catch (std::exception &e){
204 std::cout << e.what() << std::endl;
208 fail = verifyInputAdapter<ztrowgraph_t>(*trGInput, *trG);
215 trGInput->applyPartitioningSolution( *trG, mMigrate, solution);
216 newG = rcp(mMigrate);
218 catch (std::exception &e){
225 RCP<const ztrowgraph_t> cnewG =
227 RCP<adapter_t> newInput;
229 newInput = rcp(
new adapter_t(cnewG));
231 catch (std::exception &e){
233 std::cout << e.what() << std::endl;
239 "Input adapter for Tpetra::RowGraph migrated to proc 0" <<
242 fail = verifyInputAdapter<ztrowgraph_t>(*newInput, *newG);
256 std::cout <<
"PASS" << std::endl;
int globalFail(const RCP< const Comm< int > > &comm, int fail)
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
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.
void getEdgesView(const lno_t *&offsets, const gno_t *&adjIds) const
Gets adjacency lists for all vertices in a compressed sparse row (CSR) format.
Provides access for Zoltan2 to Tpetra::RowGraph data.
std::string testDataFilePath(".")