69 int Overlap,
int ival)
74 AztecOO AztecOOSolver(Problem);
75 AztecOOSolver.SetAztecOption(AZ_solver,AZ_gmres);
76 AztecOOSolver.SetAztecOption(AZ_output,AZ_none);
77 AztecOOSolver.SetAztecOption(AZ_overlap,Overlap);
78 AztecOOSolver.SetAztecOption(AZ_graph_fill,ival);
79 AztecOOSolver.SetAztecOption(AZ_poly_ord, ival);
80 AztecOOSolver.SetAztecParam(AZ_drop, 0.0);
81 AztecOOSolver.SetAztecParam(AZ_athresh, 0.0);
82 AztecOOSolver.SetAztecParam(AZ_rthresh, 0.0);
86 Teuchos::RefCountPtr<Epetra_RowMatrix> A = Teuchos::rcp(Problem.GetMatrix(),
false);
89 A->Multiply(
false,LHS,
RHS);
91 Teuchos::ParameterList List;
92 List.set(
"fact: level-of-fill", ival);
93 List.set(
"relaxation: sweeps", ival);
94 List.set(
"relaxation: damping factor", 1.0);
95 List.set(
"relaxation: zero starting solution",
true);
98 List.set(
"schwarz: combine mode",
Zero);
102 Teuchos::RefCountPtr<Ifpack_Preconditioner> Prec;
104 if (what ==
"Jacobi") {
106 List.set(
"relaxation: type",
"Jacobi");
107 AztecOOSolver.SetAztecOption(AZ_precond,AZ_Jacobi);
108 AztecOOSolver.SetAztecOption(AZ_reorder,0);
110 else if (what ==
"IC no reord") {
111 Prec = Teuchos::rcp(
new Ifpack_AdditiveSchwarz<Ifpack_IC>(&*A,Overlap) );
112 AztecOOSolver.SetAztecOption(AZ_precond,AZ_dom_decomp);
113 AztecOOSolver.SetAztecOption(AZ_subdomain_solve,AZ_icc);
114 AztecOOSolver.SetAztecOption(AZ_reorder,0);
116 else if (what ==
"IC reord") {
117 Prec = Teuchos::rcp(
new Ifpack_AdditiveSchwarz<Ifpack_IC>(&*A,Overlap) );
118 List.set(
"schwarz: use reordering",
true);
119 AztecOOSolver.SetAztecOption(AZ_precond,AZ_dom_decomp);
120 AztecOOSolver.SetAztecOption(AZ_subdomain_solve,AZ_icc);
121 AztecOOSolver.SetAztecOption(AZ_reorder,1);
123 else if (what ==
"ILU no reord") {
124 Prec = Teuchos::rcp(
new Ifpack_AdditiveSchwarz<Ifpack_ILU>(&*A,Overlap) );
125 AztecOOSolver.SetAztecOption(AZ_precond,AZ_dom_decomp);
126 AztecOOSolver.SetAztecOption(AZ_subdomain_solve,AZ_ilu);
127 AztecOOSolver.SetAztecOption(AZ_reorder,0);
129 else if (what ==
"ILU reord") {
130 Prec = Teuchos::rcp(
new Ifpack_AdditiveSchwarz<Ifpack_ILU>(&*A,Overlap) );
131 List.set(
"schwarz: use reordering",
true);
132 AztecOOSolver.SetAztecOption(AZ_precond,AZ_dom_decomp);
133 AztecOOSolver.SetAztecOption(AZ_subdomain_solve,AZ_ilu);
134 AztecOOSolver.SetAztecOption(AZ_reorder,1);
136#ifdef HAVE_IFPACK_AMESOS
137 else if (what ==
"LU") {
138 Prec = Teuchos::rcp(
new Ifpack_AdditiveSchwarz<Ifpack_Amesos>(&*A,Overlap) );
139 List.set(
"amesos: solver type",
"Klu");
140 AztecOOSolver.SetAztecOption(AZ_precond,AZ_dom_decomp);
141 AztecOOSolver.SetAztecOption(AZ_subdomain_solve,AZ_lu);
145 cerr <<
"Option not recognized" << endl;
155 Time.ResetStartTime();
156 AztecOOSolver.Iterate(150,1e-5);
160 cout <<
"==================================================" << endl;
161 cout <<
"Testing `" << what <<
"', Overlap = "
162 << Overlap <<
", ival = " << ival << endl;
164 cout <<
"[AztecOO] Total time = " << Time.ElapsedTime() <<
" (s)" << endl;
165 cout <<
"[AztecOO] Residual = " << AztecOOSolver.TrueResidual() <<
" (s)" << endl;
166 cout <<
"[AztecOO] Iterations = " << AztecOOSolver.NumIters() << endl;
170 int AztecOOPrecIters = AztecOOSolver.NumIters();
177 assert(Prec != Teuchos::null);
180 Time.ResetStartTime();
183 cout <<
"[IFPACK] Time for Initialize() = "
184 << Time.ElapsedTime() <<
" (s)" << endl;
186 Time.ResetStartTime();
189 cout <<
"[IFPACK] Time for Compute() = "
190 << Time.ElapsedTime() <<
" (s)" << endl;
193 AztecOOSolver.SetPrecOperator(&*Prec);
197 Time.ResetStartTime();
198 AztecOOSolver.Iterate(150,1e-5);
201 cout <<
"[IFPACK] Total time = " << Time2.ElapsedTime() <<
" (s)" << endl;
202 cout <<
"[IFPACK] Residual = " << AztecOOSolver.TrueResidual() <<
" (s)" << endl;
203 cout <<
"[IFPACK] Iterations = " << AztecOOSolver.NumIters() << endl;
207 int IFPACKPrecIters = AztecOOSolver.NumIters();
209 if (
IFPACK_ABS(AztecOOPrecIters - IFPACKPrecIters) > 3) {
210 cerr <<
"TEST FAILED (" << AztecOOPrecIters <<
" != "
211 << IFPACKPrecIters <<
")" << endl;
220int main(
int argc,
char *argv[])
224 MPI_Init(&argc,&argv);
231 Teuchos::ParameterList GaleriList;
232 GaleriList.set(
"n", nx * nx);
233 GaleriList.set(
"nx", nx);
234 GaleriList.set(
"ny", nx);
236 Teuchos::RefCountPtr<Epetra_Map> Map = Teuchos::rcp( Galeri::CreateMap(
"Linear", Comm, GaleriList) );
237 Teuchos::RefCountPtr<Epetra_RowMatrix> A = Teuchos::rcp( Galeri::CreateCrsMatrix(
"Laplace2D", &*Map, GaleriList) );
242 int TestPassed =
true;
245 for (
int ival = 1 ; ival < 10 ; ival += 3) {
246 TestPassed = TestPassed &&
253 TestPassed = TestPassed &&
255 TestPassed = TestPassed &&
258 vector<std::string> Tests;
260 Tests.push_back(
"ILU no reord");
261 Tests.push_back(
"ILU reord");
263#ifdef HAVE_IFPACK_AMESOS
267 for (
unsigned int i = 0 ; i < Tests.size() ; ++i) {
268 for (
int overlap = 0 ; overlap < 1 ; overlap += 2) {
269 for (
int ival = 0 ; ival < 10 ; ival += 4)
270 TestPassed = TestPassed &&
277 cerr <<
"Test `CompareWithAztecOO.exe' FAILED!" << endl;
284 cout <<
"Test `CompareWithAztecOO.exe' passed!" << endl;
int main(int argc, char *argv[])
bool CompareWithAztecOO(Epetra_LinearProblem &Problem, const std::string what, int Overlap, int ival)