46 #include "Epetra_ConfigDefs.h"
49 #include "Epetra_MpiComm.h"
51 #include "Epetra_SerialComm.h"
53 #include "Epetra_Comm.h"
54 #include "Epetra_Map.h"
55 #include "Epetra_Time.h"
56 #include "Epetra_BlockMap.h"
57 #include "Epetra_MultiVector.h"
58 #include "Epetra_Vector.h"
59 #include "Epetra_Export.h"
61 #include "Galeri_Maps.h"
62 #include "Galeri_CrsMatrices.h"
66 #include "Teuchos_RefCountPtr.hpp"
73 return std::string(s);
79 return std::string(s);
84 int main(
int argc,
char *argv[]) {
87 MPI_Init(&argc,&argv);
96 GaleriList.
set(
"nx", nx);
98 GaleriList.
set(
"mx", 1);
100 Teuchos::RefCountPtr<Epetra_Map> Map =
Teuchos::rcp( Galeri::CreateMap(
"Cartesian2D", Comm, GaleriList) );
101 Teuchos::RefCountPtr<Epetra_CrsMatrix>
A =
Teuchos::rcp( Galeri::CreateCrsMatrix(
"Laplace2D", &*Map, GaleriList) );
104 LHS->PutScalar(0.0); RHS->Random();
110 const double tol = 1e-5;
111 const int maxIter = 500;
120 solver.SetUserMatrix(&*A);
121 solver.SetLHS(&*LHS);
122 solver.SetRHS(&*RHS);
123 solver.SetAztecOption(AZ_solver,AZ_cg);
125 solver.SetAztecOption(AZ_output, 16);
126 solver.Iterate(maxIter, tol);
128 int Iters = solver.NumIters();
137 double DropTol = 0.3333;
140 Teuchos::RefCountPtr<Ifpack_CrsRick> IC;
143 IC->SetAbsoluteThreshold(0.00123);
144 IC->SetRelativeThreshold(0.9876);
150 IC->Condest(
false,Condest);
152 if( Comm.
MyPID() == 0 ) {
153 cout <<
"Condition number estimate (level-of-fill = "
154 << LevelFill <<
") = " << Condest << endl;
158 std::string label =
"Ifpack_CrsRick Preconditioner: LevelFill = " +
toString(LevelFill) +
160 IC->SetLabel(label.c_str());
166 solver.SetUserMatrix(&*A);
167 solver.SetLHS(&*LHS);
168 solver.SetRHS(&*RHS);
169 solver.SetAztecOption(AZ_solver,AZ_cg);
170 solver.SetPrecOperator(&*IC);
171 solver.SetAztecOption(AZ_output, 16);
172 solver.Iterate(maxIter, tol);
174 int RickIters = solver.NumIters();
178 if (RickIters > Iters/2)
188 Teuchos::RefCountPtr<Ifpack_Preconditioner> PrecIC =
Teuchos::rcp( Factory.
Create(
"IC", &*A) );
204 solver.SetUserMatrix(&*A);
205 solver.SetLHS(&*LHS);
206 solver.SetRHS(&*RHS);
207 solver.SetAztecOption(AZ_solver,AZ_cg);
208 solver.SetPrecOperator(&*PrecIC);
209 solver.SetAztecOption(AZ_output, 16);
210 solver.Iterate(maxIter, tol);
212 int ICIters = solver.NumIters();
216 if (ICIters > Iters/2)
224 Teuchos::RefCountPtr<Ifpack_Preconditioner> PrecICT =
Teuchos::rcp( Factory.
Create(
"ICT", &*A) );
239 solver.SetUserMatrix(&*A);
240 solver.SetLHS(&*LHS);
241 solver.SetRHS(&*RHS);
242 solver.SetAztecOption(AZ_solver,AZ_cg);
243 solver.SetPrecOperator(&*PrecICT);
244 solver.SetAztecOption(AZ_output, 16);
245 solver.Iterate(maxIter, tol);
247 int ICTIters = solver.NumIters();
251 if (ICTIters > Iters/2)
259 return(EXIT_SUCCESS);
std::string toString(const int &x)
Ifpack_IlukGraph: A class for constructing level filled graphs for use with ILU(k) class precondition...
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)
int main(int argc, char *argv[])
Ifpack_CrsRick: A class for constructing and using an incomplete Cholesky (IC) factorization of a giv...
Ifpack: a function class to define Ifpack preconditioners.
static Ifpack_Preconditioner * Create(EPrecType PrecType, Epetra_RowMatrix *Matrix, const int overlap=0, bool overrideSerialDefault=false)
Creates an instance of Ifpack_Preconditioner given the enum value of the preconditioner type (can not...
#define IFPACK_CHK_ERR(ifpack_err)