51 #include <Zoltan2_config.h> 62 typedef Tpetra::MultiVector<zscalar_t, zlno_t, zgno_t, znode_t>
tMVector_t;
75 const RCP<
const Teuchos::Comm<int> > & comm,
81 int me = comm->getRank();
83 cout <<
"Parallel partitioning of " << filename <<
".mtx: " 84 << nParts <<
" parts." << endl;
86 std::string fname(filename);
91 cout <<
"Multivector length = " << coords->getGlobalLength()
92 <<
" Num vectors = " << coords->getNumVectors() << endl;
94 RCP<const tMVector_t> coordsConst = rcp_const_cast<
const tMVector_t>(coords);
97 inputAdapter_t ia(coordsConst);
99 cout <<
"Adapter constructed" << endl;
101 Teuchos::ParameterList params(
"test params");
102 params.set(
"debug_level",
"basic_status");
103 params.set(
"num_global_parts", nParts);
104 params.set(
"algorithm",
"rcb");
105 params.set(
"imbalance_tolerance", 1.1);
106 params.set(
"bisection_num_test_cuts", 7);
107 if (doRemap) params.set(
"remap_parts",
"yes");
109 #ifdef HAVE_ZOLTAN2_MPI 116 cout <<
"Problem constructed" << endl;
121 cout <<
"Problem solved" << endl;
123 if (comm->getRank() == 0)
129 int numCoords = 1000;
132 cout <<
"Serial partitioning: " << numParts <<
" parts." << endl;
136 throw std::bad_alloc();
137 for (
int i=0; i < numCoords; i++)
139 ArrayRCP<zgno_t> globalIds(ids, 0, numCoords,
true);
141 Array<ArrayRCP<zscalar_t> > randomCoords(3);
143 randomCoords.view(0,3));
147 inputAdapter_t ia(numCoords, ids,
148 randomCoords[0].getRawPtr(), randomCoords[1].getRawPtr(),
149 randomCoords[2].getRawPtr(), 1,1,1);
151 Teuchos::ParameterList params(
"test params");
152 params.set(
"debug_level",
"basic_status");
153 params.set(
"num_global_parts", numParts);
154 params.set(
"algorithm",
"rcb");
155 params.set(
"imbalance_tolerance", 1.1);
156 params.set(
"bisection_num_test_cuts", 7);
157 if (doRemap) params.set(
"remap_parts",
"yes");
159 #ifdef HAVE_ZOLTAN2_MPI 161 &ia, ¶ms, MPI_COMM_SELF);
166 serialProblem.
solve();
176 UserInputForTests uinput(xdim, ydim, zdim,
string(
"Laplace3D"), comm,
true,
true);
180 size_t localCount = coords->getLocalLength();
183 x = coords->getDataNonConst(0).getRawPtr();
184 y = coords->getDataNonConst(1).getRawPtr();
185 z = coords->getDataNonConst(2).getRawPtr();
187 const zgno_t *globalIds = coords->getMap()->getNodeElementList().getRawPtr();
190 inputAdapter_t ia(localCount, globalIds, x, y, z, 1, 1, 1);
192 Teuchos::ParameterList params(
"test params");
193 params.set(
"bisection_num_test_cuts", 7);
194 params.set(
"rectilinear",
"yes");
196 #ifdef HAVE_ZOLTAN2_MPI 204 if (comm->getRank() == 0)
208 int main(
int argc,
char *argv[])
210 Teuchos::GlobalMPISession session(&argc, &argv);
211 RCP<const Teuchos::Comm<int> > tcomm = Teuchos::DefaultComm<int>::getComm();
212 int rank = tcomm->getRank();
213 int nParts = tcomm->getSize();
214 bool doRemap =
false;
215 string filename =
"USAir97";
218 Teuchos::CommandLineProcessor cmdp (
false,
false);
219 cmdp.setOption(
"file", &filename,
"Name of the Matrix Market file to read");
220 cmdp.setOption(
"nparts", &nParts,
"Number of parts.");
221 cmdp.setOption(
"remap",
"no-remap", &doRemap,
"Remap part numbers.");
222 cmdp.parse(argc, argv);
232 std::cout <<
"PASS" << std::endl;
void meshCoordinatesTest(const RCP< const Teuchos::Comm< int > > &comm)
A simple class that can be the User template argument for an InputAdapter.
Defines the PartitioningSolution class.
common code used by tests
Zoltan2::BasicUserTypes< zscalar_t, zlno_t, zgno_t > myTypes_t
Defines the XpetraMultiVectorAdapter.
int main(int argc, char *argv[])
void printMetrics(std::ostream &os) const
Print the array of metrics.
BasicVectorAdapter represents a vector (plus optional weights) supplied by the user as pointers to st...
An adapter for Xpetra::MultiVector.
PartitioningProblem sets up partitioning problems for the user.
void serialTest(int numParts, bool doRemap)
Tpetra::MultiVector< zscalar_t, zlno_t, zgno_t, znode_t > tMVector_t
Defines the PartitioningProblem class.
Defines the BasicVectorAdapter class.
void testFromDataFile(const RCP< const Teuchos::Comm< int > > &comm, int nParts, string &filename, bool doRemap)
void solve(bool updateInputData=true)
Direct the problem to create a solution.
std::string testDataFilePath(".")