26#include "fasp_functs.h"
32#include "PreAMGAggregation.inl"
33#include "PreAMGAggregationBSR.inl"
34#include "PreAMGAggregationUA.inl"
59 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
62 SHORT status = amg_setup_unsmoothP_unsmoothR_bsr(mgl, param);
65 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
95 const SHORT CondType = 1;
101 const INT nb = mgl[0].
A.
nb;
105 REAL setup_start, setup_end;
112 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
113 printf(
"### DEBUG: nr=%d, nc=%d, nnz=%d\n",
114 mgl[0].A.ROW, mgl[0].A.COL, mgl[0].A.NNZ);
132 for ( i=0; i<max_levels; ++i ) num_aggs[i] = 0;
168 while ( (mgl[lvl].A.ROW > min_cdof) && (lvl < max_levels-1) ) {
171 if ( lvl < param->ILU_levels ) {
175 printf(
"### WARNING: ILU setup on level-%d failed!\n", lvl);
176 printf(
"### WARNING: Disable ILU for level >= %d.\n", lvl);
185 switch ( CondType ) {
187 mgl[lvl].
PP = condenseBSR(&mgl[lvl].A);
break;
189 mgl[lvl].
PP = condenseBSRLinf(&mgl[lvl].A);
break;
197 status = aggregation_vmb (&mgl[lvl].PP, &vertices[lvl], param,
198 lvl+1, &Neighbor[lvl], &num_aggs[lvl]);
201 if ( num_aggs[lvl]*4 > mgl[lvl].PP.row )
203 else if ( num_aggs[lvl]*1.25 < mgl[lvl].PP.row )
210 mgl_csr[lvl].
A = mgl[lvl].
PP;
211 status = aggregation_nsympair (mgl_csr, param, lvl, vertices,
218 mgl_csr[lvl].
A = mgl[lvl].
PP;
219 status = aggregation_symmpair (mgl_csr, param, lvl, vertices,
232 printf(
"### WARNING: Forming aggregates on level-%d failed!\n", lvl);
238 if ( lvl == 0 && mgl[0].near_kernel_dim >0 ) {
239 form_tentative_p_bsr1(&vertices[lvl], &mgl[lvl].P, &mgl[0],
240 num_aggs[lvl], mgl[0].near_kernel_dim,
241 mgl[0].near_kernel_basis);
244 form_boolean_p_bsr(&vertices[lvl], &mgl[lvl].P, &mgl[0], num_aggs[lvl]);
254 if (mgl[lvl].A_nk != NULL){
298 mgl[lvl].
Numeric = fasp_umfpack_factorize(&mgl[lvl].Ac, 0);
314 fasp_pardiso_factorize(&mgl[lvl].Ac, &mgl[lvl].pdata, prtlvl);
329 if (mgl[0].A_nk != NULL){
341 for ( lvl = 1; lvl < max_levels; lvl++ ) {
342 const INT mm = mgl[lvl].
A.
ROW*nb;
349 if (mgl[lvl].A_nk != NULL){
366 fasp_cputime(
"Unsmoothed aggregation (BSR) setup", setup_end - setup_start);
374 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_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.
INT fasp_dbsr_trans(const dBSRmat *A, dBSRmat *AT)
Find A^T from given dBSRmat matrix A.
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_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_ua_bsr(AMG_data_bsr *mgl, AMG_param *param)
Set up phase of unsmoothed 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
REAL strong_coupled
strong coupled threshold for aggregate
SHORT ILU_type
ILU type for smoothing.
INT coarse_dof
max number of coarsest level DOF
REAL ILU_droptol
drop tolerance for ILUt
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
INT nb
dimension of each sub-block
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 INT type.