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);
93 int rv=preconditioner.Initialize();
101 const double tol = 1e-7;
113 GaleriList.
set(
"nx", nx);
114 GaleriList.
set(
"ny", ny);
119 Map = Galeri::CreateMap(
"Cartesian2D", Comm, GaleriList);
120 Matrix = Galeri::CreateCrsMatrix(
"Biharmonic2D", Map, GaleriList);
125 precList.
set(
"HYPRE_BoomerAMGSetPrintLevel", 1);
126 precList.
set(
"HYPRE_BoomerAMGSetCoarsenType", 6);
127 precList.
set(
"HYPRE_BoomerAMGSetRelaxType", 6);
128 precList.
set(
"HYPRE_BoomerAMGSetNumSweeps", 1);
129 precList.
set(
"HYPRE_BoomerAMGSetTol", 0.0);
130 precList.
set(
"HYPRE_BoomerAMGSetMaxIter", 1);
131 list.
set(
"hypre: Solver",
"PCG");
132 list.
set(
"hypre: Preconditioner",
"BoomerAMG");
133 list.
set(
"hypre: SolveOrPrecondition",
"Solver");
134 list.
set(
"hypre: SetPreconditioner",
true);
137 Ifpack_Hypre preconditioner(Matrix);
156 catch (Galeri::Exception& rhs)
158 if (Comm.
MyPID() == 0)
160 cerr <<
"Caught exception: ";
170 const double tol = 1e-7;
182 GaleriList.
set(
"nx", nx);
183 GaleriList.
set(
"ny", ny);
188 Map = Galeri::CreateMap(
"Cartesian2D", Comm, GaleriList);
189 Matrix = Galeri::CreateCrsMatrix(
"Biharmonic2D", Map, GaleriList);
194 list.
set(
"hypre: Solver",
"PCG");
196 solverList.
set(
"HYPRE_PCGSetMaxIter", 1000);
197 solverList.
set(
"HYPRE_PCGSetTol", tol);
198 solverList.
set(
"HYPRE_PCGSetTwoNorm", 1);
199 solverList.
set(
"HYPRE_PCGSetPrintLevel", 0);
200 solverList.
set(
"HYPRE_PCGSetLogging", 1);
201 list.
set(
"hypre: Solver functions",solverList);
203 list.
set(
"hypre: Preconditioner",
"BoomerAMG");
205 precList.
set(
"HYPRE_BoomerAMGSetPrintLevel", 1);
206 precList.
set(
"HYPRE_BoomerAMGSetCoarsenType", 6);
207 precList.
set(
"HYPRE_BoomerAMGSetRelaxType", 6);
208 precList.
set(
"HYPRE_BoomerAMGSetNumSweeps", 1);
209 precList.
set(
"HYPRE_BoomerAMGSetTol", 0.0);
210 precList.
set(
"HYPRE_BoomerAMGSetMaxIter", 1);
211 list.
set(
"hypre: Preconditioner functions",precList);
213 list.
set(
"hypre: SolveOrPrecondition",
"Solver");
214 list.
set(
"hypre: SetPreconditioner",
true);
217 Ifpack_Hypre preconditioner(Matrix);
236 catch (Galeri::Exception& rhs)
238 if (Comm.
MyPID() == 0)
240 cerr <<
"Caught exception: ";
250 const double tol = 1
E-7;
279 solverList.
set(
"HYPRE_PCGSetMaxIter", 1000);
280 solverList.
set(
"HYPRE_PCGSetTol", 1e-9);
281 solverList.
set(
"HYPRE_PCGSetPrintLevel", 0);
282 solverList.
set(
"HYPRE_PCGSetLogging", 1);
283 list.
set(
"hypre: Solver functions",solverList);
284 list.
set(
"hypre: SolveOrPrecondition",
"Solver");
285 list.
set(
"hypre: Solver",
"PCG");
286 list.
set(
"hypre: Preconditioner",
"ParaSails");
287 list.
set(
"hypre: SetPreconditioner",
true);
289 (
dynamic_cast<Ifpack_Hypre*
> (preconditioner.
get()))->SetParameter(
Solver,
PCG);
291 (
dynamic_cast<Ifpack_Hypre*
> (preconditioner.
get()))->SetParameter(
Solver, &HYPRE_ParCSRPCGSetMaxIter, 1000);
292 (
dynamic_cast<Ifpack_Hypre*
> (preconditioner.
get()))->SetParameter(
Solver, &HYPRE_ParCSRPCGSetTol, 1e-9);
293 (
dynamic_cast<Ifpack_Hypre*
> (preconditioner.
get()))->SetParameter(
Solver);
294 (
dynamic_cast<Ifpack_Hypre*
> (preconditioner.
get()))->SetParameter(
true);
301 (
dynamic_cast<Ifpack_Hypre*
> (preconditioner.
get()))->SetParameter(
Solver, &HYPRE_ParCSRPCGGetNumIterations, &numIters);
302 (
dynamic_cast<Ifpack_Hypre*
> (preconditioner.
get()))->SetParameter(
Solver, &HYPRE_ParCSRPCGGetFinalRelativeResidualNorm, &residual);
303 (
dynamic_cast<Ifpack_Hypre*
> (preconditioner.
get()))->CallFunctions();
304 if(MyPID == 0) printf(
"It took %d iterations, and achieved %e residual.\n", numIters, residual);
313 int myRank = comm.
MyPID();
342 accMat.
Apply(KnownX, B);
347 const double tol = 1e-7;
350 solverList.
set(
"HYPRE_PCGSetMaxIter", 1000);
351 solverList.
set(
"HYPRE_PCGSetTol", tol);
352 solverList.
set(
"HYPRE_PCGSetPrintLevel", 0);
353 solverList.
set(
"HYPRE_PCGSetLogging", 1);
354 list.
set(
"hypre: Solver",
"PCG");
355 list.
set(
"hypre: SolveOrPrecondition",
"Solver");
356 list.
set(
"hypre: SetPreconditioner",
false);
361 Ifpack_Hypre prec(&accMat);
379 int myRank = comm.
MyPID();
386 elementList[0] = 2*myRank+1;
387 elementList[1] = 2*myRank;
388 Epetra_Map ncMap(2*numProcs,2,elementList,0,comm);
407 const double tol = 1e-7;
410 solverList.
set(
"HYPRE_PCGSetMaxIter", 1000);
411 solverList.
set(
"HYPRE_PCGSetTol", tol);
412 solverList.
set(
"HYPRE_PCGSetTwoNorm", 1);
413 solverList.
set(
"HYPRE_PCGSetPrintLevel", 2);
414 solverList.
set(
"HYPRE_PCGSetLogging", 1);
415 list.
set(
"hypre: Solver",
"PCG");
416 list.
set(
"hypre: SolveOrPrecondition",
"Solver");
417 list.
set(
"hypre: SetPreconditioner",
false);
423 Ifpack_Hypre prec(&accMat);
436 accMat.
Apply(KnownX, B);
457 int myRank = comm.
MyPID();
463 elementList[0] = myRank;
464 elementList[1] = myRank+numProcs;
465 Epetra_Map badMap(2*numProcs,2,elementList,0,comm);
476 col = myRank+numProcs;
483 const double tol = 1e-7;
486 solverList.
set(
"HYPRE_PCGSetMaxIter", 1000);
487 solverList.
set(
"HYPRE_PCGSetTol", tol);
488 solverList.
set(
"HYPRE_PCGSetTwoNorm", 1);
489 solverList.
set(
"HYPRE_PCGSetPrintLevel", 2);
490 solverList.
set(
"HYPRE_PCGSetLogging", 1);
491 list.
set(
"hypre: Solver",
"PCG");
492 list.
set(
"hypre: SolveOrPrecondition",
"Solver");
493 list.
set(
"hypre: SetPreconditioner",
false);
498 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.
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)
RCP< ParameterList > sublist(const RCP< ParameterList > ¶mList, const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
virtual const Epetra_Map & OperatorDomainMap() const =0
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
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