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)
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);
89 A->Multiply(
false,LHS,RHS);
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") {
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") {
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") {
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") {
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") {
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();
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;
220 int main(
int argc,
char *argv[])
224 MPI_Init(&argc,&argv);
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;
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 &&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)