16 #include "Galeri_Maps.h" 17 #include "Galeri_CrsMatrices.h" 19 #ifdef HAVE_VALGRIND_H 20 #include <valgrind/valgrind.h> 23 #ifdef HAVE_VALGRIND_VALGRIND_H 24 #include <valgrind/valgrind.h> 39 Solver->GetTiming( TimingsList );
41 bool testPassed =
true;
54 TimingsList.
get(
"Total symbolic factorization time", 0.0 );
59 Teuchos::getParameter<double>( TimingsList,
"Total numeric factorization time" );
64 Teuchos::getParameter<double>( TimingsList,
"Total solve time" );
69 Teuchos::getParameter<double>( TimingsList,
"Total solve time" );
73 TimingsList.get(
"Total matrix redistribution time", 0.0 );
77 TimingsList.get(
"Total vector redistribution time", 0.0 );
80 catch( std::exception& e ) {
81 if (
Comm.MyPID() == 0)
82 std::cout << std::endl <<
"Exception caught in TestTiming() : " << e.what() << std::endl;
92 const std::string Descriptor,
98 if (
A.Comm().MyPID() == 0)
99 std::cout << std::endl <<
"*** " << SolverType <<
" : " 100 << Descriptor <<
" ***" << std::endl;
101 std::vector<double> Norm;
103 Norm.resize(NumVectors);
105 A.Multiply(
false,x,Ax);
108 bool TestPassed =
false;
109 double TotalNorm = 0.0;
110 for (
int i = 0 ; i < NumVectors ; ++i) {
111 TotalNorm += Norm[i];
113 if (
A.Comm().MyPID() == 0)
114 std::cout <<
"||Ax - b|| = " << TotalNorm << std::endl;
115 if (TotalNorm < 1e-5 )
120 Ax.
Update (1.0,x,-1.0,x_exact,0.0);
122 for (
int i = 0 ; i < NumVectors ; ++i) {
123 TotalNorm += Norm[i];
125 if (
A.Comm().MyPID() == 0)
126 std::cout <<
"||x - x_exact|| = " << TotalNorm << std::endl;
127 if (TotalNorm < 1e-5 )
144 bool TestPassed =
true;
167 std::string ST = SolverType ;
168 if (! ( ST ==
"Amesos_Superludist" ) ) {
171 TestPassed = TestPassed &&
172 CheckError(SolverType,
"Solve() only",
A,x_A,b_A,x_exactA) &&
199 TestPassed = TestPassed &&
200 CheckError(SolverType,
"NumFact() + Solve()",
A,x_A,b_A,x_exactA) &&
243 TestPassed = TestPassed &&
244 CheckError(SolverType,
"SymFact() + NumFact() + Solve()",
245 A,x_A,b_A,x_exactA) &&
278 TestPassed = TestPassed &&
279 CheckError(SolverType,
"Set A, solve B",
B,x_B,b_B,x_exactB) &&
300 std::string ST = SolverType ;
301 if (! ( ST ==
"Amesos_Superludist" ) ) {
310 TestPassed = TestPassed &&
311 CheckError(SolverType,
"Set A, Solve C",
C,x_C,b_C,x_exactC) &&
330 std::string ST = SolverType ;
331 if (! ( ST ==
"Amesos_Superludist" ) ) {
342 TestPassed = TestPassed &&
343 CheckError(SolverType,
"Solve A + Solve C",
C,x_C,b_C,x_exactC) &&
363 int NumVectors_AB = 7;
364 int NumVectors_C = 13;
367 if ( RUNNING_ON_VALGRIND ) {
377 GaleriList.
set(
"n", Size_AB * Size_AB);
378 GaleriList.
set(
"nx", Size_AB);
379 GaleriList.
set(
"ny", Size_AB);
384 GaleriList.
set(
"n", Size_C);
396 A.Multiply(
false,x_exactA,b_A);
402 B.Multiply(
false,x_exactB,b_B);
408 C.Multiply(
false,x_exactC,b_C);
410 std::vector<std::string> SolverType;
411 SolverType.push_back(
"Amesos_Klu");
412 SolverType.push_back(
"Amesos_Lapack");
413 SolverType.push_back(
"Amesos_Umfpack");
414 SolverType.push_back(
"Amesos_Superlu");
415 SolverType.push_back(
"Amesos_Superludist");
416 SolverType.push_back(
"Amesos_Mumps");
420 bool TestPassed =
true;
422 for (
unsigned int i = 0 ; i < SolverType.size() ; ++i) {
423 std::string
Solver = SolverType[i];
426 A, x_A, b_A, x_exactA,
427 B, x_B, b_B, x_exactB,
428 C, x_C, b_C, x_exactC);
429 TestPassed = TestPassed && ok;
433 if (
Comm.MyPID() == 0)
434 std::cout <<
"Solver " <<
Solver <<
" not available" << std::endl;
445 if (
Comm.MyPID() == 0)
446 std::cout << std::endl <<
"TEST PASSED" << std::endl << std::endl;
447 return(EXIT_SUCCESS);
450 if (
Comm.MyPID() == 0)
451 std::cout << std::endl <<
"TEST FAILED" << std::endl << std::endl;
458 int main(
int argc,
char *argv[]) {
461 MPI_Init(&argc, &argv);
468 if (
Comm.MyPID() == 0 ) {
469 std::cout <<
"Enter a char to continue" ;
int Norm2(double *Result) const
void SetLHS(Epetra_MultiVector *X)
void SetOperator(Epetra_RowMatrix *A)
int SubMain(Epetra_Comm &Comm)
T & get(ParameterList &l, const std::string &name)
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
int PutScalar(double ScalarConstant)
Amesos_TestRowMatrix: a class to test Epetra_RowMatrix based codes.
#define AMESOS_CHK_ERR(a)
bool TestTiming(const Amesos_BaseSolver *Solver, const Epetra_Comm &Comm)
Factory for binding a third party direct solver to an Epetra_LinearProblem.
int CreateCrsMatrix(const char *in_filename, const Epetra_Comm &Comm, Epetra_Map *&readMap, const bool transpose, const bool distribute, bool &symmetric, Epetra_CrsMatrix *&Matrix)
void SetRHS(Epetra_MultiVector *B)
Amesos_BaseSolver * Create(const char *ClassType, const Epetra_LinearProblem &LinearProblem)
Amesos Create method.
int Update(double ScalarA, const Epetra_MultiVector &A, double ScalarThis)
bool CheckError(const std::string SolverType, const std::string Descriptor, const Epetra_RowMatrix &A, const Epetra_MultiVector &x, const Epetra_MultiVector &b, const Epetra_MultiVector &x_exact)
int main(int argc, char *argv[])
Amesos_BaseSolver: A pure virtual class for direct solution of real-valued double-precision operators...
bool Test(char *SolverType, Epetra_RowMatrix &A, Epetra_MultiVector &x_A, Epetra_MultiVector &b_A, Epetra_MultiVector &x_exactA, Epetra_RowMatrix &B, Epetra_MultiVector &x_B, Epetra_MultiVector &b_B, Epetra_MultiVector &x_exactB, Epetra_RowMatrix &C, Epetra_MultiVector &x_C, Epetra_MultiVector &b_C, Epetra_MultiVector &x_exactC)
bool Query(const char *ClassType)
Queries whether a given interface is available or not.