15 #include "../config/config.hpp"
26 #include "_hypre_parcsr_mv.h"
27 #include "_hypre_parcsr_ls.h"
34 class ParFiniteElementSpace;
54 HypreParVector(MPI_Comm comm,
int glob_size,
double *_data,
int *col);
65 operator hypre_ParVector*()
const;
66 #ifndef HYPRE_PAR_VECTOR_STRUCT
67 operator HYPRE_ParVector()
const;
91 void Print(
const char *fname);
98 double InnerProduct(HypreParVector &x, HypreParVector &y);
99 double InnerProduct(HypreParVector *x, HypreParVector *y);
107 hypre_ParCSRMatrix *A;
110 hypre_ParCSRCommPkg *CommPkg;
124 HypreParMatrix(MPI_Comm comm,
int global_num_rows,
int global_num_cols,
127 HypreParMatrix(MPI_Comm comm,
int global_num_rows,
int global_num_cols,
128 int *row_starts,
int *col_starts,
136 HypreParMatrix(MPI_Comm comm,
int global_num_rows,
int global_num_cols,
137 int *row_starts,
int *col_starts,
Table *diag);
140 int *i_diag,
int *j_diag,
int *i_offd,
int *j_offd,
141 int *cmap,
int cmap_size);
147 HypreParMatrix(MPI_Comm comm,
int nrows,
int glob_nrows,
int glob_ncols,
148 int *I,
int *J,
double *data,
int *rows,
int *cols);
151 void SetCommPkg(hypre_ParCSRCommPkg *comm_pkg);
159 operator hypre_ParCSRMatrix*();
160 #ifndef HYPRE_PAR_CSR_MATRIX_STRUCT
161 operator HYPRE_ParCSRMatrix();
168 inline int NNZ() {
return A->num_nonzeros; }
170 inline int *
RowPart() {
return A->row_starts; }
172 inline int *
ColPart() {
return A->col_starts; }
174 inline int M() {
return A -> global_num_rows; }
176 inline int N() {
return A -> global_num_cols; }
185 {
return hypre_CSRMatrixNumRows(hypre_ParCSRMatrixDiag(A)); }
189 {
return hypre_CSRMatrixNumCols(hypre_ParCSRMatrixDiag(A)); }
201 double alpha = 1.0,
double beta = 0.0);
203 int Mult(HYPRE_ParVector x, HYPRE_ParVector y,
204 double alpha = 1.0,
double beta = 0.0);
207 double alpha = 1.0,
double beta = 0.0);
213 {
Mult(1.0, x, 0.0, y); }
225 void Print(
const char *fname,
int offi = 0,
int offj = 0);
227 void Read(MPI_Comm comm,
const char *fname);
234 HypreParMatrix *
ParMult(HypreParMatrix *A, HypreParMatrix *B);
237 HypreParMatrix *
RAP(HypreParMatrix *A, HypreParMatrix *P);
239 HypreParMatrix *
RAP(HypreParMatrix * Rt, HypreParMatrix *A, HypreParMatrix *P);
244 void EliminateBC(HypreParMatrix &A, HypreParMatrix &Ae,
245 Array<int> &ess_dof_list,
246 HypreParVector &x, HypreParVector &b);
363 virtual operator HYPRE_Solver()
const = 0;
366 virtual HYPRE_PtrToParSolverFcn
SetupFcn()
const = 0;
368 virtual HYPRE_PtrToParSolverFcn
SolveFcn()
const = 0;
371 {
mfem_error(
"HypreSolvers do not support SetOperator!"); }
385 HYPRE_Solver pcg_solver;
407 { HYPRE_ParCSRPCGGetNumIterations(pcg_solver, &num_iterations); }
410 virtual operator HYPRE_Solver()
const {
return pcg_solver; }
414 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ParCSRPCGSetup; }
417 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ParCSRPCGSolve; }
431 HYPRE_Solver gmres_solver;
449 virtual operator HYPRE_Solver()
const {
return gmres_solver; }
453 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ParCSRGMRESSetup; }
456 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ParCSRGMRESSolve; }
469 virtual operator HYPRE_Solver()
const {
return NULL; }
472 {
return (HYPRE_PtrToParSolverFcn) hypre_ParKrylovIdentitySetup; }
474 {
return (HYPRE_PtrToParSolverFcn) hypre_ParKrylovIdentity; }
485 virtual operator HYPRE_Solver()
const {
return NULL; }
488 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ParCSRDiagScaleSetup; }
490 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ParCSRDiagScale; }
500 HYPRE_Solver sai_precond;
508 virtual operator HYPRE_Solver()
const {
return sai_precond; }
511 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ParaSailsSetup; }
513 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ParaSailsSolve; }
522 HYPRE_Solver amg_precond;
533 { HYPRE_BoomerAMGSetPrintLevel(amg_precond, print_level); }
536 virtual operator HYPRE_Solver()
const {
return amg_precond; }
539 {
return (HYPRE_PtrToParSolverFcn) HYPRE_BoomerAMGSetup; }
541 {
return (HYPRE_PtrToParSolverFcn) HYPRE_BoomerAMGSolve; }
547 HypreParMatrix*
DiscreteGrad(ParFiniteElementSpace *edge_fespace,
548 ParFiniteElementSpace *vert_fespace);
550 HypreParMatrix*
DiscreteCurl(ParFiniteElementSpace *face_fespace,
551 ParFiniteElementSpace *edge_fespace);
570 virtual operator HYPRE_Solver()
const {
return ams; }
573 {
return (HYPRE_PtrToParSolverFcn) HYPRE_AMSSetup; }
575 {
return (HYPRE_PtrToParSolverFcn) HYPRE_AMSSolve; }
601 virtual operator HYPRE_Solver()
const {
return ads; }
604 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ADSSetup; }
606 {
return (HYPRE_PtrToParSolverFcn) HYPRE_ADSSolve; }
613 #endif // MFEM_USE_MPI
virtual ~HypreBoomerAMG()
void SetPreconditioner(HypreSolver &precond)
Set the hypre solver to be used as a preconditioner.
The Auxiliary-space Maxwell Solver in hypre.
HypreParVector * X0
FIR Filter Temporary Vectors.
double min_eig_est
Minimal eigenvalue estimate for polynomial smoothing.
virtual HYPRE_PtrToParSolverFcn SolveFcn() const
hypre's internal Solve function
The Auxiliary-space Divergence Solver in hypre.
int setup_called
Was hypre's Setup function called already?
HypreParVector * B
Right-hand side and solution vector.
HypreDiagScale(HypreParMatrix &A)
double window_params[3]
Paramters for windowing function of FIR filter.
virtual void Mult(const Vector &x, Vector &y) const
Operator application.
virtual HYPRE_PtrToParSolverFcn SolveFcn() const
hypre's internal Solve function
int * ColPart()
Returns the column partitioning.
HypreADS(HypreParMatrix &A, ParFiniteElementSpace *face_fespace)
void SetWindowByName(const char *window_name)
Convenience function for setting canonical windowing parameters.
HypreParMatrix(hypre_ParCSRMatrix *a)
Converts hypre's format to HypreParMatrix.
Abstract parallel finite element space.
bool iterative_mode
If true, use the second argument of Mult as an initial guess.
int M()
Returns the global number of rows.
virtual HYPRE_PtrToParSolverFcn SolveFcn() const
GMRES Solve function.
void Print(const char *fname, int offi=0, int offj=0)
Prints the locally owned rows in parallel.
void SetPrintLevel(int print_lvl)
void ScaleRows(const Vector &s)
Scale the local row i by s(i).
int Mult(HypreParVector &x, HypreParVector &y, double alpha=1.0, double beta=0.0)
Computes y = alpha * A * x + beta * y.
double poly_fraction
Fraction of spectrum to smooth for polynomial relaxation.
void SetPrintLevel(int print_lvl)
HypreParMatrix * DiscreteGrad(ParFiniteElementSpace *edge_fespace, ParFiniteElementSpace *vert_fespace)
Compute the discrete gradient matrix between the nodal linear and ND1 spaces.
int poly_scale
Apply the polynomial smoother to A or D^{-1/2} A D^{-1/2}.
HypreParVector(MPI_Comm comm, int glob_size, int *col)
The identity operator as a hypre solver.
void SetWindowParameters(double a, double b, double c)
Set parameters for windowing function for FIR smoother.
virtual void Mult(const HypreParVector &b, HypreParVector &x) const
Solve Ax=b with hypre's GMRES.
void SetSystemsOptions(int dim)
virtual void Mult(const HypreParVector &b, HypreParVector &x) const
Relax the linear system Ax=b.
hypre_ParVector * StealParVector()
Changes the ownership of the the vector.
The BoomerAMG solver in hypre.
void SetSymmetry(int sym)
virtual void MultTranspose(const Vector &x, Vector &y) const
Action of the transpose operator.
virtual ~HypreParaSails()
The ParaSails preconditioner in hypre.
void Print(const char *fname)
Prints the locally owned rows in parallel.
int MultTranspose(HypreParVector &x, HypreParVector &y, double alpha=1.0, double beta=0.0)
Computes y = alpha * A^t * x + beta * y.
MPI_Comm GetComm()
MPI communicator.
double * l1_norms
l1 norms of the rows of A
int * RowPart()
Returns the row partitioning.
void SetLogging(int logging)
void SetZeroInintialIterate()
non-hypre setting
Jacobi preconditioner in hypre.
HyprePCG(HypreParMatrix &_A)
virtual HYPRE_PtrToParSolverFcn SolveFcn() const =0
hypre's internal Solve function
void SetResidualConvergenceOptions(int res_frequency=-1, double rtol=0.0)
void SetPrintLevel(int print_level)
virtual void Mult(const HypreParVector &b, HypreParVector &x) const
Solve the linear system Ax=b.
HypreParMatrix * RAP(HypreParMatrix *A, HypreParMatrix *P)
Returns the matrix P^t * A * P.
virtual HYPRE_PtrToParSolverFcn SolveFcn() const
PCG Solve function.
int Randomize(int seed)
Set random values.
HypreParMatrix * DiscreteCurl(ParFiniteElementSpace *face_fespace, ParFiniteElementSpace *edge_fespace)
Compute the discrete curl matrix between the ND1 and RT0 spaces.
double relax_weight
Damping coefficient (usually <= 1)
Parallel smoothers in hypre.
virtual HYPRE_PtrToParSolverFcn SetupFcn() const
hypre's internal Setup function
void EliminateBC(HypreParMatrix &A, HypreParMatrix &Ae, Array< int > &ess_dof_list, HypreParVector &x, HypreParVector &b)
virtual HYPRE_PtrToParSolverFcn SetupFcn() const
hypre's internal Setup function
HypreParMatrix * A
The linear system matrix.
HypreAMS(HypreParMatrix &A, ParFiniteElementSpace *edge_fespace)
virtual HYPRE_PtrToParSolverFcn SolveFcn() const
hypre's internal Solve function
virtual void SetOperator(const Operator &op)
virtual HYPRE_PtrToParSolverFcn SetupFcn() const =0
hypre's internal Setup function
void SetLogging(int logging)
virtual HYPRE_PtrToParSolverFcn SetupFcn() const
hypre's internal Setup function
void SetMaxIter(int max_iter)
HypreParMatrix * GetData()
void SetSOROptions(double relax_weight, double omega)
Set SOR-related parameters.
Wrapper for hypre's parallel vector class.
virtual HYPRE_PtrToParSolverFcn SetupFcn() const
hypre's internal Setup function
int N()
Returns the global number of columns.
int * GetColStarts() const
Vector * GlobalVector()
Returns the global vector in each processor.
void mfem_error(const char *msg)
virtual HYPRE_PtrToParSolverFcn SolveFcn() const
hypre's internal Solve function
int GetGlobalNumCols() const
virtual ~HypreDiagScale()
int GetNumRows() const
Returns the number of rows in the diagonal block of the ParCSRMatrix.
virtual void SetOperator(const Operator &op)
Set/update the solver for the given operator.
double max_eig_est
Maximal eigenvalue estimate for polynomial smoothing.
HypreParMatrix * Transpose()
Returns the transpose of *this.
virtual HYPRE_PtrToParSolverFcn SetupFcn() const
hypre's internal Setup function
int NNZ()
Returns the number of nonzeros.
void SetFIRCoefficients(double max_eig)
Compute window and Chebyshev coefficients for given polynomial order.
double * fir_coeffs
Combined coefficients for windowing and Chebyshev polynomials.
double InnerProduct(HypreParVector *x, HypreParVector *y)
int * GetRowStarts() const
void SetData(double *_data)
void InvScaleRows(const Vector &s)
Scale the local row i by 1./s(i)
void SetTaubinOptions(double lambda, double mu, int iter)
Set parameters for Taubin's lambda-mu method.
HypreParVector * B
Right-hand side and solution vectors.
void SetCommPkg(hypre_ParCSRCommPkg *comm_pkg)
void SetZeroInintialIterate()
non-hypre setting
int GetNumCols() const
Returns the number of columns in the diagonal block of the ParCSRMatrix.
void SetPreconditioner(HypreSolver &precond)
Set the hypre solver to be used as a preconditioner.
void SetPolyOptions(int poly_order, double poly_fraction)
Set parameters for polynomial smoothing.
void GetNumIterations(int &num_iterations)
int relax_times
Number of relaxation sweeps.
void operator*=(double s)
Scale all entries by s: A_scaled = s*A.
Abstract class for hypre's solvers and preconditioners.
int GetGlobalNumRows() const
HypreParVector & operator=(double d)
Set constant values.
void GetDiag(Vector &diag)
Get the diagonal of the matrix.
HypreGMRES(HypreParMatrix &_A)
virtual ~HypreParMatrix()
Calls hypre's destroy function.
hypre_ParCSRMatrix * StealData()
Changes the ownership of the the matrix.
HypreParMatrix * A
The linear system matrix.
void SetMaxIter(int max_iter)
double omega
SOR parameter (usually in (0,2))
virtual HYPRE_PtrToParSolverFcn SetupFcn() const
hypre's internal Setup function
virtual HYPRE_PtrToParSolverFcn SetupFcn() const
PCG Setup function.
Wrapper for hypre's ParCSR matrix class.
virtual HYPRE_PtrToParSolverFcn SolveFcn() const
hypre's internal Solve function
~HypreParVector()
Calls hypre's destroy function.
virtual void Mult(const HypreParVector &b, HypreParVector &x) const
Solve Ax=b with hypre's PCG.
void Read(MPI_Comm comm, const char *fname)
Reads the matrix from a file.
HypreParVector * V
Temporary vectors.
void SetType(HypreSmoother::Type type, int relax_times=1)
Set the relaxation type and number of sweeps.
HypreParaSails(HypreParMatrix &A)
virtual HYPRE_PtrToParSolverFcn SetupFcn() const
GMRES Setup function.
int poly_order
Order of the smoothing polynomial.
double lambda
Taubin's lambda-mu method parameters.
HypreParMatrix * ParMult(HypreParMatrix *A, HypreParMatrix *B)
Returns the matrix A * B.
HypreBoomerAMG(HypreParMatrix &A)
virtual HYPRE_PtrToParSolverFcn SolveFcn() const
hypre's internal Solve function