43 #ifndef IFPACK2_HYPRE_DECL_HPP
44 #define IFPACK2_HYPRE_DECL_HPP
46 #include "Ifpack2_ConfigDefs.hpp"
47 #if defined(HAVE_IFPACK2_HYPRE) && defined(HAVE_IFPACK2_MPI)
51 #include "Tpetra_MultiVector.hpp"
52 #include "Tpetra_Vector.hpp"
53 #include "Tpetra_CrsGraph.hpp"
54 #include "Tpetra_CrsMatrix.hpp"
55 #include "Tpetra_Map.hpp"
56 #include "Tpetra_CrsMatrix.hpp"
58 #include "Teuchos_RefCountPtr.hpp"
59 #include "Teuchos_ArrayRCP.hpp"
60 #include "Teuchos_Exceptions.hpp"
62 #include "Ifpack2_Hypre_FunctionParameters.hpp"
67 struct hypre_IJMatrix_struct;
68 typedef struct hypre_IJMatrix_struct *HYPRE_IJMatrix;
69 struct hypre_IJVector_struct;
70 typedef struct hypre_IJVector_struct *HYPRE_IJVector;
71 struct hypre_ParCSRMatrix_struct;
72 typedef struct hypre_ParCSRMatrix_struct* HYPRE_ParCSRMatrix;
73 struct hypre_ParVector_struct;
74 typedef struct hypre_ParVector_struct * HYPRE_ParVector;
75 struct hypre_Solver_struct;
76 typedef struct hypre_Solver_struct *HYPRE_Solver;
77 struct hypre_ParVector_struct;
78 typedef struct hypre_ParVector_struct hypre_ParVector;
103 Hypre_Is_Preconditioner
110 NotImplemented(
const std::string& what_arg) : Teuchos::ExceptionBase(what_arg) {}
119 template<
class MatrixType>
122 typename MatrixType::local_ordinal_type,
123 typename MatrixType::global_ordinal_type,
124 typename MatrixType::node_type>,
126 typename MatrixType::local_ordinal_type,
127 typename MatrixType::global_ordinal_type,
128 typename MatrixType::node_type> >
133 typedef typename MatrixType::scalar_type scalar_type;
136 typedef typename MatrixType::local_ordinal_type local_ordinal_type;
139 typedef typename MatrixType::global_ordinal_type global_ordinal_type;
142 typedef typename MatrixType::node_type::device_type device_type;
145 typedef typename MatrixType::node_type node_type;
154 typedef Tpetra::RowMatrix<scalar_type, local_ordinal_type,
155 global_ordinal_type, node_type> row_matrix_type;
157 static_assert (std::is_same<MatrixType, row_matrix_type>::value,
158 "Ifpack2::Hypre: MatrixType must be a Tpetra::RowMatrix "
159 "specialization. Don't use Tpetra::CrsMatrix here.");
163 typedef Tpetra::CrsMatrix<scalar_type, local_ordinal_type,
164 global_ordinal_type, node_type> crs_matrix_type;
167 typedef Tpetra::Map<local_ordinal_type, global_ordinal_type, node_type> map_type;
174 typedef Tpetra::Vector<scalar_type, local_ordinal_type,
175 global_ordinal_type, node_type> vector_type;
178 typedef Tpetra::MultiVector<scalar_type, local_ordinal_type,
179 global_ordinal_type, node_type> multivector_type;
182 explicit Hypre(
const Teuchos::RCP<const row_matrix_type>& A) {
throw NotImplemented(
"Ifpack2::Hypre only works when instantiated on <HYPRE_REAL, LocalOrdinal, HYPRE_Int, Node>"); }
190 bool isInitialized()
const{
return false;}
198 bool isComputed()
const{
return false;}
261 apply (
const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
262 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
274 bool hasTransposeApply()
const {
return false; }
297 applyMat (
const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
298 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
306 int getNumInitialize()
const {
return 0; }
309 int getNumCompute()
const {
return 0; }
312 int getNumApply()
const {
return 0; }
315 double getInitializeTime()
const {
return 0.0; }
318 double getComputeTime()
const {
return 0.0; }
321 double getApplyTime()
const {
return 0.0; }
326 template<
class LocalOrdinal,
class Node>
327 class Hypre<Tpetra::RowMatrix<HYPRE_Real, LocalOrdinal, HYPRE_Int, Node> >:
342 typedef Tpetra::RowMatrix<HYPRE_Real, LocalOrdinal, HYPRE_Int, Node> MatrixType;
345 typedef typename MatrixType::scalar_type scalar_type;
348 typedef typename MatrixType::local_ordinal_type local_ordinal_type;
351 typedef typename MatrixType::global_ordinal_type global_ordinal_type;
354 typedef typename MatrixType::node_type::device_type device_type;
357 typedef typename MatrixType::node_type node_type;
366 typedef Tpetra::RowMatrix<scalar_type, local_ordinal_type,
367 global_ordinal_type, node_type> row_matrix_type;
369 static_assert (std::is_same<MatrixType, row_matrix_type>::value,
370 "Ifpack2::Hypre: MatrixType must be a Tpetra::RowMatrix "
371 "specialization. Don't use Tpetra::CrsMatrix here.");
375 typedef Tpetra::CrsMatrix<scalar_type, local_ordinal_type,
376 global_ordinal_type, node_type> crs_matrix_type;
379 typedef Tpetra::Map<local_ordinal_type, global_ordinal_type, node_type> map_type;
386 typedef Tpetra::Vector<scalar_type, local_ordinal_type,
387 global_ordinal_type, node_type> vector_type;
390 typedef Tpetra::MultiVector<scalar_type, local_ordinal_type,
391 global_ordinal_type, node_type> multivector_type;
397 typedef global_ordinal_type (*HYPRE_PtrToParSolverFcn)(HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector);
435 bool isInitialized()
const{
return(IsInitialized_);}
443 bool isComputed()
const{
return(IsComputed_);}
485 int SetParameter(Hypre_Chooser chooser, HYPRE_Int (*pt2Func)(HYPRE_Solver, HYPRE_Int), HYPRE_Int parameter);
496 int SetParameter(Hypre_Chooser chooser, HYPRE_Int (*pt2Func)(HYPRE_Solver, HYPRE_Real), HYPRE_Real parameter);
508 int SetParameter(Hypre_Chooser chooser, HYPRE_Int (*pt2Func)(HYPRE_Solver, HYPRE_Real, HYPRE_Int), HYPRE_Real parameter1, HYPRE_Int parameter2);
520 int SetParameter(Hypre_Chooser chooser, HYPRE_Int (*pt2Func)(HYPRE_Solver, HYPRE_Int, HYPRE_Real), HYPRE_Int parameter1, HYPRE_Real parameter2);
532 int SetParameter(Hypre_Chooser chooser, HYPRE_Int (*pt2Func)(HYPRE_Solver, HYPRE_Int, HYPRE_Int), HYPRE_Int parameter1, HYPRE_Int parameter2);
543 int SetParameter(Hypre_Chooser chooser, HYPRE_Int (*pt2Func)(HYPRE_Solver, HYPRE_Real*), HYPRE_Real* parameter);
554 int SetParameter(Hypre_Chooser chooser, HYPRE_Int (*pt2Func)(HYPRE_Solver, HYPRE_Int*), HYPRE_Int* parameter);
566 int SetParameter(Hypre_Chooser chooser, HYPRE_Int (*pt2Func)(HYPRE_Solver, HYPRE_Int**), HYPRE_Int** parameter);
578 int SetParameter(Hypre_Chooser chooser, Hypre_Solver Solver);
589 int SetParameter(
bool UsePreconditioner){ UsePreconditioner_ = UsePreconditioner;
return 0;}
598 int SetParameter(Hypre_Chooser chooser) { SolveOrPrec_ = chooser;
return 0;}
607 int CallFunctions()
const;
668 apply (
const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
669 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
681 bool hasTransposeApply()
const;
704 applyMat (
const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
705 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
723 getCrsMatrix()
const;
726 int getNumInitialize()
const;
729 int getNumCompute()
const;
732 int getNumApply()
const;
735 double getInitializeTime()
const;
738 double getComputeTime()
const;
741 double getApplyTime()
const;
748 std::string description()
const;
762 typedef Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type> MV;
765 Hypre(
const Hypre<MatrixType>&);
768 Hypre<MatrixType>& operator= (
const Hypre<MatrixType>&);
771 int SetSolverType(Hypre_Solver solver);
774 int SetPrecondType(Hypre_Solver precond);
783 int CopyTpetraToHypre();
789 HYPRE_Int Hypre_BoomerAMGCreate(MPI_Comm comm, HYPRE_Solver *solver);
792 HYPRE_Int Hypre_ParaSailsCreate(MPI_Comm comm, HYPRE_Solver *solver);
795 HYPRE_Int Hypre_EuclidCreate(MPI_Comm comm, HYPRE_Solver *solver);
798 HYPRE_Int Hypre_AMSCreate(MPI_Comm comm, HYPRE_Solver *solver);
801 HYPRE_Int Hypre_ParCSRHybridCreate(MPI_Comm comm, HYPRE_Solver *solver);
804 HYPRE_Int Hypre_ParCSRPCGCreate(MPI_Comm comm, HYPRE_Solver *solver);
807 HYPRE_Int Hypre_ParCSRGMRESCreate(MPI_Comm comm, HYPRE_Solver *solver);
810 HYPRE_Int Hypre_ParCSRFlexGMRESCreate(MPI_Comm comm, HYPRE_Solver *solver);
813 HYPRE_Int Hypre_ParCSRLGMRESCreate(MPI_Comm comm, HYPRE_Solver *solver);
816 HYPRE_Int Hypre_ParCSRBiCGSTABCreate(MPI_Comm comm, HYPRE_Solver *solver);
844 mutable int NumApply_;
846 double InitializeTime_;
853 mutable double ApplyTime_;
855 double ComputeFlops_;
860 mutable double ApplyFlops_;
864 mutable HYPRE_IJMatrix HypreA_;
866 mutable HYPRE_ParCSRMatrix ParMatrix_;
871 mutable HYPRE_IJMatrix HypreG_;
873 mutable HYPRE_ParCSRMatrix ParMatrixG_;
876 mutable HYPRE_IJVector XHypre_;
878 mutable HYPRE_IJVector YHypre_;
879 mutable HYPRE_ParVector ParX_;
880 mutable HYPRE_ParVector ParY_;
885 mutable HYPRE_IJVector xHypre_;
886 mutable HYPRE_IJVector yHypre_;
887 mutable HYPRE_IJVector zHypre_;
888 mutable HYPRE_ParVector xPar_;
889 mutable HYPRE_ParVector yPar_;
890 mutable HYPRE_ParVector zPar_;
893 mutable HYPRE_Solver Solver_;
895 mutable HYPRE_Solver Preconditioner_;
897 HYPRE_Int (Hypre::*SolverCreatePtr_)(MPI_Comm, HYPRE_Solver*);
898 HYPRE_Int (*SolverDestroyPtr_)(HYPRE_Solver);
899 HYPRE_Int (*SolverSetupPtr_)(HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector);
900 HYPRE_Int (*SolverSolvePtr_)(HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector);
901 HYPRE_Int (*SolverPrecondPtr_)(HYPRE_Solver, HYPRE_PtrToParSolverFcn, HYPRE_PtrToParSolverFcn, HYPRE_Solver);
902 HYPRE_Int (Hypre::*PrecondCreatePtr_)(MPI_Comm, HYPRE_Solver*);
903 HYPRE_Int (*PrecondDestroyPtr_)(HYPRE_Solver);
904 HYPRE_Int (*PrecondSetupPtr_)(HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector);
905 HYPRE_Int (*PrecondSolvePtr_)(HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector);
907 bool IsSolverCreated_;
908 bool IsPrecondCreated_;
910 Hypre_Chooser SolveOrPrec_;
919 Hypre_Solver SolverType_;
921 Hypre_Solver PrecondType_;
923 bool UsePreconditioner_;
925 std::vector<Teuchos::RCP<FunctionParameter> > FunsToCall_;
936 #endif // HAVE_IFPACK2_HYPRE && HAVE_IFPACK2_MPI
Mix-in interface for preconditioners that can change their matrix after construction.
Definition: Ifpack2_Details_CanChangeMatrix.hpp:93
Interface for all Ifpack2 preconditioners.
Definition: Ifpack2_Preconditioner.hpp:107
Declaration of interface for preconditioners that can change their matrix after construction.
static const EVerbosityLevel verbLevel_default
Uses AztecOO's GMRES.
Definition: Ifpack2_CondestType.hpp:53