25#include "fasp_functs.h"
70 REAL solve_start, solve_end;
74 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
75 printf(
"### DEBUG: rhs/sol size: %d %d\n", b->
row, x->
row);
84 ITS_CHECK ( MaxIt, tol );
87 switch ( itsolver_type ) {
121 printf(
"### ERROR: Unknown iterative solver type %d! [%s]\n",
122 itsolver_type, __FUNCTION__);
127 if ( (prtlvl >=
PRINT_SOME) && (iter >= 0) ) {
129 fasp_cputime(
"Iterative method", solve_end - solve_start);
133 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
172 REAL solve_start, solve_end;
176 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
177 printf(
"### DEBUG: rhs/sol size: %d %d\n", b->
row, x->
row);
186 ITS_CHECK ( MaxIt, tol );
189 switch ( itsolver_type ) {
211 printf(
"### ERROR: Unknown iterative solver type %d! [%s]\n",
212 itsolver_type, __FUNCTION__);
217 if ( (prtlvl >=
PRINT_SOME) && (iter >= 0) ) {
219 fasp_cputime(
"Iterative method", solve_end - solve_start);
223 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
254 REAL solve_start, solve_end;
257 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
258 printf(
"### DEBUG: matrix size: %d %d %d\n", A->
row, A->
col, A->
nnz);
259 printf(
"### DEBUG: rhs/sol size: %d %d\n", b->
row, x->
row);
268 fasp_cputime(
"Krylov method totally", solve_end - solve_start);
272 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
303 REAL solve_start, solve_end;
306 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
307 printf(
"### DEBUG: matrix size: %d %d %d\n", A->
row, A->
col, A->
nnz);
308 printf(
"### DEBUG: rhs/sol size: %d %d\n", b->
row, x->
row);
317 fasp_cputime(
"Krylov method totally", solve_end - solve_start);
321 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
352 REAL solve_start, solve_end;
355 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
356 printf(
"### DEBUG: matrix size: %d %d %d\n", A->
row, A->
col, A->
nnz);
357 printf(
"### DEBUG: rhs/sol size: %d %d\n", b->
row, x->
row);
374 fasp_cputime(
"Diag_Krylov method totally", solve_end - solve_start);
380 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
419 REAL setup_start, setup_end;
420 REAL solve_start, solve_end;
424 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
425 printf(
"### DEBUG: matrix size: %d %d %d\n", A->
row, A->
col, A->
nnz);
426 printf(
"### DEBUG: rhs/sol size: %d %d\n", b->
row, x->
row);
443 printf(
"SWZ_Krylov method setup %f seconds.\n", setup_end - setup_start);
454 fasp_cputime(
"SWZ_Krylov method totally", solve_end - solve_start);
458 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
495 REAL solve_start, solve_end;
504 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
505 printf(
"### DEBUG: matrix size: %d %d %d\n", A->
row, A->
col, A->
nnz);
506 printf(
"### DEBUG: rhs/sol size: %d %d\n", b->
row, x->
row);
534 if (status < 0)
goto FINISHED;
563 fasp_cputime(
"AMG_Krylov method totally", solve_end - solve_start);
570 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
603 REAL solve_start, solve_end, solve_time;
606 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
607 printf(
"### DEBUG: matrix size: %d %d %d\n", A->
row, A->
col, A->
nnz);
608 printf(
"### DEBUG: rhs/sol size: %d %d\n", b->
row, x->
row);
630 solve_time = solve_end - solve_start;
637 fasp_cputime(
"ILUtp_Krylov method totally", solve_time);
648 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
686 REAL solve_start, solve_end, solve_time;
690 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
691 printf(
"### DEBUG: matrix size: %d %d %d\n", A->
row, A->
col, A->
nnz);
692 printf(
"### DEBUG: rhs/sol size: %d %d\n", b->
row, x->
row);
714 solve_time = solve_end - solve_start;
732 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
774 REAL solve_start, solve_end, solve_time;
783 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
784 printf(
"### DEBUG: matrix size: %d %d %d\n", A->
row, A->
col, A->
nnz);
785 printf(
"### DEBUG: rhs/sol size: %d %d\n", b->
row, x->
row);
813 if (status < 0)
goto FINISHED;
829 pcdata.
A_nk = &A_tran;
845 solve_time = solve_end - solve_start;
857 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 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 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 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 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 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 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 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 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