43 #ifndef IFPACK_HYPRE_H
44 #define IFPACK_HYPRE_H
52 #include "Epetra_CompObject.h"
53 #include "Epetra_MultiVector.h"
54 #include "Epetra_Vector.h"
55 #include "Epetra_CrsGraph.h"
56 #include "Epetra_CrsMatrix.h"
57 #include "Epetra_BlockMap.h"
58 #include "Epetra_Map.h"
59 #include "Epetra_Object.h"
60 #include "Epetra_Comm.h"
61 #include "Epetra_CrsMatrix.h"
62 #include "Epetra_Time.h"
63 #include "Teuchos_RefCountPtr.hpp"
64 #include "Teuchos_ArrayRCP.hpp"
65 #include "Epetra_MpiComm.h"
72 struct hypre_IJMatrix_struct;
73 typedef struct hypre_IJMatrix_struct *HYPRE_IJMatrix;
74 struct hypre_IJVector_struct;
75 typedef struct hypre_IJVector_struct *HYPRE_IJVector;
76 struct hypre_ParCSRMatrix_struct;
77 typedef struct hypre_ParCSRMatrix_struct* HYPRE_ParCSRMatrix;
78 struct hypre_ParVector_struct;
79 typedef struct hypre_ParVector_struct * HYPRE_ParVector;
80 struct hypre_Solver_struct;
81 typedef struct hypre_Solver_struct *HYPRE_Solver;
82 struct hypre_ParVector_struct;
83 typedef struct hypre_ParVector_struct hypre_ParVector;
87 typedef int HYPRE_Int;
89 typedef HYPRE_Int (*HYPRE_PtrToParSolverFcn)(HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector);
114 class FunctionParameter;
134 ~Ifpack_Hypre(){ Destroy();}
151 bool IsComputed()
const{
return(IsComputed_);}
194 int SetParameter(
Hypre_Chooser chooser,
int (*pt2Func)(HYPRE_Solver,
int),
int parameter);
205 int SetParameter(
Hypre_Chooser chooser,
int (*pt2Func)(HYPRE_Solver,
double),
double parameter);
217 int SetParameter(
Hypre_Chooser chooser,
int (*pt2Func)(HYPRE_Solver,
double,
int),
double parameter1,
int parameter2);
229 int SetParameter(
Hypre_Chooser chooser,
int (*pt2Func)(HYPRE_Solver,
int,
double),
int parameter1,
double parameter2);
241 int SetParameter(
Hypre_Chooser chooser,
int (*pt2Func)(HYPRE_Solver,
int,
int),
int parameter1,
int parameter2);
252 int SetParameter(
Hypre_Chooser chooser,
int (*pt2Func)(HYPRE_Solver,
double*),
double* parameter);
263 int SetParameter(
Hypre_Chooser chooser,
int (*pt2Func)(HYPRE_Solver,
int*),
int* parameter);
275 int SetParameter(
Hypre_Chooser chooser,
int (*pt2Func)(HYPRE_Solver,
int**),
int** parameter);
298 int SetParameter(
bool UsePreconditioner){ UsePreconditioner_ = UsePreconditioner;
return 0;}
307 int SetParameter(
Hypre_Chooser chooser) { SolveOrPrec_ = chooser;
return 0;}
316 int CallFunctions()
const;
328 int SetUseTranspose(
bool UseTranspose_in) {UseTranspose_ = UseTranspose_in;
return(0);};
369 const int MaxIters = 1550,
370 const double Tol = 1e-9,
374 double Condest()
const{
return(Condest_);}
380 const char*
Label()
const {
return(Label_);}
383 int SetLabel(
const char* Label_in)
385 strcpy(Label_,Label_in);
396 double NormInf()
const {
return(0.0);};
412 const HYPRE_IJMatrix& HypreMatrix()
421 virtual std::ostream&
Print(std::ostream& os)
const;
427 virtual int NumCompute()
const{
return(NumCompute_);}
436 virtual double ComputeTime()
const{
return(ComputeTime_);}
445 virtual double ComputeFlops()
const{
return(ComputeFlops_);}
456 Ifpack_Hypre(
const Ifpack_Hypre&
RHS) : Time_(RHS.Comm()){}
459 Ifpack_Hypre& operator=(
const Ifpack_Hypre& ){
return(*
this);}
465 MPI_Comm GetMpiComm()
const
466 {
return (dynamic_cast<const Epetra_MpiComm*>(&A_->Comm()))->GetMpiComm();}
483 int NumGlobalRows()
const {
return(A_->NumGlobalRows());};
486 int NumGlobalCols()
const {
return(A_->NumGlobalCols());};
489 int NumMyRows()
const {
return(A_->NumMyRows());};
492 int NumMyCols()
const {
return(A_->NumMyCols());};
507 int CopyEpetraToHypre();
513 int Hypre_BoomerAMGCreate(MPI_Comm comm, HYPRE_Solver *solver);
516 int Hypre_ParaSailsCreate(MPI_Comm comm, HYPRE_Solver *solver);
519 int Hypre_EuclidCreate(MPI_Comm comm, HYPRE_Solver *solver);
522 int Hypre_AMSCreate(MPI_Comm comm, HYPRE_Solver *solver);
525 int Hypre_ParCSRHybridCreate(MPI_Comm comm, HYPRE_Solver *solver);
528 int Hypre_ParCSRPCGCreate(MPI_Comm comm, HYPRE_Solver *solver);
531 int Hypre_ParCSRGMRESCreate(MPI_Comm comm, HYPRE_Solver *solver);
534 int Hypre_ParCSRFlexGMRESCreate(MPI_Comm comm, HYPRE_Solver *solver);
537 int Hypre_ParCSRLGMRESCreate(MPI_Comm comm, HYPRE_Solver *solver);
540 int Hypre_ParCSRBiCGSTABCreate(MPI_Comm comm, HYPRE_Solver *solver);
566 mutable int NumApplyInverse_;
568 double InitializeTime_;
572 mutable double ApplyInverseTime_;
574 double ComputeFlops_;
576 mutable double ApplyInverseFlops_;
581 mutable HYPRE_IJMatrix HypreA_;
583 mutable HYPRE_ParCSRMatrix ParMatrix_;
588 mutable HYPRE_IJMatrix HypreG_;
590 mutable HYPRE_ParCSRMatrix ParMatrixG_;
593 mutable HYPRE_IJVector XHypre_;
595 mutable HYPRE_IJVector YHypre_;
596 mutable HYPRE_ParVector ParX_;
597 mutable HYPRE_ParVector ParY_;
602 mutable HYPRE_IJVector xHypre_;
603 mutable HYPRE_IJVector yHypre_;
604 mutable HYPRE_IJVector zHypre_;
605 mutable HYPRE_ParVector xPar_;
606 mutable HYPRE_ParVector yPar_;
607 mutable HYPRE_ParVector zPar_;
610 mutable HYPRE_Solver Solver_;
612 mutable HYPRE_Solver Preconditioner_;
614 int (Ifpack_Hypre::*SolverCreatePtr_)(MPI_Comm, HYPRE_Solver*);
615 int (*SolverDestroyPtr_)(HYPRE_Solver);
616 int (*SolverSetupPtr_)(HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector);
617 int (*SolverSolvePtr_)(HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector);
618 int (*SolverPrecondPtr_)(HYPRE_Solver, HYPRE_PtrToParSolverFcn, HYPRE_PtrToParSolverFcn, HYPRE_Solver);
619 int (Ifpack_Hypre::*PrecondCreatePtr_)(MPI_Comm, HYPRE_Solver*);
620 int (*PrecondDestroyPtr_)(HYPRE_Solver);
621 int (*PrecondSetupPtr_)(HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector);
622 int (*PrecondSolvePtr_)(HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector);
624 bool IsSolverCreated_;
625 bool IsPrecondCreated_;
640 bool UsePreconditioner_;
642 std::vector<Teuchos::RCP<FunctionParameter> > FunsToCall_;
virtual int NumInitialize() const =0
Returns the number of calls to Initialize().
virtual int SetUseTranspose(bool UseTranspose)=0
virtual double ComputeTime() const =0
Returns the time spent in Compute().
virtual double ComputeFlops() const =0
Returns the number of flops in the computation phase.
virtual double ApplyInverseTime() const =0
Returns the time spent in ApplyInverse().
virtual double ApplyInverseFlops() const =0
Returns the number of flops in the application of the preconditioner.
virtual const Epetra_RowMatrix & Matrix() const =0
Returns a pointer to the matrix to be preconditioned.
virtual bool IsInitialized() const =0
Returns true if the preconditioner has been successfully initialized, false otherwise.
virtual std::ostream & Print(std::ostream &os) const =0
Prints basic information on iostream. This function is used by operator<<.
virtual const Epetra_Map & OperatorDomainMap() const =0
virtual const char * Label() const =0
virtual int Initialize()=0
Computes all it is necessary to initialize the preconditioner.
virtual double InitializeTime() const =0
Returns the time spent in Initialize().
Ifpack_CondestType
Ifpack_CondestType: enum to define the type of condition number estimate.
virtual int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const =0
virtual const Epetra_Map & OperatorRangeMap() const =0
virtual const Epetra_Comm & Comm() const =0
virtual int SetParameters(Teuchos::ParameterList &List)=0
Sets all parameters for the preconditioner.
virtual double Condest() const =0
Returns the computed condition number estimate, or -1.0 if not computed.
virtual bool UseTranspose() const =0
Ifpack_ScalingType enumerable type.
Ifpack_Preconditioner: basic class for preconditioning in Ifpack.
virtual int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const =0
Applies the preconditioner to vector X, returns the result in Y.
virtual double InitializeFlops() const =0
Returns the number of flops in the initialization phase.
void BiCGSTAB(Epetra_CrsMatrix &A, Epetra_Vector &x, Epetra_Vector &b, Ifpack_CrsRiluk *M, int Maxiter, double Tolerance, double *residual, bool verbose)
virtual bool HasNormInf() const =0
virtual int NumCompute() const =0
Returns the number of calls to Compute().
virtual double NormInf() const =0
virtual bool IsComputed() const =0
Returns true if the preconditioner has been successfully computed, false otherwise.
virtual int Compute()=0
Computes all it is necessary to apply the preconditioner.
int Solve(int, TYPE *, TYPE *, TYPE *)
virtual int NumApplyInverse() const =0
Returns the number of calls to ApplyInverse().