24#include "fasp_functs.h"
70 REAL solve_start, solve_end;
73 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
74 printf(
"### DEBUG: rhs/sol size: %d %d\n", b->
row, x->
row);
80 ITS_CHECK ( MaxIt, tol );
82 switch (itsolver_type) {
105 printf(
"### ERROR: Unknown iterative solver type %d! [%s]\n",
106 itsolver_type, __FUNCTION__);
111 if ( (prtlvl >
PRINT_MIN) && (iter >= 0) ) {
113 fasp_cputime(
"Iterative method", solve_end - solve_start);
117 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
146 REAL solve_start, solve_end;
149 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
160 fasp_cputime(
"Krylov method totally", solve_end - solve_start);
163 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
194 REAL solve_start, solve_end;
202 INT myid, mybegin, myend;
203 INT nthreads = fasp_get_num_threads();
210 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
216#pragma omp parallel for private(myid, mybegin, myend, i, k)
217 for (myid=0; myid<nthreads; ++myid) {
219 for (i = mybegin; i < myend; ++i) {
220 for (k = A->
IA[i]; k < A->IA[i+1]; ++k) {
229 for (i = 0; i < ROW; ++i) {
230 for (k = A->
IA[i]; k < A->IA[i+1]; ++k) {
242#pragma omp parallel for if(ROW>OPENMP_HOLDS)
244 for (i=0; i<ROW; ++i){
260 fasp_cputime(
"Diag_Krylov method totally", solve_end - solve_start);
266 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
296 REAL solve_start, solve_end;
303 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
304 printf(
"### DEBUG: matrix size: %d %d %d\n", A->
ROW, A->
COL, A->
NNZ);
305 printf(
"### DEBUG: rhs/sol size: %d %d\n", b->
row, x->
row);
325 fasp_cputime(
"ILUk_Krylov method totally", solve_end - solve_start);
331 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
375 REAL setup_start, setup_end, solve_end;
378 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
403 if (status < 0)
goto FINISHED;
408 precdata.
tol = amgparam->
tol;
424 prec.
data = &precdata;
445 fasp_cputime(
"BSR Krylov method", solve_end - setup_start);
451 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
458 printf(
"### ERROR: Cannot allocate memory! [%s]\n", __FUNCTION__);
506 REAL setup_start, setup_end, setup_time;
507 REAL solve_start, solve_end, solve_time;
510 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
539 if (status < 0)
goto FINISHED;
544 precdata.
tol = amgparam->
tol;
566 precdata.
A_nk = &A_tran;
568 precdata.
A_nk = A_nk;
571 precdata.
P_nk = P_nk;
572 precdata.
R_nk = R_nk;
574 if (status < 0)
goto FINISHED;
577 prec.
data = &precdata;
583 setup_time = setup_end - setup_start;
596 solve_time = solve_end - solve_start;
599 fasp_cputime(
"BSR Krylov method", setup_time+solve_time);
606 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
616 printf(
"### ERROR: Cannot allocate memory! [%s]\n", __FUNCTION__);
665 REAL setup_start, setup_end, setup_time;
666 REAL solve_start, solve_end, solve_time;
669 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
691 for ( i=0; i < mgl->
near_kernel_dim; ++i ) mgl[0].near_kernel_basis[i] = nk[i].val;
703 if (status < 0)
goto FINISHED;
708 precdata.
tol = amgparam->
tol;
723 if (status < 0)
goto FINISHED;
726 prec.
data = &precdata;
738 setup_time = setup_end - setup_start;
751 solve_time = solve_end - solve_start;
754 fasp_cputime(
"BSR Krylov method", setup_time+solve_time);
761 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
768 printf(
"### ERROR: Cannot allocate memory! [%s]\n", __FUNCTION__);
SHORT fasp_mem_iludata_check(const ILU_data *iludata)
Check wether a ILU_data has enough work space.
void * fasp_mem_calloc(const unsigned int size, const unsigned int type)
Allocate, initiate, and check memory.
void fasp_cputime(const char *message, const REAL cputime)
Print CPU walltime.
void fasp_get_start_end(const INT procid, const INT nprocs, const INT n, INT *start, INT *end)
Assign Load to each thread.
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.
void fasp_dvec_alloc(const INT m, dvector *u)
Create dvector data space of REAL type.
SHORT fasp_ilu_dbsr_setup(dBSRmat *A, ILU_data *iludata, ILU_param *iluparam)
Get ILU decoposition of a BSR matrix A.
SHORT fasp_smat_inv(REAL *a, const INT n)
Compute the inverse matrix of a small full matrix a.
dBSRmat fasp_dbsr_create(const INT ROW, const INT COL, const INT NNZ, const INT nb, const INT storage_manner)
Create BSR sparse matrix data memory space.
void fasp_dbsr_cp(const dBSRmat *A, dBSRmat *B)
copy a dCSRmat to a new one B=A
dCSRmat fasp_dcsr_create(const INT m, const INT n, const INT nnz)
Create CSR sparse matrix data memory space.
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.
INT fasp_solver_dbsr_pbcgs(dBSRmat *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 BSR matrix.
INT fasp_solver_dbsr_pcg(dBSRmat *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_dbsr_pgmres(dBSRmat *A, dvector *b, dvector *x, precond *pc, const REAL tol, const INT MaxIt, const SHORT restart, const SHORT StopType, const SHORT PrtLvl)
Preconditioned GMRES method for solving Au=b.
INT fasp_solver_dbsr_pvfgmres(dBSRmat *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_dbsr_pvgmres(dBSRmat *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...
SHORT fasp_amg_setup_sa_bsr(AMG_data_bsr *mgl, AMG_param *param)
Set up phase of smoothed aggregation AMG (BSR format)
SHORT fasp_amg_setup_ua_bsr(AMG_data_bsr *mgl, AMG_param *param)
Set up phase of unsmoothed aggregation AMG (BSR format)
void fasp_precond_dbsr_amg(REAL *r, REAL *z, void *data)
AMG preconditioner.
void fasp_precond_dbsr_amg_nk(REAL *r, REAL *z, void *data)
AMG with extra near kernel solve preconditioner.
void fasp_precond_dbsr_diag(REAL *r, REAL *z, void *data)
Diagonal preconditioner z=inv(D)*r.
void fasp_precond_dbsr_ilu(REAL *r, REAL *z, void *data)
ILU preconditioner.
void fasp_precond_dbsr_namli(REAL *r, REAL *z, void *data)
Nonlinear AMLI-cycle AMG preconditioner.
AMG_data_bsr * fasp_amg_data_bsr_create(SHORT max_levels)
Create and initialize AMG_data data sturcture for AMG/SAMG (BSR format)
void fasp_ilu_data_free(ILU_data *iludata)
Create ILU_data sturcture.
void fasp_amg_data_bsr_free(AMG_data_bsr *mgl)
Free AMG_data_bsr data memeory space.
INT fasp_solver_dbsr_krylov_amg_nk(dBSRmat *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 with extra near kernel solve preconditioned Krylov methods.
INT fasp_solver_dbsr_krylov_ilu(dBSRmat *A, dvector *b, dvector *x, ITS_param *itparam, ILU_param *iluparam)
Solve Ax=b by ILUs preconditioned Krylov methods.
INT fasp_solver_dbsr_krylov_diag(dBSRmat *A, dvector *b, dvector *x, ITS_param *itparam)
Solve Ax=b by diagonal preconditioned Krylov methods.
INT fasp_solver_dbsr_krylov(dBSRmat *A, dvector *b, dvector *x, ITS_param *itparam)
Solve Ax=b by standard Krylov methods for BSR matrices.
INT fasp_solver_dbsr_itsolver(dBSRmat *A, dvector *b, dvector *x, precond *pc, ITS_param *itparam)
Solve Ax=b by preconditioned Krylov methods for BSR matrices.
INT fasp_solver_dbsr_krylov_nk_amg(dBSRmat *A, dvector *b, dvector *x, ITS_param *itparam, AMG_param *amgparam, const INT nk_dim, dvector *nk)
Solve Ax=b by AMG preconditioned Krylov methods with extra kernal space.
INT fasp_solver_dbsr_krylov_amg(dBSRmat *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.
Data for multigrid levels in dBSRmat format.
INT near_kernel_dim
dimension of the near kernel for SAMG
dBSRmat A
pointer to the matrix at level level_num
dCSRmat * A_nk
Matrix data for near kernal.
dvector b
pointer to the right-hand side at level level_num
REAL ** near_kernel_basis
basis of near kernel space for SAMG
INT num_levels
number of levels in use <= max_levels
dCSRmat * R_nk
Resriction for near kernal.
dvector x
pointer to the iterative solution at level level_num
dCSRmat * P_nk
Prolongation for near kernal.
Parameters for AMG methods.
SHORT print_level
print level for AMG
SHORT coarsening_type
coarsening type
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
stopping tolerance for AMG solver
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
REAL tentative_smooth
relaxation parameter for smoothing the tentative prolongation
SHORT postsmooth_iter
number of postsmoothers
SHORT max_levels
max number of levels of AMG
SHORT presmooth_iter
number of presmoothers
INT maxit
max number of iterations of AMG
Parameters for iterative solvers.
Block sparse row storage matrix of REAL type.
INT COL
number of cols of sub-blocks in matrix A, N
INT NNZ
number of nonzero sub-blocks in matrix A, NNZ
INT nb
dimension of each sub-block
INT * IA
integer array of row pointers, the size is ROW+1
INT ROW
number of rows of sub-blocks in matrix A, M
INT storage_manner
storage manner for each sub-block
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.
REAL * val
actual vector entries
Data for preconditioners in dBSRmat format.
SHORT print_level
print level in AMG preconditioner
SHORT coarsening_type
coarsening type
SHORT coarse_scaling
switch of scaling of the coarse grid correction
dCSRmat * A_nk
Matrix data for near kernal.
REAL * amli_coef
coefficients of the polynomial used by AMLI cycle
REAL tol
tolerance for AMG preconditioner
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
dCSRmat * R_nk
Resriction for near kernal.
AMG_data_bsr * mgl_data
AMG preconditioner data.
INT max_levels
max number of AMG levels
dCSRmat * P_nk
Prolongation for near kernal.
SHORT presmooth_iter
number of presmoothing
INT maxit
max number of iterations of AMG preconditioner
Data for diagnal preconditioners in dBSRmat format.
INT nb
dimension of each sub-block
dvector diag
diagnal elements
Preconditioner data and action.
void * data
data for preconditioner, void pointer
void(* fct)(REAL *, REAL *, void *)
action for preconditioner, void function pointer