Fast Auxiliary Space Preconditioning 2.7.7 Aug/28/2022
Loading...
Searching...
No Matches
AuxMessage.c
Go to the documentation of this file.
1
13#include <math.h>
14
15#include "fasp.h"
16#include "fasp_functs.h"
17
18/*---------------------------------*/
19/*-- Public Functions --*/
20/*---------------------------------*/
21
41void fasp_itinfo (const INT ptrlvl,
42 const INT stop_type,
43 const INT iter,
44 const REAL relres,
45 const REAL absres,
46 const REAL factor)
47{
48 if ( ptrlvl >= PRINT_SOME ) {
49
50 if ( iter > 0 ) {
51 printf("%6d | %13.6e | %13.6e | %10.4f\n", iter, relres, absres, factor);
52 }
53 else { // iter = 0: initial guess
54 printf("-----------------------------------------------------------\n");
55 switch (stop_type) {
56 case STOP_REL_RES:
57 printf("It Num | ||r||/||b|| | ||r|| | Conv. Factor\n");
58 break;
60 printf("It Num | ||r||_B/||b||_B | ||r||_B | Conv. Factor\n");
61 break;
63 printf("It Num | ||r||/||x|| | ||r|| | Conv. Factor\n");
64 break;
65 }
66 printf("-----------------------------------------------------------\n");
67 printf("%6d | %13.6e | %13.6e | -.-- \n", iter, relres, absres);
68 } // end if iter
69
70 } // end if ptrlvl
71}
72
85 const SHORT prtlvl)
86{
87 const SHORT max_levels = mgl->num_levels;
88 SHORT level;
89 REAL gridcom = 0.0, opcom = 0.0;
90
91 if ( prtlvl >= PRINT_SOME ) {
92
93 printf("-----------------------------------------------------------\n");
94 printf(" Level Num of rows Num of nonzeros Avg. NNZ / row \n");
95 printf("-----------------------------------------------------------\n");
96
97 for ( level = 0; level < max_levels; ++level) {
98 const REAL AvgNNZ = (REAL) mgl[level].A.nnz/mgl[level].A.row;
99 printf("%5d %13d %17d %14.2f\n",
100 level, mgl[level].A.row, mgl[level].A.nnz, AvgNNZ);
101 gridcom += mgl[level].A.row;
102 opcom += mgl[level].A.nnz;
103
104#if 0 // Save coarser linear systems for debugging purposes --Chensong
105 char matA[max_levels], rhsb[max_levels];
106 if (level > 0) {
107 sprintf(matA, "A%d.coo", level);
108 sprintf(rhsb, "b%d.coo", level);
109 fasp_dcsrvec_write2(matA, rhsb, &(mgl[level].A), &(mgl[level].b));
110 }
111#endif
112 }
113 printf("-----------------------------------------------------------\n");
114
115 gridcom /= mgl[0].A.row;
116 opcom /= mgl[0].A.nnz;
117 printf(" Grid complexity = %.3f |", gridcom);
118 printf(" Operator complexity = %.3f\n", opcom);
119
120 printf("-----------------------------------------------------------\n");
121 }
122}
123
137 const SHORT prtlvl)
138{
139 const SHORT max_levels = mgl->num_levels;
140 SHORT level;
141 REAL gridcom = 0.0, opcom = 0.0;
142
143 if ( prtlvl >= PRINT_SOME ) {
144
145 printf("-----------------------------------------------------------\n");
146 printf(" Level Num of rows Num of nonzeros Avg. NNZ / row \n");
147 printf("-----------------------------------------------------------\n");
148
149 for ( level = 0; level < max_levels; ++level ) {
150 const REAL AvgNNZ = (REAL) mgl[level].A.NNZ/mgl[level].A.ROW;
151 printf("%5d %13d %17d %14.2f\n",
152 level,mgl[level].A.ROW, mgl[level].A.NNZ, AvgNNZ);
153 gridcom += mgl[level].A.ROW;
154 opcom += mgl[level].A.NNZ;
155 }
156 printf("-----------------------------------------------------------\n");
157
158 gridcom /= mgl[0].A.ROW;
159 opcom /= mgl[0].A.NNZ;
160 printf(" Grid complexity = %.3f |", gridcom);
161 printf(" Operator complexity = %.3f\n", opcom);
162
163 printf("-----------------------------------------------------------\n");
164
165 }
166}
167
179void fasp_cputime (const char *message,
180 const REAL cputime)
181{
182 printf("%s costs %.4f seconds\n", message, cputime);
183}
184
196void fasp_message (const INT ptrlvl,
197 const char *message)
198{
199 if ( ptrlvl > PRINT_NONE ) printf("%s", message);
200}
201
213void fasp_chkerr (const SHORT status,
214 const char *fctname)
215{
216 if ( status >= 0 ) return; // No error found!!!
217
218 switch ( status ) {
219 case ERROR_READ_FILE:
220 printf("### ERROR: Cannot read file! [%s]\n", fctname);
221 break;
222 case ERROR_OPEN_FILE:
223 printf("### ERROR: Cannot open file! [%s]\n", fctname);
224 break;
225 case ERROR_WRONG_FILE:
226 printf("### ERROR: Unknown file format! [%s]\n", fctname);
227 break;
228 case ERROR_INPUT_PAR:
229 printf("### ERROR: Unknown input argument! [%s]\n", fctname);
230 break;
231 case ERROR_REGRESS:
232 printf("### ERROR: Regression test failed! [%s]\n", fctname);
233 break;
234 case ERROR_ALLOC_MEM:
235 printf("### ERROR: Cannot allocate memory! [%s]\n", fctname);
236 break;
237 case ERROR_NUM_BLOCKS:
238 printf("### ERROR: Unexpected number of blocks! [%s]\n", fctname);
239 break;
241 printf("### ERROR: Wrong data structure! [%s]\n", fctname);
242 break;
244 printf("### ERROR: Matrix has zero diagonal entries! [%s]\n", fctname);
245 break;
246 case ERROR_DUMMY_VAR:
247 printf("### ERROR: Unknown input argument! [%s]\n", fctname);
248 break;
250 printf("### ERROR: Unknown AMG interpolation type! [%s]\n", fctname);
251 break;
253 printf("### ERROR: Unknown AMG coarsening type! [%s]\n", fctname);
254 break;
256 printf("### ERROR: Unknown AMG smoother type! [%s]\n", fctname);
257 break;
259 printf("### ERROR: Unknown solver type! [%s]\n", fctname);
260 break;
262 printf("### ERROR: Unknown preconditioner type! [%s]\n", fctname);
263 break;
265 printf("### ERROR: Solver stagnation! [%s]\n", fctname);
266 break;
268 printf("### ERROR: Solution close to zero! [%s]\n", fctname);
269 break;
271 printf("### ERROR: Convergence tolerance too small! [%s]\n", fctname);
272 break;
274 printf("### ERROR: ILU setup failed! [%s]\n", fctname);
275 break;
277 printf("### ERROR: Max iteration number reached! [%s]\n", fctname);
278 break;
280 printf("### ERROR: Iterative solver failed! [%s]\n", fctname);
281 break;
283 printf("### ERROR: Unknown solver runtime error! [%s]\n", fctname);
284 break;
285 case ERROR_MISC:
286 printf("### ERROR: Miscellaneous error! [%s]\n", fctname);
287 break;
288 case ERROR_QUAD_TYPE:
289 printf("### ERROR: Unknown quadrature rules! [%s]\n", fctname);
290 break;
291 case ERROR_QUAD_DIM:
292 printf("### ERROR: Num of quad points not supported! [%s]\n", fctname);
293 break;
294 case ERROR_UNKNOWN:
295 printf("### ERROR: Unknown error! [%s]\n", fctname);
296 break;
297 default:
298 break;
299 }
300
301 exit(status);
302}
303
304/*---------------------------------*/
305/*-- End of File --*/
306/*---------------------------------*/
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_amgcomplexity_bsr(const AMG_data_bsr *mgl, const SHORT prtlvl)
Print complexities of AMG method for BSR matrices.
Definition: AuxMessage.c:136
void fasp_itinfo(const INT ptrlvl, const INT stop_type, const INT iter, const REAL relres, const REAL absres, const REAL factor)
Print out iteration information for iterative solvers.
Definition: AuxMessage.c:41
void fasp_chkerr(const SHORT status, const char *fctname)
Check error status and print out error messages before quit.
Definition: AuxMessage.c:213
void fasp_message(const INT ptrlvl, const char *message)
Print output information if necessary.
Definition: AuxMessage.c:196
void fasp_dcsrvec_write2(const char *filemat, const char *filerhs, dCSRmat *A, dvector *b)
Write A and b to two separate disk files.
Definition: BlaIO.c:1145
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 INT
Definition: fasp.h:72
#define ERROR_NUM_BLOCKS
Definition: fasp_const.h:27
#define ERROR_SOLVER_STAG
Definition: fasp_const.h:43
#define ERROR_OPEN_FILE
Definition: fasp_const.h:22
#define ERROR_AMG_INTERP_TYPE
Definition: fasp_const.h:35
#define ERROR_MISC
Definition: fasp_const.h:28
#define ERROR_SOLVER_MAXIT
Definition: fasp_const.h:48
#define ERROR_AMG_SMOOTH_TYPE
Definition: fasp_const.h:36
#define ERROR_SOLVER_ILUSETUP
Definition: fasp_const.h:46
#define STOP_REL_RES
Definition of iterative solver stopping criteria types.
Definition: fasp_const.h:132
#define ERROR_READ_FILE
Definition: fasp_const.h:21
#define ERROR_SOLVER_TYPE
Definition: fasp_const.h:41
#define ERROR_SOLVER_MISC
Definition: fasp_const.h:47
#define STOP_MOD_REL_RES
Definition: fasp_const.h:134
#define ERROR_SOLVER_SOLSTAG
Definition: fasp_const.h:44
#define ERROR_REGRESS
Definition: fasp_const.h:25
#define ERROR_SOLVER_PRECTYPE
Definition: fasp_const.h:42
#define ERROR_WRONG_FILE
Definition: fasp_const.h:23
#define ERROR_QUAD_DIM
Definition: fasp_const.h:52
#define ERROR_QUAD_TYPE
Definition: fasp_const.h:51
#define STOP_REL_PRECRES
Definition: fasp_const.h:133
#define ERROR_DATA_STRUCTURE
Definition: fasp_const.h:31
#define PRINT_SOME
Definition: fasp_const.h:75
#define ERROR_DUMMY_VAR
Definition: fasp_const.h:33
#define ERROR_AMG_COARSE_TYPE
Definition: fasp_const.h:37
#define ERROR_ALLOC_MEM
Definition: fasp_const.h:30
#define ERROR_INPUT_PAR
Definition: fasp_const.h:24
#define PRINT_NONE
Print level for all subroutines – not including DEBUG output.
Definition: fasp_const.h:73
#define ERROR_SOLVER_EXIT
Definition: fasp_const.h:49
#define ERROR_SOLVER_TOLSMALL
Definition: fasp_const.h:45
#define ERROR_UNKNOWN
Definition: fasp_const.h:56
#define ERROR_DATA_ZERODIAG
Definition: fasp_const.h:32
Data for multigrid levels in dBSRmat format.
Definition: fasp_block.h:146
dBSRmat A
pointer to the matrix at level level_num
Definition: fasp_block.h:155
INT num_levels
number of levels in use <= max_levels
Definition: fasp_block.h:152
Data for AMG methods.
Definition: fasp.h:804
dCSRmat A
pointer to the matrix at level level_num
Definition: fasp.h:817
SHORT num_levels
number of levels in use <= max_levels
Definition: fasp.h:812
INT NNZ
number of nonzero sub-blocks in matrix A, NNZ
Definition: fasp_block.h:43
INT ROW
number of rows of sub-blocks in matrix A, M
Definition: fasp_block.h:37
INT row
row number of matrix A, m
Definition: fasp.h:154
INT nnz
number of nonzero entries
Definition: fasp.h:160