21#include "fasp_functs.h"
27#include "PreMGUtil.inl"
28#include "PreMGSmoother.inl"
59 const REAL tol = param->
tol * 1e-4;
78 for ( i =
MAX_AMG_LVL-2; i > 0; i -= 2 ) ncycles[i] = 2;
81 for ( i =
MAX_AMG_LVL-1; i > 0; i -= 2 ) ncycles[i] = 2;
84 for ( i = 0; i <
MAX_AMG_LVL; i += 1 ) ncycles[i] = cycle_type;
88 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
89 printf(
"### DEBUG: n=%d, nnz=%d\n", mgl[0].A.row, mgl[0].
A.
nnz);
93 printf(
"### DEBUG: AMG_level = %d, ILU_level = %d\n", nl, mgl->
ILU_levels);
102 if ( l < mgl->ILU_levels ) {
107 else if ( l < mgl->SWZ_levels ) {
108 switch (mgl[l].Schwarz.SWZ_type) {
123 fasp_smoother_dcsr_gs_multicolor (&mgl[l].x, &mgl[l].A, &mgl[l].b, param->
presmooth_iter,1);
125 fasp_dcsr_presmoothing(smoother, &mgl[l].A, &mgl[l].b, &mgl[l].x,
127 relax, ndeg, smooth_order, mgl[l].
cfmark.
val);
136 switch ( amg_type ) {
152 switch ( coarse_solver ) {
157 fasp_pardiso_solve(&mgl[nl-1].A, &mgl[nl-1].b, &mgl[nl-1].x, &mgl[nl-1].pdata, 0);
174 fasp_umfpack_solve(&mgl[nl-1].A, &mgl[nl-1].b, &mgl[nl-1].x, mgl[nl-1].Numeric, 0);
189 fasp_coarse_itsolver(&mgl[nl-1].A, &mgl[nl-1].b, &mgl[nl-1].x, tol, prtlvl);
202 alpha =
MIN(alpha, 1.0);
206 switch ( amg_type ) {
216 if ( l < mgl->ILU_levels ) {
221 else if ( l < mgl->SWZ_levels ) {
222 switch (mgl[l].Schwarz.SWZ_type) {
236 fasp_smoother_dcsr_gs_multicolor (&mgl[l].x, &mgl[l].A, &mgl[l].b, param->
postsmooth_iter,-1);
238 fasp_dcsr_postsmoothing(smoother, &mgl[l].A, &mgl[l].b, &mgl[l].x,
240 relax, ndeg, smooth_order, mgl[l].
cfmark.
val);
245 if ( num_lvl[l] < ncycles[l] )
break;
249 if ( l > 0 )
goto ForwardSweep;
252 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
286 if ( mgl[0].A_nk != NULL ) {
292 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
296 printf(
"### DEBUG: AMG_level = %d, ILU_level = %d\n", nl, mgl->
ILU_levels);
303 if ( l < mgl->ILU_levels ) {
305 for ( i=0; i<steps; i++ )
310 switch ( smoother ) {
312 for (i=0; i<steps; i++)
317 for (i=0; i<steps; i++)
322 for (i=0; i<steps; i++){
330 for (i=0; i<steps; i++)
332 mgl[l].diaginv.val, relax);
335 for (i=0; i<steps; i++) {
337 mgl[l].diaginv.val, relax);
340 mgl[l].diaginv.val, relax);
343 printf(
"### ERROR: Unknown smoother type %d!\n", smoother);
350 if (mgl[l].A_nk != NULL) {
366 fasp_coarse_itsolver(mgl[l].A_nk, &r_nk, &z_nk, 1e-12, 0);
387 switch ( coarse_solver ) {
392 fasp_pardiso_solve(&mgl[nl-1].Ac, &mgl[nl-1].b, &mgl[nl-1].x, &mgl[nl-1].pdata, 0);
408 fasp_umfpack_solve(&mgl[nl-1].Ac, &mgl[nl-1].b, &mgl[nl-1].x, mgl[nl-1].Numeric, 0);
421 const INT csize = mgl[nl-1].
A.
ROW*mgl[nl-1].
A.
nb;
422 const INT cmaxit =
MIN(csize*csize, 200);
425 NULL,ctol,cmaxit,25,1,0) < 0 ) {
427 printf(
"### WARNING: Coarse level solver did not converge!\n");
428 printf(
"### WARNING: Consider to increase maxit to %d!\n", 2*cmaxit);
450 alpha =
MIN(alpha, 1.0);
458 if ( mgl[l].A_nk != NULL ) {
473 fasp_coarse_itsolver(mgl[l].A_nk, &r_nk, &z_nk, 1e-12, 0);
481 if ( l < mgl->ILU_levels ) {
483 for ( i=0; i<steps; i++ )
489 switch ( smoother ) {
491 for (i=0; i<steps; i++)
496 for (i=0; i<steps; i++)
501 for (i=0; i<steps; i++){
509 for (i=0; i<steps; i++)
511 mgl[l].diaginv.val, relax);
514 for (i=0; i<steps; i++)
516 mgl[l].diaginv.val, relax);
518 mgl[l].diaginv.val, relax);
521 printf(
"### ERROR: Unknown smoother type %d!\n", smoother);
527 if ( nu_l[l] < cycle_type )
break;
531 if ( l > 0 )
goto ForwardSweep;
534 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
void fasp_darray_cp(const INT n, const REAL *x, REAL *y)
Copy an array to the other y=x.
void fasp_chkerr(const SHORT status, const char *fctname)
Check error status and print out error messages before quit.
void fasp_dvec_set(INT n, dvector *x, const REAL val)
Initialize dvector x[i]=val for i=0:n-1.
void fasp_dvec_alloc(const INT m, dvector *u)
Create dvector data space of REAL type.
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_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_gs_descend(dBSRmat *A, dvector *b, dvector *u, REAL *diaginv)
Gauss-Seidel relaxation in the descending order.
void fasp_smoother_dbsr_jacobi1(dBSRmat *A, dvector *b, dvector *u, REAL *diaginv)
Jacobi relaxation.
void fasp_smoother_dbsr_gs_ascend(dBSRmat *A, dvector *b, dvector *u, REAL *diaginv)
Gauss-Seidel relaxation in the ascending order.
void fasp_smoother_dbsr_sor_ascend(dBSRmat *A, dvector *b, dvector *u, REAL *diaginv, REAL weight)
SOR relaxation in the ascending order.
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_sor_descend(dBSRmat *A, dvector *b, dvector *u, REAL *diaginv, REAL weight)
SOR relaxation in the descending order.
void fasp_smoother_dcsr_ilu(dCSRmat *A, dvector *b, dvector *x, void *data)
ILU method as a smoother.
INT fasp_solver_dbsr_pvgmres(dBSRmat *A, dvector *b, dvector *x, precond *pc, const REAL tol, const INT MaxIt, const SHORT restart, const SHORT StopType, const SHORT PrtLvl)
Right preconditioned GMRES method in which the restart parameter can be adaptively modified during it...
void fasp_solver_mgcycle_bsr(AMG_data_bsr *mgl, AMG_param *param)
Solve Ax=b with non-recursive multigrid cycle.
void fasp_solver_mgcycle(AMG_data *mgl, AMG_param *param)
Solve Ax=b with non-recursive multigrid 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.
INT fasp_solver_umfpack(dCSRmat *ptrA, dvector *b, dvector *u, const SHORT prtlvl)
Solve Au=b by UMFpack.
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.
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
INT ILU_levels
number of levels use ILU smoother
INT num_levels
number of levels in use <= max_levels
dvector x
pointer to the iterative solution at level level_num
dvector w
temporary work space
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
INT ILU_levels
number of levels use ILU smoother
dvector x
pointer to the iterative solution at level level_num
SHORT num_levels
number of levels in use <= max_levels
dvector w
temporary work space
ivector cfmark
pointer to the CF marker at level level_num
Parameters for AMG methods.
SHORT print_level
print level for AMG
SHORT polynomial_degree
degree of the polynomial smoother
SHORT coarse_scaling
switch of scaling of the coarse grid correction
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 cycle_type
type of AMG 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
INT nb
dimension of each sub-block
INT ROW
number of rows of sub-blocks in matrix A, M
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