14 #include "Galeri_Maps.h"
15 #include "Galeri_CrsMatrices.h"
17 using namespace Galeri;
61 if (Solver->
Solve())
return(
false);
64 double d = 0.0, d_tot = 0.0;
67 for (
int j = 0 ; j < lhs->NumVectors() ; ++j)
68 d += ((*lhs)[j][i] - 1.0) * ((*lhs)[j][i] - 1.0);
73 std::vector<double> Norm(rhs->NumVectors());
78 Ax.Update(1.0, *rhs, -1.0);
81 std::string msg = ProblemType;
85 std::cout << std::endl;
86 std::cout << msg <<
" : Using " << A->
Comm().
NumProc() <<
" processes, UseTranspose = " << UseTranspose << std::endl;
87 for (
int j = 0 ; j < rhs->NumVectors() ; ++j)
88 std::cout << msg <<
" : eq " << j
89 <<
", ||A x - b||_2 = " << Norm[j] << std::endl;
90 std::cout << msg <<
" : ||x_exact - x||_2 = " << sqrt(d_tot) << std::endl;
95 std::cerr << std::endl << msg <<
" WARNING : TEST FAILED!" << std::endl;
105 std::vector<std::string>& SolverType)
107 std::string ProblemType;
109 ProblemType =
"Laplace2D";
111 ProblemType =
"Recirc2D";
114 GaleriList.
set(
"nx", 8);
116 GaleriList.
set(
"mx", 1);
119 Epetra_Map* Map = CreateMap(
"Cartesian2D", Comm, GaleriList);
132 for (
unsigned int i = 0 ; i < SolverType.size() ; ++i)
134 std::string
Solver = SolverType[i];
136 if (Factory.
Query((
char*)Solver.c_str()))
140 AmesosList.
set(
"Redistribute",
true);
141 res =
TestAmesos((
char*)Solver.c_str(), AmesosList,
false,
143 assert (res ==
true);
147 res =
TestAmesos((
char*)Solver.c_str(), AmesosList,
true,
149 assert (res ==
true);
155 std::cerr << std::endl;
156 std::cerr <<
"WARNING: SOLVER `" << Solver <<
"' NOT TESTED" << std::endl;
157 std::cerr << std::endl;
169 int main(
int argc,
char *argv[])
172 MPI_Init(&argc, &argv);
178 if ( argc > 1 && argv[1][0] ==
'-' && argv[1][1] ==
'q' )
quiet = true ;
185 std::vector<std::string> SolverType;
186 SolverType.push_back(
"Amesos_Lapack");
187 SolverType.push_back(
"Amesos_Klu");
188 SolverType.push_back(
"Amesos_Umfpack");
189 SolverType.push_back(
"Amesos_Superlu");
191 SolverType.push_back(
"Amesos_Scalapack");
192 driver(Comm,
false,
true, SolverType);
198 std::vector<std::string> SolverType;
201 SolverType.push_back(
"Amesos_Superludist");
202 driver(Comm,
false,
false, SolverType);
209 std::vector<std::string> SolverType;
210 SolverType.push_back(
"Amesos_Taucs");
211 driver(Comm,
true,
false, SolverType);
void driver(Epetra_Comm &Comm, const bool IsSymmetric, const bool UseTranspose, std::vector< std::string > &SolverType)
void SetLHS(Epetra_MultiVector *X)
void SetOperator(Epetra_RowMatrix *A)
bool TestAmesos(char ProblemType[], Teuchos::ParameterList &AmesosList, bool UseTranspose, Epetra_RowMatrix *A, Epetra_MultiVector *lhs, Epetra_MultiVector *rhs)
virtual int Solve()=0
Solves A X = B (or AT x = B)
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
virtual int NumericFactorization()=0
Performs NumericFactorization on the matrix A.
virtual int SymbolicFactorization()=0
Performs SymbolicFactorization on the matrix A.
virtual int SetParameters(Teuchos::ParameterList &ParameterList)=0
Updates internal variables.
Amesos_TestRowMatrix: a class to test Epetra_RowMatrix based codes.
virtual int MyPID() const =0
virtual int SumAll(double *PartialSums, double *GlobalSums, int Count) const =0
int NumMyElements() const
virtual const Epetra_Comm & Comm() const =0
virtual const Epetra_BlockMap & Map() const =0
int main(int argc, char *argv[])
Factory for binding a third party direct solver to an Epetra_LinearProblem.
virtual int SetUseTranspose(bool UseTranspose)=0
If set true, X will be set to the solution of AT X = B (not A X = B)
int CreateCrsMatrix(const char *in_filename, const Epetra_Comm &Comm, Epetra_Map *&readMap, const bool transpose, const bool distribute, bool &symmetric, Epetra_CrsMatrix *&Matrix)
virtual int Multiply(bool TransA, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const =0
void SetRHS(Epetra_MultiVector *B)
Amesos_BaseSolver * Create(const char *ClassType, const Epetra_LinearProblem &LinearProblem)
Amesos Create method.
virtual int NumProc() const =0
Amesos_BaseSolver: A pure virtual class for direct solution of real-valued double-precision operators...
bool Query(const char *ClassType)
Queries whether a given interface is available or not.