21#include "fasp_functs.h"
27#include "PreMGSmoother.inl"
28#include "PreMGUtil.inl"
58 const REAL tol = param->
tol * 1e-4;
77 for (i =
MAX_AMG_LVL - 2; i > 0; i -= 2) ncycles[i] = 2;
80 for (i =
MAX_AMG_LVL - 1; i > 0; i -= 2) ncycles[i] = 2;
83 for (i = 0; i <
MAX_AMG_LVL; i += 1) ncycles[i] = cycle_type;
87 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
88 printf(
"### DEBUG: n=%d, nnz=%d\n", mgl[0].A.row, mgl[0].
A.
nnz);
92 printf(
"### DEBUG: AMG_level = %d, ILU_level = %d\n", nl, mgl->
ILU_levels);
101 if (l < mgl->ILU_levels) {
106 else if (l < mgl->SWZ_levels) {
107 switch (mgl[l].Schwarz.SWZ_type) {
126 fasp_smoother_dcsr_gs_multicolor(&mgl[l].x, &mgl[l].A, &mgl[l].b,
129 fasp_dcsr_presmoothing(smoother, &mgl[l].A, &mgl[l].b, &mgl[l].x,
156 switch (coarse_solver) {
162 fasp_pardiso_solve(&mgl[nl - 1].A, &mgl[nl - 1].b, &mgl[nl - 1].x,
163 &mgl[nl - 1].pdata, 0);
183 fasp_umfpack_solve(&mgl[nl - 1].A, &mgl[nl - 1].b, &mgl[nl - 1].x,
184 mgl[nl - 1].Numeric, 0);
200 fasp_coarse_itsolver(&mgl[nl - 1].A, &mgl[nl - 1].b, &mgl[nl - 1].x, tol,
215 alpha =
MIN(alpha, 1.0);
230 if (l < mgl->ILU_levels) {
235 else if (l < mgl->SWZ_levels) {
236 switch (mgl[l].Schwarz.SWZ_type) {
253 fasp_smoother_dcsr_gs_multicolor(&mgl[l].x, &mgl[l].A, &mgl[l].b,
256 fasp_dcsr_postsmoothing(smoother, &mgl[l].A, &mgl[l].b, &mgl[l].x,
258 relax, ndeg, smooth_order, mgl[l].
cfmark.
val);
263 if (num_lvl[l] < ncycles[l])
269 if (l > 0)
goto ForwardSweep;
272 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
304 if (mgl[0].A_nk != NULL) {
310 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
314 printf(
"### DEBUG: AMG_level = %d, ILU_level = %d\n", nl, mgl->
ILU_levels);
321 if (l < mgl->ILU_levels) {
323 for (i = 0; i < steps; i++)
330 for (i = 0; i < steps; i++)
335 for (i = 0; i < steps; i++)
337 &mgl[l].x, mgl[l].diaginv.val);
340 for (i = 0; i < steps; i++) {
342 &mgl[l].x, mgl[l].diaginv.val);
344 &mgl[l].A, &mgl[l].b, &mgl[l].x, mgl[l].diaginv.val);
348 for (i = 0; i < steps; i++)
350 &mgl[l].x, mgl[l].diaginv.val,
354 for (i = 0; i < steps; i++) {
356 &mgl[l].x, mgl[l].diaginv.val,
360 mgl[l].diaginv.val, relax);
363 printf(
"### ERROR: Unknown smoother type %d!\n", smoother);
370 if (mgl[l].A_nk != NULL) {
386 fasp_coarse_itsolver(mgl[l].A_nk, &r_nk, &z_nk, 1e-12, 0);
407 switch (coarse_solver) {
413 fasp_pardiso_solve(&mgl[nl - 1].Ac, &mgl[nl - 1].b, &mgl[nl - 1].x,
414 &mgl[nl - 1].pdata, 0);
431 fasp_umfpack_solve(&mgl[nl - 1].Ac, &mgl[nl - 1].b, &mgl[nl - 1].x,
432 mgl[nl - 1].Numeric, 0);
446 const INT csize = mgl[nl - 1].
A.
ROW * mgl[nl - 1].
A.
nb;
447 const INT cmaxit =
MIN(csize * csize, 200);
449 const REAL atol = ctol * 1e-8;
451 &mgl[nl - 1].x, NULL, ctol, atol, cmaxit,
454 printf(
"### WARNING: Coarse level solver did not converge!\n");
455 printf(
"### WARNING: Consider to increase maxit to %d!\n",
478 alpha =
MIN(alpha, 1.0);
485 if (mgl[l].A_nk != NULL) {
500 fasp_coarse_itsolver(mgl[l].A_nk, &r_nk, &z_nk, 1e-12, 0);
508 if (l < mgl->ILU_levels) {
510 for (i = 0; i < steps; i++)
517 for (i = 0; i < steps; i++)
522 for (i = 0; i < steps; i++)
524 &mgl[l].A, &mgl[l].b, &mgl[l].x, mgl[l].diaginv.val);
527 for (i = 0; i < steps; i++) {
529 &mgl[l].x, mgl[l].diaginv.val);
531 &mgl[l].A, &mgl[l].b, &mgl[l].x, mgl[l].diaginv.val);
535 for (i = 0; i < steps; i++)
538 mgl[l].diaginv.val, relax);
541 for (i = 0; i < steps; i++)
543 &mgl[l].x, mgl[l].diaginv.val,
546 mgl[l].diaginv.val, relax);
549 printf(
"### ERROR: Unknown smoother type %d!\n", smoother);
555 if (nu_l[l] < cycle_type)
561 if (l > 0)
goto ForwardSweep;
564 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 REAL abstol, 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 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