29#include <temp_multivector.h>
30#include <_hypre_parcsr_mv.h>
31#include <_hypre_parcsr_ls.h>
34#error "MFEM does not work with HYPRE's complex numbers support"
37#if defined(MFEM_USE_DOUBLE) && defined(HYPRE_SINGLE)
38#error "MFEM_USE_DOUBLE=YES requires HYPRE build WITHOUT --enable-single!"
39#elif defined(MFEM_USE_DOUBLE) && defined(HYPRE_LONG_DOUBLE)
40#error "MFEM_USE_DOUBLE=YES requires HYPRE build WITHOUT --enable-longdouble!"
41#elif defined(MFEM_USE_SINGLE) && !defined(HYPRE_SINGLE)
42#error "MFEM_USE_SINGLE=YES requires HYPRE build with --enable-single!"
45#if defined(HYPRE_USING_GPU) && \
46 !(defined(HYPRE_USING_CUDA) || defined(HYPRE_USING_HIP))
47#error "Unsupported GPU build of HYPRE! Only CUDA and HIP builds are supported."
49#if defined(HYPRE_USING_CUDA) && !defined(MFEM_USE_CUDA)
50#error "MFEM_USE_CUDA=YES is required when HYPRE is built with CUDA!"
52#if defined(HYPRE_USING_HIP) && !defined(MFEM_USE_HIP)
53#error "MFEM_USE_HIP=YES is required when HYPRE is built with HIP!"
59class ParFiniteElementSpace;
74 static void Init() { Instance(); }
114 void SetDefaultOptions();
117 static Hypre &Instance()
123 bool finalized =
false;
130template <
typename int_type>
131inline int to_int(int_type i)
133 MFEM_ASSERT(int_type(
int(i)) == i,
"overflow converting int_type to int");
138template <>
inline int to_int(
int i) {
return i; }
143inline int to_int(HYPRE_Int i)
145 MFEM_ASSERT(HYPRE_Int(
int(i)) == i,
"overflow converting HYPRE_Int to int");
156#if !defined(HYPRE_USING_GPU)
158#elif MFEM_HYPRE_VERSION < 23100
159#if defined(HYPRE_USING_UNIFIED_MEMORY)
170#if defined(HYPRE_USING_UNIFIED_MEMORY)
181#if !defined(HYPRE_USING_GPU)
183#elif MFEM_HYPRE_VERSION < 23100
184#if defined(HYPRE_USING_UNIFIED_MEMORY)
195#if defined(HYPRE_USING_UNIFIED_MEMORY)
216 inline void _SetDataAndSize_();
223 own_ParVector =
false;
286 operator hypre_ParVector*()
const {
return x; }
287#ifndef HYPRE_PAR_VECTOR_STRUCT
289 operator HYPRE_ParVector()
const {
return (HYPRE_ParVector) x; }
367 void Print(
const char *fname)
const;
370 void Read(MPI_Comm comm,
const char *fname);
391 hypre_ParCSRMatrix *A;
418 signed char diagOwner, offdOwner, colMapOwner;
421 signed char ParCSROwner;
434 void Write(
MemoryClass mc,
bool set_diag =
true,
bool set_offd =
true);
442 hypre_CSRMatrix *hypre_csr,
448 static signed char CopyBoolCSR(
Table *bool_csr,
450 hypre_CSRMatrix *hypre_csr);
457 static signed char HypreCsrToMem(hypre_CSRMatrix *h_mat,
MemoryType h_mat_mt,
511 bool own_diag_offd =
false);
526 HYPRE_Int *diag_i, HYPRE_Int *diag_j,
real_t *diag_data,
527 HYPRE_Int *offd_i, HYPRE_Int *offd_j,
real_t *offd_data,
528 HYPRE_Int offd_num_cols,
530 bool hypre_arrays =
false);
555 HYPRE_Int *i_diag, HYPRE_Int *j_diag, HYPRE_Int *i_offd,
557 HYPRE_Int cmap_size);
581 operator hypre_ParCSRMatrix*()
const {
return A; }
582#ifndef HYPRE_PAR_CSR_MATRIX_STRUCT
584 operator HYPRE_ParCSRMatrix() {
return (HYPRE_ParCSRMatrix) A; }
590 void SetOwnerFlags(
signed char diag,
signed char offd,
signed char colmap);
651 bool interleaved_rows =
false,
652 bool interleaved_cols =
false)
const;
659#if MFEM_HYPRE_VERSION >= 21800
661 real_t threshold=0.0)
const;
667 return internal::to_int(
668 hypre_CSRMatrixNumRows(hypre_ParCSRMatrixDiag(A)));
674 return internal::to_int(
675 hypre_CSRMatrixNumCols(hypre_ParCSRMatrixDiag(A)));
680 {
return hypre_ParCSRMatrixGlobalNumRows(A); }
684 {
return hypre_ParCSRMatrixGlobalNumCols(A); }
720 HYPRE_Int
Mult(HYPRE_ParVector x, HYPRE_ParVector y,
739 {
Mult(1.0, x, 0.0, y); }
749 {
Mult(
a, x, 1.0, y); }
751 const real_t a = 1.0)
const override
770 internal::hypre_ParCSRMatrixBooleanMatvec(A,
alpha,
const_cast<int*
>(x),
780 internal::hypre_ParCSRMatrixBooleanMatvecT(A,
alpha,
const_cast<int*
>(x),
788#if MFEM_HYPRE_VERSION < 22200
789 internal::hypre_ParCSRMatrixSetConstantValues(A, value);
791 hypre_ParCSRMatrixSetConstantValues(A, value);
809 MFEM_VERIFY(internal::hypre_ParCSRMatrixSum(A,
beta, B.A) == 0,
810 "error in hypre_ParCSRMatrixSum");
923 void Print(
const char *fname, HYPRE_Int offi = 0, HYPRE_Int offj = 0)
const;
925 void Read(MPI_Comm comm,
const char *fname);
957#if MFEM_HYPRE_VERSION >= 21800
970 const Vector *
b, HypreParVector *d,
982HypreParMatrix *
ParMult(
const HypreParMatrix *A,
const HypreParMatrix *B,
983 bool own_matrix =
false);
987HypreParMatrix *
ParAdd(
const HypreParMatrix *A,
const HypreParMatrix *B);
990HypreParMatrix *
RAP(
const HypreParMatrix *A,
const HypreParMatrix *P);
992HypreParMatrix *
RAP(
const HypreParMatrix * Rt,
const HypreParMatrix *A,
993 const HypreParMatrix *P);
1004 Array2D<real_t> *blockCoeff=NULL);
1007 Array2D<HypreParMatrix*> &blocks,
1008 Array2D<real_t> *blockCoeff=NULL);
1014void EliminateBC(
const HypreParMatrix &A,
const HypreParMatrix &Ae,
1015 const Array<int> &ess_dof_list,
const Vector &X, Vector &B);
1093#if !defined(HYPRE_USING_GPU)
1199 virtual operator HYPRE_Solver()
const = 0;
1218 {
mfem_error(
"HypreSolvers do not support SetOperator!"); }
1247#if MFEM_HYPRE_VERSION >= 21800
1256 virtual operator HYPRE_Solver()
const {
return NULL; }
1259 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ParCSROnProcTriSetup; }
1261 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ParCSROnProcTriSolve; }
1277 HYPRE_Solver pcg_solver;
1311 HYPRE_ParCSRPCGGetNumIterations(pcg_solver, &num_it);
1312 num_iterations = internal::to_int(num_it);
1317 HYPRE_ParCSRPCGGetFinalRelativeResidualNorm(pcg_solver,
1322 virtual operator HYPRE_Solver()
const {
return pcg_solver; }
1326 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ParCSRPCGSetup; }
1329 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ParCSRPCGSolve; }
1342 HYPRE_Solver gmres_solver;
1347 void SetDefaultOptions();
1375 HYPRE_ParCSRGMRESGetNumIterations(gmres_solver, &num_it);
1376 num_iterations = internal::to_int(num_it);
1381 HYPRE_ParCSRGMRESGetFinalRelativeResidualNorm(gmres_solver,
1386 virtual operator HYPRE_Solver()
const {
return gmres_solver; }
1390 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ParCSRGMRESSetup; }
1393 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ParCSRGMRESSolve; }
1406 HYPRE_Solver fgmres_solver;
1411 void SetDefaultOptions();
1438 HYPRE_ParCSRFlexGMRESGetNumIterations(fgmres_solver, &num_it);
1439 num_iterations = internal::to_int(num_it);
1444 HYPRE_ParCSRFlexGMRESGetFinalRelativeResidualNorm(fgmres_solver,
1449 virtual operator HYPRE_Solver()
const {
return fgmres_solver; }
1453 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ParCSRFlexGMRESSetup; }
1456 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ParCSRFlexGMRESSolve; }
1469 virtual operator HYPRE_Solver()
const {
return NULL; }
1472 {
return (HYPRE_PtrToParSolverFcn) hypre_ParKrylovIdentitySetup; }
1474 {
return (HYPRE_PtrToParSolverFcn) hypre_ParKrylovIdentity; }
1485 virtual operator HYPRE_Solver()
const {
return NULL; }
1490 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ParCSRDiagScaleSetup; }
1492 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ParCSRDiagScale; }
1507 HYPRE_Solver sai_precond;
1510 void SetDefaultOptions();
1515 void ResetSAIPrecond(MPI_Comm comm);
1573 virtual operator HYPRE_Solver()
const {
return sai_precond; }
1576 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ParaSailsSetup; }
1578 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ParaSailsSolve; }
1594 HYPRE_Solver euc_precond;
1597 void SetDefaultOptions();
1602 void ResetEuclidPrecond(MPI_Comm comm);
1618 virtual operator HYPRE_Solver()
const {
return euc_precond; }
1621 {
return (HYPRE_PtrToParSolverFcn) HYPRE_EuclidSetup; }
1623 {
return (HYPRE_PtrToParSolverFcn) HYPRE_EuclidSolve; }
1628#if MFEM_HYPRE_VERSION >= 21900
1646 HYPRE_Solver ilu_precond;
1649 void SetDefaultOptions();
1655 void ResetILUPrecond();
1666 void SetType(HYPRE_Int ilu_type);
1668 void SetTol(HYPRE_Real tol);
1675 virtual operator HYPRE_Solver()
const {
return ilu_precond; }
1681 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ILUSetup; }
1685 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ILUSolve; }
1693 HYPRE_Solver amg_precond;
1702 void RecomputeRBMs();
1705 void SetDefaultOptions();
1710 void ResetAMGPrecond();
1729 bool interp_refine =
true);
1731#if MFEM_HYPRE_VERSION >= 21800
1741 const std::string &postrelax=
"FFC");
1745 { HYPRE_BoomerAMGSetStrongThresholdR(amg_precond, strengthR); }
1749 { HYPRE_BoomerAMGSetFilterThresholdR(amg_precond, filterR); }
1753 { HYPRE_BoomerAMGSetRestriction(amg_precond, restrict_type); }
1757 { HYPRE_BoomerAMGSetIsTriangular(amg_precond, 1); }
1761 { HYPRE_BoomerAMGSetGMRESSwitchR(amg_precond, gmres_switch); }
1766 HYPRE_BoomerAMGSetCycleNumSweeps(amg_precond, prerelax, 1);
1767 HYPRE_BoomerAMGSetCycleNumSweeps(amg_precond, postrelax, 2);
1772 { HYPRE_BoomerAMGSetPrintLevel(amg_precond, print_level); }
1775 { HYPRE_BoomerAMGSetMaxIter(amg_precond, max_iter); }
1779 { HYPRE_BoomerAMGSetMaxLevels(amg_precond, max_levels); }
1783 { HYPRE_BoomerAMGSetTol(amg_precond, tol); }
1787 { HYPRE_BoomerAMGSetStrongThreshold(amg_precond, strength); }
1791 { HYPRE_BoomerAMGSetInterpType(amg_precond, interp_type); }
1795 { HYPRE_BoomerAMGSetCoarsenType(amg_precond, coarsen_type); }
1799 { HYPRE_BoomerAMGSetRelaxType(amg_precond, relax_type); }
1803 { HYPRE_BoomerAMGSetCycleType(amg_precond, cycle_type); }
1808 HYPRE_BoomerAMGGetNumIterations(amg_precond, &num_it);
1809 num_iterations = internal::to_int(num_it);
1815 HYPRE_BoomerAMGSetNumFunctions(amg_precond, blocksize);
1816 HYPRE_BoomerAMGSetNodal(amg_precond, 1);
1821 { HYPRE_BoomerAMGSetAggNumLevels(amg_precond, num_levels); }
1824 virtual operator HYPRE_Solver()
const {
return amg_precond; }
1827 {
return (HYPRE_PtrToParSolverFcn) HYPRE_BoomerAMGSetup; }
1829 {
return (HYPRE_PtrToParSolverFcn) HYPRE_BoomerAMGSolve; }
1852 void MakeSolver(
int sdim,
int cycle_type);
1861 void ResetAMSPrecond();
1873 int ams_cycle_type = 0;
1877 bool singular =
false;
1879 int print_level = 1;
1905 HYPRE_AMSSetBetaPoissonMatrix(ams, NULL);
1910 virtual operator HYPRE_Solver()
const {
return ams; }
1913 {
return (HYPRE_PtrToParSolverFcn) HYPRE_AMSSetup; }
1915 {
return (HYPRE_PtrToParSolverFcn) HYPRE_AMSSolve; }
1949 const int cycle_type = 11;
1951 const int ams_cycle_type = 14;
1953 int print_level = 1;
1957 void ResetADSPrecond();
1977 virtual operator HYPRE_Solver()
const {
return ads; }
1980 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ADSSetup; }
1982 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ADSSolve; }
2022 HYPRE_Solver lobpcg_solver;
2025 mv_InterfaceInterpreter interpreter;
2028 HYPRE_MatvecFunctions matvec_fn;
2034 class HypreMultiVector;
2037 HypreMultiVector * multi_vec;
2046 class HypreMultiVector
2050 mv_MultiVectorPtr mv_ptr;
2060 mv_InterfaceInterpreter & interpreter);
2061 ~HypreMultiVector();
2064 void Randomize(HYPRE_Int seed);
2072 operator mv_MultiVectorPtr()
const {
return mv_ptr; }
2074 mv_MultiVectorPtr & GetMultiVector() {
return mv_ptr; }
2077 static void * OperatorMatvecCreate(
void *A,
void *x );
2078 static HYPRE_Int OperatorMatvec(
void *matvec_data,
2079 HYPRE_Complex
alpha,
2084 static HYPRE_Int OperatorMatvecDestroy(
void *matvec_data );
2086 static HYPRE_Int PrecondSolve(
void *solver,
2090 static HYPRE_Int PrecondSetup(
void *solver,
2158 HYPRE_Solver ame_solver;
2164 HYPRE_Real * eigenvalues;
2167 HYPRE_ParVector * multi_vec;
2172 void createDummyVectors()
const;
Dynamic 2D array using row-major layout.
static MemoryType GetHostMemoryType()
Get the current Host MemoryType. This is the MemoryType used by most MFEM classes when allocating mem...
static MemoryClass GetHostMemoryClass()
Get the current Host MemoryClass. This is the MemoryClass used by most MFEM host Memory objects.
The Auxiliary-space Divergence Solver in hypre.
HypreADS(ParFiniteElementSpace *face_fespace)
virtual void SetOperator(const Operator &op)
Set/update the solver for the given operator.
virtual HYPRE_PtrToParSolverFcn SolveFcn() const
hypre's internal Solve function
virtual HYPRE_PtrToParSolverFcn SetupFcn() const
hypre's internal Setup function
void SetPrintLevel(int print_lvl)
void SetNumModes(int num_eigs)
void SetPreconditioner(HypreSolver &precond)
void SetPrintLevel(int logging)
void SetMassMatrix(const HypreParMatrix &M)
const HypreParVector & GetEigenvector(unsigned int i) const
Extract a single eigenvector.
void GetEigenvalues(Array< real_t > &eigenvalues) const
Collect the converged eigenvalues.
void SetOperator(const HypreParMatrix &A)
void Solve()
Solve the eigenproblem.
void SetMaxIter(int max_iter)
HypreParVector ** StealEigenvectors()
Transfer ownership of the converged eigenvectors.
void SetRelTol(real_t rel_tol)
The Auxiliary-space Maxwell Solver in hypre.
virtual void SetOperator(const Operator &op)
Set/update the solver for the given operator.
virtual HYPRE_PtrToParSolverFcn SolveFcn() const
hypre's internal Solve function
HypreAMS(ParFiniteElementSpace *edge_fespace)
Construct the AMS solver on the given edge finite element space.
virtual HYPRE_PtrToParSolverFcn SetupFcn() const
hypre's internal Setup function
void SetPrintLevel(int print_lvl)
void SetSingularProblem()
Set this option when solving a curl-curl problem with zero mass term.
The BoomerAMG solver in hypre.
void SetAggressiveCoarsening(int num_levels)
Expert option - consult hypre documentation/team.
virtual HYPRE_PtrToParSolverFcn SetupFcn() const
hypre's internal Setup function
void GetNumIterations(int &num_iterations) const
void SetInterpolation(int interp_type)
Expert option - consult hypre documentation/team.
virtual void SetOperator(const Operator &op)
Set/update the solver for the given operator.
void SetCycleNumSweeps(int prerelax, int postrelax)
Expert option - consult hypre documentation/team.
virtual HYPRE_PtrToParSolverFcn SolveFcn() const
hypre's internal Solve function
void SetIsTriangular()
Expert option - consult hypre documentation/team.
void SetSystemsOptions(int dim, bool order_bynodes=false)
void SetCoarsening(int coarsen_type)
Expert option - consult hypre documentation/team.
void SetElasticityOptions(ParFiniteElementSpace *fespace, bool interp_refine=true)
void SetPrintLevel(int print_level)
void SetRestriction(int restrict_type)
Expert option - consult hypre documentation/team.
void SetStrongThresholdR(real_t strengthR)
Expert option - consult hypre documentation/team.
void SetMaxLevels(int max_levels)
Expert option - consult hypre documentation/team.
void SetCycleType(int cycle_type)
Expert option - consult hypre documentation/team.
void SetAdvectiveOptions(int distance=15, const std::string &prerelax="", const std::string &postrelax="FFC")
void SetGMRESSwitchR(int gmres_switch)
Expert option - consult hypre documentation/team.
void SetFilterThresholdR(real_t filterR)
Expert option - consult hypre documentation/team.
virtual ~HypreBoomerAMG()
void SetRelaxType(int relax_type)
Expert option - consult hypre documentation/team.
void SetNodal(int blocksize)
Expert option - consult hypre documentation/team.
void SetStrengthThresh(real_t strength)
Expert option - consult hypre documentation/team.
void SetTol(real_t tol)
Expert option - consult hypre documentation/team.
void SetMaxIter(int max_iter)
Jacobi preconditioner in hypre.
HypreDiagScale(const HypreParMatrix &A)
const HypreParMatrix * GetData() const
MFEM_DEPRECATED HypreParMatrix * GetData()
Deprecated. Use HypreDiagScale::GetData() const instead.
virtual void SetOperator(const Operator &op)
Set/update the solver for the given operator.
virtual HYPRE_PtrToParSolverFcn SetupFcn() const
hypre's internal Setup function
virtual HYPRE_PtrToParSolverFcn SolveFcn() const
hypre's internal Solve function
virtual ~HypreDiagScale()
virtual HYPRE_PtrToParSolverFcn SetupFcn() const
hypre's internal Setup function
virtual void SetOperator(const Operator &op)
Set/update the solver for the given operator.
HypreEuclid(MPI_Comm comm)
virtual HYPRE_PtrToParSolverFcn SolveFcn() const
hypre's internal Solve function
void SetRowScale(int row_scale)
Flexible GMRES solver in hypre.
virtual HYPRE_PtrToParSolverFcn SolveFcn() const
FGMRES Solve function.
virtual HYPRE_PtrToParSolverFcn SetupFcn() const
FGMRES Setup function.
void SetMaxIter(int max_iter)
virtual void Mult(const HypreParVector &b, HypreParVector &x) const
Solve Ax=b with hypre's FGMRES.
virtual void SetOperator(const Operator &op)
Set/update the solver for the given operator.
MFEM_DEPRECATED void SetZeroInintialIterate()
deprecated: use SetZeroInitialIterate()
HypreFGMRES(MPI_Comm comm)
void SetPreconditioner(HypreSolver &precond)
Set the hypre solver to be used as a preconditioner.
void SetZeroInitialIterate()
non-hypre setting
void SetPrintLevel(int print_lvl)
void GetFinalResidualNorm(real_t &final_res_norm) const
void SetLogging(int logging)
void GetNumIterations(int &num_iterations) const
virtual HYPRE_PtrToParSolverFcn SetupFcn() const
GMRES Setup function.
void GetFinalResidualNorm(real_t &final_res_norm) const
virtual void Mult(const HypreParVector &b, HypreParVector &x) const
Solve Ax=b with hypre's GMRES.
void SetLogging(int logging)
void SetPreconditioner(HypreSolver &precond)
Set the hypre solver to be used as a preconditioner.
void SetMaxIter(int max_iter)
void GetNumIterations(int &num_iterations) const
void SetPrintLevel(int print_lvl)
HypreGMRES(MPI_Comm comm)
virtual void SetOperator(const Operator &op)
Set/update the solver for the given operator.
virtual HYPRE_PtrToParSolverFcn SolveFcn() const
GMRES Solve function.
void SetAbsTol(real_t tol)
void SetZeroInitialIterate()
non-hypre setting
MFEM_DEPRECATED void SetZeroInintialIterate()
deprecated: use SetZeroInitialIterate()
Wrapper for Hypre's native parallel ILU preconditioner.
HypreILU()
Constructor; sets the default options.
void SetType(HYPRE_Int ilu_type)
void SetLocalReordering(HYPRE_Int reorder_type)
virtual HYPRE_PtrToParSolverFcn SolveFcn() const
ILU Solve function.
void SetMaxIter(HYPRE_Int max_iter)
void SetLevelOfFill(HYPRE_Int lev_fill)
Set the fill level for ILU(k); the default is k=1.
virtual void SetOperator(const Operator &op)
Set/update the solver for the given operator.
void SetTol(HYPRE_Real tol)
void SetPrintLevel(HYPRE_Int print_level)
Set the print level: 0 = none, 1 = setup, 2 = solve, 3 = setup+solve.
virtual HYPRE_PtrToParSolverFcn SetupFcn() const
ILU Setup function.
The identity operator as a hypre solver.
virtual HYPRE_PtrToParSolverFcn SetupFcn() const
hypre's internal Setup function
virtual HYPRE_PtrToParSolverFcn SolveFcn() const
hypre's internal Solve function
void SetMassMatrix(Operator &M)
HypreLOBPCG(MPI_Comm comm)
void SetPrintLevel(int logging)
void SetPreconditioner(Solver &precond)
void GetEigenvalues(Array< real_t > &eigenvalues) const
Collect the converged eigenvalues.
HypreParVector ** StealEigenvectors()
Transfer ownership of the converged eigenvectors.
void SetOperator(Operator &A)
void SetNumModes(int num_eigs)
void Solve()
Solve the eigenproblem.
void SetPrecondUsageMode(int pcg_mode)
void SetRandomSeed(int s)
void SetInitialVectors(int num_vecs, HypreParVector **vecs)
void SetSubSpaceProjector(Operator &proj)
void SetMaxIter(int max_iter)
void SetRelTol(real_t rel_tol)
const HypreParVector & GetEigenvector(unsigned int i) const
Extract a single eigenvector.
MFEM_DEPRECATED void SetZeroInintialIterate()
deprecated: use SetZeroInitialIterate()
void GetNumIterations(int &num_iterations) const
virtual HYPRE_PtrToParSolverFcn SetupFcn() const
PCG Setup function.
virtual void SetOperator(const Operator &op)
Set/update the solver for the given operator.
void SetResidualConvergenceOptions(int res_frequency=-1, real_t rtol=0.0)
void SetZeroInitialIterate()
non-hypre setting
void SetPrintLevel(int print_lvl)
virtual HYPRE_PtrToParSolverFcn SolveFcn() const
PCG Solve function.
void SetLogging(int logging)
void SetPreconditioner(HypreSolver &precond)
Set the hypre solver to be used as a preconditioner.
virtual void Mult(const HypreParVector &b, HypreParVector &x) const
Solve Ax=b with hypre's PCG.
void SetMaxIter(int max_iter)
void GetFinalResidualNorm(real_t &final_res_norm) const
void SetAbsTol(real_t atol)
Wrapper for hypre's ParCSR matrix class.
const Memory< real_t > & GetDiagMemoryData() const
void HypreReadWrite()
Update the internal hypre_ParCSRMatrix object, A, to be in hypre memory space.
signed char OwnsDiag() const
Get diag ownership flag.
void operator*=(real_t s)
Scale all entries by s: A_scaled = s*A.
signed char OwnsColMap() const
Get colmap ownership flag.
virtual ~HypreParMatrix()
Calls hypre's destroy function.
HYPRE_BigInt N() const
Returns the global number of columns.
void ScaleRows(const Vector &s)
Scale the local row i by s(i).
void AbsMultTranspose(real_t a, const Vector &x, real_t b, Vector &y) const
Computes y = a * |At| * x + b * y, using entry-wise absolute values of the transpose of the matrix A.
HYPRE_BigInt * ColPart()
Returns the column partitioning.
void HostReadWrite()
Update the internal hypre_ParCSRMatrix object, A, to be on host.
void DropSmallEntries(real_t tol)
Wrapper for hypre_ParCSRMatrixDropSmallEntries in different versions of hypre. Drop off-diagonal entr...
const Memory< HYPRE_Int > & GetDiagMemoryI() const
const Memory< HYPRE_Int > & GetDiagMemoryJ() const
void PrintCommPkg(std::ostream &out=mfem::out) const
Print information about the hypre_ParCSRCommPkg of the HypreParMatrix.
void GetDiag(Vector &diag) const
Get the local diagonal of the matrix.
const HYPRE_BigInt * RowPart() const
Returns the row partitioning (const version)
HYPRE_Int MultTranspose(HypreParVector &x, HypreParVector &y, real_t alpha=1.0, real_t beta=0.0) const
Computes y = alpha * A^t * x + beta * y.
MemoryClass GetMemoryClass() const override
Return the MemoryClass preferred by the Operator.
void Threshold(real_t threshold=0.0)
Remove values smaller in absolute value than some threshold.
Memory< HYPRE_Int > & GetDiagMemoryI()
HypreParMatrix * LeftDiagMult(const SparseMatrix &D, HYPRE_BigInt *row_starts=NULL) const
Multiply the HypreParMatrix on the left by a block-diagonal parallel matrix D and return the result a...
void EliminateRows(const Array< int > &rows)
Eliminate rows from the diagonal and off-diagonal blocks of the matrix.
void AbsMult(real_t a, const Vector &x, real_t b, Vector &y) const
Computes y = a * |A| * x + b * y, using entry-wise absolute values of the matrix A.
int GetNumCols() const
Returns the number of columns in the diagonal block of the ParCSRMatrix.
void SetOwnerFlags(signed char diag, signed char offd, signed char colmap)
Explicitly set the three ownership flags, see docs for diagOwner etc.
void InvScaleRows(const Vector &s)
Scale the local row i by 1./s(i)
void ResetTranspose() const
Reset (destroy) the internal transpose matrix that is created by EnsureMultTranspose() and MultTransp...
void WrapHypreParCSRMatrix(hypre_ParCSRMatrix *a, bool owner=true)
Converts hypre's format to HypreParMatrix.
int GetNumRows() const
Returns the number of rows in the diagonal block of the ParCSRMatrix.
void AddMult(const Vector &x, Vector &y, const real_t a=1.0) const override
Operator application: y+=A(x) (default) or y+=a*A(x).
Memory< HYPRE_Int > & GetDiagMemoryJ()
HYPRE_BigInt * GetRowStarts() const
Return the parallel row partitioning array.
HypreParMatrix(hypre_ParCSRMatrix *a, bool owner=true)
Converts hypre's format to HypreParMatrix.
void HypreRead() const
Update the internal hypre_ParCSRMatrix object, A, to be in hypre memory space.
HYPRE_BigInt NNZ() const
Returns the global number of nonzeros.
const HYPRE_BigInt * ColPart() const
Returns the column partitioning (const version)
void BooleanMultTranspose(int alpha, const int *x, int beta, int *y)
The "Boolean" analog of y = alpha * A^T * x + beta * y, where elements in the sparsity pattern of the...
HypreParMatrix & operator+=(const HypreParMatrix &B)
HypreParMatrix()
An empty matrix to be used as a reference to an existing matrix.
signed char OwnsOffd() const
Get offd ownership flag.
HYPRE_BigInt GetGlobalNumRows() const
Return the global number of rows.
void PrintHash(std::ostream &out) const
Print sizes and hashes for all data arrays of the HypreParMatrix from the local MPI rank.
void HostWrite()
Update the internal hypre_ParCSRMatrix object, A, to be on host.
HYPRE_BigInt GetGlobalNumCols() const
Return the global number of columns.
void HostRead() const
Update the internal hypre_ParCSRMatrix object, A, to be on host.
void EliminateRowsCols(const Array< int > &rows_cols, const HypreParVector &X, HypreParVector &B)
HYPRE_Int Mult(HypreParVector &x, HypreParVector &y, real_t alpha=1.0, real_t beta=0.0) const
Computes y = alpha * A * x + beta * y.
void MultTranspose(const Vector &x, Vector &y) const override
Computes y = A^t * x.
HypreParMatrix * ExtractSubmatrix(const Array< int > &indices, real_t threshold=0.0) const
void EnsureMultTranspose() const
Ensure the action of the transpose is performed fast.
void Mult(const Vector &x, Vector &y) const override
Operator application: y=A(x).
MPI_Comm GetComm() const
MPI communicator.
Memory< real_t > & GetDiagMemoryData()
HYPRE_BigInt * GetColStarts() const
Return the parallel column partitioning array.
void EliminateZeroRows()
If a row contains only zeros, set its diagonal to 1.
HypreParMatrix & Add(const real_t beta, const HypreParMatrix &B)
void GetBlocks(Array2D< HypreParMatrix * > &blocks, bool interleaved_rows=false, bool interleaved_cols=false) const
void EliminateBC(const HypreParMatrix &Ae, const Array< int > &ess_dof_list, const Vector &X, Vector &B) const
Eliminate essential BC specified by ess_dof_list from the solution X to the r.h.s....
void MakeRef(const HypreParMatrix &master)
Make this HypreParMatrix a reference to 'master'.
void AddMultTranspose(const Vector &x, Vector &y, const real_t a=1.0) const override
Operator transpose application: y+=A^t(x) (default) or y+=a*A^t(x).
void BooleanMult(int alpha, const int *x, int beta, int *y)
The "Boolean" analog of y = alpha * A * x + beta * y, where elements in the sparsity pattern of the m...
void GetOffd(SparseMatrix &offd, HYPRE_BigInt *&cmap) const
Get the local off-diagonal block. NOTE: 'offd' will not own any data.
HYPRE_BigInt * RowPart()
Returns the row partitioning.
void AssembleDiagonal(Vector &diag) const override
Return the diagonal of the matrix (Operator interface).
void HypreWrite()
Update the internal hypre_ParCSRMatrix object, A, to be in hypre memory space.
HYPRE_BigInt M() const
Returns the global number of rows.
HypreParMatrix & operator=(real_t value)
Initialize all entries with value.
hypre_ParCSRMatrix * StealData()
Changes the ownership of the matrix.
HypreParMatrix * Transpose() const
Returns the transpose of *this.
void MergeDiagAndOffd(SparseMatrix &merged)
Get a single SparseMatrix containing all rows from this processor, merged from the diagonal and off-d...
void Read_IJMatrix(MPI_Comm comm, const char *fname)
Read a matrix saved as a HYPRE_IJMatrix.
HypreParMatrix * EliminateCols(const Array< int > &cols)
void Print(const char *fname, HYPRE_Int offi=0, HYPRE_Int offj=0) const
Prints the locally owned rows in parallel.
Wrapper for hypre's parallel vector class.
void WrapMemoryWrite(Memory< real_t > &mem)
Replace the HypreParVector's data with the given Memory, mem, and prepare the vector for write access...
void HypreRead() const
Prepare the HypreParVector for read access in hypre's device memory space, HYPRE_MEMORY_DEVICE.
HypreParVector CreateCompatibleVector() const
Constructs a HypreParVector compatible with the calling vector.
hypre_ParVector * StealParVector()
Changes the ownership of the vector.
void WrapMemoryReadWrite(Memory< real_t > &mem)
Replace the HypreParVector's data with the given Memory, mem, and prepare the vector for read and wri...
~HypreParVector()
Calls hypre's destroy function.
void WrapHypreParVector(hypre_ParVector *y, bool owner=true)
Converts hypre's format to HypreParVector.
HYPRE_Int Randomize(HYPRE_Int seed)
Set random values.
const HYPRE_BigInt * Partitioning() const
Returns the parallel row/column partitioning.
void HypreReadWrite()
Prepare the HypreParVector for read and write access in hypre's device memory space,...
MPI_Comm GetComm() const
MPI communicator.
HYPRE_BigInt GlobalSize() const
Returns the global number of rows.
void HypreWrite()
Prepare the HypreParVector for write access in hypre's device memory space, HYPRE_MEMORY_DEVICE.
HypreParVector()
Default constructor, no underlying hypre_ParVector is created.
void WrapMemoryRead(const Memory< real_t > &mem)
Replace the HypreParVector's data with the given Memory, mem, and prepare the vector for read access ...
MFEM_DEPRECATED HYPRE_BigInt * Partitioning()
Returns a non-const pointer to the parallel row/column partitioning. Deprecated in favor of HypreParV...
void Print(const char *fname) const
Prints the locally owned rows in parallel.
HypreParVector & operator=(real_t d)
Set constant values.
void SetData(real_t *data_)
Sets the data of the Vector and the hypre_ParVector to data_.
int GetOwnership() const
Gets ownership of the internal hypre_ParVector.
Vector * GlobalVector() const
Returns the global vector in each processor.
void Read(MPI_Comm comm, const char *fname)
Reads a HypreParVector from files saved with HypreParVector::Print.
void SetOwnership(int own)
Sets ownership of the internal hypre_ParVector.
The ParaSails preconditioner in hypre.
void SetReuse(int reuse)
Set the pattern reuse parameter.
virtual HYPRE_PtrToParSolverFcn SolveFcn() const
hypre's internal Solve function
virtual void SetOperator(const Operator &op)
Set/update the solver for the given operator.
void SetSymmetry(int sym)
Set symmetry parameter.
virtual HYPRE_PtrToParSolverFcn SetupFcn() const
hypre's internal Setup function
void SetParams(real_t thresh, int nlevels)
Set the threshold and levels parameters.
void SetLoadBal(real_t loadbal)
Set the load balance parameter.
HypreParaSails(MPI_Comm comm)
void SetFilter(real_t filter)
Set the filter parameter.
void SetLogging(int logging)
Set the logging parameter.
virtual ~HypreParaSails()
Parallel smoothers in hypre.
int eig_est_cg_iter
Number of CG iterations to determine eigenvalue estimates.
int poly_order
Order of the smoothing polynomial.
void SetPolyOptions(int poly_order, real_t poly_fraction, int eig_est_cg_iter=10)
Set parameters for polynomial smoothing.
void SetOperatorSymmetry(bool is_sym)
void SetFIRCoefficients(real_t max_eig)
Compute window and Chebyshev coefficients for given polynomial order.
void SetWindowParameters(real_t a, real_t b, real_t c)
Set parameters for windowing function for FIR smoother.
real_t poly_fraction
Fraction of spectrum to smooth for polynomial relaxation.
HypreParVector * V
Temporary vectors.
HypreParMatrix * A
The linear system matrix.
real_t * fir_coeffs
Combined coefficients for windowing and Chebyshev polynomials.
int relax_times
Number of relaxation sweeps.
void SetWindowByName(const char *window_name)
Convenience function for setting canonical windowing parameters.
virtual void SetOperator(const Operator &op)
virtual void Mult(const HypreParVector &b, HypreParVector &x) const
Relax the linear system Ax=b.
real_t * l1_norms
l1 norms of the rows of A
void SetPositiveDiagonal(bool pos=true)
After computing l1-norms, replace them with their absolute values.
real_t max_eig_est
Maximal eigenvalue estimate for polynomial smoothing.
void SetTaubinOptions(real_t lambda, real_t mu, int iter)
Set parameters for Taubin's lambda-mu method.
bool pos_l1_norms
If set, take absolute values of the computed l1_norms.
real_t window_params[3]
Parameters for windowing function of FIR filter.
virtual void MultTranspose(const Vector &b, Vector &x) const
Apply transpose of the smoother to relax the linear system Ax=b.
static MFEM_DEPRECATED constexpr Type default_type
real_t omega
SOR parameter (usually in (0,2))
int poly_scale
Apply the polynomial smoother to A or D^{-1/2} A D^{-1/2}.
HypreParVector * B
Right-hand side and solution vectors.
real_t relax_weight
Damping coefficient (usually <= 1)
real_t min_eig_est
Minimal eigenvalue estimate for polynomial smoothing.
void SetSOROptions(real_t relax_weight, real_t omega)
Set SOR-related parameters.
void SetType(HypreSmoother::Type type, int relax_times=1)
Set the relaxation type and number of sweeps.
Type
HYPRE smoother types.
@ lumpedJacobi
lumped Jacobi
@ l1GS
l1-scaled block Gauss-Seidel/SSOR
@ FIR
FIR polynomial smoother.
@ l1GStr
truncated l1-scaled block Gauss-Seidel/SSOR
@ Taubin
Taubin polynomial smoother.
@ l1Jacobi
l1-scaled Jacobi
real_t lambda
Taubin's lambda-mu method parameters.
Memory< real_t > auxB
Auxiliary buffers for the case when the input or output arrays in methods like Mult(const Vector &,...
bool A_is_symmetric
A flag that indicates whether the linear system matrix A is symmetric.
HypreParVector * X0
FIR Filter Temporary Vectors.
static Type DefaultType()
Default value for the smoother type used by the constructors: Type::l1GS when HYPRE is running on CPU...
Abstract class for hypre's solvers and preconditioners.
const HypreParMatrix * A
The linear system matrix.
int setup_called
Was hypre's Setup function called already?
ErrorMode
How to treat errors returned by hypre function calls.
@ WARN_HYPRE_ERRORS
Issue warnings on hypre errors.
@ IGNORE_HYPRE_ERRORS
Ignore hypre errors (see e.g. HypreADS)
@ ABORT_HYPRE_ERRORS
Abort on hypre errors (default in base class)
virtual HYPRE_PtrToParSolverFcn SolveFcn() const =0
hypre's internal Solve function
HypreParVector * B
Right-hand side and solution vector.
bool WrapVectors(const Vector &b, Vector &x) const
Makes the internal HypreParVectors B and X wrap the input vectors b and x.
void SetErrorMode(ErrorMode err_mode) const
Set the behavior for treating hypre errors, see the ErrorMode enum. The default mode in the base clas...
virtual MemoryClass GetMemoryClass() const
Return the MemoryClass preferred by the Operator.
virtual void Mult(const HypreParVector &b, HypreParVector &x) const
Solve the linear system Ax=b.
ErrorMode error_mode
How to treat hypre errors.
virtual void SetOperator(const Operator &op)
Set/update the solver for the given operator.
virtual void Setup(const HypreParVector &b, HypreParVector &x) const
Set up the solver (if not set up already, also called automatically by HypreSolver::Mult).
virtual HYPRE_PtrToParSolverFcn SetupFcn() const =0
hypre's internal Setup function
const HypreParMatrix * GetData() const
virtual HYPRE_PtrToParSolverFcn SetupFcn() const
hypre's internal Setup function
virtual HYPRE_PtrToParSolverFcn SolveFcn() const
hypre's internal Solve function
MFEM_DEPRECATED HypreParMatrix * GetData()
Deprecated. Use HypreTriSolve::GetData() const instead.
HypreTriSolve(const HypreParMatrix &A)
A simple singleton class for hypre's global settings, that 1) calls HYPRE_Init() and sets some GPU-re...
static void InitDevice()
Configure HYPRE's compute and memory policy.
static void Init()
Initialize hypre by calling HYPRE_Init() and set default options. After calling Hypre::Init(),...
static bool configure_runtime_policy_from_mfem
Use MFEM's device policy to configure HYPRE's device policy, true by default. This variable is used b...
static void Finalize()
Finalize hypre (called automatically at program exit if Hypre::Init() has been called).
A class to initialize the size of a Tensor.
Class used by MFEM to store pointers to host and/or device memory.
virtual void Mult(const Vector &x, Vector &y) const =0
Operator application: y=A(x).
DiagonalPolicy
Defines operator diagonal policy upon elimination of rows and/or columns.
Type
Enumeration defining IDs for some classes derived from Operator.
@ Hypre_ParCSR
ID for class HypreParMatrix.
virtual void MultTranspose(const Vector &x, Vector &y) const
Action of the transpose operator: y=A^t(x). The default behavior in class Operator is to generate an ...
Abstract parallel finite element space.
bool iterative_mode
If true, use the second argument of Mult() as an initial guess.
virtual const real_t * Read(bool on_dev=true) const
Shortcut for mfem::Read(vec.GetMemory(), vec.Size(), on_dev).
real_t proj(GridFunction &psi, real_t target_volume, real_t tol=1e-12, int max_its=10)
Bregman projection of ρ = sigmoid(ψ) onto the subspace ∫_Ω ρ dx = θ vol(Ω) as follows:
MemoryType GetHypreMemoryType()
The MemoryType used by MFEM when allocating arrays for Hypre objects.
const T * Read(const Memory< T > &mem, int size, bool on_dev=true)
Get a pointer for read access to mem with the mfem::Device's DeviceMemoryClass, if on_dev = true,...
real_t ParNormlp(const Vector &vec, real_t p, MPI_Comm comm)
Compute the l_p norm of the Vector which is split without overlap across the given communicator.
void mfem_error(const char *msg)
T * Write(Memory< T > &mem, int size, bool on_dev=true)
Get a pointer for write access to mem with the mfem::Device's DeviceMemoryClass, if on_dev = true,...
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
HypreParMatrix * DiscreteGrad(ParFiniteElementSpace *edge_fespace, ParFiniteElementSpace *vert_fespace)
Compute the discrete gradient matrix between the nodal linear and ND1 spaces.
real_t InnerProduct(HypreParVector *x, HypreParVector *y)
MemoryClass
Memory classes identify sets of memory types.
@ MANAGED
Memory types: { MANAGED }.
MemoryClass GetHypreMemoryClass()
The MemoryClass used by Hypre objects.
T * ReadWrite(Memory< T > &mem, int size, bool on_dev=true)
Get a pointer for read+write access to mem with the mfem::Device's DeviceMemoryClass,...
void RAP(const DenseMatrix &A, const DenseMatrix &P, DenseMatrix &RAP)
HypreParMatrix * DiscreteCurl(ParFiniteElementSpace *face_fespace, ParFiniteElementSpace *edge_fespace)
Compute the discrete curl matrix between the ND1 and RT0 spaces.
HypreParMatrix * HypreParMatrixFromBlocks(Array2D< const HypreParMatrix * > &blocks, Array2D< real_t > *blockCoeff)
Returns a merged hypre matrix constructed from hypre matrix blocks.
HypreParMatrix * ParAdd(const HypreParMatrix *A, const HypreParMatrix *B)
Returns the matrix A + B.
void HypreStealOwnership(HypreParMatrix &A_hyp, SparseMatrix &A_diag)
Make A_hyp steal ownership of its diagonal part A_diag.
HypreParMatrix * ParMult(const HypreParMatrix *A, const HypreParMatrix *B, bool own_matrix)
int to_int(const std::string &str)
Convert a string to an int.
bool HypreUsingGPU()
Return true if HYPRE is configured to use GPU.
void BlockInverseScale(const HypreParMatrix *A, HypreParMatrix *C, const Vector *b, HypreParVector *d, int blocksize, BlockInverseScaleJob job)
MemoryType
Memory types supported by MFEM.
@ DEVICE
Device memory; using CUDA or HIP *Malloc and *Free.
void EliminateBC(const HypreParMatrix &A, const HypreParMatrix &Ae, const Array< int > &ess_dof_list, const Vector &X, Vector &B)
Eliminate essential BC specified by ess_dof_list from the solution X to the r.h.s....
HYPRE_MemoryLocation GetHypreMemoryLocation()
Return the configured HYPRE_MemoryLocation.
void Add(const DenseMatrix &A, const DenseMatrix &B, real_t alpha, DenseMatrix &C)
C = A + alpha*B.
real_t p(const Vector &x, real_t t)