20 subroutine gen57pt(nx,ny,nz,al,mode,n,a,ja,ia,iau,rhs)
21 integer ja(*),ia(*),iau(*), nx, ny, nz, mode, n
22 real*8 a(*), rhs(*), al(6)
153 integer ix, iy, iz, kx, ky, kz, node, iedge
154 real*8 r, h, stencil(7)
155 logical value, genrhs
183 &
getsten(nx,ny,nz,mode,ix-1,iy-1,iz-1,stencil,h,r)
187 if (value) a(iedge) = stencil(2)
193 if (value) a(iedge) = stencil(4)
199 if (value) a(iedge) = stencil(6)
205 if (value) a(iedge) = stencil(1)
210 if (value) a(iedge) = stencil(3)
216 if (value) a(iedge) = stencil(5)
222 if (value) a(iedge) = stencil(7)
226 if (genrhs) rhs(node) = r
235 call
fdaddbc(nx,ny,nz,a,ja,ia,iau,rhs,al,h)
239 call
fdreduce(nx,ny,nz,al,n,a,ja,ia,iau,rhs,stencil)
248 subroutine getsten (nx,ny,nz,mode,kx,ky,kz,stencil,h,rhs)
249 integer nx,ny,nz,mode,kx,ky,kz
250 real*8 stencil(*),h,rhs,
afun,
bfun,
cfun,
dfun,
efun,
ffun,
gfun,
hfun
274 parameter(zero=0.0d0,half=0.5d0)
279 real*8 hhalf,cntr, x, y, z, coeff
283 if (mode .lt. 0)
return
295 coeff =
afun(x+hhalf,y,z)
296 stencil(3) = stencil(3) + coeff
299 coeff =
afun(x-hhalf,y,z)
300 stencil(2) = stencil(2) + coeff
303 coeff =
dfun(x,y,z)*hhalf
304 stencil(3) = stencil(3) + coeff
305 stencil(2) = stencil(2) - coeff
306 if (ny .le. 1) goto 99
310 coeff =
bfun(x,y+hhalf,z)
311 stencil(5) = stencil(5) + coeff
314 coeff =
bfun(x,y-hhalf,z)
315 stencil(4) = stencil(4) + coeff
318 coeff =
efun(x,y,z)*hhalf
319 stencil(5) = stencil(5) + coeff
320 stencil(4) = stencil(4) - coeff
321 if (nz .le. 1) goto 99
325 coeff =
cfun(x,y,z+hhalf)
326 stencil(7) = stencil(7) + coeff
329 coeff =
cfun(x,y,z-hhalf)
330 stencil(6) = stencil(6) + coeff
333 coeff =
ffun(x,y,z)*hhalf
334 stencil(7) = stencil(7) + coeff
335 stencil(6) = stencil(6) - coeff
339 99 coeff =
gfun(x,y,z)
340 stencil(1) = h*h*coeff - cntr
344 if (mode .gt. 0) rhs = h*h*
hfun(x,y,z)
351 subroutine gen57bl (nx,ny,nz,nfree,na,n,a,ja,ia,iau,stencil)
353 integer ja(*),ia(*),iau(*),nx,ny,nz,nfree,na,n
354 real*8 a(na,1), stencil(7,1)
443 integer iedge,ix,iy,iz,k,kx,ky,kz,nfree2,node
457 call
bsten(nx,ny,nz,ix,iy,iz,nfree,stencil,h)
462 a(k,iedge) = stencil(2,k)
470 a(k,iedge) = stencil(4,k)
478 a(k,iedge) = stencil(6,k)
486 a(k,iedge) = stencil(1,k)
494 a(k,iedge) = stencil(3,k)
502 a(k,iedge) = stencil(5,k)
510 a(k,iedge) = stencil(7,k)
536 subroutine bsten (nx,ny,nz,kx,ky,kz,nfree,stencil,h)
559 parameter(zero=0.0d0,half=0.5d0)
563 integer i,k,kx,ky,kz,nfree,nfree2,nx,ny,nz
564 real*8 stencil(7,*), cntr(225), coeff(225),h,h2,hhalf,x,y,z
566 if (nfree .gt. 15)
then
567 print *,
' ERROR ** nfree too large '
585 call
afunbl(nfree,x+hhalf,y,z,coeff)
587 stencil(3,k) = stencil(3,k) + coeff(k)
588 cntr(k) = cntr(k) + coeff(k)
591 call
afunbl(nfree,x-hhalf,y,z,coeff)
593 stencil(2,k) = stencil(2,k) + coeff(k)
594 cntr(k) = cntr(k) + coeff(k)
597 call
dfunbl(nfree,x,y,z,coeff)
599 stencil(3,k) = stencil(3,k) + coeff(k)*hhalf
600 stencil(2,k) = stencil(2,k) - coeff(k)*hhalf
602 if (ny .le. 1) goto 99
606 call
bfunbl(nfree,x,y+hhalf,z,coeff)
608 stencil(5,k) = stencil(5,k) + coeff(k)
609 cntr(k) = cntr(k) + coeff(k)
612 call
bfunbl(nfree,x,y-hhalf,z,coeff)
614 stencil(4,k) = stencil(4,k) + coeff(k)
615 cntr(k) = cntr(k) + coeff(k)
618 call
efunbl(nfree,x,y,z,coeff)
620 stencil(5,k) = stencil(5,k) + coeff(k)*hhalf
621 stencil(4,k) = stencil(4,k) - coeff(k)*hhalf
623 if (nz .le. 1) goto 99
627 call
cfunbl(nfree,x,y,z+hhalf,coeff)
629 stencil(7,k) = stencil(7,k) + coeff(k)
630 cntr(k) = cntr(k) + coeff(k)
633 call
cfunbl(nfree,x,y,z-hhalf,coeff)
635 stencil(6,k) = stencil(6,k) + coeff(k)
636 cntr(k) = cntr(k) + coeff(k)
639 call
ffunbl(nfree,x,y,z,coeff)
641 stencil(7,k) = stencil(7,k) + coeff(k)*hhalf
642 stencil(6,k) = stencil(6,k) - coeff(k)*hhalf
647 99 call
gfunbl(nfree,x,y,z,coeff)
649 stencil(1,k) = h2*coeff(k) - cntr(k)
656 subroutine fdreduce(nx,ny,nz,alpha,n,a,ja,ia,iau,rhs,stencil)
658 integer nx,ny, nz, n, ia(*), ja(*), iau(*)
659 real*8 alpha(*), a(*), rhs(*), stencil(*)
669 parameter(zero=0.0d0)
673 integer i,j,k,kx,ky,kz,lx,ux,ly,uy,lz,uz,node,nbnode,lk,ld,iedge
699 if (alpha(1) .eq. zero)
then
703 node = (k-1)*kz + (j-1)*ky + 1
705 lk =
lctcsr(nbnode, node, ja, ia)
707 val = rhs(node)/a(ld)
709 rhs(nbnode) = rhs(nbnode) - a(lk)*val
716 if (alpha(2) .eq. zero)
then
720 node = (k-1)*kz + (j-1)*ky + nx
722 lk =
lctcsr(nbnode, node, ja, ia)
724 val = rhs(node)/a(ld)
726 rhs(nbnode) = rhs(nbnode) - a(lk)*val
733 if (ny .le. 1) goto 100
737 if (alpha(3) .eq. zero)
then
743 lk =
lctcsr(nbnode, node, ja, ia)
745 val = rhs(node)/a(ld)
747 rhs(nbnode) = rhs(nbnode) - a(lk)*val
754 if (alpha(4) .eq. zero)
then
758 node = (k-1)*kz + i + (ny-1)*ky
760 lk =
lctcsr(nbnode, node, ja, ia)
762 val = rhs(node)/a(ld)
764 rhs(nbnode) = rhs(nbnode) - a(lk)*val
771 if (nz .le. 1) goto 100
775 if (alpha(5) .eq. zero)
then
781 lk =
lctcsr(nbnode, node, ja, ia)
783 val = rhs(node)/a(ld)
785 rhs(nbnode) = rhs(nbnode) - a(lk)*val
792 if (alpha(6) .eq. zero)
then
796 node = (nz-1)*kz + (j-1)*ky + i
798 lk =
lctcsr(nbnode, node, ja, ia)
800 val = rhs(node)/a(ld)
802 rhs(nbnode) = rhs(nbnode) - a(lk)*val
814 kz = (uy - ly + 1) * ky
822 nbnode = ((k-1)*ny + j-1)*nx + i
849 if (k.lt.nz) stencil(7) = a(lk)
877 a(iedge) = stencil(1)
898 rhs(node) = rhs(nbnode)
916 subroutine fdaddbc(nx,ny,nz,a,ja,ia,iau,rhs,al,h)
917 integer nx, ny, nz, ia(nx*ny*nz), ja(7*nx*ny*nz), iau(nx*ny*nz)
918 real*8 h, al(6), a(7*nx*ny*nz), rhs(nx*ny*nz)
951 real*8 half,zero,one,two
952 parameter(half=0.5d0,zero=0.0d0,one=1.0d0,two=2.0d0)
957 integer i,j,k,kx,ky,kz,node,nbr,ly,uy,lx,ux
958 real*8 coeff, ctr, hhalf, x, y, z
1012 node = 1+(j-1)*ky+(k-1)*kz
1016 if (al(1) .eq. zero)
then
1017 call
clrow(node, a, ja, ia)
1018 a(iau(node)) =
betfun(side,x,y,z)
1019 rhs(node) =
gamfun(side,x,y,z)
1025 nbr =
lctcsr(node, node+kx, ja, ia)
1027 coeff = two*
afun(x,y,z)
1028 ctr = (h*
dfun(x,y,z) - coeff)*h/al(1)
1029 rhs(node) = rhs(node) + ctr *
gamfun(side,x,y,z)
1030 ctr =
afun(x-hhalf,y,z) + ctr *
betfun(side,x,y,z)
1031 coeff =
afun(x+hhalf,y,z)
1032 a(iau(node)) = a(iau(node)) - coeff + ctr
1067 node = (k-1)*kz + j*ky
1069 if (al(2) .eq. zero)
then
1070 call
clrow(node, a, ja, ia)
1071 a(iau(node)) =
betfun(side,x,y,z)
1072 rhs(node) =
gamfun(side,x,y,z)
1074 nbr =
lctcsr(node, node-kx, ja, ia)
1076 coeff = two*
afun(x,y,z)
1077 ctr = (coeff + h*
dfun(x,y,z))*h/al(2)
1078 rhs(node) = rhs(node) - ctr *
gamfun(side,x,y,z)
1079 ctr =
afun(x+hhalf,y,z) - ctr *
betfun(side,x,y,z)
1080 coeff =
afun(x-hhalf,y,z)
1081 a(iau(node)) = a(iau(node)) - coeff + ctr
1089 if (ny .le. 1)
return
1100 if (al(1) .eq. zero)
then
1105 if (al(2) .eq. zero)
then
1118 if (al(3) .eq. zero)
then
1119 call
clrow(node, a, ja, ia)
1120 a(iau(node)) =
betfun(side,x,y,z)
1121 rhs(node) =
gamfun(side,x,y,z)
1123 nbr =
lctcsr(node, node+ky, ja, ia)
1125 coeff = two*
bfun(x,y,z)
1126 ctr = (h*
efun(x,y,z) - coeff)*h/al(3)
1127 rhs(node) = rhs(node) + ctr *
gamfun(side,x,y,z)
1128 ctr =
bfun(x,y-hhalf,z) + ctr *
betfun(side,x,y,z)
1129 coeff =
bfun(x,y+hhalf,z)
1130 a(iau(node)) = a(iau(node)) - coeff + ctr
1144 node = (k-1)*kz+(ny-1)*ky + i
1146 if (al(4) .eq. zero)
then
1147 call
clrow(node, a, ja, ia)
1148 a(iau(node)) =
betfun(side,x,y,z)
1149 rhs(node) =
gamfun(side,x,y,z)
1151 nbr =
lctcsr(node, node-ky, ja, ia)
1153 coeff = two*
bfun(x,y,z)
1154 ctr = (coeff + h*
efun(x,y,z))*h/al(4)
1155 rhs(node) = rhs(node) - ctr *
gamfun(side,x,y,z)
1156 ctr =
bfun(x,y+hhalf,z) - ctr *
betfun(side,x,y,z)
1157 coeff =
bfun(x,y-hhalf,z)
1158 a(iau(node)) = a(iau(node)) - coeff + ctr
1166 if (nz .le. 1)
return
1173 if (al(3) .eq. zero)
then
1178 if (al(4) .eq. zero)
then
1192 if (al(5) .eq. zero)
then
1193 call
clrow(node, a, ja, ia)
1194 a(iau(node)) =
betfun(side,x,y,z)
1195 rhs(node) =
gamfun(side,x,y,z)
1197 nbr =
lctcsr(node, node+kz, ja, ia)
1199 coeff = two*
cfun(x,y,z)
1200 ctr = (h*
ffun(x,y,z) - coeff)*h/al(5)
1201 rhs(node) = rhs(node) + ctr *
gamfun(side,x,y,z)
1202 ctr =
cfun(x,y,z-hhalf) + ctr *
betfun(side,x,y,z)
1203 coeff =
cfun(x,y,z+hhalf)
1204 a(iau(node)) = a(iau(node)) - coeff + ctr
1218 node = (nz-1)*kz + (j-1)*ky + i
1220 if (al(6) .eq. zero)
then
1221 call
clrow(node, a, ja, ia)
1222 a(iau(node)) =
betfun(side,x,y,z)
1223 rhs(node) =
gamfun(side,x,y,z)
1225 nbr =
lctcsr(node, node-kz, ja, ia)
1227 coeff = two*
cfun(x,y,z)
1228 ctr = (coeff + h*
ffun(x,y,z))*h/al(6)
1229 rhs(node) = rhs(node) - ctr *
gamfun(side,x,y,z)
1230 ctr =
cfun(x,y,z+hhalf) - ctr *
betfun(side,x,y,z)
1231 coeff =
cfun(x,y,z-hhalf)
1232 a(iau(node)) = a(iau(node)) - coeff + ctr
1246 integer i, ja(*), ia(*), k
1252 do 10 k = ia(i), ia(i+1)-1
1261 integer lctcsr, i, j, ja(*), ia(*), k
1268 10
if (k .lt. ia(i+1) .and. (
lctcsr .eq. -1))
then
1269 if (ja(k) .eq. j)
lctcsr = k
1279 subroutine csrcsc (n,job,ipos,a,ja,ia,ao,jao,iao)
1280 integer ia(n+1),iao(n+1),ja(*),jao(*)
1318 call
csrcsc2(n,n,job,ipos,a,ja,ia,ao,jao,iao)
1321 subroutine csrcsc2 (n,n2,job,ipos,a,ja,ia,ao,jao,iao)
1322 integer ia(n+1),iao(n2+1),ja(*),jao(*)
1369 do 2 k=ia(i), ia(i+1)-1
1377 iao(i+1) = iao(i) + iao(i+1)
1381 do 62 k=ia(i),ia(i+1)-1
1384 if (job .eq. 1) ao(next) = a(k)
subroutine gen57pt(nx, ny, nz, al, mode, n, a, ja, ia, iau, rhs)
integer function lctcsr(i, j, ja, ia)
void csrcsc(int OUTINDEX, const int nrow, const int ncol, int job, double *a, int *ja, int *ia, double *ao, int *jao, int *iao)
convert csr to csc Assume input csr is 0-based index output csc 0/1 index specified by OUTINDEX * ...
subroutine gen57bl(nx, ny, nz, nfree, na, n, a, ja, ia, iau, stencil)
real *8 function efun(x, y, z)
real *8 function betfun(side, x, y, z)
subroutine bfunbl(nfree, x, y, z, coeff)
subroutine csrcsc2(n, n2, job, ipos, a, ja, ia, ao, jao, iao)
subroutine dfunbl(nfree, x, y, z, coeff)
subroutine ffunbl(nfree, x, y, z, coeff)
real *8 function ffun(x, y, z)
subroutine bsten(nx, ny, nz, kx, ky, kz, nfree, stencil, h)
subroutine clrow(i, a, ja, ia)
subroutine getsten(nx, ny, nz, mode, kx, ky, kz, stencil, h, rhs)
real *8 function cfun(x, y, z)
real *8 function gamfun(side, x, y, z)
subroutine fdaddbc(nx, ny, nz, a, ja, ia, iau, rhs, al, h)
real *8 function gfun(x, y, z)
subroutine cfunbl(nfree, x, y, z, coeff)
real *8 function dfun(x, y, z)
real *8 function hfun(x, y, z)
subroutine gfunbl(nfree, x, y, z, coeff)
subroutine efunbl(nfree, x, y, z, coeff)
real *8 function afun(x, y, z)
subroutine afunbl(nfree, x, y, z, coeff)
real *8 function bfun(x, y, z)
subroutine fdreduce(nx, ny, nz, alpha, n, a, ja, ia, iau, rhs, stencil)