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"
61#include "Ifpack2_Hypre_FunctionParameters.hpp"
66struct hypre_IJMatrix_struct;
67typedef struct hypre_IJMatrix_struct *HYPRE_IJMatrix;
68struct hypre_IJVector_struct;
69typedef struct hypre_IJVector_struct *HYPRE_IJVector;
70struct hypre_ParCSRMatrix_struct;
71typedef struct hypre_ParCSRMatrix_struct* HYPRE_ParCSRMatrix;
72struct hypre_ParVector_struct;
73typedef struct hypre_ParVector_struct * HYPRE_ParVector;
74struct hypre_Solver_struct;
75typedef struct hypre_Solver_struct *HYPRE_Solver;
76struct hypre_ParVector_struct;
77typedef struct hypre_ParVector_struct hypre_ParVector;
102 Hypre_Is_Preconditioner
113template<
class MatrixType>
116 typename MatrixType::local_ordinal_type,
117 typename MatrixType::global_ordinal_type,
118 typename MatrixType::node_type>,
120 typename MatrixType::local_ordinal_type,
121 typename MatrixType::global_ordinal_type,
122 typename MatrixType::node_type> >
130 typedef MatrixType matrix_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;
148 typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitude_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;
185 typedef global_ordinal_type (*HYPRE_PtrToParSolverFcn)(HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector);
212 explicit Hypre(
const Teuchos::RCP<const row_matrix_type>& A);
223 bool isInitialized()
const{
return(IsInitialized_);}
231 bool isComputed()
const{
return(IsComputed_);}
262 void setParameters(
const Teuchos::ParameterList& parameterlist);
273 int SetParameter(Hypre_Chooser chooser, global_ordinal_type (*pt2Func)(HYPRE_Solver, global_ordinal_type), global_ordinal_type parameter);
284 int SetParameter(Hypre_Chooser chooser, global_ordinal_type (*pt2Func)(HYPRE_Solver,
double),
double parameter);
296 int SetParameter(Hypre_Chooser chooser, global_ordinal_type (*pt2Func)(HYPRE_Solver,
double, global_ordinal_type),
double parameter1, global_ordinal_type parameter2);
308 int SetParameter(Hypre_Chooser chooser, global_ordinal_type (*pt2Func)(HYPRE_Solver, global_ordinal_type, global_ordinal_type), global_ordinal_type parameter1, global_ordinal_type parameter2);
319 int SetParameter(Hypre_Chooser chooser, global_ordinal_type (*pt2Func)(HYPRE_Solver,
double*),
double* parameter);
330 int SetParameter(Hypre_Chooser chooser, global_ordinal_type (*pt2Func)(HYPRE_Solver, global_ordinal_type*), global_ordinal_type* parameter);
342 int SetParameter(Hypre_Chooser chooser, global_ordinal_type (*pt2Func)(HYPRE_Solver, global_ordinal_type**), global_ordinal_type** parameter);
354 int SetParameter(Hypre_Chooser chooser, Hypre_Solver Solver);
365 int SetParameter(
bool UsePreconditioner){ UsePreconditioner_ = UsePreconditioner;
return 0;}
374 int SetParameter(Hypre_Chooser chooser) { SolveOrPrec_ = chooser;
return 0;}
377 int SetCoordinates(Teuchos::RCP<multivector_type> coords);
380 int SetDiscreteGradient(Teuchos::RCP<const crs_matrix_type> G);
383 int CallFunctions()
const;
412 setMatrix (
const Teuchos::RCP<const row_matrix_type>& A);
444 apply (
const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
445 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
446 Teuchos::ETransp mode = Teuchos::NO_TRANS,
447 scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(),
448 scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero())
const;
451 Teuchos::RCP<const map_type> getDomainMap()
const;
454 Teuchos::RCP<const map_type> getRangeMap()
const;
457 bool hasTransposeApply()
const;
480 applyMat (
const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
481 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
482 Teuchos::ETransp mode = Teuchos::NO_TRANS)
const;
489 Teuchos::RCP<const Teuchos::Comm<int> > getComm()
const;
492 Teuchos::RCP<const row_matrix_type> getMatrix()
const;
498 Teuchos::RCP<const Tpetra::CrsMatrix<scalar_type, local_ordinal_type, global_ordinal_type, node_type> >
499 getCrsMatrix()
const;
502 int getNumInitialize()
const;
505 int getNumCompute()
const;
508 int getNumApply()
const;
511 double getInitializeTime()
const;
514 double getComputeTime()
const;
517 double getApplyTime()
const;
524 std::string description()
const;
527 void describe(Teuchos::FancyOStream &out,
const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default)
const;
535 typedef Teuchos::ScalarTraits<typename MatrixType::scalar_type> STS;
538 typedef Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type> MV;
541 Hypre(
const Hypre<MatrixType>&);
544 Hypre<MatrixType>& operator= (
const Hypre<MatrixType>&);
547 int SetSolverType(Hypre_Solver solver);
550 int SetPrecondType(Hypre_Solver precond);
559 int CopyTpetraToHypre();
562 int AddFunToList(Teuchos::RCP<FunctionParameter> NewFun);
565 int Hypre_BoomerAMGCreate(MPI_Comm comm, HYPRE_Solver *solver);
568 int Hypre_ParaSailsCreate(MPI_Comm comm, HYPRE_Solver *solver);
571 int Hypre_EuclidCreate(MPI_Comm comm, HYPRE_Solver *solver);
574 int Hypre_AMSCreate(MPI_Comm comm, HYPRE_Solver *solver);
577 int Hypre_ParCSRHybridCreate(MPI_Comm comm, HYPRE_Solver *solver);
580 int Hypre_ParCSRPCGCreate(MPI_Comm comm, HYPRE_Solver *solver);
583 int Hypre_ParCSRGMRESCreate(MPI_Comm comm, HYPRE_Solver *solver);
586 int Hypre_ParCSRFlexGMRESCreate(MPI_Comm comm, HYPRE_Solver *solver);
589 int Hypre_ParCSRLGMRESCreate(MPI_Comm comm, HYPRE_Solver *solver);
592 int Hypre_ParCSRBiCGSTABCreate(MPI_Comm comm, HYPRE_Solver *solver);
595 Teuchos::RCP<const Tpetra::Map<typename MatrixType::local_ordinal_type, typename MatrixType::global_ordinal_type, typename MatrixType::node_type> >
596 MakeContiguousColumnMap(Teuchos::RCP<const crs_matrix_type> &Matrix)
const;
604 Teuchos::RCP<const MatrixType> A_;
606 Teuchos::ParameterList List_;
620 mutable int NumApply_;
622 double InitializeTime_;
629 mutable double ApplyTime_;
631 double ComputeFlops_;
636 mutable double ApplyFlops_;
640 mutable HYPRE_IJMatrix HypreA_;
642 mutable HYPRE_ParCSRMatrix ParMatrix_;
645 Teuchos::RCP<const crs_matrix_type> G_;
647 mutable HYPRE_IJMatrix HypreG_;
649 mutable HYPRE_ParCSRMatrix ParMatrixG_;
652 mutable HYPRE_IJVector XHypre_;
654 mutable HYPRE_IJVector YHypre_;
655 mutable HYPRE_ParVector ParX_;
656 mutable HYPRE_ParVector ParY_;
657 mutable Teuchos::RCP<hypre_ParVector> XVec_;
658 mutable Teuchos::RCP<hypre_ParVector> YVec_;
660 Teuchos::RCP<multivector_type> Coords_;
661 mutable HYPRE_IJVector xHypre_;
662 mutable HYPRE_IJVector yHypre_;
663 mutable HYPRE_IJVector zHypre_;
664 mutable HYPRE_ParVector xPar_;
665 mutable HYPRE_ParVector yPar_;
666 mutable HYPRE_ParVector zPar_;
669 mutable HYPRE_Solver Solver_;
671 mutable HYPRE_Solver Preconditioner_;
673 int (Hypre::*SolverCreatePtr_)(MPI_Comm, HYPRE_Solver*);
674 global_ordinal_type (*SolverDestroyPtr_)(HYPRE_Solver);
675 global_ordinal_type (*SolverSetupPtr_)(HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector);
676 global_ordinal_type (*SolverSolvePtr_)(HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector);
677 global_ordinal_type (*SolverPrecondPtr_)(HYPRE_Solver, HYPRE_PtrToParSolverFcn, HYPRE_PtrToParSolverFcn, HYPRE_Solver);
678 int (Hypre::*PrecondCreatePtr_)(MPI_Comm, HYPRE_Solver*);
679 global_ordinal_type (*PrecondDestroyPtr_)(HYPRE_Solver);
680 global_ordinal_type (*PrecondSetupPtr_)(HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector);
681 global_ordinal_type (*PrecondSolvePtr_)(HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector);
683 bool IsSolverCreated_;
684 bool IsPrecondCreated_;
686 Hypre_Chooser SolveOrPrec_;
688 Teuchos::RCP<const map_type> GloballyContiguousRowMap_;
689 Teuchos::RCP<const map_type> GloballyContiguousColMap_;
690 Teuchos::RCP<const map_type> GloballyContiguousNodeRowMap_;
691 Teuchos::RCP<const map_type> GloballyContiguousNodeColMap_;
695 Hypre_Solver SolverType_;
697 Hypre_Solver PrecondType_;
699 bool UsePreconditioner_;
701 std::vector<Teuchos::RCP<FunctionParameter> > FunsToCall_;
705 mutable Teuchos::ArrayRCP<double> VectorCache_;
Declaration of interface for preconditioners that can change their matrix after construction.
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:108
Preconditioners and smoothers for Tpetra sparse matrices.
Definition Ifpack2_AdditiveSchwarz_decl.hpp:74
@ GMRES
Uses AztecOO's GMRES.
Definition Ifpack2_CondestType.hpp:53