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;
69 using Teuchos::DefaultComm;
71 using Teuchos::ArrayView;
73 typedef Tpetra::CrsGraph<zlno_t, zgno_t, znode_t>
tgraph_t;
74 typedef Xpetra::CrsGraph<zlno_t, zgno_t, znode_t>
xgraph_t;
80 int rank = comm->getRank();
81 int nprocs = comm->getSize();
83 for (
int p=0; p < nprocs; p++){
85 std::cout << rank <<
":" << std::endl;
86 for (
zlno_t i=0; i < nvtx; i++){
87 std::cout <<
" vertex " << vtxIds[i] <<
": ";
88 for (
zlno_t j=offsets[i]; j < offsets[i+1]; j++){
89 std::cout << edgeIds[j] <<
" ";
91 std::cout << std::endl;
100 template <
typename User>
106 RCP<const Comm<int> > comm = graph.getComm();
107 int fail = 0, gfail=0;
119 const zgno_t *vtxIds=NULL, *edgeIds=NULL;
120 const zlno_t *offsets=NULL;
129 if (nvtx != graph.getNodeNumRows())
135 printGraph(comm, nvtx, vtxIds, offsets, edgeIds);
138 if (!fail) fail = 10;
144 int main(
int argc,
char *argv[])
146 Teuchos::GlobalMPISession session(&argc, &argv);
147 RCP<const Comm<int> > comm = DefaultComm<int>::getComm();
148 int rank = comm->getRank();
149 int fail = 0, gfail=0;
154 RCP<UserInputForTests> uinput;
160 catch(std::exception &e){
167 tG = uinput->getUITpetraCrsGraph();
168 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);
191 RCP<const tgraph_t> ctG = rcp_const_cast<
const tgraph_t>(tG);
192 RCP<Zoltan2::XpetraCrsGraphAdapter<tgraph_t> > tGInput;
198 catch (std::exception &e){
200 string(
"XpetraCrsGraphAdapter ")+e.what(), 1);
204 std::cout <<
"Input adapter for Tpetra::CrsGraph" << std::endl;
206 fail = verifyInputAdapter<tgraph_t>(*tGInput, *tG);
213 tGInput->applyPartitioningSolution( *tG, mMigrate, solution);
214 newG = rcp(mMigrate);
216 catch (std::exception &e){
223 RCP<const tgraph_t> cnewG = rcp_const_cast<
const tgraph_t>(newG);
224 RCP<Zoltan2::XpetraCrsGraphAdapter<tgraph_t> > newInput;
228 catch (std::exception &e){
230 string(
"XpetraCrsGraphAdapter 2 ")+e.what(), 1);
235 "Input adapter for Tpetra::CrsGraph migrated to proc 0" <<
238 fail = verifyInputAdapter<tgraph_t>(*newInput, *newG);
239 if (fail) fail += 100;
251 RCP<xgraph_t> xG = uinput->getUIXpetraCrsGraph();
252 RCP<const xgraph_t> cxG = rcp_const_cast<
const xgraph_t>(xG);
253 RCP<Zoltan2::XpetraCrsGraphAdapter<xgraph_t> > xGInput;
259 catch (std::exception &e){
261 string(
"XpetraCrsGraphAdapter 3 ")+e.what(), 1);
265 std::cout <<
"Input adapter for Xpetra::CrsGraph" << std::endl;
267 fail = verifyInputAdapter<xgraph_t>(*xGInput, *tG);
274 xGInput->applyPartitioningSolution( *xG, mMigrate, solution);
276 catch (std::exception &e){
283 RCP<const xgraph_t> cnewG(mMigrate);
284 RCP<Zoltan2::XpetraCrsGraphAdapter<xgraph_t> > newInput;
289 catch (std::exception &e){
291 string(
"XpetraCrsGraphAdapter 4 ")+e.what(), 1);
296 "Input adapter for Xpetra::CrsGraph migrated to proc 0" <<
299 fail = verifyInputAdapter<xgraph_t>(*newInput, *newG);
300 if (fail) fail += 100;
309 #ifdef HAVE_EPETRA_DATA_TYPES 313 RCP<egraph_t> eG = uinput->getUIEpetraCrsGraph();
314 RCP<const egraph_t> ceG = rcp_const_cast<
const egraph_t>(eG);
315 RCP<Zoltan2::XpetraCrsGraphAdapter<egraph_t> > eGInput;
321 catch (std::exception &e){
323 string(
"XpetraCrsGraphAdapter 5 ")+e.what(), 1);
327 std::cout <<
"Input adapter for Epetra_CrsGraph" << std::endl;
329 fail = verifyInputAdapter<egraph_t>(*eGInput, *tG);
336 eGInput->applyPartitioningSolution( *eG, mMigrate, solution);
338 catch (std::exception &e){
345 RCP<const egraph_t> cnewG(mMigrate,
true);
346 RCP<Zoltan2::XpetraCrsGraphAdapter<egraph_t> > newInput;
351 catch (std::exception &e){
353 string(
"XpetraCrsGraphAdapter 6 ")+e.what(), 1);
358 "Input adapter for Epetra_CrsGraph migrated to proc 0" <<
361 fail = verifyInputAdapter<egraph_t>(*newInput, *newG);
362 if (fail) fail += 100;
376 std::cout <<
"PASS" << std::endl;
int globalFail(const RCP< const Comm< int > > &comm, int fail)
#define TEST_FAIL_AND_EXIT(comm, ok, s, code)
Provides access for Zoltan2 to Xpetra::CrsGraph data.
Defines the PartitioningSolution class.
common code used by tests
size_t getLocalNumEdges() const
Returns the number of edges on this process.
Defines XpetraCrsGraphAdapter class.
A PartitioningSolution is a solution to a partitioning problem.
void getEdgesView(const lno_t *&offsets, const gno_t *&adjIds) const
Gets adjacency lists for all vertices in a compressed sparse row (CSR) format.
The user parameters, debug, timing and memory profiling output objects, and error checking methods...
void printFailureCode(const RCP< const Comm< int > > &comm, int fail)
void getVertexIDsView(const gno_t *&ids) const
Sets pointers to this process' graph entries.
size_t getLocalNumVertices() const
Returns the number of vertices on this process.
std::string testDataFilePath(".")