17 integer(4),
parameter :: krealp = 8
19 integer(kind=kint) :: NPFIU, NPFIL
20 integer(kind=kint) :: N
21 integer(kind=kint) :: NDOF, NDOF2
22 integer(kind=kint),
pointer :: inumFI1L(:) => null()
23 integer(kind=kint),
pointer :: inumFI1U(:) => null()
24 integer(kind=kint),
pointer :: FI1L(:) => null()
25 integer(kind=kint),
pointer :: FI1U(:) => null()
27 integer(kind=kint),
pointer :: indexL(:) => null()
28 integer(kind=kint),
pointer :: indexU(:) => null()
29 integer(kind=kint),
pointer :: itemL(:) => null()
30 integer(kind=kint),
pointer :: itemU(:) => null()
31 real(kind=
kreal),
pointer :: d(:) => null()
32 real(kind=
kreal),
pointer :: al(:) => null()
33 real(kind=
kreal),
pointer :: au(:) => null()
35 real(kind=krealp),
pointer :: sainvu(:) => null()
36 real(kind=krealp),
pointer :: sainvl(:) => null()
37 real(kind=krealp),
pointer :: sainvd(:) => null()
38 real(kind=
kreal),
pointer :: t(:) => null()
49 integer(kind=kint ) :: precond
50 real(kind=krealp) :: filter
60 indexl => hecmat%indexL
61 indexu => hecmat%indexU
65 if (precond.eq.20)
call form_ilu1_sainv_nn(hecmat)
67 allocate (sainvd(ndof2*hecmat%NP))
68 allocate (sainvl(ndof2*npfiu))
69 allocate (t(ndof*hecmat%NP))
74 filter= hecmat%Rarray(5)
76 write(*,
"(a,F15.8)")
"### SAINV FILTER :",filter
78 call hecmw_sainv_nn(hecmat)
80 allocate (sainvu(ndof2*npfiu))
83 call hecmw_sainv_make_u_nn(hecmat)
89 real(kind=
kreal),
intent(inout) :: zp(:)
90 real(kind=
kreal),
intent(in) :: r(:)
91 integer(kind=kint) :: in, i, j, isl, iel, isu, ieu,idof,jdof
92 real(kind=
kreal) :: sw(ndof),x(ndof)
108 x(idof) = r(ndof*(in-1)+idof)
112 sw(idof) = sw(idof) + sainvl(ndof2*(j-1)+ndof*(idof-1)+jdof)*x(jdof)
117 x(idof) = r(ndof*(i-1)+idof)
118 t(ndof*(i-1)+idof)=x(idof)+sw(idof)
122 t(ndof*(i-1)+idof)=t(ndof*(i-1)+idof)+sainvd(ndof2*(i-1)+ndof*(jdof-1)+idof)*x(jdof)
124 t(ndof*(i-1)+idof)=t(ndof*(i-1)+idof)*sainvd(ndof2*(i-1)+ndof*(idof-1)+idof)
135 isu= inumfi1u(i-1) + 1
140 x(idof) = t(ndof*(in-1)+idof)
144 sw(idof) = sw(idof) + sainvu(ndof2*(j-1)+ndof*(idof-1)+jdof)*x(jdof)
150 x(idof) = t(ndof*(i-1)+idof)
153 zp(ndof*(i-1)+idof) = x(idof) + sw(idof)
154 do jdof = ndof, idof+1, -1
155 zp(ndof*(i-1)+idof) = zp(ndof*(i-1)+idof)+sainvd(ndof2*(i-1)+ndof*(idof-1)+jdof)*x(jdof)
168 subroutine hecmw_sainv_nn(hecMAT)
172 integer(kind=kint) :: i, j, k, js, je, in, itr, idof, jdof, iitr
173 real(kind=krealp) :: dd, dtmp(hecmat%NDOF), x(hecmat%NDOF)
175 real(kind=krealp) :: filter
176 real(kind=krealp),
allocatable :: zz(:), vv(:)
178 filter= hecmat%Rarray(5)
180 allocate (vv(ndof*hecmat%NP))
181 allocate (zz(ndof*hecmat%NP))
188 zz(ndof*(itr-1)+idof)= sainvd(ndof2*(itr-1)+ndof*(idof-1)+iitr)
190 zz(ndof*(itr-1)+iitr)= 1.0d0
192 js= inumfi1l(itr-1) + 1
197 zz(ndof*(in-1)+idof)=sainvl(ndof2*(j-1)+ndof*(iitr-1)+idof)
203 x(idof)=zz(ndof*(i-1)+idof)
207 vv(ndof*(i-1)+idof) = vv(ndof*(i-1)+idof) + d(ndof2*(i-1)+ndof*(idof-1)+jdof)*x(jdof)
217 vv(ndof*(in-1)+idof) = vv(ndof*(in-1)+idof) + al(ndof2*(j-1)+ndof*(jdof-1)+idof)*x(jdof)
227 vv(ndof*(in-1)+idof) = vv(ndof*(in-1)+idof) + au(ndof2*(j-1)+ndof*(jdof-1)+idof)*x(jdof)
235 dtmp(idof)= sainvd(ndof2*(itr-1)+ndof*(idof-1)+idof)
240 sainvd(ndof2*(i-1)+ndof*(idof-1)+idof) = vv(ndof*(i-1)+idof)
242 sainvd(ndof2*(i-1)+ndof*(idof-1)+idof) = sainvd(ndof2*(i-1)+ndof*(idof-1)+idof) + &
243 & sainvd(ndof2*(i-1)+ndof*(jdof-1)+idof)*vv(ndof*(i-1)+jdof)
246 js= inumfi1l(i-1) + 1
251 x(idof)=vv(ndof*(in-1)+idof)
255 sainvd(ndof2*(i-1)+ndof*(idof-1)+idof) = sainvd(ndof2*(i-1)+ndof*(idof-1)+idof) + &
256 & sainvl(ndof2*(j-1)+ndof*(idof-1)+jdof)*x(jdof)
263 dd = 1.0d0/sainvd(ndof2*(itr-1)+ndof*(iitr-1)+iitr)
265 sainvd(ndof2*(itr-1)+ndof*(idof-1)+idof) = dtmp(idof)
268 do idof = iitr+1, ndof
269 sainvd(ndof2*(itr-1)+ndof*(idof-1)+idof) = sainvd(ndof2*(itr-1)+ndof*(idof-1)+idof)*dd
274 sainvd(ndof2*(i-1)+ndof*(idof-1)+idof) = sainvd(ndof2*(i-1)+ndof*(idof-1)+idof)*dd
280 dd = sainvd(ndof2*(itr-1)+ndof*(k-1)+k)
281 if(abs(dd) > filter)
then
283 sainvd(ndof2*(itr-1)+ndof*(jdof-1)+k)= sainvd(ndof2*(itr-1)+ndof*(jdof-1)+k) - dd*zz(ndof*(itr-1)+jdof)
285 js= inumfi1l(itr-1) + 1
290 sainvl(ndof2*(j-1)+ndof*(k-1)+idof) = sainvl(ndof2*(j-1)+ndof*(k-1)+idof)-dd*zz(ndof*(in-1)+idof)
297 js= inumfi1l(i-1) + 1
300 dd = sainvd(ndof2*(i-1)+ndof*(idof-1)+idof)
301 if(abs(dd) > filter)
then
306 sainvl(ndof2*(j-1)+ndof*(idof-1)+jdof)=sainvl(ndof2*(j-1)+ndof*(idof-1)+jdof)-dd*zz(ndof*(in-1)+jdof)
319 sainvd(ndof2*(i-1)+ndof*(idof-1)+idof)=1/sainvd(ndof2*(i-1)+ndof*(idof-1)+idof)
320 do jdof = idof+1, ndof
321 sainvd(ndof2*(i-1)+ndof*(jdof-1)+idof)=sainvd(ndof2*(i-1)+ndof*(idof-1)+jdof)
325 end subroutine hecmw_sainv_nn
327 subroutine hecmw_sainv_make_u_nn(hecMAT)
330 integer(kind=kint) i,j,k,n,m,o,idof,jdof
331 integer(kind=kint) is,ie,js,je
346 sainvu(ndof2*(n-1)+ndof*(jdof-1)+idof)=sainvl(ndof2*(j-1)+ndof*(idof-1)+jdof)
355 end subroutine hecmw_sainv_make_u_nn
360 subroutine form_ilu0_sainv_nn(hecMAT)
364 allocate (inumfi1l(0:hecmat%NP), inumfi1u(0:hecmat%NP))
365 allocate (fi1l(hecmat%NPL), fi1u(hecmat%NPU))
372 inumfi1l = hecmat%indexL
373 inumfi1u = hecmat%indexU
380 end subroutine form_ilu0_sainv_nn
385 subroutine form_ilu1_sainv_nn(hecMAT)
389 integer(kind=kint),
allocatable :: iwsl(:), iwsu(:), iw1(:), iw2(:)
390 integer(kind=kint) :: nplf1,npuf1
391 integer(kind=kint) :: i,jj,kk,l,isk,iek,isj,iej
392 integer(kind=kint) :: icou,icou0,icouu,icouu1,icouu2,icouu3,icoul,icoul1,icoul2,icoul3
393 integer(kind=kint) :: j,k,isl,isu
402 allocate (iw1(hecmat%NP) , iw2(hecmat%NP))
403 allocate (inumfi1l(0:hecmat%NP), inumfi1u(0:hecmat%NP))
414 do l= indexl(i-1)+1, indexl(i)
417 do l= indexu(i-1)+1, indexu(i)
425 isj= indexu(kk-1) + 1
429 if (iw1(jj).eq.0 .and. jj.lt.i)
then
430 inumfi1l(i)= inumfi1l(i)+1
433 if (iw1(jj).eq.0 .and. jj.gt.i)
then
434 inumfi1u(i)= inumfi1u(i)+1
439 nplf1= nplf1 + inumfi1l(i)
440 npuf1= npuf1 + inumfi1u(i)
445 allocate (iwsl(0:hecmat%NP), iwsu(0:hecmat%NP))
446 allocate (fi1l(hecmat%NPL+nplf1), fi1u(hecmat%NPU+npuf1))
448 npfiu = hecmat%NPU+npuf1
449 npfil = hecmat%NPL+nplf1
457 iwsl(i)= indexl(i)-indexl(i-1) + inumfi1l(i) + iwsl(i-1)
458 iwsu(i)= indexu(i)-indexu(i-1) + inumfi1u(i) + iwsu(i-1)
464 inumfi1l(i)= inumfi1l(i-1) + inumfi1l(i)
465 inumfi1u(i)= inumfi1u(i-1) + inumfi1u(i)
469 do l= indexl(i-1)+1, indexl(i)
472 do l= indexu(i-1)+1, indexu(i)
480 isj= indexu(kk-1) + 1
484 if (iw1(jj).eq.0 .and. jj.lt.i)
then
486 fi1l(icoul+iwsl(i-1)+indexl(i)-indexl(i-1))= jj
489 if (iw1(jj).eq.0 .and. jj.gt.i)
then
491 fi1u(icouu+iwsu(i-1)+indexu(i)-indexu(i-1))= jj
501 icoul1= indexl(i) - indexl(i-1)
502 icoul2= inumfi1l(i) - inumfi1l(i-1)
503 icoul3= icoul1 + icoul2
504 icouu1= indexu(i) - indexu(i-1)
505 icouu2= inumfi1u(i) - inumfi1u(i-1)
506 icouu3= icouu1 + icouu2
510 do k= indexl(i-1)+1, indexl(i)
515 do k= inumfi1l(i-1)+1, inumfi1l(i)
517 iw1(icou0)= fi1l(icou0+iwsl(i-1))
523 call sainv_sort_nn (iw1, iw2, icoul3, hecmat%NP)
531 do k= indexu(i-1)+1, indexu(i)
536 do k= inumfi1u(i-1)+1, inumfi1u(i)
538 iw1(icou0)= fi1u(icou0+iwsu(i-1))
544 call sainv_sort_nn (iw1, iw2, icouu3, hecmat%NP)
560 deallocate (iw1, iw2)
561 deallocate (iwsl, iwsu)
563 end subroutine form_ilu1_sainv_nn
570 subroutine sainv_sort_nn(STEM, INUM, N, NP)
573 integer(kind=kint) :: n, np
574 integer(kind=kint),
dimension(NP) :: stem
575 integer(kind=kint),
dimension(NP) :: inum
576 integer(kind=kint),
dimension(:),
allocatable :: istack
577 integer(kind=kint) :: m,nstack,jstack,l,ir,ip,i,j,k,ss,ii,temp,it
579 allocate (istack(-np:+np))
598 if (stem(i).le.ss)
goto 2
609 if (jstack.eq.0)
then
628 if (stem(l+1).gt.stem(ir))
then
637 if (stem(l).gt.stem(ir))
then
646 if (stem(l+1).gt.stem(l))
then
663 if (stem(i).lt.ss)
goto 3
667 if (stem(j).gt.ss)
goto 4
690 if (jstack.gt.nstack)
then
691 write (*,*)
'NSTACK overflow'
695 if (ir-i+1.ge.j-1)
then
709 end subroutine sainv_sort_nn
714 if (
associated(sainvd))
deallocate(sainvd)
715 if (
associated(sainvl))
deallocate(sainvl)
716 if (
associated(sainvu))
deallocate(sainvu)
717 if (
associated(inumfi1l))
deallocate(inumfi1l)
718 if (
associated(inumfi1u))
deallocate(inumfi1u)
719 if (
associated(fi1l))
deallocate(fi1l)
720 if (
associated(fi1u))
deallocate(fi1u)