FrontISTR  5.7.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
16  implicit none
17 
18  private
19  public :: hecmw_precond_setup
20  public :: hecmw_precond_clear
21  public :: hecmw_precond_apply
23  public :: hecmw_precond_get_timer
24 
25  real(kind=kreal) :: time_precond = 0.d0
26 
27 contains
28 
29  subroutine hecmw_precond_setup(hecMAT, hecMESH, sym)
30  implicit none
31  type (hecmwst_matrix), intent(inout) :: hecmat
32  type (hecmwst_local_mesh), intent(inout) :: hecmesh
33  integer(kind=kint) :: sym
34 
35  if (hecmw_mat_get_iterpremax( hecmat ).le.0) return
36 
37  select case(hecmw_mat_get_precond( hecmat ))
38  case(1,2)
39  call hecmw_precond_ssor_setup(hecmat)
40  case(3)
41  call hecmw_precond_diag_setup(hecmat)
42  case(5)
43  call hecmw_precond_ml_setup(hecmat, hecmesh, sym)
44  case(10,11,12)
45  call hecmw_precond_bilu_setup(hecmat)
46  case(20)
47  call hecmw_precond_sainv_setup(hecmat)
48  case(21)
49  call hecmw_precond_rif_setup(hecmat)
50  case default
51  write (*,'(/a )')'#### HEC-MW-SOLVER-E-1001'
52  write (*,'( a/)')' inconsistent solver/preconditioning'
54  end select
55  end subroutine hecmw_precond_setup
56 
57  subroutine hecmw_precond_clear(hecMAT)
58  implicit none
59  type (hecmwst_matrix), intent(inout) :: hecmat
60 
61  if (hecmw_mat_get_iterpremax( hecmat ).le.0) return
62 
63  select case(hecmw_mat_get_precond( hecmat ))
64  case(1,2)
65  call hecmw_precond_ssor_clear(hecmat)
66  case(3)
67  call hecmw_precond_diag_clear(hecmat%NDOF)
68  case(5)
69  call hecmw_precond_ml_clear(hecmat%NDOF)
70  case(10:12)
71  call hecmw_precond_bilu_clear(hecmat%NDOF)
72  case(20)
73  call hecmw_precond_sainv_clear(hecmat%NDOF)
74  case(21)
75  call hecmw_precond_rif_clear(hecmat%NDOF)
76  case default
77  end select
78 
79  end subroutine hecmw_precond_clear
80 
81  subroutine hecmw_precond_apply(hecMESH, hecMAT, R, Z, ZP, COMMtime)
82  implicit none
83  type (hecmwst_local_mesh), intent(inout) :: hecmesh
84  type (hecmwst_matrix), intent(inout) :: hecmat
85  real(kind=kreal), intent(inout) :: r(:)
86  real(kind=kreal), intent(inout) :: z(:), zp(:)
87  real(kind=kreal), intent(inout) :: commtime
88  integer(kind=kint ) :: i, n, np, nndof, npndof
89  integer(kind=kint) :: iterpremax, iterpre
90  real(kind=kreal) :: start_time, end_time
91 
92  start_time = hecmw_wtime()
93 
94  n = hecmat%N
95  np = hecmat%NP
96  nndof = n * hecmat%NDOF
97  npndof = np * hecmat%NDOF
98 
99  if (hecmw_mat_get_iterpremax( hecmat ).le.0) then
100  do i= 1, nndof
101  z(i)= r(i)
102  enddo
103  return
104  endif
105 
106  !C {z}= [Minv]{r}
107  do i= 1, nndof
108  zp(i)= r(i)
109  enddo
110  do i= nndof+1, npndof
111  zp(i) = 0.d0
112  enddo
113  do i= 1, npndof
114  z(i)= 0.d0
115  enddo
116 
117  iterpremax = hecmw_mat_get_iterpremax( hecmat )
118  do iterpre= 1, iterpremax
119 
120  select case(hecmw_mat_get_precond( hecmat ))
121  case(1,2)
122  call hecmw_precond_ssor_apply(zp,hecmat%NDOF)
123  case(3)
124  call hecmw_precond_diag_apply(zp,hecmat%NDOF)
125  case(5)
126  call hecmw_precond_ml_apply(zp,hecmat%NDOF)
127  case(10:12)
128  call hecmw_precond_bilu_apply(zp,hecmat%NDOF)
129  case(20)
130  call hecmw_precond_sainv_apply(r,zp,hecmat%NDOF)
131  case(21)
132  call hecmw_precond_rif_apply(zp,hecmat%NDOF)
133  case default
134  end select
135 
136  !C-- additive Schwartz
137  do i= 1, hecmat%N * hecmat%NDOF
138  z(i)= z(i) + zp(i)
139  enddo
140  if (iterpre.eq.iterpremax) exit
141 
142  !C-- {ZP} = {R} - [A] {Z}
143  call hecmw_matresid (hecmesh, hecmat, z, r, zp, commtime)
144  enddo
145 
146  end_time = hecmw_wtime()
147  time_precond = time_precond + end_time - start_time
148  end subroutine hecmw_precond_apply
149 
150  subroutine hecmw_precond_clear_timer
151  implicit none
152  time_precond = 0.d0
153  end subroutine hecmw_precond_clear_timer
154 
155  function hecmw_precond_get_timer()
156  implicit none
157  real(kind=kreal) :: hecmw_precond_get_timer
158  hecmw_precond_get_timer = time_precond
159  end function hecmw_precond_get_timer
160 
161 end module hecmw_precond
hecmw_precond_diag
Definition: hecmw_precond_DIAG.f90:6
hecmw_precond::hecmw_precond_setup
subroutine, public hecmw_precond_setup(hecMAT, hecMESH, sym)
Definition: hecmw_precond.f90:30
hecmw_precond_sainv::hecmw_precond_sainv_clear
subroutine, public hecmw_precond_sainv_clear(NDOF)
Definition: hecmw_precond_SAINV.f90:32
hecmw_precond_ssor::hecmw_precond_ssor_clear
subroutine, public hecmw_precond_ssor_clear(hecMAT)
Definition: hecmw_precond_SSOR.f90:44
hecmw_precond_rif
Definition: hecmw_precond_RIF.f90:6
hecmw_precond_ssor::hecmw_precond_ssor_setup
subroutine, public hecmw_precond_ssor_setup(hecMAT)
Definition: hecmw_precond_SSOR.f90:24
hecmw_matrix_misc::hecmw_mat_get_iterpremax
integer(kind=kint) function, public hecmw_mat_get_iterpremax(hecMAT)
Definition: hecmw_matrix_misc.f90:352
hecmw_precond_sainv
Definition: hecmw_precond_SAINV.f90:6
hecmw_util::hecmw_wtime
real(kind=kreal) function hecmw_wtime()
Definition: hecmw_util_f.F90:549
hecmw_util::hecmw_abort
subroutine hecmw_abort(comm)
Definition: hecmw_util_f.F90:534
hecmw_matrix_misc::hecmw_mat_get_precond
integer(kind=kint) function, public hecmw_mat_get_precond(hecMAT)
Definition: hecmw_matrix_misc.f90:321
hecmw_precond::hecmw_precond_clear
subroutine, public hecmw_precond_clear(hecMAT)
Definition: hecmw_precond.f90:58
hecmw_precond_bilu
Definition: hecmw_precond_BILU.f90:6
hecmw_precond_sainv::hecmw_precond_sainv_apply
subroutine, public hecmw_precond_sainv_apply(R, ZP, NDOF)
Definition: hecmw_precond_SAINV.f90:44
hecmw_solver_las
Definition: hecmw_solver_las.f90:6
hecmw_precond_diag::hecmw_precond_diag_setup
subroutine, public hecmw_precond_diag_setup(hecMAT)
Definition: hecmw_precond_DIAG.f90:24
hecmw_precond_rif::hecmw_precond_rif_clear
subroutine, public hecmw_precond_rif_clear(NDOF)
Definition: hecmw_precond_RIF.f90:32
hecmw_precond_ml::hecmw_precond_ml_clear
subroutine, public hecmw_precond_ml_clear(NDOF)
Definition: hecmw_precond_ML.f90:34
hecmw_solver_las::hecmw_matresid
subroutine, public hecmw_matresid(hecMESH, hecMAT, X, B, R, COMMtime)
Definition: hecmw_solver_las.f90:95
hecmw_precond_rif::hecmw_precond_rif_apply
subroutine, public hecmw_precond_rif_apply(ZP, NDOF)
Definition: hecmw_precond_RIF.f90:44
hecmw_util
I/O and Utility.
Definition: hecmw_util_f.F90:7
hecmw_util::hecmwst_local_mesh
Definition: hecmw_util_f.F90:234
hecmw_precond_bilu::hecmw_precond_bilu_clear
subroutine, public hecmw_precond_bilu_clear(NDOF)
Definition: hecmw_precond_BILU.f90:38
hecmw_precond_sainv::hecmw_precond_sainv_setup
subroutine, public hecmw_precond_sainv_setup(hecMAT)
Definition: hecmw_precond_SAINV.f90:20
hecmw_precond::hecmw_precond_get_timer
real(kind=kreal) function, public hecmw_precond_get_timer()
Definition: hecmw_precond.f90:156
hecmw_precond_ssor
Definition: hecmw_precond_SSOR.f90:6
hecmw_util::kreal
integer(kind=4), parameter kreal
Definition: hecmw_util_f.F90:16
hecmw_precond_diag::hecmw_precond_diag_clear
subroutine, public hecmw_precond_diag_clear(NDOF)
Definition: hecmw_precond_DIAG.f90:44
hecmw_matrix_misc
Definition: hecmw_matrix_misc.f90:6
hecmw_precond::hecmw_precond_apply
subroutine, public hecmw_precond_apply(hecMESH, hecMAT, R, Z, ZP, COMMtime)
Definition: hecmw_precond.f90:82
hecmw_precond_bilu::hecmw_precond_bilu_setup
subroutine, public hecmw_precond_bilu_setup(hecMAT)
Definition: hecmw_precond_BILU.f90:22
hecmw_precond_ml::hecmw_precond_ml_setup
subroutine, public hecmw_precond_ml_setup(hecMAT, hecMESH, sym)
Definition: hecmw_precond_ML.f90:20
hecmw_precond_ml
Definition: hecmw_precond_ML.f90:6
hecmw_precond_bilu::hecmw_precond_bilu_apply
subroutine, public hecmw_precond_bilu_apply(ZP, NDOF)
Definition: hecmw_precond_BILU.f90:54
hecmw_precond_rif::hecmw_precond_rif_setup
subroutine, public hecmw_precond_rif_setup(hecMAT)
Definition: hecmw_precond_RIF.f90:20
hecmw_precond
Definition: hecmw_precond.f90:6
hecmw_precond_ssor::hecmw_precond_ssor_apply
subroutine, public hecmw_precond_ssor_apply(ZP, NDOF)
Definition: hecmw_precond_SSOR.f90:64
hecmw_util::hecmw_comm_get_comm
integer(kind=kint) function hecmw_comm_get_comm()
Definition: hecmw_util_f.F90:571
hecmw_precond_ml::hecmw_precond_ml_apply
subroutine, public hecmw_precond_ml_apply(ZP, NDOF)
Definition: hecmw_precond_ML.f90:46
hecmw_precond::hecmw_precond_clear_timer
subroutine, public hecmw_precond_clear_timer
Definition: hecmw_precond.f90:151
hecmw_precond_diag::hecmw_precond_diag_apply
subroutine, public hecmw_precond_diag_apply(ZP, NDOF)
Definition: hecmw_precond_DIAG.f90:64
hecmw_util::hecmwst_matrix
Definition: hecmw_util_f.F90:444