46 #include "Epetra_MpiComm.h"
48 #include "Epetra_SerialComm.h"
50 #include "Epetra_CrsMatrix.h"
51 #include "Epetra_Vector.h"
52 #include "Epetra_LinearProblem.h"
53 #include "Epetra_Time.h"
54 #include "Galeri_Maps.h"
55 #include "Galeri_CrsMatrices.h"
56 #include "Teuchos_ParameterList.hpp"
57 #include "Teuchos_RefCountPtr.hpp"
69 int Overlap,
int ival)
72 AztecOO AztecOOSolver(Problem);
73 AztecOOSolver.SetAztecOption(AZ_solver,AZ_gmres);
74 AztecOOSolver.SetAztecOption(AZ_output,AZ_none);
75 AztecOOSolver.SetAztecOption(AZ_overlap,Overlap);
76 AztecOOSolver.SetAztecOption(AZ_graph_fill,ival);
77 AztecOOSolver.SetAztecOption(AZ_poly_ord, ival);
78 AztecOOSolver.SetAztecParam(AZ_drop, 0.0);
79 AztecOOSolver.SetAztecParam(AZ_athresh, 0.0);
80 AztecOOSolver.SetAztecParam(AZ_rthresh, 0.0);
87 A->Multiply(
false,LHS,RHS);
90 List.
set(
"fact: level-of-fill", ival);
91 List.
set(
"relaxation: sweeps", ival);
92 List.
set(
"relaxation: damping factor", 1.0);
93 List.
set(
"relaxation: zero starting solution",
true);
96 List.
set(
"schwarz: combine mode",
Zero);
100 Teuchos::RefCountPtr<Ifpack_Preconditioner> Prec;
102 if (what ==
"Jacobi") {
104 List.
set(
"relaxation: type",
"Jacobi");
105 AztecOOSolver.SetAztecOption(AZ_precond,AZ_Jacobi);
106 AztecOOSolver.SetAztecOption(AZ_reorder,0);
108 else if (what ==
"IC no reord") {
110 AztecOOSolver.SetAztecOption(AZ_precond,AZ_dom_decomp);
111 AztecOOSolver.SetAztecOption(AZ_subdomain_solve,AZ_icc);
112 AztecOOSolver.SetAztecOption(AZ_reorder,0);
114 else if (what ==
"IC reord") {
116 List.
set(
"schwarz: use reordering",
true);
117 AztecOOSolver.SetAztecOption(AZ_precond,AZ_dom_decomp);
118 AztecOOSolver.SetAztecOption(AZ_subdomain_solve,AZ_icc);
119 AztecOOSolver.SetAztecOption(AZ_reorder,1);
121 else if (what ==
"ILU no reord") {
123 AztecOOSolver.SetAztecOption(AZ_precond,AZ_dom_decomp);
124 AztecOOSolver.SetAztecOption(AZ_subdomain_solve,AZ_ilu);
125 AztecOOSolver.SetAztecOption(AZ_reorder,0);
127 else if (what ==
"ILU reord") {
129 List.
set(
"schwarz: use reordering",
true);
130 AztecOOSolver.SetAztecOption(AZ_precond,AZ_dom_decomp);
131 AztecOOSolver.SetAztecOption(AZ_subdomain_solve,AZ_ilu);
132 AztecOOSolver.SetAztecOption(AZ_reorder,1);
134 #ifdef HAVE_IFPACK_AMESOS
135 else if (what ==
"LU") {
137 List.
set(
"amesos: solver type",
"Klu");
138 AztecOOSolver.SetAztecOption(AZ_precond,AZ_dom_decomp);
139 AztecOOSolver.SetAztecOption(AZ_subdomain_solve,AZ_lu);
143 cerr <<
"Option not recognized" << endl;
153 Time.ResetStartTime();
154 AztecOOSolver.Iterate(150,1e-5);
158 cout <<
"==================================================" << endl;
159 cout <<
"Testing `" << what <<
"', Overlap = "
160 << Overlap <<
", ival = " << ival << endl;
162 cout <<
"[AztecOO] Total time = " << Time.ElapsedTime() <<
" (s)" << endl;
163 cout <<
"[AztecOO] Residual = " << AztecOOSolver.TrueResidual() <<
" (s)" << endl;
164 cout <<
"[AztecOO] Iterations = " << AztecOOSolver.NumIters() << endl;
168 int AztecOOPrecIters = AztecOOSolver.NumIters();
178 Time.ResetStartTime();
181 cout <<
"[IFPACK] Time for Initialize() = "
182 << Time.ElapsedTime() <<
" (s)" << endl;
184 Time.ResetStartTime();
187 cout <<
"[IFPACK] Time for Compute() = "
188 << Time.ElapsedTime() <<
" (s)" << endl;
191 AztecOOSolver.SetPrecOperator(&*Prec);
195 Time.ResetStartTime();
196 AztecOOSolver.Iterate(150,1e-5);
199 cout <<
"[IFPACK] Total time = " << Time2.ElapsedTime() <<
" (s)" << endl;
200 cout <<
"[IFPACK] Residual = " << AztecOOSolver.TrueResidual() <<
" (s)" << endl;
201 cout <<
"[IFPACK] Iterations = " << AztecOOSolver.NumIters() << endl;
205 int IFPACKPrecIters = AztecOOSolver.NumIters();
207 if (
IFPACK_ABS(AztecOOPrecIters - IFPACKPrecIters) > 3) {
208 cerr <<
"TEST FAILED (" << AztecOOPrecIters <<
" != "
209 << IFPACKPrecIters <<
")" << endl;
218 int main(
int argc,
char *argv[])
222 MPI_Init(&argc,&argv);
230 GaleriList.
set(
"n", nx * nx);
231 GaleriList.
set(
"nx", nx);
232 GaleriList.
set(
"ny", nx);
234 Teuchos::RefCountPtr<Epetra_Map> Map =
Teuchos::rcp( Galeri::CreateMap64(
"Linear", Comm, GaleriList) );
235 Teuchos::RefCountPtr<Epetra_RowMatrix>
A =
Teuchos::rcp( Galeri::CreateCrsMatrix(
"Laplace2D", &*Map, GaleriList) );
240 int TestPassed =
true;
243 for (
int ival = 1 ; ival < 10 ; ival += 3) {
244 TestPassed = TestPassed &&
251 TestPassed = TestPassed &&
253 TestPassed = TestPassed &&
256 vector<std::string> Tests;
258 Tests.push_back(
"ILU no reord");
259 Tests.push_back(
"ILU reord");
261 #ifdef HAVE_IFPACK_AMESOS
265 for (
unsigned int i = 0 ; i < Tests.size() ; ++i) {
266 for (
int overlap = 0 ; overlap < 1 ; overlap += 2) {
267 for (
int ival = 0 ; ival < 10 ; ival += 4)
268 TestPassed = TestPassed &&
275 cerr <<
"Test `CompareWithAztecOO.exe' FAILED!" << endl;
282 cout <<
"Test `CompareWithAztecOO.exe' passed!" << endl;
Epetra_MultiVector * GetLHS() const
Epetra_MultiVector * GetRHS() const
bool CompareWithAztecOO(Epetra_LinearProblem &Problem, const std::string what, int Overlap, int ival)
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Ifpack_AdditiveSchwarz: a class to define Additive Schwarz preconditioners of Epetra_RowMatrix's.
Ifpack_PointRelaxation: a class to define point relaxation preconditioners of for Epetra_RowMatrix's...
int main(int argc, char *argv[])
Epetra_RowMatrix * GetMatrix() const
#define IFPACK_CHK_ERR(ifpack_err)