23#include "fasp_functs.h"
29#include "PreMGUtil.inl"
30#include "PreMGSmoother.inl"
31#include "PreMGRecurAMLI.inl"
69 const REAL tol = param->
tol*1e-4;
77 dvector *b1 = &mgl[l+1].
b, *e1 = &mgl[l+1].
x;
96 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
97 printf(
"### DEBUG: n=%d, nnz=%d\n", mgl[0].A.row, mgl[0].
A.
nnz);
101 printf(
"AMLI level %d, smoother %d.\n", l, smoother);
103 if ( l < mgl[l].num_levels-1 ) {
106 if ( l < mgl[l].ILU_levels ) {
112 else if ( l < mgl->SWZ_levels ) {
114 switch (mgl[l].Schwarz.SWZ_type) {
128 fasp_smoother_dcsr_gs_multicolor (&mgl[l].x, &mgl[l].A, &mgl[l].b, param->
presmooth_iter,1);
131 0,m0-1,1,relax,ndeg,smooth_order,ordering);
153 for ( i=1; i<=degree; i++ ) {
173 alpha =
MIN(alpha, 1.0);
187 if ( l < mgl[l].ILU_levels ) {
193 else if (l<mgl->SWZ_levels) {
195 switch (mgl[l].Schwarz.SWZ_type) {
208 fasp_smoother_dcsr_gs_multicolor (&mgl[l].x, &mgl[l].A, &mgl[l].b, param->
postsmooth_iter,-1);
211 0,m0-1,-1,relax,ndeg,smooth_order,ordering);
219 switch (coarse_solver) {
224 fasp_pardiso_solve(A0, b0, e0, &mgl[l].pdata, 0);
239 fasp_umfpack_solve(A0, b0, e0, mgl[l].Numeric, 0);
253 fasp_coarse_itsolver(A0, b0, e0, tol, prtlvl);
260 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
295 const REAL tol = param->
tol*1e-4;
298 dvector *b0 = &mgl[l].
b, *e0 = &mgl[l].
x;
299 dvector *b1 = &mgl[l+1].
b, *e1 = &mgl[l+1].
x;
319 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
320 printf(
"### DEBUG: n=%d, nnz=%d\n", mgl[0].A.row, mgl[0].
A.
nnz);
324 printf(
"Nonlinear AMLI level %d, smoother %d.\n", num_levels, smoother);
326 if ( l < num_levels-1 ) {
329 if ( l < mgl[l].ILU_levels ) {
335 else if ( l < mgl->SWZ_levels ) {
337 switch (mgl[l].Schwarz.SWZ_type) {
351 fasp_smoother_dcsr_gs_multicolor (&mgl[l].x, &mgl[l].A, &mgl[l].b, param->
presmooth_iter,1);
354 0,m0-1,1,relax,ndeg,smooth_order,ordering);
376 if ( mgl[l+1].cycle_type <= 1 ) {
399 Kcycle_dcsr_pgcg(A1, b1, &uH, &pc);
402 Kcycle_dcsr_pgcr(A1, b1, &uH, &pc);
420 if ( l < mgl[l].ILU_levels ) {
425 else if ( l < mgl->SWZ_levels ) {
427 switch (mgl[l].Schwarz.SWZ_type) {
440 fasp_smoother_dcsr_gs_multicolor (&mgl[l].x, &mgl[l].A, &mgl[l].b, param->
postsmooth_iter,-1);
443 0,m0-1,-1,relax,ndeg,smooth_order,ordering);
451 switch (coarse_solver) {
456 fasp_pardiso_solve(A0, b0, e0, &mgl[l].pdata, 0);
471 fasp_umfpack_solve(A0, b0, e0, mgl[l].Numeric, 0);
485 fasp_coarse_itsolver(A0, b0, e0, tol, prtlvl);
492 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
529 dvector *b0 = &mgl[l].
b, *e0 = &mgl[l].
x;
530 dvector *b1 = &mgl[l+1].
b, *e1 = &mgl[l+1].
x;
544 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
545 printf(
"### DEBUG: n=%d, nnz=%d\n", mgl[0].A.ROW, mgl[0].
A.
NNZ);
549 printf(
"Nonlinear AMLI: level %d, smoother %d.\n", l, smoother);
551 if (l < num_levels-1) {
554 if (l<param->ILU_levels) {
563 for (i=0; i<steps; i++)
567 for (i=0; i<steps; i++)
571 for (i=0; i<steps; i++)
575 printf(
"### ERROR: Unknown smoother type %d!\n", smoother);
593 if (l == num_levels-2) {
625 if (l < param->ILU_levels) {
634 for (i=0; i<steps; i++)
638 for (i=0; i<steps; i++)
642 for (i=0; i<steps; i++)
646 printf(
"### ERROR: Unknown smoother type %d!\n", smoother);
656 switch (coarse_solver) {
661 fasp_pardiso_solve(&mgl[l].Ac, b0, e0, &mgl[l].pdata, 0);
676 fasp_umfpack_solve(&mgl[l].Ac, b0, e0, mgl[l].Numeric, 0);
690 fasp_coarse_itsolver(&mgl[l].Ac, b0, e0, tol, prtlvl);
697 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
716 const REAL lambda_min,
720 const REAL mu0 = 1.0/lambda_max, mu1 = 1.0/lambda_min;
721 const REAL c = (sqrt(mu0)+sqrt(mu1))*(sqrt(mu0)+sqrt(mu1));
722 const REAL a = (4*mu0*mu1)/(c);
724 const REAL kappa = lambda_max/lambda_min;
725 const REAL delta = (sqrt(kappa) - 1.0)/(sqrt(kappa)+1.0);
726 const REAL b = delta*delta;
729 coef[0] = 0.5*(mu0+mu1);
732 else if (degree == 1) {
734 coef[1] = -1.0*mu0*mu1;
737 else if (degree > 1) {
742 REAL *coef_k, *coef_km1;
743 coef_k = work; coef_km1 = work+degree;
751 coef[0] = a - b*coef_km1[0] + (1+b)*coef_k[0];
753 for (i=1; i<degree-1; i++) {
754 coef[i] = -b*coef_km1[i] + (1+b)*coef_k[i] - a*coef_k[i-1];
757 coef[degree-1] = (1+b)*coef_k[degree-1] - a*coef_k[degree-2];
759 coef[degree] = -a*coef_k[degree-1];
766 printf(
"### ERROR: Wrong AMLI degree %d!\n", degree);
void fasp_darray_cp(const INT n, const REAL *x, REAL *y)
Copy an array to the other y=x.
void fasp_mem_free(void *mem)
Free up previous allocated memory body and set pointer to NULL.
void * fasp_mem_calloc(const unsigned int size, const unsigned int type)
Allocate, initiate, and check memory.
void fasp_chkerr(const SHORT status, const char *fctname)
Check error status and print out error messages before quit.
void fasp_param_amg_to_prec(precond_data *pcdata, const AMG_param *amgparam)
Set precond_data with AMG_param.
void fasp_param_amg_to_precbsr(precond_data_bsr *pcdata, const AMG_param *amgparam)
Set precond_data_bsr with AMG_param.
void fasp_dvec_set(INT n, dvector *x, const REAL val)
Initialize dvector x[i]=val for i=0:n-1.
REAL fasp_blas_darray_dotprod(const INT n, const REAL *x, const REAL *y)
Inner product of two arraies x and y.
void fasp_blas_darray_ax(const INT n, const REAL a, REAL *x)
x = a*x
void fasp_blas_darray_axpy(const INT n, const REAL a, const REAL *x, REAL *y)
y = a*x + y
void fasp_dcsr_swz_forward(SWZ_data *swzdata, SWZ_param *swzparam, dvector *x, dvector *b)
Schwarz smoother: forward sweep.
void fasp_dcsr_swz_backward(SWZ_data *swzdata, SWZ_param *swzparam, dvector *x, dvector *b)
Schwarz smoother: backward sweep.
void fasp_blas_dbsr_aAxpy(const REAL alpha, const dBSRmat *A, const REAL *x, REAL *y)
Compute y := alpha*A*x + y.
void fasp_blas_dbsr_mxv(const dBSRmat *A, const REAL *x, REAL *y)
Compute y := A*x.
void fasp_blas_dcsr_mxv_agg(const dCSRmat *A, const REAL *x, REAL *y)
Matrix-vector multiplication y = A*x (nonzeros of A = 1)
void fasp_blas_dcsr_mxv(const dCSRmat *A, const REAL *x, REAL *y)
Matrix-vector multiplication y = A*x.
void fasp_blas_dcsr_aAxpy_agg(const REAL alpha, const dCSRmat *A, const REAL *x, REAL *y)
Matrix-vector multiplication y = alpha*A*x + y (nonzeros of A = 1)
REAL fasp_blas_dcsr_vmv(const dCSRmat *A, const REAL *x, const REAL *y)
vector-Matrix-vector multiplication alpha = y'*A*x
void fasp_blas_dcsr_aAxpy(const REAL alpha, const dCSRmat *A, const REAL *x, REAL *y)
Matrix-vector multiplication y = alpha*A*x + y.
void fasp_smoother_dbsr_ilu(dBSRmat *A, dvector *b, dvector *x, void *data)
ILU method as the smoother in solving Au=b with multigrid method.
void fasp_smoother_dbsr_jacobi(dBSRmat *A, dvector *b, dvector *u)
Jacobi relaxation.
void fasp_smoother_dbsr_gs(dBSRmat *A, dvector *b, dvector *u, INT order, INT *mark)
Gauss-Seidel relaxation.
void fasp_smoother_dbsr_sor(dBSRmat *A, dvector *b, dvector *u, INT order, INT *mark, REAL weight)
SOR relaxation.
void fasp_smoother_dcsr_ilu(dCSRmat *A, dvector *b, dvector *x, void *data)
ILU method as a smoother.
INT fasp_solver_dbsr_pvfgmres(dBSRmat *A, dvector *b, dvector *x, precond *pc, const REAL tol, const INT MaxIt, const SHORT restart, const SHORT StopType, const SHORT PrtLvl)
Solve "Ax=b" using PFGMRES(right preconditioned) iterative method in which the restart parameter can ...
void fasp_precond_dbsr_namli(REAL *r, REAL *z, void *data)
Nonlinear AMLI-cycle AMG preconditioner.
void fasp_precond_namli(REAL *r, REAL *z, void *data)
Nonlinear AMLI AMG preconditioner.
void fasp_solver_namli(AMG_data *mgl, AMG_param *param, INT l, INT num_levels)
Solve Ax=b with recursive nonlinear AMLI-cycle.
void fasp_amg_amli_coef(const REAL lambda_max, const REAL lambda_min, const INT degree, REAL *coef)
Compute the coefficients of the polynomial used by AMLI-cycle.
void fasp_solver_namli_bsr(AMG_data_bsr *mgl, AMG_param *param, INT l, INT num_levels)
Solve Ax=b with recursive nonlinear AMLI-cycle.
void fasp_solver_amli(AMG_data *mgl, AMG_param *param, INT l)
Solve Ax=b with recursive AMLI-cycle.
int fasp_solver_mumps_steps(dCSRmat *ptrA, dvector *b, dvector *u, Mumps_data *mumps)
Solve Ax=b by MUMPS in three steps.
int fasp_solver_superlu(dCSRmat *ptrA, dvector *b, dvector *u, const SHORT prtlvl)
Solve Au=b by SuperLU.
Main header file for the FASP project.
#define SHORT
FASP integer and floating point numbers.
#define SMOOTHER_JACOBI
Definition of standard smoother types.
#define ERROR_SOLVER_TYPE
#define SCHWARZ_SYMMETRIC
#define ON
Definition of switch.
#define PRINT_NONE
Print level for all subroutines – not including DEBUG output.
Data for multigrid levels in dBSRmat format.
dBSRmat A
pointer to the matrix at level level_num
Mumps_data mumps
data for MUMPS
dvector b
pointer to the right-hand side at level level_num
dvector x
pointer to the iterative solution at level level_num
dvector w
temporary work space
ILU_data LU
ILU matrix for ILU smoother.
dCSRmat A
pointer to the matrix at level level_num
Mumps_data mumps
data for MUMPS
dvector b
pointer to the right-hand side at level level_num
dvector x
pointer to the iterative solution at level level_num
dvector w
temporary work space
ivector cfmark
pointer to the CF marker at level level_num
ILU_data LU
ILU matrix for ILU smoother.
Parameters for AMG methods.
SHORT print_level
print level for AMG
SHORT polynomial_degree
degree of the polynomial smoother
SHORT nl_amli_krylov_type
type of Krylov method used by Nonlinear AMLI cycle
SHORT coarse_scaling
switch of scaling of the coarse grid correction
REAL * amli_coef
coefficients of the polynomial used by AMLI cycle
SHORT AMG_type
type of AMG method
REAL tol
stopping tolerance for AMG solver
SHORT coarse_solver
coarse solver type
REAL relaxation
relaxation parameter for Jacobi and SOR smoother
SHORT smoother
smoother type
SHORT amli_degree
degree of the polynomial used by AMLI cycle
INT SWZ_blksolver
type of Schwarz block solver
SHORT postsmooth_iter
number of postsmoothers
INT SWZ_levels
number of levels use Schwarz smoother
SHORT presmooth_iter
number of presmoothers
SHORT smooth_order
smoother order
Parameters for Schwarz method.
INT SWZ_blksolver
type of Schwarz block solver
Block sparse row storage matrix of REAL type.
INT NNZ
number of nonzero sub-blocks in matrix A, NNZ
INT nb
dimension of each sub-block
INT ROW
number of rows of sub-blocks in matrix A, M
Sparse matrix of REAL type in CSR format.
REAL * val
nonzero entries of A
INT row
row number of matrix A, m
INT nnz
number of nonzero entries
Vector with n entries of REAL type.
REAL * val
actual vector entries
INT * val
actual vector entries
Data for preconditioners in dBSRmat format.
AMG_data_bsr * mgl_data
AMG preconditioner data.
INT max_levels
max number of AMG levels
INT maxit
max number of iterations of AMG preconditioner
Data for preconditioners.
AMG_data * mgl_data
AMG preconditioner data.
SHORT max_levels
max number of AMG levels
INT maxit
max number of iterations of AMG preconditioner
Preconditioner data and action.
void * data
data for preconditioner, void pointer
void(* fct)(REAL *, REAL *, void *)
action for preconditioner, void function pointer