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;
124 static void SetDefaultOptions();
127 static Hypre &Instance()
133 enum class State { UNINITIALIZED, INITIALIZED };
143template <
typename int_type>
144inline int to_int(int_type i)
146 MFEM_ASSERT(int_type(
int(i)) == i,
"overflow converting int_type to int");
151template <>
inline int to_int(
int i) {
return i; }
156inline int to_int(HYPRE_Int i)
158 MFEM_ASSERT(HYPRE_Int(
int(i)) == i,
"overflow converting HYPRE_Int to int");
169#if !defined(HYPRE_USING_GPU)
171#elif MFEM_HYPRE_VERSION < 23100
172#if defined(HYPRE_USING_UNIFIED_MEMORY)
183#if defined(HYPRE_USING_UNIFIED_MEMORY)
194#if !defined(HYPRE_USING_GPU)
196#elif MFEM_HYPRE_VERSION < 23100
197#if defined(HYPRE_USING_UNIFIED_MEMORY)
208#if defined(HYPRE_USING_UNIFIED_MEMORY)
229 inline void _SetDataAndSize_();
236 own_ParVector =
false;
305 operator hypre_ParVector*()
const {
return x; }
306#ifndef HYPRE_PAR_VECTOR_STRUCT
308 operator HYPRE_ParVector()
const {
return (HYPRE_ParVector) x; }
387 void Print(
const std::string &fname)
const;
390 void Read(MPI_Comm comm,
const std::string &fname);
411 hypre_ParCSRMatrix *A;
438 signed char diagOwner, offdOwner, colMapOwner;
441 signed char ParCSROwner;
454 void Write(
MemoryClass mc,
bool set_diag =
true,
bool set_offd =
true);
462 hypre_CSRMatrix *hypre_csr,
468 static signed char CopyBoolCSR(
Table *bool_csr,
470 hypre_CSRMatrix *hypre_csr);
477 static signed char HypreCsrToMem(hypre_CSRMatrix *h_mat,
MemoryType h_mat_mt,
531 bool own_diag_offd =
false);
546 HYPRE_Int *diag_i, HYPRE_Int *diag_j,
real_t *diag_data,
547 HYPRE_Int *offd_i, HYPRE_Int *offd_j,
real_t *offd_data,
548 HYPRE_Int offd_num_cols,
550 bool hypre_arrays =
false);
575 HYPRE_Int *i_diag, HYPRE_Int *j_diag, HYPRE_Int *i_offd,
577 HYPRE_Int cmap_size);
601 operator hypre_ParCSRMatrix*()
const {
return A; }
602#ifndef HYPRE_PAR_CSR_MATRIX_STRUCT
604 operator HYPRE_ParCSRMatrix() {
return (HYPRE_ParCSRMatrix) A; }
610 void SetOwnerFlags(
signed char diag,
signed char offd,
signed char colmap);
671 bool interleaved_rows =
false,
672 bool interleaved_cols =
false)
const;
679#if MFEM_HYPRE_VERSION >= 21800
681 real_t threshold=0.0)
const;
687 return internal::to_int(
688 hypre_CSRMatrixNumRows(hypre_ParCSRMatrixDiag(A)));
694 return internal::to_int(
695 hypre_CSRMatrixNumCols(hypre_ParCSRMatrixDiag(A)));
700 {
return hypre_ParCSRMatrixGlobalNumRows(A); }
704 {
return hypre_ParCSRMatrixGlobalNumCols(A); }
740 HYPRE_Int
Mult(HYPRE_ParVector x, HYPRE_ParVector y,
759 {
Mult(1.0, x, 0.0, y); }
769 {
Mult(
a, x, 1.0, y); }
771 const real_t a = 1.0)
const override
790 internal::hypre_ParCSRMatrixBooleanMatvec(A,
alpha,
const_cast<int*
>(x),
800 internal::hypre_ParCSRMatrixBooleanMatvecT(A,
alpha,
const_cast<int*
>(x),
808#if MFEM_HYPRE_VERSION < 22200
809 internal::hypre_ParCSRMatrixSetConstantValues(A, value);
811 hypre_ParCSRMatrixSetConstantValues(A, value);
829 MFEM_VERIFY(internal::hypre_ParCSRMatrixSum(A,
beta, B.A) == 0,
830 "error in hypre_ParCSRMatrixSum");
944 void Print(
const std::string &fname, HYPRE_Int offi = 0,
945 HYPRE_Int offj = 0)
const;
947 void Read(MPI_Comm comm,
const std::string &fname);
983#if MFEM_HYPRE_VERSION >= 21800
996 const Vector *
b, HypreParVector *d,
1008HypreParMatrix *
ParMult(
const HypreParMatrix *A,
const HypreParMatrix *B,
1009 bool own_matrix =
false);
1013HypreParMatrix *
ParAdd(
const HypreParMatrix *A,
const HypreParMatrix *B);
1016HypreParMatrix *
RAP(
const HypreParMatrix *A,
const HypreParMatrix *P);
1018HypreParMatrix *
RAP(
const HypreParMatrix * Rt,
const HypreParMatrix *A,
1019 const HypreParMatrix *P);
1030 Array2D<real_t> *blockCoeff=NULL);
1033 Array2D<HypreParMatrix*> &blocks,
1034 Array2D<real_t> *blockCoeff=NULL);
1040void EliminateBC(
const HypreParMatrix &A,
const HypreParMatrix &Ae,
1041 const Array<int> &ess_dof_list,
const Vector &X, Vector &B);
1119#if !defined(HYPRE_USING_GPU)
1225 virtual operator HYPRE_Solver()
const = 0;
1244 {
mfem_error(
"HypreSolvers do not support SetOperator!"); }
1273#if MFEM_HYPRE_VERSION >= 21800
1282 operator HYPRE_Solver()
const override {
return NULL; }
1285 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ParCSROnProcTriSetup; }
1287 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ParCSROnProcTriSolve; }
1303 HYPRE_Solver pcg_solver;
1337 HYPRE_ParCSRPCGGetNumIterations(pcg_solver, &num_it);
1338 num_iterations = internal::to_int(num_it);
1343 HYPRE_ParCSRPCGGetFinalRelativeResidualNorm(pcg_solver,
1348 operator HYPRE_Solver()
const override {
return pcg_solver; }
1352 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ParCSRPCGSetup; }
1355 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ParCSRPCGSolve; }
1368 HYPRE_Solver gmres_solver;
1373 void SetDefaultOptions();
1401 HYPRE_ParCSRGMRESGetNumIterations(gmres_solver, &num_it);
1402 num_iterations = internal::to_int(num_it);
1407 HYPRE_ParCSRGMRESGetFinalRelativeResidualNorm(gmres_solver,
1412 operator HYPRE_Solver()
const override {
return gmres_solver; }
1416 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ParCSRGMRESSetup; }
1419 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ParCSRGMRESSolve; }
1432 HYPRE_Solver fgmres_solver;
1437 void SetDefaultOptions();
1464 HYPRE_ParCSRFlexGMRESGetNumIterations(fgmres_solver, &num_it);
1465 num_iterations = internal::to_int(num_it);
1470 HYPRE_ParCSRFlexGMRESGetFinalRelativeResidualNorm(fgmres_solver,
1475 operator HYPRE_Solver()
const override {
return fgmres_solver; }
1479 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ParCSRFlexGMRESSetup; }
1482 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ParCSRFlexGMRESSolve; }
1495 operator HYPRE_Solver()
const override {
return NULL; }
1498 {
return (HYPRE_PtrToParSolverFcn) hypre_ParKrylovIdentitySetup; }
1500 {
return (HYPRE_PtrToParSolverFcn) hypre_ParKrylovIdentity; }
1511 operator HYPRE_Solver()
const override {
return NULL; }
1516 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ParCSRDiagScaleSetup; }
1518 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ParCSRDiagScale; }
1533 HYPRE_Solver sai_precond;
1536 void SetDefaultOptions();
1541 void ResetSAIPrecond(MPI_Comm comm);
1599 operator HYPRE_Solver()
const override {
return sai_precond; }
1602 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ParaSailsSetup; }
1604 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ParaSailsSolve; }
1620 HYPRE_Solver euc_precond;
1623 void SetDefaultOptions();
1628 void ResetEuclidPrecond(MPI_Comm comm);
1644 operator HYPRE_Solver()
const override {
return euc_precond; }
1647 {
return (HYPRE_PtrToParSolverFcn) HYPRE_EuclidSetup; }
1649 {
return (HYPRE_PtrToParSolverFcn) HYPRE_EuclidSolve; }
1654#if MFEM_HYPRE_VERSION >= 21900
1672 HYPRE_Solver ilu_precond;
1675 void SetDefaultOptions();
1681 void ResetILUPrecond();
1692 void SetType(HYPRE_Int ilu_type);
1694 void SetTol(HYPRE_Real tol);
1701 operator HYPRE_Solver()
const override {
return ilu_precond; }
1707 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ILUSetup; }
1711 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ILUSolve; }
1719 HYPRE_Solver amg_precond;
1728 void RecomputeRBMs();
1731 void SetDefaultOptions();
1736 void ResetAMGPrecond();
1755 bool interp_refine =
true);
1757#if MFEM_HYPRE_VERSION >= 21800
1767 const std::string &postrelax=
"FFC");
1771 { HYPRE_BoomerAMGSetStrongThresholdR(amg_precond, strengthR); }
1775 { HYPRE_BoomerAMGSetFilterThresholdR(amg_precond, filterR); }
1779 { HYPRE_BoomerAMGSetRestriction(amg_precond, restrict_type); }
1783 { HYPRE_BoomerAMGSetIsTriangular(amg_precond, 1); }
1787 { HYPRE_BoomerAMGSetGMRESSwitchR(amg_precond, gmres_switch); }
1792 HYPRE_BoomerAMGSetCycleNumSweeps(amg_precond, prerelax, 1);
1793 HYPRE_BoomerAMGSetCycleNumSweeps(amg_precond, postrelax, 2);
1798 { HYPRE_BoomerAMGSetPrintLevel(amg_precond, print_level); }
1801 { HYPRE_BoomerAMGSetMaxIter(amg_precond, max_iter); }
1805 { HYPRE_BoomerAMGSetMaxLevels(amg_precond, max_levels); }
1809 { HYPRE_BoomerAMGSetTol(amg_precond, tol); }
1813 { HYPRE_BoomerAMGSetStrongThreshold(amg_precond, strength); }
1817 { HYPRE_BoomerAMGSetInterpType(amg_precond, interp_type); }
1821 { HYPRE_BoomerAMGSetCoarsenType(amg_precond, coarsen_type); }
1825 { HYPRE_BoomerAMGSetRelaxType(amg_precond, relax_type); }
1829 { HYPRE_BoomerAMGSetCycleType(amg_precond, cycle_type); }
1834 HYPRE_BoomerAMGGetNumIterations(amg_precond, &num_it);
1835 num_iterations = internal::to_int(num_it);
1841 HYPRE_BoomerAMGSetNumFunctions(amg_precond, blocksize);
1842 HYPRE_BoomerAMGSetNodal(amg_precond, 1);
1847 { HYPRE_BoomerAMGSetAggNumLevels(amg_precond, num_levels); }
1850 operator HYPRE_Solver()
const override {
return amg_precond; }
1853 {
return (HYPRE_PtrToParSolverFcn) HYPRE_BoomerAMGSetup; }
1855 {
return (HYPRE_PtrToParSolverFcn) HYPRE_BoomerAMGSolve; }
1878 void MakeSolver(
int sdim,
int cycle_type);
1887 void ResetAMSPrecond();
1899 int ams_cycle_type = 0;
1903 bool singular =
false;
1905 int print_level = 1;
1931 HYPRE_AMSSetBetaPoissonMatrix(ams, NULL);
1936 operator HYPRE_Solver()
const override {
return ams; }
1939 {
return (HYPRE_PtrToParSolverFcn) HYPRE_AMSSetup; }
1941 {
return (HYPRE_PtrToParSolverFcn) HYPRE_AMSSolve; }
1975 const int cycle_type = 11;
1977 const int ams_cycle_type = 14;
1979 int print_level = 1;
1983 void ResetADSPrecond();
2003 operator HYPRE_Solver()
const override {
return ads; }
2006 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ADSSetup; }
2008 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ADSSolve; }
2048 HYPRE_Solver lobpcg_solver;
2051 mv_InterfaceInterpreter interpreter;
2054 HYPRE_MatvecFunctions matvec_fn;
2060 class HypreMultiVector;
2063 HypreMultiVector * multi_vec;
2072 class HypreMultiVector
2076 mv_MultiVectorPtr mv_ptr;
2086 mv_InterfaceInterpreter & interpreter);
2087 ~HypreMultiVector();
2090 void Randomize(HYPRE_Int seed);
2098 operator mv_MultiVectorPtr()
const {
return mv_ptr; }
2100 mv_MultiVectorPtr & GetMultiVector() {
return mv_ptr; }
2103 static void * OperatorMatvecCreate(
void *A,
void *x );
2104 static HYPRE_Int OperatorMatvec(
void *matvec_data,
2105 HYPRE_Complex
alpha,
2110 static HYPRE_Int OperatorMatvecDestroy(
void *matvec_data );
2112 static HYPRE_Int PrecondSolve(
void *solver,
2116 static HYPRE_Int PrecondSetup(
void *solver,
2184 HYPRE_Solver ame_solver;
2190 HYPRE_Real * eigenvalues;
2193 HYPRE_ParVector * multi_vec;
2198 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.
void SetOperator(const Operator &op) override
Set/update the solver for the given operator.
HypreADS(ParFiniteElementSpace *face_fespace)
HYPRE_PtrToParSolverFcn SetupFcn() const override
hypre's internal Setup function
HYPRE_PtrToParSolverFcn SolveFcn() const override
hypre's internal Solve 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.
void SetOperator(const Operator &op) override
Set/update the solver for the given operator.
HypreAMS(ParFiniteElementSpace *edge_fespace)
Construct the AMS solver on the given edge finite element space.
void SetPrintLevel(int print_lvl)
HYPRE_PtrToParSolverFcn SolveFcn() const override
hypre's internal Solve function
void SetSingularProblem()
Set this option when solving a curl-curl problem with zero mass term.
HYPRE_PtrToParSolverFcn SetupFcn() const override
hypre's internal Setup function
The BoomerAMG solver in hypre.
void SetAggressiveCoarsening(int num_levels)
Expert option - consult hypre documentation/team.
void GetNumIterations(int &num_iterations) const
void SetInterpolation(int interp_type)
Expert option - consult hypre documentation/team.
void SetCycleNumSweeps(int prerelax, int postrelax)
Expert option - consult hypre documentation/team.
HYPRE_PtrToParSolverFcn SolveFcn() const override
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.
void SetOperator(const Operator &op) override
Set/update the solver for the given operator.
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)
HYPRE_PtrToParSolverFcn SetupFcn() const override
hypre's internal Setup function
Jacobi preconditioner in hypre.
HypreDiagScale(const HypreParMatrix &A)
const HypreParMatrix * GetData() const
MFEM_DEPRECATED HypreParMatrix * GetData()
Deprecated. Use HypreDiagScale::GetData() const instead.
void SetOperator(const Operator &op) override
Set/update the solver for the given operator.
HYPRE_PtrToParSolverFcn SolveFcn() const override
hypre's internal Solve function
HYPRE_PtrToParSolverFcn SetupFcn() const override
hypre's internal Setup function
virtual ~HypreDiagScale()
HYPRE_PtrToParSolverFcn SetupFcn() const override
hypre's internal Setup function
HYPRE_PtrToParSolverFcn SolveFcn() const override
hypre's internal Solve function
HypreEuclid(MPI_Comm comm)
void SetOperator(const Operator &op) override
Set/update the solver for the given operator.
void SetRowScale(int row_scale)
Flexible GMRES solver in hypre.
void SetMaxIter(int max_iter)
HYPRE_PtrToParSolverFcn SetupFcn() const override
FGMRES Setup function.
MFEM_DEPRECATED void SetZeroInintialIterate()
deprecated: use SetZeroInitialIterate()
HypreFGMRES(MPI_Comm comm)
HYPRE_PtrToParSolverFcn SolveFcn() const override
FGMRES Solve function.
void SetOperator(const Operator &op) override
Set/update the solver for the given operator.
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 Mult(const HypreParVector &b, HypreParVector &x) const override
Solve Ax=b with hypre's FGMRES.
void GetFinalResidualNorm(real_t &final_res_norm) const
void SetLogging(int logging)
void GetNumIterations(int &num_iterations) const
void SetOperator(const Operator &op) override
Set/update the solver for the given operator.
HYPRE_PtrToParSolverFcn SolveFcn() const override
GMRES Solve function.
void GetFinalResidualNorm(real_t &final_res_norm) const
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)
void Mult(const HypreParVector &b, HypreParVector &x) const override
Solve Ax=b with hypre's GMRES.
HypreGMRES(MPI_Comm comm)
void SetAbsTol(real_t tol)
HYPRE_PtrToParSolverFcn SetupFcn() const override
GMRES Setup function.
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.
HYPRE_PtrToParSolverFcn SolveFcn() const override
ILU Solve function.
void SetType(HYPRE_Int ilu_type)
void SetLocalReordering(HYPRE_Int reorder_type)
void SetMaxIter(HYPRE_Int max_iter)
void SetLevelOfFill(HYPRE_Int lev_fill)
Set the fill level for ILU(k); the default is k=1.
void SetOperator(const Operator &op) override
Set/update the solver for the given operator.
void SetTol(HYPRE_Real tol)
HYPRE_PtrToParSolverFcn SetupFcn() const override
ILU Setup function.
void SetPrintLevel(HYPRE_Int print_level)
Set the print level: 0 = none, 1 = setup, 2 = solve, 3 = setup+solve.
The identity operator as a hypre solver.
HYPRE_PtrToParSolverFcn SolveFcn() const override
hypre's internal Solve function
HYPRE_PtrToParSolverFcn SetupFcn() const override
hypre's internal Setup 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.
void Mult(const HypreParVector &b, HypreParVector &x) const override
Solve Ax=b with hypre's PCG.
HYPRE_PtrToParSolverFcn SolveFcn() const override
PCG Solve function.
MFEM_DEPRECATED void SetZeroInintialIterate()
deprecated: use SetZeroInitialIterate()
void GetNumIterations(int &num_iterations) const
void SetResidualConvergenceOptions(int res_frequency=-1, real_t rtol=0.0)
void SetZeroInitialIterate()
non-hypre setting
void SetPrintLevel(int print_lvl)
HYPRE_PtrToParSolverFcn SetupFcn() const override
PCG Setup function.
void SetLogging(int logging)
void SetPreconditioner(HypreSolver &precond)
Set the hypre solver to be used as a preconditioner.
void SetMaxIter(int max_iter)
void GetFinalResidualNorm(real_t &final_res_norm) const
void SetOperator(const Operator &op) override
Set/update the solver for the given operator.
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 Print(const std::string &fname, HYPRE_Int offi=0, HYPRE_Int offj=0) const
Prints the locally owned rows in parallel. The resulting files can be read with Read_IJMatrix().
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.
void Read_IJMatrix(MPI_Comm comm, const std::string &fname)
Read a matrix saved as a HYPRE_IJMatrix.
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'.
real_t FNorm() const
Return the Frobenius norm of the matrix (or 0 if the underlying hypre matrix is NULL)
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...
HypreParMatrix * EliminateCols(const Array< int > &cols)
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.
void Read(MPI_Comm comm, const std::string &fname)
Reads a HypreParVector from files saved with HypreParVector::Print.
HypreParVector CreateCompatibleVector() const
Constructs a HypreParVector compatible with the calling vector.
void Print(const std::string &fname) const
Prints the locally owned rows in parallel.
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...
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 SetOwnership(int own)
Sets ownership of the internal hypre_ParVector.
The ParaSails preconditioner in hypre.
void SetReuse(int reuse)
Set the pattern reuse parameter.
HYPRE_PtrToParSolverFcn SetupFcn() const override
hypre's internal Setup function
void SetOperator(const Operator &op) override
Set/update the solver for the given operator.
void SetSymmetry(int sym)
Set symmetry parameter.
HYPRE_PtrToParSolverFcn SolveFcn() const override
hypre's internal Solve 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.
void MultTranspose(const Vector &b, Vector &x) const override
Apply transpose of the smoother to relax the linear system Ax=b.
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 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 SetOperator(const Operator &op) override
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.
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.
MemoryClass GetMemoryClass() const override
Return the MemoryClass preferred by the Operator.
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 void Mult(const HypreParVector &b, HypreParVector &x) const
Solve the linear system Ax=b.
ErrorMode error_mode
How to treat hypre errors.
void SetOperator(const Operator &op) override
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
HYPRE_PtrToParSolverFcn SolveFcn() const override
hypre's internal Solve function
MFEM_DEPRECATED HypreParMatrix * GetData()
Deprecated. Use HypreTriSolve::GetData() const instead.
HypreTriSolve(const HypreParMatrix &A)
HYPRE_PtrToParSolverFcn SetupFcn() const override
hypre's internal Setup function
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)