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 "Galeri_Maps.h"
54 #include "Galeri_CrsMatrices.h"
55 #include "Teuchos_ParameterList.hpp"
56 #include "Teuchos_RefCountPtr.hpp"
69 template <
class CommType>
70 Teuchos::RefCountPtr<Epetra_RowMatrix>
71 createTriDiagMat(
int NumGlobalElements, CommType Comm,
bool str_singular,
bool num_singular) {
95 for (
int i = 0; i < NumMyElements; i++)
97 if (MyGlobalElements[i] == 0)
114 else if (MyGlobalElements[i] == NumGlobalElements-1)
116 Indices[0] = NumGlobalElements-1;
117 Indices[1] = NumGlobalElements-2;
124 Indices[0] = MyGlobalElements[i]-1;
125 Indices[1] = MyGlobalElements[i];
126 Indices[2] = MyGlobalElements[i]+1;
134 A->InsertGlobalValues(MyGlobalElements[i],
135 NumEntries, Values, Indices);
150 bool UseTranspose =
false;
158 Matrix->Multiply(UseTranspose,LHSexact,
RHS);
162 Teuchos::RefCountPtr<T> Prec;
172 AztecOO AztecOOSolver(Problem);
175 AztecOOSolver.SetAztecOption(AZ_solver,AZ_gmres);
176 AztecOOSolver.SetAztecOption(AZ_output,32);
178 AztecOOSolver.SetPrecOperator(&*Prec);
182 AztecOOSolver.Iterate(1550,1e-8);
186 std::vector<double> Norm(NumVectors);
187 LHS.Update(1.0,LHSexact,-1.0);
190 cout <<
"Norm[" << i <<
"] = " << Norm[i] << endl;
198 int main(
int argc,
char *argv[])
202 MPI_Init(&argc,&argv);
212 GaleriList.
set(
"n", nx * nx);
213 GaleriList.
set(
"nx", nx);
214 GaleriList.
set(
"ny", nx);
215 Teuchos::RefCountPtr<Epetra_Map> Map =
Teuchos::rcp( Galeri::CreateMap(
"Linear", Comm, GaleriList) );
216 Teuchos::RefCountPtr<Epetra_RowMatrix> Matrix =
Teuchos::rcp( Galeri::CreateCrsMatrix(
"Laplace2D", &*Map, GaleriList) );
221 int TestPassed =
true;
223 if (!Test<Ifpack_Chebyshev>(Matrix,List))
228 List.
set(
"polynomial: degree",3);
229 if (!Test<Ifpack_Polynomial>(Matrix,List))
235 List.
set(
"krylov: tolerance", 1e-14);
236 List.
set(
"krylov: iterations", 100);
237 List.
set(
"krylov: preconditioner", 2);
238 List.
set(
"krylov: block size", 9);
239 List.
set(
"krylov: number of sweeps", 2);
240 if (!Test<Ifpack_Krylov>(Matrix,List))
249 if (!Test<Ifpack_Amesos>(Matrix,List))
263 List.
set(
"relaxation: type",
"Gauss-Seidel");
264 if (!Test<Ifpack_PointRelaxation>(Matrix,List)) {
270 List.
set(
"relaxation: type",
"symmetric Gauss-Seidel");
271 List.
set(
"relaxation: sweeps", 5);
272 List.
set(
"partitioner: local parts", 128);
273 List.
set(
"partitioner: type",
"linear");
280 List.
set(
"relaxation: type",
"symmetric Gauss-Seidel");
281 List.
set(
"partitioner: local parts", 128);
282 List.
set(
"partitioner: type",
"linear");
289 List.
set(
"relaxation: type",
"symmetric Gauss-Seidel");
290 List.
set(
"partitioner: local parts", 128);
291 List.
set(
"partitioner: type",
"linear");
296 #ifdef HAVE_IFPACK_AMESOS
302 bool check_for_global_error =
false;
303 if (check_for_global_error) {
306 bool num_singular =
false;
307 bool str_singular =
true;
314 str_singular =
false;
323 cerr <<
"Test `TestAll.exe' FAILED!" << endl;
331 cout <<
"Test `TestAll.exe' passed!" << endl;
333 return(EXIT_SUCCESS);
bool Test(const Teuchos::RefCountPtr< Epetra_RowMatrix > &Matrix, Teuchos::ParameterList &List)
Ifpack_BlockRelaxation: a class to define block relaxation preconditioners of Epetra_RowMatrix's.
int MyGlobalElements(int *MyGlobalElementList) const
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
int NumMyElements() const
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_SparseContainer: a class for storing and solving linear systems using sparse matrices...
int main(int argc, char *argv[])
#define IFPACK_CHK_ERRB(ifpack_err)
Teuchos::RefCountPtr< Epetra_RowMatrix > createTriDiagMat(int NumGlobalElements, CommType Comm, bool str_singular, bool num_singular)