17#include "fasp_functs.h"
46 int print_usage =
FALSE;
52 while ( arg_index < argc ) {
54 if ( strcmp(argv[arg_index],
"-help") == 0 ) {
55 print_usage =
TRUE;
break;
59 else if ( strcmp(argv[arg_index],
"-ini") == 0 ) {
61 if ( arg_index >= argc ) {
62 printf(
"### ERROR: Missing ini filename! [%s]\n", __FUNCTION__);
63 print_usage =
TRUE;
break;
65 strcpy(iniparam->
inifile, argv[arg_index]);
67 if ( ++arg_index >= argc )
break;
71 else if ( strcmp(argv[arg_index],
"-print") == 0 ) {
73 if ( arg_index >= argc ) {
74 printf(
"### ERROR: Expecting print level (from 0 to 10).\n");
75 print_usage =
TRUE;
break;
78 if ( ++arg_index >= argc )
break;
81 else if ( strcmp(argv[arg_index],
"-output") == 0 ) {
83 if ( arg_index >= argc ) {
84 printf(
"### ERROR: Expecting output type (0 or 1).\n");
85 print_usage =
TRUE;
break;
88 if ( ++arg_index >= argc )
break;
91 else if ( strcmp(argv[arg_index],
"-solver") == 0 ) {
93 if ( arg_index >= argc ) {
94 printf(
"### ERROR: Expecting solver type.\n");
95 print_usage =
TRUE;
break;
98 if ( ++arg_index >= argc )
break;
101 else if ( strcmp(argv[arg_index],
"-precond") == 0 ) {
103 if ( arg_index >= argc ) {
104 printf(
"### ERROR: Expecting preconditioner type.\n");
105 print_usage =
TRUE;
break;
108 if ( ++arg_index >= argc )
break;
111 else if ( strcmp(argv[arg_index],
"-maxit") == 0 ) {
113 if ( arg_index >= argc ) {
114 printf(
"### ERROR: Expecting max number of iterations.\n");
115 print_usage =
TRUE;
break;
118 if ( ++arg_index >= argc )
break;
121 else if ( strcmp(argv[arg_index],
"-tol") == 0 ) {
123 if ( arg_index >= argc ) {
124 printf(
"### ERROR: Expecting tolerance for itsolver.\n");
125 print_usage =
TRUE;
break;
128 if ( ++arg_index >= argc )
break;
131 else if ( strcmp(argv[arg_index],
"-amgmaxit") == 0 ) {
133 if ( arg_index >= argc ) {
134 printf(
"### ERROR: Expecting max num of iterations for AMG.\n");
135 print_usage =
TRUE;
break;
137 iniparam->
AMG_maxit = atoi(argv[arg_index]);
138 if ( ++arg_index >= argc )
break;
141 else if ( strcmp(argv[arg_index],
"-amgtol") == 0 ) {
143 if ( arg_index >= argc ) {
144 printf(
"### ERROR: Expecting tolerance for AMG.\n");
145 print_usage =
TRUE;
break;
147 iniparam->
AMG_tol = atof(argv[arg_index]);
148 if ( ++arg_index >= argc )
break;
151 else if ( strcmp(argv[arg_index],
"-amgtype") == 0 ) {
153 if ( arg_index >= argc ) {
154 printf(
"### ERROR: Expecting AMG type (1, 2, 3).\n");
155 print_usage =
TRUE;
break;
157 iniparam->
AMG_type = atoi(argv[arg_index]);
158 if ( ++arg_index >= argc )
break;
161 else if ( strcmp(argv[arg_index],
"-amgcycle") == 0 ) {
163 if ( arg_index >= argc ) {
164 printf(
"### ERROR: Expecting AMG cycle type (1, 2, 3, 12, 21).\n");
165 print_usage =
TRUE;
break;
168 if ( ++arg_index >= argc )
break;
171 else if ( strcmp(argv[arg_index],
"-amgcoarsening") == 0 ) {
173 if ( arg_index >= argc ) {
174 printf(
"### ERROR: Expecting AMG coarsening type.\n");
175 print_usage =
TRUE;
break;
178 if ( ++arg_index >= argc )
break;
181 else if ( strcmp(argv[arg_index],
"-amginterplation") == 0 ) {
183 if ( arg_index >= argc ) {
184 printf(
"### ERROR: Expecting AMG interpolation type.\n");
185 print_usage =
TRUE;
break;
188 if ( ++arg_index >= argc )
break;
191 else if ( strcmp(argv[arg_index],
"-amgsmoother") == 0 ) {
193 if ( arg_index >= argc ) {
194 printf(
"### ERROR: Expecting AMG smoother type.\n");
195 print_usage =
TRUE;
break;
198 if ( ++arg_index >= argc )
break;
201 else if ( strcmp(argv[arg_index],
"-amgsthreshold") == 0 ) {
203 if ( arg_index >= argc ) {
204 printf(
"### ERROR: Expecting AMG strong threshold.\n");
205 print_usage =
TRUE;
break;
208 if ( ++arg_index >= argc )
break;
211 else if ( strcmp(argv[arg_index],
"-amgscouple") == 0 ) {
213 if ( arg_index >= argc ) {
214 printf(
"### ERROR: Expecting AMG strong coupled threshold.\n");
215 print_usage =
TRUE;
break;
218 if ( ++arg_index >= argc )
break;
230 printf(
"FASP command line options:\n");
232 printf(
"================================================================\n");
233 printf(
" -ini [CharValue] : Ini file name\n");
234 printf(
" -print [IntValue] : Print level\n");
235 printf(
" -output [IntValue] : Output to screen or a log file\n");
236 printf(
" -solver [IntValue] : Solver type\n");
237 printf(
" -precond [IntValue] : Preconditioner type\n");
238 printf(
" -maxit [IntValue] : Max number of iterations\n");
239 printf(
" -tol [RealValue] : Tolerance for iterative solvers\n");
240 printf(
" -amgmaxit [IntValue] : Max number of AMG iterations\n");
241 printf(
" -amgtol [RealValue] : Tolerance for AMG methods\n");
242 printf(
" -amgtype [IntValue] : AMG type\n");
243 printf(
" -amgcycle [IntValue] : AMG cycle type\n");
244 printf(
" -amgcoarsening [IntValue] : AMG coarsening type\n");
245 printf(
" -amginterpolation [IntValue] : AMG interpolation type\n");
246 printf(
" -amgsmoother [IntValue] : AMG smoother type\n");
247 printf(
" -amgsthreshold [RealValue] : AMG strong threshold\n");
248 printf(
" -amgscoupled [RealValue] : AMG strong coupled threshold\n");
249 printf(
" -help : Brief help messages\n");
306 printf(
"### WARNING: No input given! Use default values instead.\n");
310 if ( (itsparam == NULL) && (amgparam != NULL) ) {
327 strcpy(iniparam->
workdir,
"../data/");
413 amgparam->
tol = 1e-6;
480 itsparam->
maxit = 500;
482 itsparam->
tol = 1e-6;
694 pcdata->
tol = amgparam->
tol;
762 pcdata->
tol = amgparam->
tol;
825 printf(
"\n Parameters in AMG_param\n");
826 printf(
"-----------------------------------------------\n");
828 printf(
"AMG print level: %d\n", param->
print_level);
829 printf(
"AMG max num of iter: %d\n", param->
maxit);
830 printf(
"AMG type: %d\n", param->
AMG_type);
831 printf(
"AMG tolerance: %.2e\n", param->
tol);
832 printf(
"AMG max levels: %d\n", param->
max_levels);
833 printf(
"AMG cycle type: %d\n", param->
cycle_type);
834 printf(
"AMG coarse solver type: %d\n", param->
coarse_solver);
835 printf(
"AMG scaling of coarse correction: %d\n", param->
coarse_scaling);
836 printf(
"AMG smoother type: %d\n", param->
smoother);
837 printf(
"AMG smoother order: %d\n", param->
smooth_order);
845 printf(
"AMG relax factor: %.4f\n",
850 printf(
"AMG polynomial smoother degree: %d\n",
855 printf(
"AMG AMLI degree of polynomial: %d\n",
860 printf(
"AMG Nonlinear AMLI Krylov type: %d\n",
866 printf(
"AMG coarsening type: %d\n",
868 printf(
"AMG interpolation type: %d\n",
870 printf(
"AMG dof on coarsest grid: %d\n",
872 printf(
"AMG strong threshold: %.4f\n",
874 printf(
"AMG truncation threshold: %.4f\n",
876 printf(
"AMG max row sum: %.4f\n",
878 printf(
"AMG aggressive levels: %d\n",
880 printf(
"AMG aggressive path: %d\n",
885 printf(
"Aggregation type: %d\n",
888 printf(
"Aggregation number of pairs: %d\n",
890 printf(
"Aggregation quality bound: %.2f\n",
894 printf(
"Aggregation strong coupling: %.4f\n",
896 printf(
"Aggregation max aggregation: %d\n",
898 printf(
"Aggregation tentative smooth: %.4f\n",
900 printf(
"Aggregation smooth filter: %d\n",
902 printf(
"Aggregation smooth restriction: %d\n",
910 printf(
"AMG ILU smoother level: %d\n", param->
ILU_levels);
911 printf(
"AMG ILU type: %d\n", param->
ILU_type);
912 printf(
"AMG ILU level of fill-in: %d\n", param->
ILU_lfil);
913 printf(
"AMG ILU drop tol: %e\n", param->
ILU_droptol);
914 printf(
"AMG ILU relaxation: %f\n", param->
ILU_relax);
918 printf(
"AMG Schwarz smoother level: %d\n", param->
SWZ_levels);
919 printf(
"AMG Schwarz type: %d\n", param->
SWZ_type);
920 printf(
"AMG Schwarz forming block level: %d\n", param->
SWZ_maxlvl);
921 printf(
"AMG Schwarz maximal block size: %d\n", param->
SWZ_mmsize);
924 printf(
"-----------------------------------------------\n\n");
928 printf(
"### WARNING: AMG_param has not been set!\n");
947 printf(
"\n Parameters in ILU_param\n");
948 printf(
"-----------------------------------------------\n");
949 printf(
"ILU print level: %d\n", param->
print_level);
950 printf(
"ILU type: %d\n", param->
ILU_type);
951 printf(
"ILU level of fill-in: %d\n", param->
ILU_lfil);
952 printf(
"ILU relaxation factor: %.4f\n", param->
ILU_relax);
953 printf(
"ILU drop tolerance: %.2e\n", param->
ILU_droptol);
954 printf(
"ILU permutation tolerance: %.2e\n", param->
ILU_permtol);
955 printf(
"-----------------------------------------------\n\n");
959 printf(
"### WARNING: ILU_param has not been set!\n");
977 printf(
"\n Parameters in SWZ_param\n");
978 printf(
"-----------------------------------------------\n");
979 printf(
"Schwarz print level: %d\n", param->
print_level);
980 printf(
"Schwarz type: %d\n", param->
SWZ_type);
981 printf(
"Schwarz forming block level: %d\n", param->
SWZ_maxlvl);
982 printf(
"Schwarz maximal block size: %d\n", param->
SWZ_mmsize);
983 printf(
"Schwarz block solver type: %d\n", param->
SWZ_blksolver);
984 printf(
"-----------------------------------------------\n\n");
988 printf(
"### WARNING: SWZ_param has not been set!\n");
1006 printf(
"\n Parameters in ITS_param\n");
1007 printf(
"-----------------------------------------------\n");
1009 printf(
"Solver print level: %d\n", param->
print_level);
1011 printf(
"Solver precond type: %d\n", param->
precond_type);
1012 printf(
"Solver max num of iter: %d\n", param->
maxit);
1013 printf(
"Solver tolerance: %.2e\n", param->
tol);
1014 printf(
"Solver stopping type: %d\n", param->
stop_type);
1018 printf(
"Solver restart number: %d\n", param->
restart);
1021 printf(
"-----------------------------------------------\n\n");
1025 printf(
"### WARNING: ITS_param has not been set!\n");
void fasp_chkerr(const SHORT status, const char *fctname)
Check error status and print out error messages before quit.
void fasp_param_ilu_init(ILU_param *iluparam)
Initialize ILU parameters.
void fasp_param_init(const input_param *iniparam, ITS_param *itsparam, AMG_param *amgparam, ILU_param *iluparam, SWZ_param *swzparam)
Initialize parameters, global variables, etc.
void fasp_param_amg_to_prec(precond_data *pcdata, const AMG_param *amgparam)
Set precond_data with AMG_param.
void fasp_param_precbsr_to_amg(AMG_param *amgparam, const precond_data_bsr *pcdata)
Set AMG_param with precond_data.
void fasp_param_amg_set(AMG_param *param, const input_param *iniparam)
Set AMG_param from INPUT.
void fasp_param_amg_to_precbsr(precond_data_bsr *pcdata, const AMG_param *amgparam)
Set precond_data_bsr with AMG_param.
void fasp_param_swz_init(SWZ_param *swzparam)
Initialize Schwarz parameters.
void fasp_param_solver_print(const ITS_param *param)
Print out itsolver parameters.
void fasp_param_swz_set(SWZ_param *swzparam, const input_param *iniparam)
Set SWZ_param with INPUT.
void fasp_param_ilu_set(ILU_param *iluparam, const input_param *iniparam)
Set ILU_param with INPUT.
void fasp_param_input_init(input_param *iniparam)
Initialize input parameters.
void fasp_param_amg_print(const AMG_param *param)
Print out AMG parameters.
void fasp_param_solver_init(ITS_param *itsparam)
Initialize ITS_param.
void fasp_param_amg_init(AMG_param *amgparam)
Initialize AMG parameters.
void fasp_param_ilu_print(const ILU_param *param)
Print out ILU parameters.
void fasp_param_prec_to_amg(AMG_param *amgparam, const precond_data *pcdata)
Set AMG_param with precond_data.
void fasp_param_swz_print(const SWZ_param *param)
Print out Schwarz parameters.
void fasp_param_set(const int argc, const char *argv[], input_param *iniparam)
Read input from command-line arguments.
void fasp_param_solver_set(ITS_param *itsparam, const input_param *iniparam)
Set ITS_param with INPUT.
unsigned long total_alloc_mem
unsigned long total_alloc_count
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 COARSE_RS
Definition of coarsening types.
#define FASP_SUCCESS
Definition of return status and error messages.
#define STOP_REL_RES
Definition of iterative solver stopping criteria types.
#define PAIRWISE
Definition of aggregation types.
#define V_CYCLE
Definition of cycle types.
#define INTERP_DIR
Definition of interpolation types.
#define SOLVER_DEFAULT
Definition of solver types for iterative methods.
#define TRUE
Definition of logic type.
#define CLASSIC_AMG
Definition of AMG types.
#define ON
Definition of switch.
#define ILUk
Type of ILU methods.
#define PRINT_NONE
Print level for all subroutines – not including DEBUG output.
INT ILU_levels
number of levels use ILU smoother
INT ILU_levels
number of levels use ILU smoother
Parameters for AMG methods.
INT ILU_lfil
level of fill-in for ILUs and ILUk
INT aggressive_level
number of levels use aggressive coarsening
REAL ILU_relax
relaxation for ILUs
REAL strong_threshold
strong connection threshold for coarsening
INT SWZ_mmsize
maximal block size
INT aggressive_path
number of paths use to determine strongly coupled C points
SHORT interpolation_type
interpolation type
SHORT print_level
print level for AMG
SHORT polynomial_degree
degree of the polynomial smoother
INT SWZ_maxlvl
maximal levels
SHORT aggregation_type
aggregation type
SHORT coarsening_type
coarsening type
SHORT nl_amli_krylov_type
type of Krylov method used by Nonlinear AMLI cycle
SHORT coarse_scaling
switch of scaling of the coarse grid correction
SHORT smooth_filter
switch for filtered matrix used for smoothing the tentative prolongation
REAL * amli_coef
coefficients of the polynomial used by AMLI cycle
SHORT ILU_levels
number of levels use ILU smoother
SHORT AMG_type
type of AMG method
REAL tol
stopping tolerance for AMG solver
SHORT coarse_solver
coarse solver type
REAL strong_coupled
strong coupled threshold for aggregate
REAL relaxation
relaxation parameter for Jacobi and SOR smoother
SHORT smoother
smoother type
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
REAL tentative_smooth
relaxation parameter for smoothing the tentative prolongation
SHORT postsmooth_iter
number of postsmoothers
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
SHORT presmooth_iter
number of presmoothers
REAL truncation_threshold
truncation threshold
INT max_aggregation
max size of each aggregate
REAL ILU_permtol
permuted if permtol*|a(i,j)| > |a(i,i)|
REAL max_row_sum
maximal row sum parameter
INT maxit
max number of iterations of AMG
SHORT smooth_restriction
smooth the restriction for SA methods or not
SHORT smooth_order
smoother order
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
REAL ILU_permtol
permuted if permtol*|a(i,j)| > |a(i,i)|
Parameters for iterative solvers.
Parameters for Schwarz method.
INT SWZ_mmsize
maximal size of blocks
SHORT print_level
print leve
INT SWZ_maxlvl
maximal level for constructing the blocks
INT SWZ_blksolver
type of Schwarz block solver
SHORT SWZ_type
type for Schwarz method
Data for preconditioners in dBSRmat format.
SHORT print_level
print level in AMG preconditioner
SHORT coarsening_type
coarsening type
SHORT nl_amli_krylov_type
type of krylov method used by Nonlinear AMLI cycle
SHORT coarse_scaling
switch of scaling of the coarse grid correction
REAL * amli_coef
coefficients of the polynomial used by AMLI cycle
SHORT AMG_type
type of AMG method
REAL tol
tolerance for AMG preconditioner
SHORT coarse_solver
coarse solver type for AMG
REAL relaxation
relaxation parameter for SOR smoother
SHORT smoother
AMG smoother type.
SHORT cycle_type
AMG cycle type.
SHORT amli_degree
degree of the polynomial used by AMLI cycle
REAL tentative_smooth
smooth factor for smoothing the tentative prolongation
SHORT postsmooth_iter
number of postsmoothing
AMG_data_bsr * mgl_data
AMG preconditioner data.
INT max_levels
max number of AMG levels
SHORT presmooth_iter
number of presmoothing
INT maxit
max number of iterations of AMG preconditioner
SHORT smooth_order
AMG smoother ordering.
Data for preconditioners.
SHORT print_level
print level in AMG preconditioner
SHORT polynomial_degree
degree of the polynomial smoother
SHORT coarsening_type
switch of scaling of the coarse grid correction
SHORT nl_amli_krylov_type
type of Krylov method used by Nonlinear AMLI cycle
SHORT coarse_scaling
switch of scaling of the coarse grid correction
AMG_data * mgl_data
AMG preconditioner data.
REAL * amli_coef
coefficients of the polynomial used by AMLI cycle
SHORT AMG_type
type of AMG method
REAL tol
tolerance for AMG preconditioner
SHORT coarse_solver
coarse solver type for AMG
REAL relaxation
relaxation parameter for SOR smoother
SHORT smoother
AMG smoother type.
SHORT cycle_type
AMG cycle type.
SHORT amli_degree
degree of the polynomial used by AMLI cycle
REAL tentative_smooth
smooth factor for smoothing the tentative prolongation
SHORT postsmooth_iter
number of postsmoothing
SHORT max_levels
max number of AMG levels
SHORT presmooth_iter
number of presmoothing
INT maxit
max number of iterations of AMG preconditioner
SHORT smooth_order
AMG smoother ordering.