18#include "fasp_functs.h"
59 REAL *offdiag0=NULL, *offdiag1=NULL, *offdiag2=NULL;
60 REAL *offdiag3=NULL, *offdiag4=NULL, *offdiag5=NULL;
83 LUoffsets[0]=-1; LUoffsets[1]=1; LUoffsets[2]=-nline; LUoffsets[3]=nline;
85 else if (nband == 6) {
87 LUoffsets[0]=-1; LUoffsets[1]=1; LUoffsets[2]=-nline;
88 LUoffsets[3]=nline; LUoffsets[4]=-nplane; LUoffsets[5]=nplane;
91 printf(
"%s: number of bands for structured ILU is illegal!\n", __FUNCTION__);
99 memcpy(LU->
diag, diag, (ngrid*nc2)*
sizeof(
REAL));
102 for (i=0; i<nband; ++i) {
103 if (offsets[i] == -1) {
105 memcpy(LU->
offdiag[0],offdiag0,((ngrid -
ABS(offsets[i]))*nc2)*
sizeof(
REAL));
107 else if (offsets[i] == 1) {
109 memcpy(LU->
offdiag[1],offdiag1,((ngrid -
ABS(offsets[i]))*nc2)*
sizeof(
REAL));
111 else if (offsets[i] == -nline) {
113 memcpy(LU->
offdiag[2],offdiag2,((ngrid -
ABS(offsets[i]))*nc2)*
sizeof(
REAL));
115 else if (offsets[i] == nline) {
117 memcpy(LU->
offdiag[3],offdiag3,((ngrid -
ABS(offsets[i]))*nc2)*
sizeof(
REAL));
119 else if (offsets[i] == -nplane) {
121 memcpy(LU->
offdiag[4],offdiag4,((ngrid -
ABS(offsets[i]))*nc2)*
sizeof(
REAL));
123 else if (offsets[i] == nplane) {
125 memcpy(LU->
offdiag[5],offdiag5,((ngrid -
ABS(offsets[i]))*nc2)*
sizeof(
REAL));
128 printf(
"### ERROR: Illegal offset for ILU! [%s]\n", __FUNCTION__);
138 for (i=1;i<ngrid;++i) {
140 LU->
offdiag[0][i-1]=(offdiag0[i-1])*(LU->
diag[i-1]);
142 LU->
offdiag[2][i-nline]=(offdiag2[i-nline])*(LU->
diag[i-nline]);
144 LU->
offdiag[4][i-nplane]=(offdiag0[i-nplane])*(LU->
diag[i-nplane]);
163 for (i=1;i<ngrid;++i) {
201 for (i=1;i<ngrid;++i) {
239 for (i=1;i<ngrid;++i) {
277 for (i=1;i<ngrid;++i) {
336 const INT LUnband = 12;
339 const INT nc=A->
nc, nc2=nc*nc;
348 INT i,j,i1,ix,ixy,ixyx,ix1,ixy1,ic,i1c,ixc,ix1c,ixyc,ixy1c,ixyxc;
349 register REAL *smat,t,*tc;
374 LUoffsets[2] = 1-nline;
375 LUoffsets[3] = nline-1;
376 LUoffsets[4] = -nline;
377 LUoffsets[5] = nline;
378 LUoffsets[6] = nline-nplane;
379 LUoffsets[7] = nplane-nline;
380 LUoffsets[8] = 1-nplane;
381 LUoffsets[9] = nplane-1;
382 LUoffsets[10] = -nplane;
383 LUoffsets[11] = nplane;
399 for (i=1;i<ngrid;++i) {
401 i1=i-1;ix=i-nline;ixy=i-nplane;ix1=ix+1;ixyx=ixy+nline;ixy1=ixy+1;
464 if (i+nline-1<ngrid) {
482 if (i+nplane-nline<ngrid) {
516 for (i=1;i<ngrid;++i) {
517 i1=i-1;ix=i-nline;ixy=i-nplane;ix1=ix+1;ixyx=ixy+nline;ixy1=ixy+1;
518 ic=i*nc2;i1c=i1*nc2;ixc=ix*nc2;ix1c=ix1*nc2;ixyc=ixy*nc2;
519 ixy1c=ixy1*nc2;ixyxc=ixyx*nc2;
526 for (j=0;j<9;++j) tc[j]=0;
538 for (j=0;j<9;++j) tc[j]=0;
569 for (j=0;j<9;++j) tc[j]=0;
619 if (i+nline-1<ngrid) {
646 if (i+nplane-nline<ngrid) {
661 if (i+nplane-1<ngrid) {
710 for(i=1;i<ngrid;++i) {
711 i1=i-1;ix=i-nline;ixy=i-nplane;ix1=ix+1;ixyx=ixy+nline;ixy1=ixy+1;
712 ic=i*nc2;i1c=i1*nc2;ixc=ix*nc2;ix1c=ix1*nc2;ixyc=ixy*nc2;ixy1c=ixy1*nc2;ixyxc=ixyx*nc2;
719 for (j=0;j<25;++j) tc[j]=0;
731 for (j=0;j<25;++j) tc[j]=0;
762 for (j=0;j<25;++j) tc[j]=0;
812 if (i+nline-1<ngrid) {
839 if (i+nplane-nline<ngrid) {
854 if (i+nplane-1<ngrid) {
904 for(i=1;i<ngrid;++i) {
905 i1=i-1;ix=i-nline;ixy=i-nplane;ix1=ix+1;ixyx=ixy+nline;ixy1=ixy+1;
906 ic=i*nc2;i1c=i1*nc2;ixc=ix*nc2;ix1c=ix1*nc2;ixyc=ixy*nc2;ixy1c=ixy1*nc2;ixyxc=ixyx*nc2;
913 for (j=0;j<49;++j) tc[j]=0;
925 for (j=0;j<49;++j) tc[j]=0;
956 for (j=0;j<49;++j) tc[j]=0;
1006 if (i+nline-1<ngrid) {
1021 if (i+nline<ngrid) {
1033 if (i+nplane-nline<ngrid) {
1048 if (i+nplane-1<ngrid) {
1097 for(i=1;i<ngrid;++i) {
1099 i1=i-1;ix=i-nline;ixy=i-nplane;ix1=ix+1;ixyx=ixy+nline;ixy1=ixy+1;
1100 ic=i*nc2;i1c=i1*nc2;ixc=ix*nc2;ix1c=ix1*nc2;ixyc=ixy*nc2;ixy1c=ixy1*nc2;ixyxc=ixyx*nc2;
1107 for (j=0;j<nc2;++j) tc[j]=0;
1118 for (j=0;j<nc2;++j) tc[j]=0;
1134 memcpy(tc,&(A->
offdiag[2][ixc]),nc2*
sizeof(
REAL));
1146 for (j=0;j<nc2;++j) tc[j]=0;
1163 memcpy(tc,&(A->
offdiag[0][i1c]),nc2*
sizeof(
REAL));
1191 if (i+nline-1<ngrid) {
1206 if (i+nline<ngrid) {
1217 if (i+nplane-nline<ngrid) {
1231 if (i+nplane-1<ngrid) {
void fasp_mem_free(void *mem)
Free up previous allocated memory body and set pointer to NULL.
void * fasp_mem_calloc(const unsigned int size, const unsigned int type)
Allocate, initiate, and check memory.
void fasp_blas_darray_axpy_nc3(const REAL a, const REAL *x, REAL *y)
y = a*x + y, length of x and y should be 3
void fasp_blas_darray_axpyz(const INT n, const REAL a, const REAL *x, const REAL *y, REAL *z)
z = a*x + y
void fasp_blas_darray_axpy_nc7(const REAL a, const REAL *x, REAL *y)
y = a*x + y, length of x and y should be 7
void fasp_blas_darray_axpy_nc5(const REAL a, const REAL *x, REAL *y)
y = a*x + y, length of x and y should be 5
void fasp_blas_darray_axpyz_nc7(const REAL a, const REAL *x, const REAL *y, REAL *z)
z = a*x + y, length of x, y and z should be 7
void fasp_blas_darray_axpyz_nc3(const REAL a, const REAL *x, const REAL *y, REAL *z)
z = a*x + y, length of x, y and z should be 3
void fasp_blas_darray_axpy(const INT n, const REAL a, const REAL *x, REAL *y)
y = a*x + y
void fasp_blas_darray_axpyz_nc5(const REAL a, const REAL *x, const REAL *y, REAL *z)
z = a*x + y, length of x, y and z should be 5
void fasp_ilu_dstr_setup0(dSTRmat *A, dSTRmat *LU)
Get ILU(0) decomposition of a structured matrix A.
void fasp_ilu_dstr_setup1(dSTRmat *A, dSTRmat *LU)
Get ILU(1) decoposition of a structured matrix A.
void fasp_smat_inv_nc3(REAL *a)
Compute the inverse matrix of a 3*3 full matrix A (in place)
void fasp_smat_inv_nc7(REAL *a)
Compute the inverse matrix of a 7*7 matrix a.
SHORT fasp_smat_inv(REAL *a, const INT n)
Compute the inverse matrix of a small full matrix a.
void fasp_smat_inv_nc5(REAL *a)
Compute the inverse matrix of a 5*5 full matrix A (in place)
void fasp_blas_smat_mul(const REAL *a, const REAL *b, REAL *c, const INT n)
Compute the matrix product of two small full matrices a and b, stored in c.
void fasp_blas_smat_mul_nc3(const REAL *a, const REAL *b, REAL *c)
Compute the matrix product of two 3*3 matrices a and b, stored in c.
void fasp_blas_smat_mul_nc7(const REAL *a, const REAL *b, REAL *c)
Compute the matrix product of two 7*7 matrices a and b, stored in c.
void fasp_blas_smat_mul_nc5(const REAL *a, const REAL *b, REAL *c)
Compute the matrix product of two 5*5 matrices a and b, stored in c.
void fasp_dstr_alloc(const INT nx, const INT ny, const INT nz, const INT nxy, const INT ngrid, const INT nband, const INT nc, INT *offsets, dSTRmat *A)
Allocate STR sparse matrix memory space.
Main header file for the FASP project.
Structure matrix of REAL type.
INT * offsets
offsets of the off-diagonals (length is nband)
INT nx
number of grids in x direction
INT nxy
number of grids on x-y plane
INT ny
number of grids in y direction
INT nband
number of off-diag bands
REAL * diag
diagonal entries (length is ngrid*(nc^2))
INT nc
size of each block (number of components)
INT nz
number of grids in z direction
REAL ** offdiag
off-diagonal entries (dimension is nband * [(ngrid-|offsets|) * nc^2])