43 #include <sys/resource.h>
47 #include "Epetra_MpiComm.h"
49 #include "Epetra_SerialComm.h"
51 #include "Epetra_CrsMatrix.h"
52 #include "Epetra_MultiVector.h"
53 #include "Epetra_Vector.h"
54 #include "Epetra_LinearProblem.h"
55 #include "Epetra_Map.h"
56 #include "Galeri_Maps.h"
57 #include "Galeri_CrsMatrices.h"
58 #include "Galeri_Utils.h"
59 #include "Teuchos_ParameterList.hpp"
60 #include "Teuchos_RefCountPtr.hpp"
78 LHS.PutScalar(0.0);
RHS.Random();
84 List.
set(
"relaxation: damping factor", 1.0);
85 List.
set(
"relaxation: type", PrecType);
86 List.
set(
"relaxation: sweeps",sweeps);
87 List.
set(
"partitioner: type",
"linear");
88 List.
set(
"partitioner: local parts", A->NumMyRows());
90 int ItersPoint, ItersBlock;
104 AztecOO AztecOOSolver(Problem);
105 AztecOOSolver.SetAztecOption(AZ_solver,
Solver);
106 AztecOOSolver.SetAztecOption(AZ_output,32);
107 AztecOOSolver.SetPrecOperator(&Point);
109 AztecOOSolver.Iterate(1550,1e-2);
111 double TrueResidual = AztecOOSolver.TrueResidual();
112 ItersPoint = AztecOOSolver.NumIters();
115 cout <<
"Iterations = " << ItersPoint << endl;
116 cout <<
"Norm of the true residual = " << TrueResidual << endl;
119 if(
verbose) printf(
" point finished \n");
133 AztecOO AztecOOSolver(Problem);
134 AztecOOSolver.SetAztecOption(AZ_solver,
Solver);
135 AztecOOSolver.SetAztecOption(AZ_output,32);
136 AztecOOSolver.SetPrecOperator(&Block);
138 AztecOOSolver.Iterate(1550,1e-2);
140 double TrueResidual = AztecOOSolver.TrueResidual();
141 ItersBlock = AztecOOSolver.NumIters();
144 cout <<
"Iterations " << ItersBlock << endl;
145 cout <<
"Norm of the true residual = " << TrueResidual << endl;
149 if(
verbose) printf(
" point finished \n");
151 int diff = ItersPoint - ItersBlock;
152 if (diff < 0) diff = -diff;
156 if(
verbose) cout <<
"ComparePointandBlock TEST FAILED!" << endl;
160 if(
verbose) cout <<
"ComparePointandBlock TEST PASSED" << endl;
167 int main(
int argc,
char *argv[])
170 MPI_Init(&argc,&argv);
180 for (
int i = 1 ; i < argc ; ++i) {
181 if (strcmp(argv[i],
"-s") == 0) {
185 if(strcmp(argv[i],
"-n") == 0 && i+1 < argc) {
195 GaleriList.
set(
"nx", nx);
197 GaleriList.
set(
"mx", 1);
199 Teuchos::RefCountPtr<Epetra_Map> Map =
Teuchos::rcp( Galeri::CreateMap(
"Cartesian2D", Comm, GaleriList) );
200 Teuchos::RefCountPtr<Epetra_CrsMatrix>
A;
202 A =
Teuchos::rcp( Galeri::CreateCrsMatrix(
"Laplace2D", &*Map, GaleriList) );
204 A =
Teuchos::rcp( Galeri::CreateCrsMatrix(
"Recirc2D", &*Map, GaleriList) );
210 int TestPassed =
true;
214 struct timeval ru_utime;
216 ru_utime = usage.ru_utime;
223 TestPassed = TestPassed &&
225 if(
verbose) printf(
" Jacobi Finished \n");
228 int sec = usage.ru_utime.tv_sec -ru_utime.tv_sec;
229 int usec = usage.ru_utime.tv_usec -ru_utime.tv_usec;
230 double tt = (double)sec + 1e-6*(
double)usec;
231 ru_utime = usage.ru_utime;
232 if(
verbose) printf(
" Jacobi time %f \n",tt);
234 TestPassed = TestPassed &&
236 if(
verbose) printf(
" sGS finished \n");
239 sec = usage.ru_utime.tv_sec -ru_utime.tv_sec;
240 usec = usage.ru_utime.tv_usec -ru_utime.tv_usec;
241 tt = (double)sec + 1e-6*(
double)usec;
242 ru_utime = usage.ru_utime;
243 if(
verbose) printf(
" sGS time %f \n",tt);
246 TestPassed = TestPassed &&
249 sec = usage.ru_utime.tv_sec -ru_utime.tv_sec;
250 usec = usage.ru_utime.tv_usec -ru_utime.tv_usec;
251 tt = (double)sec + 1e-6*(
double)usec;
252 ru_utime = usage.ru_utime;
253 if(
verbose) printf(
" GS time %f \n",tt);
254 if(
verbose) printf(
" GS Finished \n");
258 cout <<
"Test `Performance.exe' failed!" << endl;
267 cout <<
"Test `Performance.exe' passed!" << endl;
269 return(EXIT_SUCCESS);
Ifpack_BlockRelaxation: a class to define block relaxation preconditioners of Epetra_RowMatrix's.
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
virtual int MyPID() const =0
virtual int SetParameters(Teuchos::ParameterList &List)
Sets all the parameters for the preconditioner.
virtual const Epetra_Comm & Comm() const =0
virtual int Compute()
Computes the preconditioner.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Ifpack_PointRelaxation: a class to define point relaxation preconditioners of for Epetra_RowMatrix's...
virtual int SetParameters(Teuchos::ParameterList &List)
Sets all the parameters for the preconditioner.
int main(int argc, char *argv[])
virtual int Compute()
Computes the preconditioners.
Epetra_RowMatrix * GetMatrix() const