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;
74 typedef Tpetra::CrsGraph<lno_t, gno_t, node_t>
tgraph_t;
75 typedef Xpetra::CrsGraph<lno_t, gno_t, node_t>
xgraph_t;
81 int rank = comm->getRank();
82 int nprocs = comm->getSize();
84 for (
int p=0; p < nprocs; p++){
86 std::cout << rank <<
":" << std::endl;
87 for (
lno_t i=0; i < nvtx; i++){
88 std::cout <<
" vertex " << vtxIds[i] <<
": ";
89 for (
lno_t j=offsets[i]; j < offsets[i+1]; j++){
90 std::cout << edgeIds[j] <<
" ";
92 std::cout << std::endl;
101 template <
typename User>
105 RCP<const Comm<int> > comm = graph.getComm();
106 int fail = 0, gfail=0;
116 const gno_t *vtxIds=NULL, *edgeIds=NULL;
117 const lno_t *offsets=NULL;
124 if (nvtx != graph.getNodeNumRows())
130 printGraph(comm, nvtx, vtxIds, offsets, edgeIds);
133 if (!fail) fail = 10;
139 int main(
int argc,
char *argv[])
141 Teuchos::GlobalMPISession session(&argc, &argv);
142 RCP<const Comm<int> > comm = DefaultComm<int>::getComm();
143 int rank = comm->getRank();
144 int fail = 0, gfail=0;
149 RCP<uinput_t> uinput;
155 catch(std::exception &e){
162 tG = uinput->getTpetraCrsGraph();
163 size_t nvtx = tG->getNodeNumRows();
164 ArrayView<const gno_t> rowGids = tG->getRowMap()->getNodeElementList();
174 ArrayRCP<const gno_t> gidArray = arcpFromArrayView(rowGids);
175 RCP<const idmap_t> idMap = rcp(
new idmap_t(env, comm, gidArray));
181 ArrayRCP<zoltan2_partId_t> solnParts(p, 0, nvtx,
true);
185 soln_t solution(env, comm, idMap, weightDim);
186 solution.setParts(gidArray, solnParts,
true);
191 RCP<const tgraph_t> ctG = rcp_const_cast<
const tgraph_t>(tG);
192 RCP<Zoltan2::XpetraCrsGraphInput<tgraph_t> > tGInput;
198 catch (std::exception &e){
200 string(
"XpetraCrsGraphInput ")+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::XpetraCrsGraphInput<tgraph_t> > newInput;
228 catch (std::exception &e){
230 string(
"XpetraCrsGraphInput 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->getXpetraCrsGraph();
252 RCP<const xgraph_t> cxG = rcp_const_cast<
const xgraph_t>(xG);
253 RCP<Zoltan2::XpetraCrsGraphInput<xgraph_t> > xGInput;
259 catch (std::exception &e){
261 string(
"XpetraCrsGraphInput 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::XpetraCrsGraphInput<xgraph_t> > newInput;
289 catch (std::exception &e){
291 string(
"XpetraCrsGraphInput 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->getEpetraCrsGraph();
314 RCP<const egraph_t> ceG = rcp_const_cast<
const egraph_t>(eG);
315 RCP<Zoltan2::XpetraCrsGraphInput<egraph_t> > eGInput;
321 catch (std::exception &e){
323 string(
"XpetraCrsGraphInput 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::XpetraCrsGraphInput<egraph_t> > newInput;
351 catch (std::exception &e){
353 string(
"XpetraCrsGraphInput 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;
An IdentifierMap manages a global space of object identifiers.
int globalFail(const RCP< const Comm< int > > &comm, int fail)
#define TEST_FAIL_AND_EXIT(comm, ok, s, code)
Defines the PartitioningSolution class.
common code used by tests
int zoltan2_partId_t
a data type for part IDs
A PartitioningSolution is a solution to a partitioning problem.
The user parameters, debug, timing and memory profiling output objects, and error checking methods...
void printFailureCode(const RCP< const Comm< int > > &comm, int fail)
std::string testDataFilePath(".")