26#include "fasp_functs.h"
32#include "PreAMGAggregation.inl"
33#include "PreAMGAggregationCSR.inl"
34#include "PreAMGAggregationUA.inl"
60 if (prtlvl >
PRINT_NONE) printf(
"\nSetting up UA AMG ...\n");
63 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
64 printf(
"### DEBUG: nr=%d, nc=%d, nnz=%d\n", mgl[0].A.row, mgl[0].
A.
col,
68 SHORT status = amg_setup_unsmoothP_unsmoothR(mgl, param);
71 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
110 const REAL cplxmax = 3.0;
111 const REAL xsi = 0.6;
118 REAL setup_start, setup_end;
123 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
124 printf(
"### DEBUG: nr=%d, nc=%d, nnz=%d\n", mgl[0].A.row, mgl[0].A.col,
140 for (i = 0; i < max_levels; ++i) num_aggs[i] = 0;
174 REAL lambda_max = 2.0, lambda_min = lambda_max / 4;
193 while ((mgl[lvl].A.row > min_cdof) && (lvl < max_levels - 1)) {
196 printf(
"### DEBUG: level = %d, row = %d, nnz = %d\n", lvl, mgl[lvl].A.row,
201 if (lvl < param->ILU_levels) {
205 printf(
"### WARNING: ILU setup on level-%d failed!\n", lvl);
206 printf(
"### WARNING: Disable ILU for level >= %d.\n", lvl);
213 if (lvl < param->SWZ_levels) {
219 printf(
"### WARNING: Schwarz on level-%d failed!\n", lvl);
220 printf(
"### WARNING: Disable Schwarz for level >= %d.\n", lvl);
231 status = aggregation_vmb(&mgl[lvl].A, &vertices[lvl], param, lvl + 1,
232 &Neighbor[lvl], &num_aggs[lvl]);
235 if (num_aggs[lvl] * 4.0 > mgl[lvl].A.row)
237 else if (num_aggs[lvl] * 1.25 < mgl[lvl].A.row)
244 aggregation_nsympair(mgl, param, lvl, vertices, &num_aggs[lvl]);
247 if (status !=
FASP_SUCCESS || num_aggs[lvl] * 2.0 > mgl[lvl].A.row) {
249 printf(
"### WARNING: Non-symmetric pairwise matching failed on "
252 printf(
"### WARNING: Switch to VMB aggregation on level %d!\n",
256 status = aggregation_vmb(&mgl[lvl].A, &vertices[lvl], param,
257 lvl + 1, &Neighbor[lvl], &num_aggs[lvl]);
264 aggregation_symmpair(mgl, param, lvl, vertices, &num_aggs[lvl]);
271 printf(
"### WARNING: Stop coarsening on level %d!\n", lvl);
280 form_tentative_p(&vertices[lvl], &mgl[lvl].P, mgl[0].near_kernel_basis,
291 if (mgl[lvl].P.row > mgl[lvl].P.col *
MAX_CRATE) {
293 printf(
"### WARNING: Coarsening might be too aggressive!\n");
294 printf(
"### WARNING: Fine level = %d, coarse level = %d. Discard!\n",
295 mgl[lvl].P.row, mgl[lvl].P.col);
352 mgl[lvl].
Numeric = fasp_umfpack_factorize(&mgl[lvl].A, 0);
361 fasp_pardiso_factorize(&mgl[lvl].A, &mgl[lvl].pdata, prtlvl);
374 for (lvl = 1; lvl < max_levels; ++lvl) {
391 eta = xsi / ((1 - xsi) * (cplxmax - 1));
395 for (lvl = 1; lvl < max_levels - 1; ++lvl) {
396 fracratio = (
REAL)mgl[lvl].A.nnz / mgl[0].A.nnz;
397 mgl[lvl].cycle_type =
398 (
INT)(pow((
REAL)xsi, (
REAL)lvl) / (eta * fracratio * icum));
407 int threads = fasp_get_num_threads();
408 if (threads > max_levels - 1) threads = max_levels - 1;
409#pragma omp parallel for private(lvl, rowmax, Colors) schedule(static, 1) \
412 for (lvl = 0; lvl < max_levels - 1; lvl++) {
420 printf(
"mgl[%3d].A.row = %12d, rowmax = %5d, rowavg = %7.2lf, colors = "
421 "%5d, Theta = %le.\n",
422 lvl, mgl[lvl].A.row, rowmax, (
double)mgl[lvl].A.nnz / mgl[lvl].A.row,
423 mgl[lvl].A.color, mgl[lvl].GS_Theta);
430 fasp_cputime(
"Unsmoothed aggregation setup", setup_end - setup_start);
441 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
void fasp_darray_set(const INT n, REAL *x, const REAL val)
Set initial value for an array to be x=val.
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.
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_agg(const dCSRmat *R, const dCSRmat *A, const dCSRmat *P, dCSRmat *RAP)
Triple sparse matrix multiplication B=R*A*P (nonzeros of R, P = 1)
SHORT fasp_amg_setup_ua(AMG_data *mgl, AMG_param *param)
Set up phase of unsmoothed aggregation 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 FASP_SUCCESS
Definition of return status and error messages.
#define PAIRWISE
Definition of aggregation types.
#define PRINT_NONE
Print level for all subroutines – not including DEBUG output.
INT near_kernel_dim
dimension of the near kernel for SAMG
dCSRmat A
pointer to the matrix at level level_num
Mumps_data mumps
data for MUMPS
SWZ_data Schwarz
data of Schwarz smoother
dvector b
pointer to the right-hand side at level level_num
REAL ** near_kernel_basis
basis of near kernel space for SAMG
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
Parameters for AMG methods.
INT ILU_lfil
level of fill-in for ILUs and ILUk
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 aggregation_type
aggregation 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
REAL strong_coupled
strong coupled threshold for aggregate
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
REAL quality_bound
quality threshold for pairwise aggregation
INT coarse_dof
max number of coarsest level DOF
REAL ILU_droptol
drop tolerance for ILUt
INT SWZ_levels
number of levels use Schwarz smoother
INT pair_number
number of pairwise matchings
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
Vector with n entries of INT type.