10 #ifndef IFPACK2_HYPRE_DECL_HPP
11 #define IFPACK2_HYPRE_DECL_HPP
13 #include "Ifpack2_ConfigDefs.hpp"
14 #if defined(HAVE_IFPACK2_HYPRE) && defined(HAVE_IFPACK2_MPI)
18 #include "Tpetra_MultiVector.hpp"
19 #include "Tpetra_Vector.hpp"
20 #include "Tpetra_CrsGraph.hpp"
21 #include "Tpetra_CrsMatrix.hpp"
22 #include "Tpetra_Map.hpp"
23 #include "Tpetra_CrsMatrix.hpp"
25 #include "Teuchos_RefCountPtr.hpp"
26 #include "Teuchos_ArrayRCP.hpp"
27 #include "Teuchos_Exceptions.hpp"
29 #include "Ifpack2_Hypre_FunctionParameters.hpp"
34 struct hypre_IJMatrix_struct;
35 typedef struct hypre_IJMatrix_struct* HYPRE_IJMatrix;
36 struct hypre_IJVector_struct;
37 typedef struct hypre_IJVector_struct* HYPRE_IJVector;
38 struct hypre_ParCSRMatrix_struct;
39 typedef struct hypre_ParCSRMatrix_struct* HYPRE_ParCSRMatrix;
40 struct hypre_ParVector_struct;
41 typedef struct hypre_ParVector_struct* HYPRE_ParVector;
42 struct hypre_Solver_struct;
43 typedef struct hypre_Solver_struct* HYPRE_Solver;
44 struct hypre_ParVector_struct;
45 typedef struct hypre_ParVector_struct hypre_ParVector;
69 Hypre_Is_Preconditioner
75 NotImplemented(
const std::string& what_arg)
76 : Teuchos::ExceptionBase(what_arg) {}
85 template <
class MatrixType>
87 typename MatrixType::local_ordinal_type,
88 typename MatrixType::global_ordinal_type,
89 typename MatrixType::node_type>,
91 typename MatrixType::local_ordinal_type,
92 typename MatrixType::global_ordinal_type,
93 typename MatrixType::node_type> > {
96 typedef typename MatrixType::scalar_type scalar_type;
99 typedef typename MatrixType::local_ordinal_type local_ordinal_type;
102 typedef typename MatrixType::global_ordinal_type global_ordinal_type;
105 typedef typename MatrixType::node_type::device_type device_type;
108 typedef typename MatrixType::node_type node_type;
117 typedef Tpetra::RowMatrix<scalar_type, local_ordinal_type,
118 global_ordinal_type, node_type>
121 static_assert(std::is_same<MatrixType, row_matrix_type>::value,
122 "Ifpack2::Hypre: MatrixType must be a Tpetra::RowMatrix "
123 "specialization. Don't use Tpetra::CrsMatrix here.");
126 typedef Tpetra::CrsMatrix<scalar_type, local_ordinal_type,
127 global_ordinal_type, node_type>
131 typedef Tpetra::Map<local_ordinal_type, global_ordinal_type, node_type> map_type;
138 typedef Tpetra::Vector<scalar_type, local_ordinal_type,
139 global_ordinal_type, node_type>
143 typedef Tpetra::MultiVector<scalar_type, local_ordinal_type,
144 global_ordinal_type, node_type>
147 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>"); }
155 bool isInitialized()
const {
return false; }
163 bool isComputed()
const {
return false; }
225 apply(
const Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& X,
226 Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& Y,
238 bool hasTransposeApply()
const {
return false; }
261 applyMat(
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,
270 int getNumInitialize()
const {
return 0; }
273 int getNumCompute()
const {
return 0; }
276 int getNumApply()
const {
return 0; }
279 double getInitializeTime()
const {
return 0.0; }
282 double getComputeTime()
const {
return 0.0; }
285 double getApplyTime()
const {
return 0.0; }
288 template <
class LocalOrdinal,
class Node>
289 class Hypre<Tpetra::RowMatrix<HYPRE_Real, LocalOrdinal, HYPRE_Int, Node> > :
virtual public Ifpack2::Preconditioner<HYPRE_Real,
302 typedef Tpetra::RowMatrix<HYPRE_Real, LocalOrdinal, HYPRE_Int, Node> MatrixType;
305 typedef typename MatrixType::scalar_type scalar_type;
308 typedef typename MatrixType::local_ordinal_type local_ordinal_type;
311 typedef typename MatrixType::global_ordinal_type global_ordinal_type;
314 typedef typename MatrixType::node_type::device_type device_type;
317 typedef typename MatrixType::node_type node_type;
326 typedef Tpetra::RowMatrix<scalar_type, local_ordinal_type,
327 global_ordinal_type, node_type>
330 static_assert(std::is_same<MatrixType, row_matrix_type>::value,
331 "Ifpack2::Hypre: MatrixType must be a Tpetra::RowMatrix "
332 "specialization. Don't use Tpetra::CrsMatrix here.");
335 typedef Tpetra::CrsMatrix<scalar_type, local_ordinal_type,
336 global_ordinal_type, node_type>
340 typedef Tpetra::Map<local_ordinal_type, global_ordinal_type, node_type> map_type;
347 typedef Tpetra::Vector<scalar_type, local_ordinal_type,
348 global_ordinal_type, node_type>
352 typedef Tpetra::MultiVector<scalar_type, local_ordinal_type,
353 global_ordinal_type, node_type>
360 typedef global_ordinal_type (*HYPRE_PtrToParSolverFcn)(HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector);
398 bool isInitialized()
const {
return (IsInitialized_); }
406 bool isComputed()
const {
return (IsComputed_); }
448 int SetParameter(Hypre_Chooser chooser, HYPRE_Int (*pt2Func)(HYPRE_Solver, HYPRE_Int), HYPRE_Int parameter);
459 int SetParameter(Hypre_Chooser chooser, HYPRE_Int (*pt2Func)(HYPRE_Solver, HYPRE_Real), HYPRE_Real parameter);
471 int SetParameter(Hypre_Chooser chooser, HYPRE_Int (*pt2Func)(HYPRE_Solver, HYPRE_Real, HYPRE_Int), HYPRE_Real parameter1, HYPRE_Int parameter2);
483 int SetParameter(Hypre_Chooser chooser, HYPRE_Int (*pt2Func)(HYPRE_Solver, HYPRE_Int, HYPRE_Real), HYPRE_Int parameter1, HYPRE_Real parameter2);
495 int SetParameter(Hypre_Chooser chooser, HYPRE_Int (*pt2Func)(HYPRE_Solver, HYPRE_Int, HYPRE_Int), HYPRE_Int parameter1, HYPRE_Int parameter2);
506 int SetParameter(Hypre_Chooser chooser, HYPRE_Int (*pt2Func)(HYPRE_Solver, HYPRE_Real*), HYPRE_Real* parameter);
517 int SetParameter(Hypre_Chooser chooser, HYPRE_Int (*pt2Func)(HYPRE_Solver, HYPRE_Int*), HYPRE_Int* parameter);
529 int SetParameter(Hypre_Chooser chooser, HYPRE_Int (*pt2Func)(HYPRE_Solver, HYPRE_Int**), HYPRE_Int** parameter);
541 int SetParameter(Hypre_Chooser chooser, Hypre_Solver Solver);
552 int SetParameter(
bool UsePreconditioner) {
553 UsePreconditioner_ = UsePreconditioner;
564 int SetParameter(Hypre_Chooser chooser) {
565 SolveOrPrec_ = chooser;
576 int CallFunctions()
const;
637 apply(
const Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& X,
638 Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& Y,
650 bool hasTransposeApply()
const;
673 applyMat(
const Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& X,
674 Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& Y,
692 getCrsMatrix()
const;
695 int getNumInitialize()
const;
698 int getNumCompute()
const;
701 int getNumApply()
const;
704 double getInitializeTime()
const;
707 double getComputeTime()
const;
710 double getApplyTime()
const;
717 std::string description()
const;
731 typedef Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type> MV;
734 Hypre(
const Hypre<MatrixType>&);
737 Hypre<MatrixType>& operator=(
const Hypre<MatrixType>&);
740 int SetSolverType(Hypre_Solver solver);
743 int SetPrecondType(Hypre_Solver precond);
752 int CopyTpetraToHypre();
758 HYPRE_Int Hypre_BoomerAMGCreate(MPI_Comm comm, HYPRE_Solver* solver);
761 HYPRE_Int Hypre_ParaSailsCreate(MPI_Comm comm, HYPRE_Solver* solver);
764 HYPRE_Int Hypre_EuclidCreate(MPI_Comm comm, HYPRE_Solver* solver);
767 HYPRE_Int Hypre_AMSCreate(MPI_Comm comm, HYPRE_Solver* solver);
770 HYPRE_Int Hypre_ParCSRHybridCreate(MPI_Comm comm, HYPRE_Solver* solver);
773 HYPRE_Int Hypre_ParCSRPCGCreate(MPI_Comm comm, HYPRE_Solver* solver);
776 HYPRE_Int Hypre_ParCSRGMRESCreate(MPI_Comm comm, HYPRE_Solver* solver);
779 HYPRE_Int Hypre_ParCSRFlexGMRESCreate(MPI_Comm comm, HYPRE_Solver* solver);
782 HYPRE_Int Hypre_ParCSRLGMRESCreate(MPI_Comm comm, HYPRE_Solver* solver);
785 HYPRE_Int Hypre_ParCSRBiCGSTABCreate(MPI_Comm comm, HYPRE_Solver* solver);
813 mutable int NumApply_;
815 double InitializeTime_;
822 mutable double ApplyTime_;
824 double ComputeFlops_;
829 mutable double ApplyFlops_;
832 mutable HYPRE_IJMatrix HypreA_;
834 mutable HYPRE_ParCSRMatrix ParMatrix_;
839 mutable HYPRE_IJMatrix HypreG_;
841 mutable HYPRE_ParCSRMatrix ParMatrixG_;
844 mutable HYPRE_IJVector XHypre_;
846 mutable HYPRE_IJVector YHypre_;
847 mutable HYPRE_ParVector ParX_;
848 mutable HYPRE_ParVector ParY_;
853 mutable HYPRE_IJVector xHypre_;
854 mutable HYPRE_IJVector yHypre_;
855 mutable HYPRE_IJVector zHypre_;
856 mutable HYPRE_ParVector xPar_;
857 mutable HYPRE_ParVector yPar_;
858 mutable HYPRE_ParVector zPar_;
861 mutable HYPRE_Solver Solver_;
863 mutable HYPRE_Solver Preconditioner_;
865 HYPRE_Int (Hypre::*SolverCreatePtr_)(MPI_Comm, HYPRE_Solver*);
866 HYPRE_Int (*SolverDestroyPtr_)(HYPRE_Solver);
867 HYPRE_Int (*SolverSetupPtr_)(HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector);
868 HYPRE_Int (*SolverSolvePtr_)(HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector);
869 HYPRE_Int (*SolverPrecondPtr_)(HYPRE_Solver, HYPRE_PtrToParSolverFcn, HYPRE_PtrToParSolverFcn, HYPRE_Solver);
870 HYPRE_Int (Hypre::*PrecondCreatePtr_)(MPI_Comm, HYPRE_Solver*);
871 HYPRE_Int (*PrecondDestroyPtr_)(HYPRE_Solver);
872 HYPRE_Int (*PrecondSetupPtr_)(HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector);
873 HYPRE_Int (*PrecondSolvePtr_)(HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector);
875 bool IsSolverCreated_;
876 bool IsPrecondCreated_;
878 Hypre_Chooser SolveOrPrec_;
887 Hypre_Solver SolverType_;
889 Hypre_Solver PrecondType_;
891 bool UsePreconditioner_;
893 std::vector<Teuchos::RCP<FunctionParameter> > FunsToCall_;
902 #endif // HAVE_IFPACK2_HYPRE && HAVE_IFPACK2_MPI
Mix-in interface for preconditioners that can change their matrix after construction.
Definition: Ifpack2_Details_CanChangeMatrix.hpp:60
Interface for all Ifpack2 preconditioners.
Definition: Ifpack2_Preconditioner.hpp:74
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:20