43 #ifndef IFPACK_HYPRE_H
44 #define IFPACK_HYPRE_H
46 #if defined(Ifpack_SHOW_DEPRECATED_WARNINGS)
48 #warning "The Ifpack package is deprecated"
52 #include "Ifpack_ConfigDefs.h"
55 #include "Ifpack_Preconditioner.h"
56 #include "Ifpack_Condest.h"
58 #include "Epetra_CompObject.h"
59 #include "Epetra_MultiVector.h"
60 #include "Epetra_Vector.h"
61 #include "Epetra_CrsGraph.h"
62 #include "Epetra_CrsMatrix.h"
63 #include "Epetra_BlockMap.h"
64 #include "Epetra_Map.h"
65 #include "Epetra_Object.h"
66 #include "Epetra_Comm.h"
67 #include "Epetra_CrsMatrix.h"
68 #include "Epetra_Time.h"
69 #include "Teuchos_RefCountPtr.hpp"
70 #include "Teuchos_ArrayRCP.hpp"
71 #include "Epetra_MpiComm.h"
78 struct hypre_IJMatrix_struct;
79 typedef struct hypre_IJMatrix_struct *HYPRE_IJMatrix;
80 struct hypre_IJVector_struct;
81 typedef struct hypre_IJVector_struct *HYPRE_IJVector;
82 struct hypre_ParCSRMatrix_struct;
83 typedef struct hypre_ParCSRMatrix_struct* HYPRE_ParCSRMatrix;
84 struct hypre_ParVector_struct;
85 typedef struct hypre_ParVector_struct * HYPRE_ParVector;
86 struct hypre_Solver_struct;
87 typedef struct hypre_Solver_struct *HYPRE_Solver;
88 struct hypre_ParVector_struct;
89 typedef struct hypre_ParVector_struct hypre_ParVector;
93 typedef int HYPRE_Int;
95 typedef HYPRE_Int (*HYPRE_PtrToParSolverFcn)(HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector);
120 class FunctionParameter;
140 ~Ifpack_Hypre(){ Destroy();}
157 bool IsComputed()
const{
return(IsComputed_);}
200 int SetParameter(Hypre_Chooser chooser,
int (*pt2Func)(HYPRE_Solver,
int),
int parameter);
211 int SetParameter(Hypre_Chooser chooser,
int (*pt2Func)(HYPRE_Solver,
double),
double parameter);
223 int SetParameter(Hypre_Chooser chooser,
int (*pt2Func)(HYPRE_Solver,
double,
int),
double parameter1,
int parameter2);
235 int SetParameter(Hypre_Chooser chooser,
int (*pt2Func)(HYPRE_Solver,
int,
double),
int parameter1,
double parameter2);
247 int SetParameter(Hypre_Chooser chooser,
int (*pt2Func)(HYPRE_Solver,
int,
int),
int parameter1,
int parameter2);
258 int SetParameter(Hypre_Chooser chooser,
int (*pt2Func)(HYPRE_Solver,
double*),
double* parameter);
269 int SetParameter(Hypre_Chooser chooser,
int (*pt2Func)(HYPRE_Solver,
int*),
int* parameter);
281 int SetParameter(Hypre_Chooser chooser,
int (*pt2Func)(HYPRE_Solver,
int**),
int** parameter);
293 int SetParameter(Hypre_Chooser chooser, Hypre_Solver Solver);
304 int SetParameter(
bool UsePreconditioner){ UsePreconditioner_ = UsePreconditioner;
return 0;}
313 int SetParameter(Hypre_Chooser chooser) { SolveOrPrec_ = chooser;
return 0;}
316 int SetCoordinates(Teuchos::RCP<Epetra_MultiVector> coords);
319 int SetDiscreteGradient(Teuchos::RCP<const Epetra_CrsMatrix> G);
322 int CallFunctions()
const;
334 int SetUseTranspose(
bool UseTranspose_in) {UseTranspose_ = UseTranspose_in;
return(0);};
374 double Condest(
const Ifpack_CondestType CT = Ifpack_Cheap,
375 const int MaxIters = 1550,
376 const double Tol = 1e-9,
380 double Condest()
const{
return(Condest_);}
386 const char*
Label()
const {
return(Label_);}
389 int SetLabel(
const char* Label_in)
391 strcpy(Label_,Label_in);
402 double NormInf()
const {
return(0.0);};
418 const HYPRE_IJMatrix& HypreMatrix()
427 virtual std::ostream&
Print(std::ostream& os)
const;
433 virtual int NumCompute()
const{
return(NumCompute_);}
442 virtual double ComputeTime()
const{
return(ComputeTime_);}
451 virtual double ComputeFlops()
const{
return(ComputeFlops_);}
462 Ifpack_Hypre(
const Ifpack_Hypre& RHS) : Time_(RHS.Comm()){}
465 Ifpack_Hypre& operator=(
const Ifpack_Hypre& ){
return(*
this);}
471 MPI_Comm GetMpiComm()
const
472 {
return (dynamic_cast<const Epetra_MpiComm*>(&A_->Comm()))->GetMpiComm();}
489 int NumGlobalRows()
const {
return(A_->NumGlobalRows());};
492 int NumGlobalCols()
const {
return(A_->NumGlobalCols());};
495 int NumMyRows()
const {
return(A_->NumMyRows());};
498 int NumMyCols()
const {
return(A_->NumMyCols());};
501 int SetSolverType(Hypre_Solver solver);
504 int SetPrecondType(Hypre_Solver precond);
513 int CopyEpetraToHypre();
516 int AddFunToList(Teuchos::RCP<FunctionParameter> NewFun);
519 int Hypre_BoomerAMGCreate(MPI_Comm comm, HYPRE_Solver *solver);
522 int Hypre_ParaSailsCreate(MPI_Comm comm, HYPRE_Solver *solver);
525 int Hypre_EuclidCreate(MPI_Comm comm, HYPRE_Solver *solver);
528 int Hypre_AMSCreate(MPI_Comm comm, HYPRE_Solver *solver);
531 int Hypre_ParCSRHybridCreate(MPI_Comm comm, HYPRE_Solver *solver);
534 int Hypre_ParCSRPCGCreate(MPI_Comm comm, HYPRE_Solver *solver);
537 int Hypre_ParCSRGMRESCreate(MPI_Comm comm, HYPRE_Solver *solver);
540 int Hypre_ParCSRFlexGMRESCreate(MPI_Comm comm, HYPRE_Solver *solver);
543 int Hypre_ParCSRLGMRESCreate(MPI_Comm comm, HYPRE_Solver *solver);
546 int Hypre_ParCSRBiCGSTABCreate(MPI_Comm comm, HYPRE_Solver *solver);
549 Teuchos::RCP<const Epetra_Map> MakeContiguousColumnMap(Teuchos::RCP<const Epetra_RowMatrix> &Matrix)
const;
554 Teuchos::RCP<Epetra_RowMatrix> A_;
556 Teuchos::ParameterList List_;
572 mutable int NumApplyInverse_;
574 double InitializeTime_;
578 mutable double ApplyInverseTime_;
580 double ComputeFlops_;
582 mutable double ApplyInverseFlops_;
587 mutable HYPRE_IJMatrix HypreA_;
589 mutable HYPRE_ParCSRMatrix ParMatrix_;
592 Teuchos::RCP<const Epetra_CrsMatrix> G_;
594 mutable HYPRE_IJMatrix HypreG_;
596 mutable HYPRE_ParCSRMatrix ParMatrixG_;
599 mutable HYPRE_IJVector XHypre_;
601 mutable HYPRE_IJVector YHypre_;
602 mutable HYPRE_ParVector ParX_;
603 mutable HYPRE_ParVector ParY_;
604 mutable Teuchos::RCP<hypre_ParVector> XVec_;
605 mutable Teuchos::RCP<hypre_ParVector> YVec_;
607 Teuchos::RCP<Epetra_MultiVector> Coords_;
608 mutable HYPRE_IJVector xHypre_;
609 mutable HYPRE_IJVector yHypre_;
610 mutable HYPRE_IJVector zHypre_;
611 mutable HYPRE_ParVector xPar_;
612 mutable HYPRE_ParVector yPar_;
613 mutable HYPRE_ParVector zPar_;
616 mutable HYPRE_Solver Solver_;
618 mutable HYPRE_Solver Preconditioner_;
620 int (Ifpack_Hypre::*SolverCreatePtr_)(MPI_Comm, HYPRE_Solver*);
621 int (*SolverDestroyPtr_)(HYPRE_Solver);
622 int (*SolverSetupPtr_)(HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector);
623 int (*SolverSolvePtr_)(HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector);
624 int (*SolverPrecondPtr_)(HYPRE_Solver, HYPRE_PtrToParSolverFcn, HYPRE_PtrToParSolverFcn, HYPRE_Solver);
625 int (Ifpack_Hypre::*PrecondCreatePtr_)(MPI_Comm, HYPRE_Solver*);
626 int (*PrecondDestroyPtr_)(HYPRE_Solver);
627 int (*PrecondSetupPtr_)(HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector);
628 int (*PrecondSolvePtr_)(HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector);
630 bool IsSolverCreated_;
631 bool IsPrecondCreated_;
633 Hypre_Chooser SolveOrPrec_;
635 Teuchos::RCP<const Epetra_Map> GloballyContiguousRowMap_;
636 Teuchos::RCP<const Epetra_Map> GloballyContiguousColMap_;
637 Teuchos::RCP<const Epetra_Map> GloballyContiguousNodeRowMap_;
638 Teuchos::RCP<const Epetra_Map> GloballyContiguousNodeColMap_;
642 Hypre_Solver SolverType_;
644 Hypre_Solver PrecondType_;
646 bool UsePreconditioner_;
648 std::vector<Teuchos::RCP<FunctionParameter> > FunsToCall_;
652 mutable Teuchos::ArrayRCP<double> VectorCache_;
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().
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.
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.
virtual int NumApplyInverse() const =0
Returns the number of calls to ApplyInverse().