Fast Auxiliary Space Preconditioning 2.7.7 Aug/28/2022
Loading...
Searching...
No Matches
PreAMGSetupCR.c
Go to the documentation of this file.
1
23#include <math.h>
24#include <time.h>
25
26#include "fasp.h"
27#include "fasp_functs.h"
28
29/*---------------------------------*/
30/*-- Public Functions --*/
31/*---------------------------------*/
32
49 AMG_param *param)
50{
51 const SHORT prtlvl = param->print_level;
52 const SHORT min_cdof = MAX(param->coarse_dof,50);
53 const INT m = mgl[0].A.row;
54
55 // local variables
56 INT i_0 = 0, i_n;
57 SHORT level = 0, status = FASP_SUCCESS;
58 SHORT max_levels = param->max_levels;
59 REAL setup_start, setup_end;
60
61 // The variable vertices stores level info (fine: 0; coarse: 1)
62 ivector vertices = fasp_ivec_create(m);
63
64 fasp_gettime(&setup_start);
65
66#if DEBUG_MODE > 0
67 printf("### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
68 printf("### DEBUG: nr=%d, nc=%d, nnz=%d\n",
69 mgl[0].A.row, mgl[0].A.col, mgl[0].A.nnz);
70#endif
71
72#if DIAGONAL_PREF
73 fasp_dcsr_diagpref(&mgl[0].A); // reorder each row to make diagonal appear first
74#endif
75
76 // Main AMG setup loop
77 while ( (mgl[level].A.row > min_cdof) && (level < max_levels-1) ) {
78
79 /*-- Coarsen and form the structure of interpolation --*/
80 i_n = mgl[level].A.row-1;
81
82 fasp_amg_coarsening_cr(i_0,i_n,&mgl[level].A, &vertices, param);
83
84 /*-- Form interpolation --*/
85 /* 1. SPARSITY -- Form ip and jp */
86 /* First a symbolic one
87 then gather the list */
88 /* 2. COEFFICIENTS -- Form P */
89 // energymin(mgl[level].A, &vertices[level], mgl[level].P, param);
90 // fasp_mem_free(vertices[level].val); vertices[level].val = NULL;
91
92 /*-- Form coarse level stiffness matrix --*/
93 // fasp_dcsr_trans(mgl[level].P, mgl[level].R);
94
95 /*-- Form coarse level stiffness matrix --*/
96 //fasp_blas_dcsr_rap(mgl[level].R, mgl[level].A, mgl[level].P, mgl[level+1].A);
97
98 ++level;
99
100#if DIAGONAL_PREF
101 fasp_dcsr_diagpref(&mgl[level].A); // reorder each row to make diagonal appear first
102#endif
103 }
104
105 // setup total level number and current level
106 mgl[0].num_levels = max_levels = level+1;
107 mgl[0].w = fasp_dvec_create(m);
108
109 for ( level = 1; level < max_levels; ++level ) {
110 INT mm = mgl[level].A.row;
111 mgl[level].num_levels = max_levels;
112 mgl[level].b = fasp_dvec_create(mm);
113 mgl[level].x = fasp_dvec_create(mm);
114 mgl[level].w = fasp_dvec_create(mm);
115 }
116
117 if ( prtlvl > PRINT_NONE ) {
118 fasp_gettime(&setup_end);
119 fasp_amgcomplexity(mgl,prtlvl);
120 fasp_cputime("Compatible relaxation setup", setup_end - setup_start);
121 }
122
123 fasp_ivec_free(&vertices);
124
125#if DEBUG_MODE > 0
126 printf("### DEBUG: [--End--] %s ...\n", __FUNCTION__);
127#endif
128
129 return status;
130}
131
132/*---------------------------------*/
133/*-- End of File --*/
134/*---------------------------------*/
void fasp_cputime(const char *message, const REAL cputime)
Print CPU walltime.
Definition: AuxMessage.c:179
void fasp_amgcomplexity(const AMG_data *mgl, const SHORT prtlvl)
Print level and complexity information of AMG.
Definition: AuxMessage.c:84
void fasp_gettime(REAL *time)
Get system time.
Definition: AuxTiming.c:37
void fasp_ivec_free(ivector *u)
Free vector data space of INT type.
Definition: AuxVector.c:164
dvector fasp_dvec_create(const INT m)
Create dvector data space of REAL type.
Definition: AuxVector.c:62
ivector fasp_ivec_create(const INT m)
Create vector data space of INT type.
Definition: AuxVector.c:84
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...
Definition: BlaSparseCSR.c:680
INT fasp_amg_coarsening_cr(const INT i_0, const INT i_n, dCSRmat *A, ivector *vertices, AMG_param *param)
CR coarsening.
SHORT fasp_amg_setup_cr(AMG_data *mgl, AMG_param *param)
Set up phase of Brannick Falgout CR coarsening for classic AMG.
Definition: PreAMGSetupCR.c:48
Main header file for the FASP project.
#define REAL
Definition: fasp.h:75
#define SHORT
FASP integer and floating point numbers.
Definition: fasp.h:71
#define MAX(a, b)
Definition of max, min, abs.
Definition: fasp.h:82
#define INT
Definition: fasp.h:72
#define FASP_SUCCESS
Definition of return status and error messages.
Definition: fasp_const.h:19
#define PRINT_NONE
Print level for all subroutines – not including DEBUG output.
Definition: fasp_const.h:73
Data for AMG methods.
Definition: fasp.h:804
dCSRmat A
pointer to the matrix at level level_num
Definition: fasp.h:817
dvector b
pointer to the right-hand side at level level_num
Definition: fasp.h:826
dvector x
pointer to the iterative solution at level level_num
Definition: fasp.h:829
SHORT num_levels
number of levels in use <= max_levels
Definition: fasp.h:812
dvector w
temporary work space
Definition: fasp.h:863
Parameters for AMG methods.
Definition: fasp.h:455
SHORT print_level
print level for AMG
Definition: fasp.h:461
INT coarse_dof
max number of coarsest level DOF
Definition: fasp.h:473
SHORT max_levels
max number of levels of AMG
Definition: fasp.h:470
INT col
column of matrix A, n
Definition: fasp.h:157
INT row
row number of matrix A, m
Definition: fasp.h:154
INT nnz
number of nonzero entries
Definition: fasp.h:160
Vector with n entries of INT type.
Definition: fasp.h:368