17#include "fasp_functs.h"
44 int print_usage =
FALSE;
50 while (arg_index < argc) {
52 if (strcmp(argv[arg_index],
"-help") == 0) {
58 else if (strcmp(argv[arg_index],
"-ini") == 0) {
60 if (arg_index >= argc) {
61 printf(
"### ERROR: Missing ini filename! [%s]\n", __FUNCTION__);
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");
79 if (++arg_index >= argc)
break;
82 else if (strcmp(argv[arg_index],
"-output") == 0) {
84 if (arg_index >= argc) {
85 printf(
"### ERROR: Expecting output type (0 or 1).\n");
90 if (++arg_index >= argc)
break;
93 else if (strcmp(argv[arg_index],
"-solver") == 0) {
95 if (arg_index >= argc) {
96 printf(
"### ERROR: Expecting solver type.\n");
101 if (++arg_index >= argc)
break;
104 else if (strcmp(argv[arg_index],
"-precond") == 0) {
106 if (arg_index >= argc) {
107 printf(
"### ERROR: Expecting preconditioner type.\n");
112 if (++arg_index >= argc)
break;
115 else if (strcmp(argv[arg_index],
"-maxit") == 0) {
117 if (arg_index >= argc) {
118 printf(
"### ERROR: Expecting max number of iterations.\n");
123 if (++arg_index >= argc)
break;
126 else if (strcmp(argv[arg_index],
"-tol") == 0) {
128 if (arg_index >= argc) {
129 printf(
"### ERROR: Expecting tolerance for itsolver.\n");
134 if (++arg_index >= argc)
break;
137 else if (strcmp(argv[arg_index],
"-abstol") == 0) {
139 if (arg_index >= argc) {
140 printf(
"### ERROR: Expecting absolute tolerance for itsolver.\n");
145 if (++arg_index >= argc)
break;
148 else if (strcmp(argv[arg_index],
"-amgmaxit") == 0) {
150 if (arg_index >= argc) {
151 printf(
"### ERROR: Expecting max num of iterations for AMG.\n");
155 iniparam->
AMG_maxit = atoi(argv[arg_index]);
156 if (++arg_index >= argc)
break;
159 else if (strcmp(argv[arg_index],
"-amgtol") == 0) {
161 if (arg_index >= argc) {
162 printf(
"### ERROR: Expecting tolerance for AMG.\n");
166 iniparam->
AMG_tol = atof(argv[arg_index]);
167 if (++arg_index >= argc)
break;
170 else if (strcmp(argv[arg_index],
"-amgtype") == 0) {
172 if (arg_index >= argc) {
173 printf(
"### ERROR: Expecting AMG type (1, 2, 3).\n");
177 iniparam->
AMG_type = atoi(argv[arg_index]);
178 if (++arg_index >= argc)
break;
181 else if (strcmp(argv[arg_index],
"-amgcycle") == 0) {
183 if (arg_index >= argc) {
184 printf(
"### ERROR: Expecting AMG cycle type (1, 2, 3, 12, 21).\n");
189 if (++arg_index >= argc)
break;
192 else if (strcmp(argv[arg_index],
"-amgcoarsening") == 0) {
194 if (arg_index >= argc) {
195 printf(
"### ERROR: Expecting AMG coarsening type.\n");
200 if (++arg_index >= argc)
break;
203 else if (strcmp(argv[arg_index],
"-amginterplation") == 0) {
205 if (arg_index >= argc) {
206 printf(
"### ERROR: Expecting AMG interpolation type.\n");
211 if (++arg_index >= argc)
break;
214 else if (strcmp(argv[arg_index],
"-amgsmoother") == 0) {
216 if (arg_index >= argc) {
217 printf(
"### ERROR: Expecting AMG smoother type.\n");
222 if (++arg_index >= argc)
break;
225 else if (strcmp(argv[arg_index],
"-amgsthreshold") == 0) {
227 if (arg_index >= argc) {
228 printf(
"### ERROR: Expecting AMG strong threshold.\n");
233 if (++arg_index >= argc)
break;
236 else if (strcmp(argv[arg_index],
"-amgscouple") == 0) {
238 if (arg_index >= argc) {
239 printf(
"### ERROR: Expecting AMG strong coupled threshold.\n");
244 if (++arg_index >= argc)
break;
255 printf(
"FASP command line options:\n");
257 printf(
"================================================================\n");
258 printf(
" -ini [CharValue] : Ini file name\n");
259 printf(
" -print [IntValue] : Print level\n");
260 printf(
" -output [IntValue] : Output to screen or a log file\n");
261 printf(
" -solver [IntValue] : Solver type\n");
262 printf(
" -precond [IntValue] : Preconditioner type\n");
263 printf(
" -maxit [IntValue] : Max number of iterations\n");
264 printf(
" -tol [RealValue] : Tolerance for iterative solvers\n");
265 printf(
" -amgmaxit [IntValue] : Max number of AMG iterations\n");
266 printf(
" -amgtol [RealValue] : Tolerance for AMG methods\n");
267 printf(
" -amgtype [IntValue] : AMG type\n");
268 printf(
" -amgcycle [IntValue] : AMG cycle type\n");
269 printf(
" -amgcoarsening [IntValue] : AMG coarsening type\n");
270 printf(
" -amginterpolation [IntValue] : AMG interpolation type\n");
271 printf(
" -amgsmoother [IntValue] : AMG smoother type\n");
272 printf(
" -amgsthreshold [RealValue] : AMG strong threshold\n");
273 printf(
" -amgscoupled [RealValue] : AMG strong coupled threshold\n");
274 printf(
" -help : Brief help messages\n");
328 printf(
"### WARNING: No input given! Use default values instead.\n");
332 if ((itsparam == NULL) && (amgparam != NULL)) {
349 strcpy(iniparam->
workdir,
"../data/");
437 amgparam->
tol = 1e-6;
488 amgparam->
theta = -1.0;
508 amgparam_dest->
tol = amgparam_src->
tol;
579 itsparam->
maxit = 500;
581 itsparam->
tol = 1e-6;
788 pcdata->
tol = amgparam->
tol;
854 pcdata->
tol = amgparam->
tol;
916 printf(
"\n Parameters in AMG_param\n");
917 printf(
"-----------------------------------------------\n");
919 printf(
"AMG print level: %d\n", param->
print_level);
920 printf(
"AMG max num of iter: %d\n", param->
maxit);
921 printf(
"AMG type: %d\n", param->
AMG_type);
922 printf(
"AMG tolerance: %.2e\n", param->
tol);
923 printf(
"AMG max levels: %d\n", param->
max_levels);
924 printf(
"AMG cycle type: %d\n", param->
cycle_type);
925 printf(
"AMG coarse solver type: %d\n", param->
coarse_solver);
926 printf(
"AMG scaling of coarse correction: %d\n", param->
coarse_scaling);
927 printf(
"AMG smoother type: %d\n", param->
smoother);
928 printf(
"AMG smoother order: %d\n", param->
smooth_order);
934 printf(
"AMG relax factor: %.4f\n", param->
relaxation);
942 printf(
"AMG AMLI degree of polynomial: %d\n", param->
amli_degree);
946 printf(
"AMG Nonlinear AMLI Krylov type: %d\n",
952 printf(
"AMG coarsening type: %d\n",
954 printf(
"AMG interpolation type: %d\n",
956 printf(
"AMG dof on coarsest grid: %d\n", param->
coarse_dof);
957 printf(
"AMG strong threshold: %.4f\n",
959 printf(
"AMG truncation threshold: %.4f\n",
961 printf(
"AMG max row sum: %.4f\n", param->
max_row_sum);
962 printf(
"AMG aggressive levels: %d\n",
964 printf(
"AMG aggressive path: %d\n",
969 printf(
"Aggregation type: %d\n",
972 printf(
"Aggregation number of pairs: %d\n",
974 printf(
"Aggregation quality bound: %.2f\n",
978 printf(
"Aggregation strong coupling: %.4f\n",
980 printf(
"Aggregation max aggregation: %d\n",
982 printf(
"Aggregation tentative smooth: %.4f\n",
984 printf(
"Aggregation smooth filter: %d\n",
986 printf(
"Aggregation smooth restriction: %d\n",
993 printf(
"AMG ILU smoother level: %d\n", param->
ILU_levels);
994 printf(
"AMG ILU type: %d\n", param->
ILU_type);
995 printf(
"AMG ILU level of fill-in: %d\n", param->
ILU_lfil);
996 printf(
"AMG ILU drop tol: %e\n", param->
ILU_droptol);
997 printf(
"AMG ILU relaxation: %f\n", param->
ILU_relax);
1001 printf(
"AMG Schwarz smoother level: %d\n", param->
SWZ_levels);
1002 printf(
"AMG Schwarz type: %d\n", param->
SWZ_type);
1003 printf(
"AMG Schwarz forming block level: %d\n", param->
SWZ_maxlvl);
1004 printf(
"AMG Schwarz maximal block size: %d\n", param->
SWZ_mmsize);
1007 printf(
"-----------------------------------------------\n\n");
1010 printf(
"### WARNING: AMG_param has not been set!\n");
1028 printf(
"\n Parameters in ILU_param\n");
1029 printf(
"-----------------------------------------------\n");
1030 printf(
"ILU print level: %d\n", param->
print_level);
1031 printf(
"ILU type: %d\n", param->
ILU_type);
1032 printf(
"ILU level of fill-in: %d\n", param->
ILU_lfil);
1033 printf(
"ILU relaxation factor: %.4f\n", param->
ILU_relax);
1034 printf(
"ILU drop tolerance: %.2e\n", param->
ILU_droptol);
1035 printf(
"ILU permutation tolerance: %.2e\n", param->
ILU_permtol);
1036 printf(
"-----------------------------------------------\n\n");
1039 printf(
"### WARNING: ILU_param has not been set!\n");
1057 printf(
"\n Parameters in SWZ_param\n");
1058 printf(
"-----------------------------------------------\n");
1059 printf(
"Schwarz print level: %d\n", param->
print_level);
1060 printf(
"Schwarz type: %d\n", param->
SWZ_type);
1061 printf(
"Schwarz forming block level: %d\n", param->
SWZ_maxlvl);
1062 printf(
"Schwarz maximal block size: %d\n", param->
SWZ_mmsize);
1063 printf(
"Schwarz block solver type: %d\n", param->
SWZ_blksolver);
1064 printf(
"-----------------------------------------------\n\n");
1067 printf(
"### WARNING: SWZ_param has not been set!\n");
1085 printf(
"\n Parameters in ITS_param\n");
1086 printf(
"-----------------------------------------------\n");
1088 printf(
"Solver print level: %d\n", param->
print_level);
1090 printf(
"Solver precond type: %d\n", param->
precond_type);
1091 printf(
"Solver max num of iter: %d\n", param->
maxit);
1092 printf(
"Solver tolerance: %.5e\n", param->
tol);
1093 printf(
"Solver absolute tolerance: %.5e\n", param->
abstol);
1094 printf(
"Solver stopping type: %d\n", param->
stop_type);
1098 printf(
"Solver restart number: %d\n", param->
restart);
1101 printf(
"-----------------------------------------------\n\n");
1104 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_amg_copy(AMG_param *amgparam_src, AMG_param *amgparam_dest)
Copy AMG parameters from amgparam_src to amgparam_dest.
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.
SHORT aggregation_norm_type
aggregation norm type
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 theta
theta for reduction-based amg
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.