18#include "fasp_functs.h"
24#include "PreMGUtil.inl"
57 INT max_levels, nnz, m, n;
59 switch (precond_type) {
104 nnz = A->nnz; m = A->row; n = A->col;
180 memcpy(z,r,m*
sizeof(
REAL));
203 const INT m=iludata->
row, mm1=m-1, memneed=2*m;
206 if (iludata->
nwork<memneed)
goto MEMERR;
209 zr = iludata->
work+m;
213 INT i, j, jj, begin_row, end_row, mm2=m-2;
220 for (i=1;i<=mm1;++i) {
221 begin_row=ijlu[i]; end_row=ijlu[i+1]-1;
222 for (j=begin_row;j<=end_row;++j) {
224 if (jj<i) zr[i]-=lu[j]*zz[jj];
231 z[mm1]=zz[mm1]*lu[mm1];
232 for (i=mm2;i>=0;i--) {
233 begin_row=ijlu[i]; end_row=ijlu[i+1]-1;
234 for (j=end_row;j>=begin_row;j--) {
236 if (jj>i) zz[i]-=lu[j]*z[jj];
246 printf(
"### ERROR: Need %d memory, only %d available!\n",
247 memneed, iludata->
nwork);
268 const INT m=iludata->
row, mm1=m-1, memneed=2*m;
271 if (iludata->
nwork<memneed)
goto MEMERR;
274 zr = iludata->
work+m;
278 INT i, j, jj, begin_row, end_row;
284 for (i=1;i<=mm1;++i) {
285 begin_row=ijlu[i]; end_row=ijlu[i+1]-1;
286 for (j=begin_row;j<=end_row;++j) {
288 if (jj<i) zr[i]-=lu[j]*zz[jj];
300 printf(
"### ERROR: Need %d memory, only %d available!",
301 memneed, iludata->
nwork);
322 const INT m=iludata->
row, mm1=m-1, memneed=2*m;
325 if (iludata->
nwork<memneed)
goto MEMERR;
331 INT i, j, jj, begin_row, end_row, mm2=m-2;
336 z[mm1]=zz[mm1]*lu[mm1];
337 for (i=mm2;i>=0;i--) {
338 begin_row=ijlu[i]; end_row=ijlu[i+1]-1;
339 for (j=end_row;j>=begin_row;j--) {
341 if (jj>i) zz[i]-=lu[j]*z[jj];
352 printf(
"### ERROR: Need %d memory, only %d available!",
353 memneed, iludata->
nwork);
578 fasp_coarse_itsolver(A_nk, &r_nk, &z_nk, 1e-12, 0);
612 fasp_coarse_itsolver(A_nk, &r_nk, &z_nk, 1e-12, 0);
void fasp_darray_set(const INT n, REAL *x, const REAL val)
Set initial value for an array to be x=val.
void fasp_darray_cp(const INT n, const REAL *x, REAL *y)
Copy an array to the other y=x.
void * fasp_mem_calloc(const unsigned int size, const unsigned int type)
Allocate, initiate, and check memory.
void fasp_chkerr(const SHORT status, const char *fctname)
Check error status and print out error messages before quit.
void fasp_param_amg_to_prec(precond_data *pcdata, const AMG_param *amgparam)
Set precond_data with AMG_param.
void fasp_param_amg_init(AMG_param *amgparam)
Initialize AMG parameters.
void fasp_param_prec_to_amg(AMG_param *amgparam, const precond_data *pcdata)
Set AMG_param with precond_data.
dvector fasp_dvec_create(const INT m)
Create dvector data space of REAL type.
void fasp_dvec_set(INT n, dvector *x, const REAL val)
Initialize dvector x[i]=val for i=0:n-1.
void fasp_dvec_alloc(const INT m, dvector *u)
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.
void fasp_dcsr_swz_forward(SWZ_data *swzdata, SWZ_param *swzparam, dvector *x, dvector *b)
Schwarz smoother: forward sweep.
void fasp_dcsr_swz_backward(SWZ_data *swzdata, SWZ_param *swzparam, dvector *x, dvector *b)
Schwarz smoother: backward sweep.
dCSRmat fasp_dcsr_create(const INT m, const INT n, const INT nnz)
Create CSR sparse matrix data memory space.
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.
void fasp_blas_dcsr_mxv(const dCSRmat *A, const REAL *x, REAL *y)
Matrix-vector multiplication y = A*x.
void fasp_blas_dcsr_aAxpy(const REAL alpha, const dCSRmat *A, const REAL *x, REAL *y)
Matrix-vector multiplication y = alpha*A*x + y.
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_backward(REAL *r, REAL *z, void *data)
ILU preconditioner: only backward sweep.
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.
precond * fasp_precond_setup(const SHORT precond_type, AMG_param *amgparam, ILU_param *iluparam, dCSRmat *A)
Setup preconditioner interface for iterative methods.
void fasp_precond_famg(REAL *r, REAL *z, void *data)
Full AMG preconditioner.
void fasp_precond_ilu_forward(REAL *r, REAL *z, void *data)
ILU preconditioner: only forward sweep.
void fasp_precond_amli(REAL *r, REAL *z, void *data)
AMLI AMG preconditioner.
AMG_data * fasp_amg_data_create(SHORT max_levels)
Create and initialize AMG_data for classical and SA AMG.
void fasp_solver_fmgcycle(AMG_data *mgl, AMG_param *param)
Solve Ax=b with non-recursive full multigrid K-cycle.
void fasp_solver_mgcycle(AMG_data *mgl, AMG_param *param)
Solve Ax=b with non-recursive multigrid cycle.
void fasp_solver_namli(AMG_data *mgl, AMG_param *param, INT l, INT num_levels)
Solve Ax=b with recursive nonlinear AMLI-cycle.
void fasp_solver_amli(AMG_data *mgl, AMG_param *param, INT l)
Solve Ax=b with recursive AMLI-cycle.
INT fasp_solver_umfpack(dCSRmat *ptrA, dvector *b, dvector *u, const SHORT prtlvl)
Solve Au=b by UMFpack.
Main header file for the FASP project.
#define SHORT
FASP integer and floating point numbers.
#define SCHWARZ_SYMMETRIC
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
INT * ijlu
integer array of row pointers and column indexes, the size is nzlu
REAL * luval
nonzero entries of LU
INT row
row number of matrix LU, m
Data for Schwarz methods.
dCSRmat A
pointer to the original coefficient matrix
SWZ_param * swzparam
param for Schwarz
INT SWZ_type
Schwarz method type.
Parameters 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.
REAL * val
actual vector entries
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.
INT maxit
max number of iterations of AMG preconditioner
Preconditioner data and action.
void * data
data for preconditioner, void pointer
void(* fct)(REAL *, REAL *, void *)
action for preconditioner, void function pointer