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 if (doRemap) params.set(
"remap_parts",
true);
108 #ifdef HAVE_ZOLTAN2_MPI 115 cout <<
"Problem constructed" << endl;
120 cout <<
"Problem solved" << endl;
125 int numCoords = 1000;
128 cout <<
"Serial partitioning: " << numParts <<
" parts." << endl;
132 throw std::bad_alloc();
133 for (
int i=0; i < numCoords; i++)
135 ArrayRCP<zgno_t> globalIds(ids, 0, numCoords,
true);
137 Array<ArrayRCP<zscalar_t> > randomCoords(3);
139 randomCoords.view(0,3));
143 inputAdapter_t ia(numCoords, ids,
144 randomCoords[0].getRawPtr(), randomCoords[1].getRawPtr(),
145 randomCoords[2].getRawPtr(), 1,1,1);
147 Teuchos::ParameterList params(
"test params");
148 params.set(
"debug_level",
"basic_status");
149 params.set(
"num_global_parts", numParts);
150 params.set(
"algorithm",
"rcb");
151 params.set(
"imbalance_tolerance", 1.1);
152 if (doRemap) params.set(
"remap_parts",
true);
154 #ifdef HAVE_ZOLTAN2_MPI 156 &ia, ¶ms, MPI_COMM_SELF);
161 serialProblem.
solve();
169 UserInputForTests uinput(xdim, ydim, zdim,
string(
"Laplace3D"), comm,
true,
true);
173 size_t localCount = coords->getLocalLength();
176 x = coords->getDataNonConst(0).getRawPtr();
177 y = coords->getDataNonConst(1).getRawPtr();
178 z = coords->getDataNonConst(2).getRawPtr();
180 const zgno_t *globalIds = coords->getMap()->getNodeElementList().getRawPtr();
183 inputAdapter_t ia(localCount, globalIds, x, y, z, 1, 1, 1);
185 Teuchos::ParameterList params(
"test params");
186 params.set(
"rectilinear",
true);
188 #ifdef HAVE_ZOLTAN2_MPI 197 int main(
int argc,
char *argv[])
199 Teuchos::GlobalMPISession session(&argc, &argv);
200 RCP<const Teuchos::Comm<int> > tcomm = Teuchos::DefaultComm<int>::getComm();
201 int rank = tcomm->getRank();
202 int nParts = tcomm->getSize();
203 bool doRemap =
false;
204 string filename =
"USAir97";
207 Teuchos::CommandLineProcessor cmdp (
false,
false);
208 cmdp.setOption(
"file", &filename,
"Name of the Matrix Market file to read");
209 cmdp.setOption(
"nparts", &
nParts,
"Number of parts.");
210 cmdp.setOption(
"remap",
"no-remap", &doRemap,
"Remap part numbers.");
211 cmdp.parse(argc, argv);
221 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[])
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(".")