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"
34struct hypre_IJMatrix_struct;
35typedef struct hypre_IJMatrix_struct *HYPRE_IJMatrix;
36struct hypre_IJVector_struct;
37typedef struct hypre_IJVector_struct *HYPRE_IJVector;
38struct hypre_ParCSRMatrix_struct;
39typedef struct hypre_ParCSRMatrix_struct* HYPRE_ParCSRMatrix;
40struct hypre_ParVector_struct;
41typedef struct hypre_ParVector_struct * HYPRE_ParVector;
42struct hypre_Solver_struct;
43typedef struct hypre_Solver_struct *HYPRE_Solver;
44struct hypre_ParVector_struct;
45typedef struct hypre_ParVector_struct hypre_ParVector;
70 Hypre_Is_Preconditioner
75class NotImplemented :
public Teuchos::ExceptionBase {
77 NotImplemented(
const std::string& what_arg) : Teuchos::ExceptionBase(what_arg) {}
86template<
class MatrixType>
88 virtual public Ifpack2::Preconditioner<typename MatrixType::scalar_type,
89 typename MatrixType::local_ordinal_type,
90 typename MatrixType::global_ordinal_type,
91 typename MatrixType::node_type>,
92 virtual public Ifpack2::Details::CanChangeMatrix<Tpetra::RowMatrix<typename MatrixType::scalar_type,
93 typename MatrixType::local_ordinal_type,
94 typename MatrixType::global_ordinal_type,
95 typename MatrixType::node_type> >
100 typedef typename MatrixType::scalar_type scalar_type;
103 typedef typename MatrixType::local_ordinal_type local_ordinal_type;
106 typedef typename MatrixType::global_ordinal_type global_ordinal_type;
109 typedef typename MatrixType::node_type::device_type device_type;
112 typedef typename MatrixType::node_type node_type;
115 typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitude_type;
121 typedef Tpetra::RowMatrix<scalar_type, local_ordinal_type,
122 global_ordinal_type, node_type> row_matrix_type;
124 static_assert (std::is_same<MatrixType, row_matrix_type>::value,
125 "Ifpack2::Hypre: MatrixType must be a Tpetra::RowMatrix "
126 "specialization. Don't use Tpetra::CrsMatrix here.");
130 typedef Tpetra::CrsMatrix<scalar_type, local_ordinal_type,
131 global_ordinal_type, node_type> crs_matrix_type;
134 typedef Tpetra::Map<local_ordinal_type, global_ordinal_type, node_type> map_type;
141 typedef Tpetra::Vector<scalar_type, local_ordinal_type,
142 global_ordinal_type, node_type> vector_type;
145 typedef Tpetra::MultiVector<scalar_type, local_ordinal_type,
146 global_ordinal_type, node_type> multivector_type;
149 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>"); }
157 bool isInitialized()
const{
return false;}
165 bool isComputed()
const{
return false;}
167 void setParameters(
const Teuchos::ParameterList& parameterlist) {}
196 setMatrix (
const Teuchos::RCP<const row_matrix_type>& A) {}
228 apply (
const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
229 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
230 Teuchos::ETransp mode = Teuchos::NO_TRANS,
231 scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(),
232 scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero())
const {}
235 Teuchos::RCP<const map_type> getDomainMap()
const {
return Teuchos::null; }
238 Teuchos::RCP<const map_type> getRangeMap()
const {
return Teuchos::null; }
241 bool hasTransposeApply()
const {
return false; }
264 applyMat (
const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
265 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
266 Teuchos::ETransp mode = Teuchos::NO_TRANS)
const {}
268 Teuchos::RCP<const row_matrix_type> getMatrix()
const {
return Teuchos::null; }
273 int getNumInitialize()
const {
return 0; }
276 int getNumCompute()
const {
return 0; }
279 int getNumApply()
const {
return 0; }
282 double getInitializeTime()
const {
return 0.0; }
285 double getComputeTime()
const {
return 0.0; }
288 double getApplyTime()
const {
return 0.0; }
293template<
class LocalOrdinal,
class Node>
294class Hypre<Tpetra::RowMatrix<HYPRE_Real, LocalOrdinal, HYPRE_Int, Node> >:
295 virtual public Ifpack2::Preconditioner<HYPRE_Real,
299 virtual public Ifpack2::Details::CanChangeMatrix<Tpetra::RowMatrix<HYPRE_Real,
309 typedef Tpetra::RowMatrix<HYPRE_Real, LocalOrdinal, HYPRE_Int, Node> MatrixType;
312 typedef typename MatrixType::scalar_type scalar_type;
315 typedef typename MatrixType::local_ordinal_type local_ordinal_type;
318 typedef typename MatrixType::global_ordinal_type global_ordinal_type;
321 typedef typename MatrixType::node_type::device_type device_type;
324 typedef typename MatrixType::node_type node_type;
327 typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitude_type;
333 typedef Tpetra::RowMatrix<scalar_type, local_ordinal_type,
334 global_ordinal_type, node_type> row_matrix_type;
336 static_assert (std::is_same<MatrixType, row_matrix_type>::value,
337 "Ifpack2::Hypre: MatrixType must be a Tpetra::RowMatrix "
338 "specialization. Don't use Tpetra::CrsMatrix here.");
342 typedef Tpetra::CrsMatrix<scalar_type, local_ordinal_type,
343 global_ordinal_type, node_type> crs_matrix_type;
346 typedef Tpetra::Map<local_ordinal_type, global_ordinal_type, node_type> map_type;
353 typedef Tpetra::Vector<scalar_type, local_ordinal_type,
354 global_ordinal_type, node_type> vector_type;
357 typedef Tpetra::MultiVector<scalar_type, local_ordinal_type,
358 global_ordinal_type, node_type> multivector_type;
364 typedef global_ordinal_type (*HYPRE_PtrToParSolverFcn)(HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector);
391 explicit Hypre(
const Teuchos::RCP<const row_matrix_type>& A);
402 bool isInitialized()
const{
return(IsInitialized_);}
410 bool isComputed()
const{
return(IsComputed_);}
441 void setParameters(
const Teuchos::ParameterList& parameterlist);
452 int SetParameter(Hypre_Chooser chooser, HYPRE_Int (*pt2Func)(HYPRE_Solver, HYPRE_Int), HYPRE_Int parameter);
463 int SetParameter(Hypre_Chooser chooser, HYPRE_Int (*pt2Func)(HYPRE_Solver, HYPRE_Real), HYPRE_Real parameter);
475 int SetParameter(Hypre_Chooser chooser, HYPRE_Int (*pt2Func)(HYPRE_Solver, HYPRE_Real, HYPRE_Int), HYPRE_Real parameter1, HYPRE_Int parameter2);
487 int SetParameter(Hypre_Chooser chooser, HYPRE_Int (*pt2Func)(HYPRE_Solver, HYPRE_Int, HYPRE_Real), HYPRE_Int parameter1, HYPRE_Real parameter2);
499 int SetParameter(Hypre_Chooser chooser, HYPRE_Int (*pt2Func)(HYPRE_Solver, HYPRE_Int, HYPRE_Int), HYPRE_Int parameter1, HYPRE_Int parameter2);
510 int SetParameter(Hypre_Chooser chooser, HYPRE_Int (*pt2Func)(HYPRE_Solver, HYPRE_Real*), HYPRE_Real* parameter);
521 int SetParameter(Hypre_Chooser chooser, HYPRE_Int (*pt2Func)(HYPRE_Solver, HYPRE_Int*), HYPRE_Int* parameter);
533 int SetParameter(Hypre_Chooser chooser, HYPRE_Int (*pt2Func)(HYPRE_Solver, HYPRE_Int**), HYPRE_Int** parameter);
545 int SetParameter(Hypre_Chooser chooser, Hypre_Solver Solver);
556 int SetParameter(
bool UsePreconditioner){ UsePreconditioner_ = UsePreconditioner;
return 0;}
565 int SetParameter(Hypre_Chooser chooser) { SolveOrPrec_ = chooser;
return 0;}
568 int SetCoordinates(Teuchos::RCP<multivector_type> coords);
571 int SetDiscreteGradient(Teuchos::RCP<const crs_matrix_type> G);
574 int CallFunctions()
const;
603 setMatrix (
const Teuchos::RCP<const row_matrix_type>& A);
635 apply (
const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
636 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
637 Teuchos::ETransp mode = Teuchos::NO_TRANS,
638 scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(),
639 scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero())
const;
642 Teuchos::RCP<const map_type> getDomainMap()
const;
645 Teuchos::RCP<const map_type> getRangeMap()
const;
648 bool hasTransposeApply()
const;
671 applyMat (
const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
672 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
673 Teuchos::ETransp mode = Teuchos::NO_TRANS)
const;
680 Teuchos::RCP<const Teuchos::Comm<int> > getComm()
const;
683 Teuchos::RCP<const row_matrix_type> getMatrix()
const;
689 Teuchos::RCP<const Tpetra::CrsMatrix<scalar_type, local_ordinal_type, global_ordinal_type, node_type> >
690 getCrsMatrix()
const;
693 int getNumInitialize()
const;
696 int getNumCompute()
const;
699 int getNumApply()
const;
702 double getInitializeTime()
const;
705 double getComputeTime()
const;
708 double getApplyTime()
const;
715 std::string description()
const;
718 void describe(Teuchos::FancyOStream &out,
const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default)
const;
726 typedef Teuchos::ScalarTraits<typename MatrixType::scalar_type> STS;
729 typedef Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type> MV;
732 Hypre(
const Hypre<MatrixType>&);
735 Hypre<MatrixType>& operator= (
const Hypre<MatrixType>&);
738 int SetSolverType(Hypre_Solver solver);
741 int SetPrecondType(Hypre_Solver precond);
750 int CopyTpetraToHypre();
753 int AddFunToList(Teuchos::RCP<FunctionParameter> NewFun);
756 HYPRE_Int Hypre_BoomerAMGCreate(MPI_Comm comm, HYPRE_Solver *solver);
759 HYPRE_Int Hypre_ParaSailsCreate(MPI_Comm comm, HYPRE_Solver *solver);
762 HYPRE_Int Hypre_EuclidCreate(MPI_Comm comm, HYPRE_Solver *solver);
765 HYPRE_Int Hypre_AMSCreate(MPI_Comm comm, HYPRE_Solver *solver);
768 HYPRE_Int Hypre_ParCSRHybridCreate(MPI_Comm comm, HYPRE_Solver *solver);
771 HYPRE_Int Hypre_ParCSRPCGCreate(MPI_Comm comm, HYPRE_Solver *solver);
774 HYPRE_Int Hypre_ParCSRGMRESCreate(MPI_Comm comm, HYPRE_Solver *solver);
777 HYPRE_Int Hypre_ParCSRFlexGMRESCreate(MPI_Comm comm, HYPRE_Solver *solver);
780 HYPRE_Int Hypre_ParCSRLGMRESCreate(MPI_Comm comm, HYPRE_Solver *solver);
783 HYPRE_Int Hypre_ParCSRBiCGSTABCreate(MPI_Comm comm, HYPRE_Solver *solver);
786 Teuchos::RCP<const Tpetra::Map<LocalOrdinal, HYPRE_Int, Node> >
787 MakeContiguousColumnMap(Teuchos::RCP<const crs_matrix_type> &Matrix)
const;
795 Teuchos::RCP<const MatrixType> A_;
797 Teuchos::ParameterList List_;
811 mutable int NumApply_;
813 double InitializeTime_;
820 mutable double ApplyTime_;
822 double ComputeFlops_;
827 mutable double ApplyFlops_;
831 mutable HYPRE_IJMatrix HypreA_;
833 mutable HYPRE_ParCSRMatrix ParMatrix_;
836 Teuchos::RCP<const crs_matrix_type> G_;
838 mutable HYPRE_IJMatrix HypreG_;
840 mutable HYPRE_ParCSRMatrix ParMatrixG_;
843 mutable HYPRE_IJVector XHypre_;
845 mutable HYPRE_IJVector YHypre_;
846 mutable HYPRE_ParVector ParX_;
847 mutable HYPRE_ParVector ParY_;
848 mutable Teuchos::RCP<hypre_ParVector> XVec_;
849 mutable Teuchos::RCP<hypre_ParVector> YVec_;
851 Teuchos::RCP<multivector_type> Coords_;
852 mutable HYPRE_IJVector xHypre_;
853 mutable HYPRE_IJVector yHypre_;
854 mutable HYPRE_IJVector zHypre_;
855 mutable HYPRE_ParVector xPar_;
856 mutable HYPRE_ParVector yPar_;
857 mutable HYPRE_ParVector zPar_;
860 mutable HYPRE_Solver Solver_;
862 mutable HYPRE_Solver Preconditioner_;
864 HYPRE_Int (Hypre::*SolverCreatePtr_)(MPI_Comm, HYPRE_Solver*);
865 HYPRE_Int (*SolverDestroyPtr_)(HYPRE_Solver);
866 HYPRE_Int (*SolverSetupPtr_)(HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector);
867 HYPRE_Int (*SolverSolvePtr_)(HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector);
868 HYPRE_Int (*SolverPrecondPtr_)(HYPRE_Solver, HYPRE_PtrToParSolverFcn, HYPRE_PtrToParSolverFcn, HYPRE_Solver);
869 HYPRE_Int (Hypre::*PrecondCreatePtr_)(MPI_Comm, HYPRE_Solver*);
870 HYPRE_Int (*PrecondDestroyPtr_)(HYPRE_Solver);
871 HYPRE_Int (*PrecondSetupPtr_)(HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector);
872 HYPRE_Int (*PrecondSolvePtr_)(HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector);
874 bool IsSolverCreated_;
875 bool IsPrecondCreated_;
877 Hypre_Chooser SolveOrPrec_;
879 Teuchos::RCP<const map_type> GloballyContiguousRowMap_;
880 Teuchos::RCP<const map_type> GloballyContiguousColMap_;
881 Teuchos::RCP<const map_type> GloballyContiguousNodeRowMap_;
882 Teuchos::RCP<const map_type> GloballyContiguousNodeColMap_;
886 Hypre_Solver SolverType_;
888 Hypre_Solver PrecondType_;
890 bool UsePreconditioner_;
892 std::vector<Teuchos::RCP<FunctionParameter> > FunsToCall_;
896 mutable Teuchos::ArrayRCP<scalar_type> VectorCache_;
Declaration of interface for preconditioners that can change their matrix after construction.
Preconditioners and smoothers for Tpetra sparse matrices.
Definition Ifpack2_AdditiveSchwarz_decl.hpp:41
@ GMRES
Uses AztecOO's GMRES.
Definition Ifpack2_CondestType.hpp:20