25#include "fasp_functs.h"
68 REAL solve_start, solve_end;
72 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
73 printf(
"### DEBUG: rhs/sol size: %d %d\n", b->
row, x->
row);
82 ITS_CHECK(MaxIt, tol);
85 switch (itsolver_type) {
127 printf(
"### ERROR: Unknown iterative solver type %d! [%s]\n", itsolver_type,
134 fasp_cputime(
"Iterative method", solve_end - solve_start);
138 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
174 REAL solve_start, solve_end;
178 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
179 printf(
"### DEBUG: rhs/sol size: %d %d\n", b->
row, x->
row);
188 ITS_CHECK(MaxIt, tol);
191 switch (itsolver_type) {
216 printf(
"### ERROR: Unknown iterative solver type %d! [%s]\n", itsolver_type,
223 fasp_cputime(
"Iterative method", solve_end - solve_start);
227 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
255 REAL solve_start, solve_end;
258 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
259 printf(
"### DEBUG: matrix size: %d %d %d\n", A->
row, A->
col, A->
nnz);
260 printf(
"### DEBUG: rhs/sol size: %d %d\n", b->
row, x->
row);
269 fasp_cputime(
"Krylov method totally", solve_end - solve_start);
273 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
301 REAL solve_start, solve_end;
304 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
305 printf(
"### DEBUG: matrix size: %d %d %d\n", A->
row, A->
col, A->
nnz);
306 printf(
"### DEBUG: rhs/sol size: %d %d\n", b->
row, x->
row);
315 fasp_cputime(
"Krylov method totally", solve_end - solve_start);
319 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
347 REAL solve_start, solve_end;
350 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
351 printf(
"### DEBUG: matrix size: %d %d %d\n", A->
row, A->
col, A->
nnz);
352 printf(
"### DEBUG: rhs/sol size: %d %d\n", b->
row, x->
row);
370 fasp_cputime(
"Diag_Krylov method totally", solve_end - solve_start);
376 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
412 REAL setup_start, setup_end;
413 REAL solve_start, solve_end;
417 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
418 printf(
"### DEBUG: matrix size: %d %d %d\n", A->
row, A->
col, A->
nnz);
419 printf(
"### DEBUG: rhs/sol size: %d %d\n", b->
row, x->
row);
436 printf(
"SWZ_Krylov method setup %f seconds.\n", setup_end - setup_start);
447 fasp_cputime(
"SWZ_Krylov method totally", solve_end - solve_start);
451 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
485 REAL solve_start, solve_end;
494 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
495 printf(
"### DEBUG: matrix size: %d %d %d\n", A->
row, A->
col, A->
nnz);
496 printf(
"### DEBUG: rhs/sol size: %d %d\n", b->
row, x->
row);
527 if (status < 0)
goto FINISHED;
558 fasp_cputime(
"AMG_Krylov method totally", solve_end - solve_start);
565 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
595 REAL solve_start, solve_end, solve_time;
598 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
599 printf(
"### DEBUG: matrix size: %d %d %d\n", A->
row, A->
col, A->
nnz);
600 printf(
"### DEBUG: rhs/sol size: %d %d\n", b->
row, x->
row);
622 solve_time = solve_end - solve_start;
629 fasp_cputime(
"ILUtp_Krylov method totally", solve_time);
640 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
674 REAL solve_start, solve_end, solve_time;
678 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
679 printf(
"### DEBUG: matrix size: %d %d %d\n", A->
row, A->
col, A->
nnz);
680 printf(
"### DEBUG: rhs/sol size: %d %d\n", b->
row, x->
row);
702 solve_time = solve_end - solve_start;
720 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
758 REAL solve_start, solve_end, solve_time;
767 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
768 printf(
"### DEBUG: matrix size: %d %d %d\n", A->
row, A->
col, A->
nnz);
769 printf(
"### DEBUG: rhs/sol size: %d %d\n", b->
row, x->
row);
800 if (status < 0)
goto FINISHED;
816 pcdata.
A_nk = &A_tran;
833 solve_time = solve_end - solve_start;
845 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
void fasp_mem_usage(void)
Show total allocated memory currently.
SHORT fasp_mem_iludata_check(const ILU_data *iludata)
Check wether a ILU_data has enough work space.
void fasp_cputime(const char *message, const REAL cputime)
Print CPU walltime.
void fasp_param_amg_to_prec(precond_data *pcdata, const AMG_param *amgparam)
Set precond_data with AMG_param.
void fasp_gettime(REAL *time)
Get system time.
void fasp_dvec_free(dvector *u)
Free vector data space of REAL type.
dvector fasp_dvec_create(const INT m)
Create dvector data space of REAL type.
SHORT fasp_ilu_dcsr_setup(dCSRmat *A, ILU_data *iludata, ILU_param *iluparam)
Get ILU decomposition of a CSR matrix A.
INT fasp_swz_dcsr_setup(SWZ_data *swzdata, SWZ_param *swzparam)
Setup phase for the Schwarz methods.
dCSRmat fasp_dcsr_create(const INT m, const INT n, const INT nnz)
Create CSR sparse matrix data memory space.
void fasp_dcsr_shift(dCSRmat *A, const INT offset)
Re-index a REAL matrix in CSR format to make the index starting from 0 or 1.
void fasp_dcsr_free(dCSRmat *A)
Free CSR sparse matrix data memory space.
void fasp_dcsr_transz(dCSRmat *A, INT *p, dCSRmat *AT)
Generalized transpose of A: (n x m) matrix given in dCSRmat format.
void fasp_dcsr_cp(const dCSRmat *A, dCSRmat *B)
copy a dCSRmat to a new one B=A
void fasp_dcsr_getdiag(INT n, const dCSRmat *A, dvector *diag)
Get first n diagonal entries of a CSR matrix A.
dCSRmat fasp_dcsr_sympart(dCSRmat *A)
Get symmetric part of a dCSRmat matrix.
void fasp_check_dCSRmat(const dCSRmat *A)
Check whether an dCSRmat matrix is supported or not.
INT fasp_solver_dcsr_pbcgs(dCSRmat *A, dvector *b, dvector *u, precond *pc, const REAL tol, const REAL abstol, const INT MaxIt, const SHORT StopType, const SHORT PrtLvl)
Preconditioned BiCGstab method for solving Au=b for CSR matrix.
INT fasp_solver_dcsr_pcg(dCSRmat *A, dvector *b, dvector *u, precond *pc, const REAL tol, const REAL abstol, const INT MaxIt, const SHORT StopType, const SHORT PrtLvl)
Preconditioned conjugate gradient method for solving Au=b.
INT fasp_solver_dcsr_pgcg(dCSRmat *A, dvector *b, dvector *u, precond *pc, const REAL tol, const REAL abstol, const INT MaxIt, const SHORT StopType, const SHORT PrtLvl)
Preconditioned generilzed conjugate gradient (GCG) method for solving Au=b.
INT fasp_solver_dcsr_pgcr(dCSRmat *A, dvector *b, dvector *x, precond *pc, const REAL tol, const REAL abstol, const INT MaxIt, const SHORT restart, const SHORT StopType, const SHORT PrtLvl)
A preconditioned GCR method for solving Au=b.
INT fasp_solver_dcsr_pgmres(dCSRmat *A, dvector *b, dvector *x, precond *pc, const REAL tol, const REAL abstol, const INT MaxIt, const SHORT restart, const SHORT StopType, const SHORT PrtLvl)
Right preconditioned GMRES method for solving Au=b.
INT fasp_solver_dcsr_pminres(dCSRmat *A, dvector *b, dvector *u, precond *pc, const REAL tol, const REAL abstol, const INT MaxIt, const SHORT StopType, const SHORT PrtLvl)
A preconditioned minimal residual (Minres) method for solving Au=b.
INT fasp_solver_dcsr_pvfgmres(dCSRmat *A, dvector *b, dvector *x, precond *pc, const REAL tol, const REAL abstol, const INT MaxIt, const SHORT restart, const SHORT StopType, const SHORT PrtLvl)
Solve "Ax=b" using PFGMRES(right preconditioned) iterative method in which the restart parameter can ...
INT fasp_solver_dcsr_pvgmres(dCSRmat *A, dvector *b, dvector *x, precond *pc, const REAL tol, const REAL abstol, const INT MaxIt, const SHORT restart, const SHORT StopType, const SHORT PrtLvl)
Right preconditioned GMRES method in which the restart parameter can be adaptively modified during it...
INT fasp_solver_dcsr_spbcgs(const dCSRmat *A, const dvector *b, dvector *u, precond *pc, const REAL tol, const INT MaxIt, const SHORT StopType, const SHORT PrtLvl)
Preconditioned BiCGstab method for solving Au=b with safety net.
INT fasp_solver_dcsr_spcg(const dCSRmat *A, const dvector *b, dvector *u, precond *pc, const REAL tol, const INT MaxIt, const SHORT StopType, const SHORT PrtLvl)
Preconditioned conjugate gradient method for solving Au=b with safety net.
INT fasp_solver_dcsr_spgmres(const dCSRmat *A, const dvector *b, dvector *x, precond *pc, const REAL tol, const INT MaxIt, SHORT restart, const SHORT StopType, const SHORT PrtLvl)
Preconditioned GMRES method for solving Au=b with safe-guard.
INT fasp_solver_dcsr_spminres(const dCSRmat *A, const dvector *b, dvector *u, precond *pc, const REAL tol, const INT MaxIt, const SHORT StopType, const SHORT PrtLvl)
A preconditioned minimal residual (Minres) method for solving Au=b with safety net.
INT fasp_solver_dcsr_spvgmres(const dCSRmat *A, const dvector *b, dvector *x, precond *pc, const REAL tol, const INT MaxIt, SHORT restart, const SHORT StopType, const SHORT PrtLvl)
Solve "Ax=b" using PGMRES(right preconditioned) iterative method in which the restart parameter can b...
SHORT fasp_amg_setup_rs(AMG_data *mgl, AMG_param *param)
Setup phase of Ruge and Stuben's classic AMG.
SHORT fasp_amg_setup_sa(AMG_data *mgl, AMG_param *param)
Set up phase of smoothed aggregation AMG.
SHORT fasp_amg_setup_ua(AMG_data *mgl, AMG_param *param)
Set up phase of unsmoothed aggregation AMG.
void fasp_precond_amg(REAL *r, REAL *z, void *data)
AMG preconditioner.
void fasp_precond_ilu(REAL *r, REAL *z, void *data)
ILU preconditioner.
void fasp_precond_swz(REAL *r, REAL *z, void *data)
get z from r by Schwarz
void fasp_precond_namli(REAL *r, REAL *z, void *data)
Nonlinear AMLI AMG preconditioner.
void fasp_precond_amg_nk(REAL *r, REAL *z, void *data)
AMG with extra near kernel solve as preconditioner.
void fasp_precond_diag(REAL *r, REAL *z, void *data)
Diagonal preconditioner z=inv(D)*r.
void fasp_precond_famg(REAL *r, REAL *z, void *data)
Full AMG preconditioner.
void fasp_precond_amli(REAL *r, REAL *z, void *data)
AMLI AMG preconditioner.
void fasp_swz_data_free(SWZ_data *swzdata)
Free SWZ_data data memeory space.
AMG_data * fasp_amg_data_create(SHORT max_levels)
Create and initialize AMG_data for classical and SA AMG.
void fasp_amg_data_free(AMG_data *mgl, AMG_param *param)
Free AMG_data data memeory space.
void fasp_ilu_data_free(ILU_data *iludata)
Create ILU_data sturcture.
INT fasp_solver_dcsr_itsolver(dCSRmat *A, dvector *b, dvector *x, precond *pc, ITS_param *itparam)
Solve Ax=b by preconditioned Krylov methods for CSR matrices.
INT fasp_solver_dcsr_krylov_amg_nk(dCSRmat *A, dvector *b, dvector *x, ITS_param *itparam, AMG_param *amgparam, dCSRmat *A_nk, dCSRmat *P_nk, dCSRmat *R_nk)
Solve Ax=b by AMG preconditioned Krylov methods with an extra near kernel solve.
INT fasp_solver_dcsr_krylov_ilu_M(dCSRmat *A, dvector *b, dvector *x, ITS_param *itparam, ILU_param *iluparam, dCSRmat *M)
Solve Ax=b by ILUs preconditioned Krylov methods: ILU of M as preconditioner.
INT fasp_solver_dcsr_krylov_ilu(dCSRmat *A, dvector *b, dvector *x, ITS_param *itparam, ILU_param *iluparam)
Solve Ax=b by ILUs preconditioned Krylov methods.
INT fasp_solver_dcsr_krylov_diag(dCSRmat *A, dvector *b, dvector *x, ITS_param *itparam)
Solve Ax=b by diagonal preconditioned Krylov methods.
INT fasp_solver_dcsr_krylov_s(dCSRmat *A, dvector *b, dvector *x, ITS_param *itparam)
Solve Ax=b by standard Krylov methods with safe-net for CSR matrices.
INT fasp_solver_dcsr_krylov(dCSRmat *A, dvector *b, dvector *x, ITS_param *itparam)
Solve Ax=b by standard Krylov methods for CSR matrices.
INT fasp_solver_dcsr_krylov_swz(dCSRmat *A, dvector *b, dvector *x, ITS_param *itparam, SWZ_param *schparam)
Solve Ax=b by overlapping Schwarz Krylov methods.
INT fasp_solver_dcsr_itsolver_s(dCSRmat *A, dvector *b, dvector *x, precond *pc, ITS_param *itparam)
Solve Ax=b by preconditioned Krylov methods with safe-net for CSR matrices.
INT fasp_solver_dcsr_krylov_amg(dCSRmat *A, dvector *b, dvector *x, ITS_param *itparam, AMG_param *amgparam)
Solve Ax=b by AMG preconditioned Krylov methods.
Main header file for the FASP project.
#define SHORT
FASP integer and floating point numbers.
#define FASP_SUCCESS
Definition of return status and error messages.
#define ERROR_SOLVER_TYPE
#define PRINT_NONE
Print level for all subroutines – not including DEBUG output.
dCSRmat A
pointer to the matrix at level level_num
dvector b
pointer to the right-hand side at level level_num
dvector x
pointer to the iterative solution at level level_num
SHORT num_levels
number of levels in use <= max_levels
Parameters for AMG methods.
SHORT AMG_type
type of AMG method
SHORT cycle_type
type of AMG cycle
SHORT max_levels
max number of levels of AMG
SHORT ILU_type
ILU type for decomposition.
Parameters for iterative solvers.
Data for Schwarz methods.
dCSRmat A
pointer to the original coefficient matrix
Parameters for Schwarz method.
INT SWZ_mmsize
maximal size of blocks
INT SWZ_maxlvl
maximal level for constructing the blocks
INT SWZ_blksolver
type of Schwarz block solver
SHORT SWZ_type
type for Schwarz method
Sparse matrix of REAL type in CSR format.
INT col
column of matrix A, n
INT row
row number of matrix A, m
INT nnz
number of nonzero entries
Vector with n entries of REAL type.
Data for preconditioners.
AMG_data * mgl_data
AMG preconditioner data.
dCSRmat * A_nk
Matrix data for near kernel.
dCSRmat * R_nk
Restriction for near kernel.
SHORT max_levels
max number of AMG levels
dCSRmat * P_nk
Prolongation for near kernel.
Preconditioner data and action.
void * data
data for preconditioner, void pointer
void(* fct)(REAL *, REAL *, void *)
action for preconditioner, void function pointer