30#include "fasp_functs.h"
36#include "PreAMGAggregation.inl"
37#include "PreAMGAggregationBSR.inl"
38#include "PreAMGAggregationUA.inl"
65 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
68 SHORT status = amg_setup_smoothP_smoothR_bsr(mgl, param);
71 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
96static void smooth_agg_bsr (
const dBSRmat *A,
103 const INT nb = A->
nb, nb2 = nb*nb;
122 for ( i=0; i<=row; ++i ) S.
IA[i] = A->
IA[i];
123 for ( i=0; i<nnz; ++i ) S.
JA[i] = A->
JA[i];
128 for (i=0; i<row; ++i) {
130 for (j=S.
IA[i]; j<S.
IA[i+1]; ++j) {
180 const SHORT CondType = 1;
186 const INT nb = mgl[0].
A.
nb;
191 REAL setup_start, setup_end;
198 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
199 printf(
"### DEBUG: nr=%d, nc=%d, nnz=%d\n",
200 mgl[0].A.
ROW, mgl[0].A.COL, mgl[0].A.NNZ);
221 for ( i=0; i<max_levels; ++i ) num_aggs[i] = 0;
255 while ( (mgl[lvl].A.
ROW > min_cdof) && (lvl < max_levels-1) ) {
258 if ( lvl < param->ILU_levels ) {
262 printf(
"### WARNING: ILU setup on level-%d failed!\n", lvl);
263 printf(
"### WARNING: Disable ILU for level >= %d.\n", lvl);
272 switch ( CondType ) {
274 mgl[lvl].
PP = condenseBSR(&mgl[lvl].A);
break;
276 mgl[lvl].
PP = condenseBSRLinf(&mgl[lvl].A);
break;
284 mgl_csr[lvl].
A = mgl[lvl].
PP;
285 status = aggregation_nsympair (mgl_csr, param, lvl, vertices,
292 mgl_csr[lvl].
A = mgl[lvl].
PP;
293 status = aggregation_symmpair (mgl_csr, param, lvl, vertices,
305 printf(
"### WARNING: Aggregation on level-%d failed!\n", lvl);
311 if (lvl == 0 && mgl[0].near_kernel_dim >0 ){
312 form_tentative_p_bsr1(&vertices[lvl], &tentp[lvl], &mgl[0],
313 num_aggs[lvl], mgl[0].near_kernel_dim,
314 mgl[0].near_kernel_basis);
317 form_boolean_p_bsr(&vertices[lvl], &tentp[lvl], &mgl[0], num_aggs[lvl]);
321 smooth_agg_bsr(&mgl[lvl].A, &tentp[lvl], &mgl[lvl].P, param, &Neighbor[lvl]);
330 if (mgl[lvl].A_nk != NULL){
375 mgl[lvl].
Numeric = fasp_umfpack_factorize(&mgl[lvl].Ac, 0);
391 fasp_pardiso_factorize(&mgl[lvl].Ac, &mgl[lvl].pdata, prtlvl);
405 if (mgl[0].A_nk != NULL){
413 mgl[0].
Numeric = fasp_umfpack_factorize(mgl[0].A_nk, 0);
418 for ( lvl = 1; lvl < max_levels; lvl++ ) {
419 const INT mm = mgl[lvl].
A.
ROW*nb;
426 if (mgl[lvl].A_nk != NULL){
434 mgl[lvl].
Numeric = fasp_umfpack_factorize(mgl[lvl].A_nk, 0);
444 fasp_cputime(
"Smoothed aggregation (BSR) setup", setup_end - setup_start);
452 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_bsr(const AMG_data_bsr *mgl, const SHORT prtlvl)
Print complexities of AMG method for BSR matrices.
void fasp_gettime(REAL *time)
Get system time.
void fasp_dvec_free(dvector *u)
Free vector data space of REAL type.
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_dbsr_setup(dBSRmat *A, ILU_data *iludata, ILU_param *iluparam)
Get ILU decoposition of a BSR matrix A.
void fasp_smat_identity(REAL *a, const INT n, const INT n2)
Set a n*n full matrix to be a identity.
void fasp_blas_smat_axm(REAL *a, const INT n, const REAL alpha)
Compute a = alpha*a (in place)
void fasp_blas_smat_mul(const REAL *a, const REAL *b, REAL *c, const INT n)
Compute the matrix product of two small full matrices a and b, stored in c.
void fasp_blas_smat_add(const REAL *a, const REAL *b, const INT n, const REAL alpha, const REAL beta, REAL *c)
Compute c = alpha*a + beta*b.
dBSRmat fasp_dbsr_create(const INT ROW, const INT COL, const INT NNZ, const INT nb, const INT storage_manner)
Create BSR sparse matrix data memory space.
INT fasp_dbsr_trans(const dBSRmat *A, dBSRmat *AT)
Find A^T from given dBSRmat matrix A.
void fasp_dbsr_free(dBSRmat *A)
Free memory space for BSR format sparse matrix.
dvector fasp_dbsr_getdiaginv(const dBSRmat *A)
Get D^{-1} of matrix A.
void fasp_dcsr_free(dCSRmat *A)
Free CSR sparse matrix data memory space.
void fasp_dcsr_sort(dCSRmat *A)
Sort each row of A in ascending order w.r.t. column indices.
void fasp_dcsr_cp(const dCSRmat *A, dCSRmat *B)
copy a dCSRmat to a new one B=A
INT fasp_dcsr_trans(const dCSRmat *A, dCSRmat *AT)
Find transpose of dCSRmat matrix A.
void fasp_blas_dbsr_mxm(const dBSRmat *A, const dBSRmat *B, dBSRmat *C)
Sparse matrix multiplication C=A*B.
void fasp_blas_dbsr_rap(const dBSRmat *R, const dBSRmat *A, const dBSRmat *P, dBSRmat *B)
dBSRmat sparse matrix multiplication B=R*A*P
void fasp_blas_dcsr_mxm(const dCSRmat *A, const dCSRmat *B, dCSRmat *C)
Sparse matrix multiplication C=A*B.
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_setup_sa_bsr(AMG_data_bsr *mgl, AMG_param *param)
Set up phase of smoothed aggregation AMG (BSR format)
AMG_data * fasp_amg_data_create(SHORT max_levels)
Create and initialize AMG_data for classical and SA AMG.
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.
Data for multigrid levels in dBSRmat format.
dCSRmat PP
pointer to the pressure block (only for reservoir simulation)
dBSRmat A
pointer to the matrix at level level_num
dCSRmat * A_nk
Matrix data for near kernal.
dCSRmat Ac
pointer to the matrix at level level_num (csr format)
Mumps_data mumps
data for MUMPS
dvector b
pointer to the right-hand side at level level_num
void * Numeric
pointer to the numerical dactorization from UMFPACK
INT ILU_levels
number of levels use ILU smoother
INT num_levels
number of levels in use <= max_levels
dCSRmat * R_nk
Resriction for near kernal.
dvector x
pointer to the iterative solution at level level_num
dCSRmat * P_nk
Prolongation for near kernal.
dvector diaginv
pointer to the diagonal inverse at level level_num
dvector w
temporary work space
dCSRmat A
pointer to the matrix at level level_num
Parameters for AMG methods.
INT ILU_lfil
level of fill-in for ILUs and ILUk
REAL ILU_relax
relaxation for ILUs
SHORT print_level
print level for AMG
SHORT aggregation_type
aggregation type
SHORT ILU_levels
number of levels use ILU smoother
SHORT coarse_solver
coarse solver type
SHORT ILU_type
ILU type for smoothing.
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 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
Block sparse row storage matrix of REAL type.
INT COL
number of cols of sub-blocks in matrix A, N
INT NNZ
number of nonzero sub-blocks in matrix A, NNZ
INT nb
dimension of each sub-block
INT * IA
integer array of row pointers, the size is ROW+1
INT ROW
number of rows of sub-blocks in matrix A, M
Sparse matrix of REAL type in CSR format.
Vector with n entries of REAL type.
REAL * val
actual vector entries
Vector with n entries of INT type.