FrontISTR  5.9.0
Large-scale structural analysis program with finit element method
hecmw_precond.f90
Go to the documentation of this file.
1 !-------------------------------------------------------------------------------
2 ! Copyright (c) 2019 FrontISTR Commons
3 ! This software is released under the MIT License, see LICENSE.txt
4 !-------------------------------------------------------------------------------
5 
7  use hecmw_util
17  implicit none
18 
19  private
20  public :: hecmw_precond_setup
21  public :: hecmw_precond_clear
22  public :: hecmw_precond_apply
24  public :: hecmw_precond_get_timer
25 
26  real(kind=kreal) :: time_precond = 0.d0
27 
28 contains
29 
30  subroutine hecmw_precond_setup(hecMAT, hecMESH, sym)
31  implicit none
32  type (hecmwst_matrix), intent(inout) :: hecmat
33  type (hecmwst_local_mesh), intent(inout) :: hecmesh
34  integer(kind=kint) :: sym
35 
36  if (hecmw_mat_get_iterpremax( hecmat ).le.0) return
37 
38  select case(hecmw_mat_get_precond( hecmat ))
39  case(1,2)
40  call hecmw_precond_ssor_setup(hecmat)
41  case(3)
42  call hecmw_precond_diag_setup(hecmat)
43  case(5)
44  call hecmw_precond_ml_setup(hecmat, hecmesh, sym)
45  case(10,11,12)
46  call hecmw_precond_bilu_setup(hecmat)
47  case(20)
48  call hecmw_precond_sainv_setup(hecmat)
49  case(21)
50  call hecmw_precond_rif_setup(hecmat)
51  case(22)
52  call hecmw_precond_saamg_setup(hecmat, hecmesh, sym)
53  case default
54  write (*,'(/a )')'#### HEC-MW-SOLVER-E-1001'
55  write (*,'( a/)')' inconsistent solver/preconditioning'
57  end select
58  end subroutine hecmw_precond_setup
59 
60  subroutine hecmw_precond_clear(hecMAT)
61  implicit none
62  type (hecmwst_matrix), intent(inout) :: hecmat
63 
64  if (hecmw_mat_get_iterpremax( hecmat ).le.0) return
65 
66  select case(hecmw_mat_get_precond( hecmat ))
67  case(1,2)
68  call hecmw_precond_ssor_clear(hecmat)
69  case(3)
70  call hecmw_precond_diag_clear(hecmat%NDOF)
71  case(5)
72  call hecmw_precond_ml_clear(hecmat%NDOF)
73  case(10:12)
74  call hecmw_precond_bilu_clear(hecmat%NDOF)
75  case(20)
76  call hecmw_precond_sainv_clear(hecmat%NDOF)
77  case(21)
78  call hecmw_precond_rif_clear(hecmat%NDOF)
79  case(22)
80  call hecmw_precond_saamg_clear(hecmat%NDOF)
81  case default
82  end select
83 
84  end subroutine hecmw_precond_clear
85 
86  subroutine hecmw_precond_apply(hecMESH, hecMAT, R, Z, ZP, COMMtime)
87  implicit none
88  type (hecmwst_local_mesh), intent(inout) :: hecmesh
89  type (hecmwst_matrix), intent(inout) :: hecmat
90  real(kind=kreal), intent(inout) :: r(:)
91  real(kind=kreal), intent(inout) :: z(:), zp(:)
92  real(kind=kreal), intent(inout) :: commtime
93  integer(kind=kint ) :: i, n, np, nndof, npndof
94  integer(kind=kint) :: iterpremax, iterpre
95  real(kind=kreal) :: start_time, end_time
96 
97  start_time = hecmw_wtime()
98 
99  n = hecmat%N
100  np = hecmat%NP
101  nndof = n * hecmat%NDOF
102  npndof = np * hecmat%NDOF
103 
104  if (hecmw_mat_get_iterpremax( hecmat ).le.0) then
105  !$acc kernels
106  !$acc loop independent
107  do i= 1, nndof
108  z(i)= r(i)
109  enddo
110  !$acc end kernels
111  return
112  endif
113 
114  !C {z}= [Minv]{r}
115  !$acc kernels
116  !$acc loop independent
117  do i= 1, nndof
118  zp(i)= r(i)
119  enddo
120  !$acc end kernels
121 
122  !$acc kernels
123  !$acc loop independent
124  do i= nndof+1, npndof
125  zp(i) = 0.d0
126  enddo
127  !$acc end kernels
128 
129  !$acc kernels
130  !$acc loop independent
131  do i= 1, npndof
132  z(i)= 0.d0
133  enddo
134  !$acc end kernels
135 
136  iterpremax = hecmw_mat_get_iterpremax( hecmat )
137  do iterpre= 1, iterpremax
138 
139  select case(hecmw_mat_get_precond( hecmat ))
140  case(1,2)
141  call hecmw_precond_ssor_apply(zp,hecmat%NDOF)
142  case(3)
143  call hecmw_precond_diag_apply(zp,hecmat%NDOF)
144  case(5)
145  call hecmw_precond_ml_apply(zp,hecmat%NDOF)
146  case(10:12)
147  call hecmw_precond_bilu_apply(zp,hecmat%NDOF)
148  case(20)
149  call hecmw_precond_sainv_apply(r,zp,hecmat%NDOF)
150  case(21)
151  call hecmw_precond_rif_apply(zp,hecmat%NDOF)
152  case(22)
153  call hecmw_precond_saamg_apply(zp,hecmat%NDOF)
154  case default
155  end select
156 
157  !C-- additive Schwartz
158  !$acc kernels
159  !$acc loop independent
160  do i= 1, hecmat%N * hecmat%NDOF
161  z(i)= z(i) + zp(i)
162  enddo
163  !$acc end kernels
164  if (iterpre.eq.iterpremax) exit
165 
166  !C-- {ZP} = {R} - [A] {Z}
167  call hecmw_matresid (hecmesh, hecmat, z, r, zp, commtime)
168  enddo
169 
170  end_time = hecmw_wtime()
171  time_precond = time_precond + end_time - start_time
172  end subroutine hecmw_precond_apply
173 
175  implicit none
176  time_precond = 0.d0
177  end subroutine hecmw_precond_clear_timer
178 
180  implicit none
181  real(kind=kreal) :: hecmw_precond_get_timer
182  hecmw_precond_get_timer = time_precond
183  end function hecmw_precond_get_timer
184 
185 end module hecmw_precond
integer(kind=kint) function, public hecmw_mat_get_iterpremax(hecMAT)
integer(kind=kint) function, public hecmw_mat_get_precond(hecMAT)
subroutine, public hecmw_precond_bilu_setup(hecMAT)
subroutine, public hecmw_precond_bilu_apply(ZP, NDOF)
subroutine, public hecmw_precond_bilu_clear(NDOF)
subroutine, public hecmw_precond_diag_setup(hecMAT)
subroutine, public hecmw_precond_diag_clear(NDOF)
subroutine, public hecmw_precond_diag_apply(ZP, NDOF)
subroutine, public hecmw_precond_ml_clear(NDOF)
subroutine, public hecmw_precond_ml_setup(hecMAT, hecMESH, sym)
subroutine, public hecmw_precond_ml_apply(ZP, NDOF)
subroutine, public hecmw_precond_rif_clear(NDOF)
subroutine, public hecmw_precond_rif_apply(ZP, NDOF)
subroutine, public hecmw_precond_rif_setup(hecMAT)
Smoothed Aggregation AMG preconditioner : FrontISTR backend (id 22)
subroutine, public hecmw_precond_saamg_setup(hecMAT, hecMESH, sym)
subroutine, public hecmw_precond_saamg_apply(ZP, NDOF)
subroutine, public hecmw_precond_saamg_clear(NDOF)
subroutine, public hecmw_precond_sainv_setup(hecMAT)
subroutine, public hecmw_precond_sainv_clear(NDOF)
subroutine, public hecmw_precond_sainv_apply(R, ZP, NDOF)
subroutine, public hecmw_precond_ssor_apply(ZP, NDOF)
subroutine, public hecmw_precond_ssor_setup(hecMAT)
subroutine, public hecmw_precond_ssor_clear(hecMAT)
subroutine, public hecmw_precond_clear_timer
real(kind=kreal) function, public hecmw_precond_get_timer()
subroutine, public hecmw_precond_clear(hecMAT)
subroutine, public hecmw_precond_setup(hecMAT, hecMESH, sym)
subroutine, public hecmw_precond_apply(hecMESH, hecMAT, R, Z, ZP, COMMtime)
subroutine, public hecmw_matresid(hecMESH, hecMAT, X, B, R, COMMtime)
I/O and Utility.
Definition: hecmw_util_f.F90:7
subroutine hecmw_abort(comm, code)
integer(kind=kint) function hecmw_comm_get_comm()
integer(kind=4), parameter kreal
real(kind=kreal) function hecmw_wtime()