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"
65 #include "Teuchos_RefCountPtr.hpp"
74 return std::string(s);
80 return std::string(s);
85 int main(
int argc,
char *argv[]) {
88 MPI_Init(&argc,&argv);
94 int MyPID = Comm.
MyPID();
96 if (MyPID==0) verbose =
true;
117 GaleriList.
set(
"nx", nx);
119 GaleriList.
set(
"mx", 1);
121 Teuchos::RefCountPtr<Epetra_Map> Map =
Teuchos::rcp( Galeri::CreateMap(
"Cartesian2D", Comm, GaleriList) );
122 Teuchos::RefCountPtr<Epetra_CrsMatrix>
A =
Teuchos::rcp( Galeri::CreateCrsMatrix(
"Laplace2D", &*Map, GaleriList) );
128 LHS->PutScalar(0.0); RHS->Random();
134 const double tol = 1e-5;
135 const int maxIter = 500;
144 solver.SetUserMatrix(&*A);
145 solver.SetLHS(&*LHS);
146 solver.SetRHS(&*RHS);
147 solver.SetAztecOption(AZ_solver,AZ_cg);
148 solver.SetAztecOption(AZ_output, 16);
149 solver.Iterate(maxIter, tol);
151 int Iters = solver.NumIters();
158 #ifdef HAVE_IFPACK_AMESOS
164 Teuchos::RefCountPtr<Ifpack_Preconditioner> PrecSupportAmesos =
Teuchos::rcp( Factory.
Create(
"MSF Amesos", &*A) );
165 List.
set(
"amesos: solver type",
"Klu");
166 List.
set(
"MST: keep diagonal", 1.0);
167 List.
set(
"MST: randomize", 1);
179 solver.SetUserMatrix(&*A);
180 solver.SetLHS(&*LHS);
181 solver.SetRHS(&*RHS);
182 solver.SetAztecOption(AZ_solver,AZ_cg);
183 solver.SetPrecOperator(&*PrecSupportAmesos);
184 solver.SetAztecOption(AZ_output, 16);
185 solver.Iterate(maxIter, tol);
187 SupportIters = solver.NumIters();
194 if (SupportIters > 2*Iters)
205 Teuchos::RefCountPtr<Ifpack_Preconditioner> PrecSupportIC =
Teuchos::rcp( Factory.
Create(
"MSF IC", &*A) );
217 solver.SetUserMatrix(&*A);
218 solver.SetLHS(&*LHS);
219 solver.SetRHS(&*RHS);
220 solver.SetAztecOption(AZ_solver,AZ_cg);
221 solver.SetPrecOperator(&*PrecSupportIC);
222 solver.SetAztecOption(AZ_output, 16);
223 solver.Iterate(maxIter, tol);
225 SupportIters = solver.NumIters();
228 if (SupportIters > 2*Iters)
239 return(EXIT_SUCCESS);
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
std::string toString(const int &x)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
int main(int argc, char *argv[])
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)