5 #include "Epetra_MpiComm.h" 7 #include "Epetra_SerialComm.h" 9 #include "Epetra_Map.h" 10 #include "Epetra_MultiVector.h" 11 #include "Epetra_Time.h" 12 #include "Epetra_CrsMatrix.h" 14 #include "Teuchos_ParameterList.hpp" 15 #include "Teuchos_Array.hpp" 16 #include "Galeri_Maps.h" 17 #include "Galeri_CrsMatrices.h" 26 const Epetra_BlockMap& Map = A.OperatorDomainMap();
28 Epetra_MultiVector x2(Map,NumVectors);
29 Epetra_MultiVector x1(Map,NumVectors);
30 Epetra_MultiVector x(Map,NumVectors);
31 Epetra_MultiVector b(Map,NumVectors);
32 Epetra_MultiVector residual(Map,NumVectors);
33 Epetra_MultiVector temp(Map,NumVectors);
35 Teuchos::ParameterList ParamList ;
36 Epetra_LinearProblem Problem;
42 Abase = Afactory.
Create(ProblemType,Problem );
46 Problem.SetOperator(&A);
72 A.Multiply(
false,x2, temp) ;
73 A.Multiply(
false,temp, x2) ;
74 A.Multiply(
false,x2, temp) ;
75 residual.Update( 1.0, temp, -1.0, b, 0.0 ) ;
77 Teuchos::Array<double> norm_residual(NumVectors);
78 residual.Norm2( norm_residual.getRawPtr() ) ;
80 if (A.Comm().MyPID() == 0) {
81 std::cout <<
"norm2(A^3 x-b) = " << norm_residual << std::endl ;
86 for (Teuchos::Array<double>::const_iterator it = norm_residual.begin(); it != norm_residual.end(); ++it) {
93 int main(
int argc,
char *argv[]) {
96 MPI_Init(&argc, &argv);
97 Epetra_MpiComm Comm(MPI_COMM_WORLD);
99 Epetra_SerialComm Comm;
104 Teuchos::ParameterList GaleriList;
105 GaleriList.set(
"nx", 8);
106 GaleriList.set(
"ny", 8 * Comm.NumProc());
107 GaleriList.set(
"mx", 1);
108 GaleriList.set(
"my", Comm.NumProc());
110 Epetra_Map* Map = CreateMap(
"Cartesian2D", Comm, GaleriList);
115 std::vector<std::string> SolverType;
117 SolverType.push_back(
"Amesos_Klu");
118 SolverType.push_back(
"Amesos_Umfpack");
119 SolverType.push_back(
"Amesos_Pardiso");
120 SolverType.push_back(
"Amesos_Taucs");
121 SolverType.push_back(
"Amesos_Superlu");
122 SolverType.push_back(
"Amesos_Superludist");
123 SolverType.push_back(
"Amesos_Mumps");
124 SolverType.push_back(
"Amesos_Dscpack");
126 bool TestPassed =
true;
128 for (
unsigned int i = 0 ; i < SolverType.size() ; ++i) {
129 std::string
Solver = SolverType[i];
130 std::cout <<
Solver <<
" next " << std::endl;
132 if (Comm.MyPID() == 0)
133 std::cout <<
"Testing " <<
Solver << std::endl;
135 std::cout <<
Solver <<
" Failed " << std::endl;
138 std::cout <<
Solver <<
" Passed " << std::endl;
141 if (Comm.MyPID() == 0) {
142 std::cerr << std::endl;
143 std::cerr <<
"WARNING: SOLVER `" <<
Solver <<
"' NOT TESTED" << std::endl;
144 std::cerr << std::endl;
156 if (Comm.MyPID() == 0)
157 std::cout <<
"TESTS PASSED!" << std::endl;
158 return( EXIT_SUCCESS );
161 if (Comm.MyPID() == 0)
162 std::cout <<
"TESTS FAILED!" << std::endl;
163 return( EXIT_FAILURE );
virtual int Solve()=0
Solves A X = B (or AT x = B)
virtual int NumericFactorization()=0
Performs NumericFactorization on the matrix A.
virtual int SymbolicFactorization()=0
Performs SymbolicFactorization on the matrix A.
Factory for binding a third party direct solver to an Epetra_LinearProblem.
int main(int argc, char *argv[])
#define EPETRA_CHK_ERR(xxx)
int CreateCrsMatrix(const char *in_filename, const Epetra_Comm &Comm, Epetra_Map *&readMap, const bool transpose, const bool distribute, bool &symmetric, Epetra_CrsMatrix *&Matrix)
bool TestAmesos(char ProblemType[], Epetra_RowMatrix &A, int NumVectors)
Amesos_BaseSolver * Create(const char *ClassType, const Epetra_LinearProblem &LinearProblem)
Amesos Create method.
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.