46 #include "Galeri_Maps.h"
47 #include "Galeri_CrsMatrices.h"
48 #include "Galeri_Utils.h"
49 #include "Epetra_MultiVector.h"
51 #include "Teuchos_UnitTestHarness.hpp"
52 #include "Teuchos_RCP.hpp"
53 #include "Epetra_ConfigDefs.h"
54 #include "Epetra_Vector.h"
55 #include "Epetra_RowMatrix.h"
56 #include "Epetra_MultiVector.h"
57 #include "Epetra_CrsMatrix.h"
58 #include "Epetra_Map.h"
61 #include "Epetra_MpiComm.h"
63 #include "Epetra_SerialComm.h"
68 #include "Teuchos_Array.hpp"
84 for(
int i = 0; i <
N; i++){
92 Ifpack_Hypre preconditioner(&Matrix);
100 const double tol = 1e-7;
112 GaleriList.
set(
"nx", nx);
113 GaleriList.
set(
"ny", ny);
118 Map = Galeri::CreateMap(
"Cartesian2D", Comm, GaleriList);
119 Matrix = Galeri::CreateCrsMatrix(
"Biharmonic2D", Map, GaleriList);
124 functs[0] =
rcp(
new FunctionParameter(
Solver, &HYPRE_PCGSetMaxIter, 1000));
125 functs[1] =
rcp(
new FunctionParameter(
Solver, &HYPRE_PCGSetTol, tol));
126 functs[2] =
rcp(
new FunctionParameter(
Solver, &HYPRE_PCGSetTwoNorm, 1));
127 functs[3] =
rcp(
new FunctionParameter(
Solver, &HYPRE_PCGSetPrintLevel, 0));
128 functs[4] =
rcp(
new FunctionParameter(
Solver, &HYPRE_PCGSetLogging, 1));
129 functs[5] =
rcp(
new FunctionParameter(
Preconditioner, &HYPRE_BoomerAMGSetPrintLevel, 1));
130 functs[6] =
rcp(
new FunctionParameter(
Preconditioner, &HYPRE_BoomerAMGSetCoarsenType, 6));
131 functs[7] =
rcp(
new FunctionParameter(
Preconditioner, &HYPRE_BoomerAMGSetRelaxType, 6));
132 functs[8] =
rcp(
new FunctionParameter(
Preconditioner, &HYPRE_BoomerAMGSetNumSweeps, 1));
133 functs[9] =
rcp(
new FunctionParameter(
Preconditioner, &HYPRE_BoomerAMGSetTol, 0.0));
134 functs[10] =
rcp(
new FunctionParameter(
Preconditioner, &HYPRE_BoomerAMGSetMaxIter, 1));
139 list.
set(
"SetPreconditioner",
true);
140 list.
set(
"NumFunctions", 11);
144 Ifpack_Hypre preconditioner(Matrix);
163 catch (Galeri::Exception& rhs)
165 if (Comm.
MyPID() == 0)
167 cerr <<
"Caught exception: ";
177 const double tol = 1
E-7;
205 functs[0] =
rcp(
new FunctionParameter(
Solver, &HYPRE_PCGSetMaxIter, 1000));
206 functs[1] =
rcp(
new FunctionParameter(
Solver, &HYPRE_PCGSetTol, 1e-9));
207 functs[2] =
rcp(
new FunctionParameter(
Solver, &HYPRE_PCGSetLogging, 1));
208 functs[3] =
rcp(
new FunctionParameter(
Solver, &HYPRE_PCGSetPrintLevel, 0));
209 functs[4] =
rcp(
new FunctionParameter(
Preconditioner, &HYPRE_ParaSailsSetLogging, 0));
210 list.set(
"NumFunctions", 5);
212 list.set(
"SolveOrPrecondition",
Solver);
213 list.set(
"Solver",
PCG);
215 list.set(
"SetPreconditioner",
true);
217 (
dynamic_cast<Ifpack_Hypre*
> (preconditioner.
get()))->SetParameter(
Solver,
PCG);
219 (
dynamic_cast<Ifpack_Hypre*
> (preconditioner.
get()))->SetParameter(
Solver, &HYPRE_ParCSRPCGSetMaxIter, 1000);
220 (
dynamic_cast<Ifpack_Hypre*
> (preconditioner.
get()))->SetParameter(
Solver, &HYPRE_ParCSRPCGSetTol, 1e-9);
221 (
dynamic_cast<Ifpack_Hypre*
> (preconditioner.
get()))->SetParameter(
Solver);
222 (
dynamic_cast<Ifpack_Hypre*
> (preconditioner.
get()))->SetParameter(
true);
229 (
dynamic_cast<Ifpack_Hypre*
> (preconditioner.
get()))->SetParameter(
Solver, &HYPRE_ParCSRPCGGetNumIterations, &numIters);
230 (
dynamic_cast<Ifpack_Hypre*
> (preconditioner.
get()))->SetParameter(
Solver, &HYPRE_ParCSRPCGGetFinalRelativeResidualNorm, &residual);
231 (
dynamic_cast<Ifpack_Hypre*
> (preconditioner.
get()))->CallFunctions();
232 if(MyPID == 0) printf(
"It took %d iterations, and achieved %e residual.\n", numIters, residual);
241 int myRank = comm.
MyPID();
270 accMat.
Apply(KnownX, B);
275 const double tol = 1e-7;
278 functs[0] =
rcp(
new FunctionParameter(
Solver, &HYPRE_PCGSetMaxIter, 100));
279 functs[1] =
rcp(
new FunctionParameter(
Solver, &HYPRE_PCGSetTol, tol));
280 functs[2] =
rcp(
new FunctionParameter(
Solver, &HYPRE_PCGSetTwoNorm, 1));
281 functs[3] =
rcp(
new FunctionParameter(
Solver, &HYPRE_PCGSetPrintLevel, 2));
282 functs[4] =
rcp(
new FunctionParameter(
Solver, &HYPRE_PCGSetLogging, 1));
285 list.
set(
"SetPreconditioner",
false);
286 list.
set(
"NumFunctions", 5);
292 Ifpack_Hypre prec(&accMat);
310 int myRank = comm.
MyPID();
317 elementList[0] = 2*myRank+1;
318 elementList[1] = 2*myRank;
319 Epetra_Map ncMap(2*numProcs,2,elementList,0,comm);
338 const double tol = 1e-7;
341 functs[0] =
rcp(
new FunctionParameter(
Solver, &HYPRE_PCGSetMaxIter, 100));
342 functs[1] =
rcp(
new FunctionParameter(
Solver, &HYPRE_PCGSetTol, tol));
343 functs[2] =
rcp(
new FunctionParameter(
Solver, &HYPRE_PCGSetTwoNorm, 1));
344 functs[3] =
rcp(
new FunctionParameter(
Solver, &HYPRE_PCGSetPrintLevel, 2));
345 functs[4] =
rcp(
new FunctionParameter(
Solver, &HYPRE_PCGSetLogging, 1));
348 list.
set(
"SetPreconditioner",
false);
349 list.
set(
"NumFunctions", 5);
355 Ifpack_Hypre prec(&accMat);
368 accMat.
Apply(KnownX, B);
389 int myRank = comm.
MyPID();
395 elementList[0] = myRank;
396 elementList[1] = myRank+numProcs;
397 Epetra_Map badMap(2*numProcs,2,elementList,0,comm);
408 col = myRank+numProcs;
415 const double tol = 1e-7;
418 functs[0] =
rcp(
new FunctionParameter(
Solver, &HYPRE_PCGSetMaxIter, 1));
419 functs[1] =
rcp(
new FunctionParameter(
Solver, &HYPRE_PCGSetTol, tol));
420 functs[2] =
rcp(
new FunctionParameter(
Solver, &HYPRE_PCGSetTwoNorm, 1));
421 functs[3] =
rcp(
new FunctionParameter(
Solver, &HYPRE_PCGSetPrintLevel, 2));
422 functs[4] =
rcp(
new FunctionParameter(
Solver, &HYPRE_PCGSetLogging, 1));
425 list.
set(
"SetPreconditioner",
false);
426 list.
set(
"NumFunctions", 5);
432 Ifpack_Hypre prec(&badMat);
virtual double Condest(const Ifpack_CondestType CT=Ifpack_Cheap, const int MaxIters=1550, const double Tol=1e-9, Epetra_RowMatrix *Matrix=0)=0
Computes the condition number estimate, returns its value.
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
virtual int InsertGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
bool EquivalentVectors(Epetra_MultiVector &Y1, Epetra_MultiVector &Y2, const double tol)
virtual const Epetra_Map & OperatorDomainMap() const =0
virtual int Initialize()=0
Computes all it is necessary to initialize the preconditioner.
virtual int MyPID() const =0
int FillComplete(bool OptimizeDataStorage=true)
virtual int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const =0
virtual const Epetra_Map & OperatorRangeMap() const =0
virtual int SetParameters(Teuchos::ParameterList &List)=0
Sets all parameters for the preconditioner.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
virtual int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const =0
Applies the preconditioner to vector X, returns the result in Y.
virtual void Print(std::ostream &os) const
TEUCHOS_UNIT_TEST(Ifpack_Hypre, Construct)
virtual int NumProc() const =0
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...
virtual int Compute()=0
Computes all it is necessary to apply the preconditioner.
#define TEST_EQUALITY(v1, v2)
Epetra_CrsMatrix * newCrsMatrix(int N)
const Epetra_Comm & Comm() const