FrontISTR  6.0.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 #ifdef HECMW_ARCH_FX64
91  real(kind=kreal), intent(in) :: r(hecmat%N*hecmat%NDOF)
92  real(kind=kreal), intent(inout) :: z(hecmat%NP*hecmat%NDOF)
93  real(kind=kreal), intent(inout) :: zp(hecmat%NP*hecmat%NDOF)
94 #else
95  real(kind=kreal), intent(inout) :: r(:)
96  real(kind=kreal), intent(inout) :: z(:), zp(:)
97 #endif
98  real(kind=kreal), intent(inout) :: commtime
99  integer(kind=kint ) :: i, n, np, nndof, npndof
100  integer(kind=kint) :: iterpremax, iterpre
101  real(kind=kreal) :: start_time, end_time
102 
103  start_time = hecmw_wtime()
104 
105  n = hecmat%N
106  np = hecmat%NP
107  nndof = n * hecmat%NDOF
108  npndof = np * hecmat%NDOF
109 
110  if (hecmw_mat_get_iterpremax( hecmat ).le.0) then
111  !$acc kernels
112  !$acc loop independent
113  do i= 1, nndof
114  z(i)= r(i)
115  enddo
116  !$acc end kernels
117  return
118  endif
119 
120  !C {z}= [Minv]{r}
121  !$acc kernels
122  !$acc loop independent
123  do i= 1, nndof
124  zp(i)= r(i)
125  enddo
126  !$acc end kernels
127 
128  !$acc kernels
129  !$acc loop independent
130  do i= nndof+1, npndof
131  zp(i) = 0.d0
132  enddo
133  !$acc end kernels
134 
135  !$acc kernels
136  !$acc loop independent
137  do i= 1, npndof
138  z(i)= 0.d0
139  enddo
140  !$acc end kernels
141 
142  iterpremax = hecmw_mat_get_iterpremax( hecmat )
143  do iterpre= 1, iterpremax
144 
145  select case(hecmw_mat_get_precond( hecmat ))
146  case(1,2)
147  call hecmw_precond_ssor_apply(zp,hecmat%NDOF)
148  case(3)
149  call hecmw_precond_diag_apply(zp,hecmat%NDOF)
150  case(5)
151  call hecmw_precond_ml_apply(zp,hecmat%NDOF)
152  case(10:12)
153  call hecmw_precond_bilu_apply(zp,hecmat%NDOF)
154  case(20)
155  call hecmw_precond_sainv_apply(r,zp,hecmat%NDOF)
156  case(21)
157  call hecmw_precond_rif_apply(zp,hecmat%NDOF)
158  case(22)
159  call hecmw_precond_saamg_apply(zp,hecmat%NDOF)
160  case default
161  end select
162 
163  !C-- additive Schwartz
164  !$acc kernels
165  !$acc loop independent
166  do i= 1, hecmat%N * hecmat%NDOF
167  z(i)= z(i) + zp(i)
168  enddo
169  !$acc end kernels
170  if (iterpre.eq.iterpremax) exit
171 
172  !C-- {ZP} = {R} - [A] {Z}
173  call hecmw_matresid (hecmesh, hecmat, z, r, zp, commtime)
174  enddo
175 
176  end_time = hecmw_wtime()
177  time_precond = time_precond + end_time - start_time
178  end subroutine hecmw_precond_apply
179 
181  implicit none
182  time_precond = 0.d0
183  end subroutine hecmw_precond_clear_timer
184 
186  implicit none
187  real(kind=kreal) :: hecmw_precond_get_timer
188  hecmw_precond_get_timer = time_precond
189  end function hecmw_precond_get_timer
190 
191 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()