16 #include <Teuchos_ParameterList.hpp>
17 #include <Teuchos_RCP.hpp>
18 #include <Teuchos_FancyOStream.hpp>
19 #include <Teuchos_CommandLineProcessor.hpp>
20 #include <Tpetra_CrsMatrix.hpp>
21 #include <Tpetra_Vector.hpp>
22 #include <MatrixMarket_Tpetra.hpp>
36 typedef Tpetra::Vector<z2TestScalar, z2TestLO, z2TestGO>
Vector;
37 typedef Vector::node_type
Node;
39 typedef Tpetra::MultiVector<z2TestScalar, z2TestLO, z2TestGO,znode_t>
tMVector_t;
47 #define epsilon 0.00000001
49 int testNDwithRCB(RCP<SparseMatrix_t> &origMatrix,RCP<tMVector_t> &coords,
int numParts,
int me);
50 int testNDwithPHG(RCP<SparseMatrix_t> &origMatrix,
int numParts,
int me);
54 int main(
int narg,
char** arg)
59 Tpetra::ScopeGuard tscope(&narg, &arg);
60 Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
61 int me = comm->getRank();
64 std::string inputFile =
"";
66 bool distributeInput =
true;
73 Teuchos::CommandLineProcessor cmdp (
false,
false);
74 cmdp.setOption(
"inputPath", &inputPath,
75 "Path to the MatrixMarket or Zoltan file to be read; "
76 "if not specified, a default path will be used.");
77 cmdp.setOption(
"inputFile", &inputFile,
78 "Name of the Matrix Market or Zoltan file to read; "
80 cmdp.setOption(
"distribute",
"no-distribute", &distributeInput,
81 "for Zoltan input files only, "
82 "indicate whether or not to distribute "
83 "input across the communicator");
84 cmdp.setOption(
"numParts", &numParts,
85 "Global number of parts;");
87 Teuchos::CommandLineProcessor::EParseCommandLineReturn
88 parseReturn= cmdp.parse( narg, arg );
90 if( parseReturn == Teuchos::CommandLineProcessor::PARSE_HELP_PRINTED )
99 RCP<UserInputForTests> uinput;
104 true, distributeInput));
108 std::cout <<
"Input file must be specified." << std::endl;
111 RCP<SparseMatrix_t> origMatrix = uinput->getUITpetraCrsMatrix();
116 std::cout <<
"NumRows = " << origMatrix->getGlobalNumRows() << std::endl
117 <<
"NumNonzeros = " << origMatrix->getGlobalNumEntries() << std::endl
118 <<
"NumProcs = " << comm->getSize() << std::endl
119 <<
"NumParts = " << numParts << std::endl;
122 if (origMatrix->getGlobalNumRows() < 40)
124 Teuchos::FancyOStream out(Teuchos::rcp(&std::cout,
false));
125 origMatrix->describe(out, Teuchos::VERB_EXTREME);
132 RCP<tMVector_t> coords;
135 coords = uinput->getUICoordinates();
140 std::cout <<
"FAIL: get coordinates" << std::endl;
165 int testNDwithRCB(RCP<SparseMatrix_t> &origMatrix,RCP<tMVector_t> &coords,
int numParts,
int me)
172 Teuchos::ParameterList params;
174 params.set(
"num_global_parts", numParts);
175 params.set(
"order_method",
"nd");
176 params.set(
"edge_separator_method",
"rcb");
193 std::cout <<
"FAIL: vector adapter" << std::endl;
208 if (me == 0) std::cout <<
"Calling solve() " << std::endl;
210 if (me == 0) std::cout <<
"Done solve() " << std::endl;
212 catch (std::runtime_error &e)
214 std::cout <<
"Runtime exception returned from solve(): " << e.what();
215 if (!strncmp(e.what(),
"BUILD ERROR", 11)) {
217 std::cout <<
" PASS" << std::endl;
222 std::cout <<
" FAIL" << std::endl;
226 catch (std::logic_error &e)
228 std::cout <<
"Logic exception returned from solve(): " << e.what()
229 <<
" FAIL" << std::endl;
232 catch (std::bad_alloc &e)
234 std::cout <<
"Bad_alloc exception returned from solve(): " << e.what()
235 <<
" FAIL" << std::endl;
238 catch (std::exception &e)
240 std::cout <<
"Unknown exception returned from solve(). " << e.what()
241 <<
" FAIL" << std::endl;
250 std::cout <<
"PASS" << std::endl;
265 Teuchos::ParameterList params;
267 params.set(
"num_global_parts", numParts);
268 params.set(
"order_method",
"nd");
269 params.set(
"edge_separator_method",
"phg");
286 if (me == 0) std::cout <<
"Calling solve() " << std::endl;
288 if (me == 0) std::cout <<
"Done solve() " << std::endl;
290 catch (std::runtime_error &e)
292 std::cout <<
"Runtime exception returned from solve(): " << e.what();
293 if (!strncmp(e.what(),
"BUILD ERROR", 11)) {
295 std::cout <<
" PASS" << std::endl;
300 std::cout <<
" FAIL" << std::endl;
304 catch (std::logic_error &e)
306 std::cout <<
"Logic exception returned from solve(): " << e.what()
307 <<
" FAIL" << std::endl;
310 catch (std::bad_alloc &e)
312 std::cout <<
"Bad_alloc exception returned from solve(): " << e.what()
313 <<
" FAIL" << std::endl;
316 catch (std::exception &e)
318 std::cout <<
"Unknown exception returned from solve(). " << e.what()
319 <<
" FAIL" << std::endl;
324 std::cout <<
"PASS" << std::endl;
Provides access for Zoltan2 to Xpetra::CrsMatrix data.
int testNDwithRCB(RCP< SparseMatrix_t > &origMatrix, RCP< tMVector_t > &coords, int numParts, int me)
Tpetra::CrsMatrix< z2TestScalar, z2TestLO, z2TestGO > SparseMatrix_t
int main(int narg, char **arg)
common code used by tests
Tpetra::Vector< z2TestScalar, z2TestLO, z2TestGO > Vector
Defines the XpetraMultiVectorAdapter.
OrderingProblem sets up ordering problems for the user.
Defines the XpetraCrsMatrixAdapter class.
Zoltan2::XpetraCrsMatrixAdapter< SparseMatrix_t, tMVector_t > SparseMatrixAdapter_t
void solve(bool updateInputData=true)
Direct the problem to create a solution.
Zoltan2::XpetraMultiVectorAdapter< tMVector_t > MultiVectorAdapter_t
An adapter for Xpetra::MultiVector.
Tpetra::Map::local_ordinal_type zlno_t
Defines the OrderingProblem class.
int testNDwithPHG(RCP< SparseMatrix_t > &origMatrix, int numParts, int me)
void setCoordinateInput(VectorAdapter< UserCoord > *coordData) override
Allow user to provide additional data that contains coordinate info associated with the MatrixAdapter...
Tpetra::MultiVector< zscalar_t, zlno_t, zgno_t, znode_t > tMVector_t
Tpetra::Map::global_ordinal_type zgno_t
std::string testDataFilePath(".")