28#include "fasp_functs.h"
64 REAL setup_start, setup_end;
73 if ( prtlvl >
PRINT_NONE ) printf(
"\nSetting up Classical AMG ...\n");
76 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
77 printf(
"### DEBUG: n = %d, nnz = %d\n", mgl[0].A.row, mgl[0].
A.
nnz);
124 while ( (mgl[lvl].A.row > min_cdof) && (lvl < max_lvls-1) ) {
127 printf(
"### DEBUG: level = %d, row = %d, nnz = %d\n",
128 lvl, mgl[lvl].A.row, mgl[lvl].
A.
nnz);
132 if ( lvl < param->ILU_levels ) {
136 printf(
"### WARNING: ILU setup on level-%d failed!\n", lvl);
137 printf(
"### WARNING: Disable ILU for level >= %d.\n", lvl);
144 if ( lvl < param->SWZ_levels ) {
150 printf(
"### WARNING: Schwarz on level-%d failed!\n", lvl);
151 printf(
"### WARNING: Disable Schwarz for level >= %d.\n", lvl);
169 printf(
"### WARNING: Could not find any C-variables!\n");
170 printf(
"### WARNING: Stop coarsening on level=%d!\n", lvl);
184 if ( mgl[lvl].P.row > mgl[lvl].
P.
col * 10.0 ) {
186 printf(
"### WARNING: Coarsening might be too aggressive!\n");
187 printf(
"### WARNING: Fine level = %d, coarse level = %d. Discard!\n",
188 mgl[lvl].P.row, mgl[lvl].
P.
col);
205 memcpy(mgl[lvl].cfmark.val, vertices.
val, size*
sizeof(
INT));
261 if ( mgl[lvl].A.nnz / mgl[lvl].
A.
row > mgl[lvl].
A.
col * 0.2 ) {
263 printf(
"### WARNING: Coarse matrix is too dense!\n");
264 printf(
"### WARNING: m = n = %d, nnz = %d!\n",
265 mgl[lvl].A.col, mgl[lvl].
A.
nnz);
296 mgl[lvl].
Numeric = fasp_umfpack_factorize(&mgl[lvl].A, 0);
304 fasp_pardiso_factorize(&mgl[lvl].A, &mgl[lvl].pdata, prtlvl);
318 for ( lvl = 1; lvl < max_lvls; ++lvl ) {
341 int threads = fasp_get_num_threads();
342 if (threads > max_lvls-1 ) threads = max_lvls-1;
343#pragma omp parallel for private(lvl,rowmax,Colors) schedule(static, 1) num_threads(threads)
345 for (lvl=0; lvl<max_lvls-1; lvl++){
353 printf(
"mgl[%3d].A.row = %12d, rowmax = %5d, rowavg = %7.2lf, colors = %5d, Theta = %le.\n",
354 lvl, mgl[lvl].A.row, rowmax, (
double)mgl[lvl].
A.
nnz/mgl[lvl].
A.
row,
355 mgl[lvl].
A.color, mgl[lvl].GS_Theta);
362 fasp_cputime(
"Classical AMG setup", setup_end - setup_start);
366 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
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_cputime(const char *message, const REAL cputime)
Print CPU walltime.
void fasp_amgcomplexity(const AMG_data *mgl, const SHORT prtlvl)
Print level and complexity information of AMG.
void fasp_gettime(REAL *time)
Get system time.
void fasp_ivec_free(ivector *u)
Free vector data space of INT type.
dvector fasp_dvec_create(const INT m)
Create dvector data space of REAL type.
ivector fasp_ivec_create(const INT m)
Create vector data space of INT type.
SHORT fasp_ilu_dcsr_setup(dCSRmat *A, ILU_data *iludata, ILU_param *iluparam)
Get ILU decomposition of a CSR matrix A.
INT fasp_swz_dcsr_setup(SWZ_data *swzdata, SWZ_param *swzparam)
Setup phase for the Schwarz methods.
void fasp_dcsr_diagpref(dCSRmat *A)
Re-order the column and data arrays of a CSR matrix, so that the first entry in each row is the diago...
dCSRmat fasp_dcsr_create(const INT m, const INT n, const INT nnz)
Create CSR sparse matrix data memory space.
void fasp_dcsr_shift(dCSRmat *A, const INT offset)
Re-index a REAL matrix in CSR format to make the index starting from 0 or 1.
void dCSRmat_Multicoloring_Theta(dCSRmat *A, REAL theta, INT *rowmax, INT *groups)
Use the greedy multicoloring algorithm to get color groups for for the adjacency graph of A.
void fasp_dcsr_free(dCSRmat *A)
Free CSR sparse matrix data memory space.
void fasp_dcsr_transz(dCSRmat *A, INT *p, dCSRmat *AT)
Generalized transpose of A: (n x m) matrix given in dCSRmat format.
void fasp_dcsr_sort(dCSRmat *A)
Sort each row of A in ascending order w.r.t. column indices.
void dCSRmat_Multicoloring(dCSRmat *A, INT *rowmax, INT *groups)
Use the greedy multicoloring algorithm to get color groups for for the adjacency graph of A.
void fasp_dcsr_cp(const dCSRmat *A, dCSRmat *B)
copy a dCSRmat to a new one B=A
dCSRmat fasp_dcsr_sympart(dCSRmat *A)
Get symmetric part of a dCSRmat matrix.
INT fasp_dcsr_trans(const dCSRmat *A, dCSRmat *AT)
Find transpose of dCSRmat matrix A.
void fasp_blas_dcsr_rap(const dCSRmat *R, const dCSRmat *A, const dCSRmat *P, dCSRmat *RAP)
Triple sparse matrix multiplication B=R*A*P.
SHORT fasp_amg_coarsening_rs(dCSRmat *A, ivector *vertices, dCSRmat *P, iCSRmat *S, AMG_param *param)
Standard and aggressive coarsening schemes.
void fasp_amg_interp(dCSRmat *A, ivector *vertices, dCSRmat *P, iCSRmat *S, AMG_param *param)
Generate interpolation operator P.
SHORT fasp_amg_setup_rs(AMG_data *mgl, AMG_param *param)
Setup phase of Ruge and Stuben's classic AMG.
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.
int fasp_solver_mumps_steps(dCSRmat *ptrA, dvector *b, dvector *u, Mumps_data *mumps)
Solve Ax=b by MUMPS in three steps.
Main header file for the FASP project.
#define SHORT
FASP integer and floating point numbers.
#define MAX(a, b)
Definition of max, min, abs.
#define COARSE_RS
Definition of coarsening types.
#define FASP_SUCCESS
Definition of return status and error messages.
#define PRINT_NONE
Print level for all subroutines – not including DEBUG output.
dCSRmat A
pointer to the matrix at level level_num
Mumps_data mumps
data for MUMPS
dCSRmat P
prolongation operator at level level_num
SWZ_data Schwarz
data of Schwarz smoother
dvector b
pointer to the right-hand side at level level_num
void * Numeric
pointer to the numerical factorization from UMFPACK
INT ILU_levels
number of levels use ILU smoother
INT SWZ_levels
number of levels use Schwarz 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.
INT ILU_lfil
level of fill-in for ILUs and ILUk
INT aggressive_level
number of levels use aggressive coarsening
REAL ILU_relax
relaxation for ILUs
INT SWZ_mmsize
maximal block size
SHORT print_level
print level for AMG
INT SWZ_maxlvl
maximal levels
SHORT coarsening_type
coarsening type
REAL * amli_coef
coefficients of the polynomial used by AMLI cycle
SHORT ILU_levels
number of levels use ILU smoother
SHORT coarse_solver
coarse solver type
SHORT cycle_type
type of AMG cycle
SHORT amli_degree
degree of the polynomial used by AMLI cycle
SHORT ILU_type
ILU type for smoothing.
INT SWZ_blksolver
type of Schwarz block solver
INT SWZ_type
type of Schwarz method
INT coarse_dof
max number of coarsest level DOF
REAL ILU_droptol
drop tolerance for ILUt
REAL tentative_smooth
relaxation parameter for smoothing the tentative prolongation
INT SWZ_levels
number of levels use Schwarz smoother
SHORT max_levels
max number of levels of AMG
INT ILU_lfil
level of fill-in for ILUk
REAL ILU_relax
add the sum of dropped elements to diagonal element in proportion relax
SHORT print_level
print level
SHORT ILU_type
ILU type for decomposition.
REAL ILU_droptol
drop tolerance for ILUt
dCSRmat A
pointer to the original coefficient matrix
Parameters for Schwarz method.
INT SWZ_mmsize
maximal size of blocks
INT SWZ_maxlvl
maximal level for constructing the blocks
INT SWZ_blksolver
type of Schwarz block solver
SHORT SWZ_type
type for Schwarz method
Sparse matrix of REAL type in CSR format.
INT col
column of matrix A, n
INT row
row number of matrix A, m
INT nnz
number of nonzero entries
Sparse matrix of INT type in CSR format.
INT * IA
integer array of row pointers, the size is m+1
INT * JA
integer array of column indexes, the size is nnz
Vector with n entries of INT type.
INT * val
actual vector entries