FrontISTR  5.7.0
Large-scale structural analysis program with finit element method
hecmw_ML_helper_33_f.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 
6 subroutine hecmw_ml_getrow_33(id, n_requested_rows, requested_rows, &
7  allocated_space, cols, values, row_lengths, ierr)
9  use hecmw_mat_id
10  implicit none
11  integer(kind=kint), intent(in) :: id
12  integer(kind=kint), intent(in) :: n_requested_rows
13  integer(kind=kint), intent(in) :: requested_rows(n_requested_rows)
14  integer(kind=kint), intent(in) :: allocated_space
15  integer(kind=kint), intent(out) :: cols(allocated_space)
16  real(kind=kreal), intent(out) :: values(allocated_space)
17  integer(kind=kint), intent(out) :: row_lengths(n_requested_rows)
18  integer(kind=kint), intent(out) :: ierr
19  type(hecmwst_matrix), pointer :: hecMAT
20  type(hecmwst_local_mesh), pointer :: hecMESH
21  integer(kind=kint) :: m, i, row, inod, idof, nl, nd, nu, js, je, j, jj, jdof, start
22  ierr = 0
23  call hecmw_mat_id_get(id, hecmat, hecmesh)
24  m = 1
25  do i = 1, n_requested_rows
26  row = requested_rows(i) + 1 ! '+1' for Fortran-numbering
27  inod = (row-1)/3 + 1
28  idof = row - (inod-1)*3
29  nl = (hecmat%indexL(inod) - hecmat%indexL(inod-1)) * 3
30  nd = 3
31  nu = (hecmat%indexU(inod) - hecmat%indexU(inod-1)) * 3
32  if (allocated_space < m + nl + nd + nu) return
33  start = m
34  js = hecmat%indexL(inod-1)+1
35  je = hecmat%indexL(inod)
36  do j = js, je
37  jj = hecmat%itemL(j)
38  do jdof = 1, 3
39  cols(m) = (jj-1)*3 + jdof - 1 ! '-1' for C-numbering
40  values(m) = hecmat%AL((j-1)*9 + (idof-1)*3 + jdof)
41  m = m+1
42  enddo
43  enddo
44  do jdof = 1, 3
45  cols(m) = (inod-1)*3 + jdof - 1 ! '-1' for C-numbering
46  values(m) = hecmat%D((inod-1)*9 + (idof-1)*3 + jdof)
47  m = m+1
48  enddo
49  js = hecmat%indexU(inod-1)+1
50  je = hecmat%indexU(inod)
51  do j = js, je
52  jj = hecmat%itemU(j)
53  do jdof = 1, 3
54  cols(m) = (jj-1)*3 + jdof - 1 ! '-1' for C-numbering
55  values(m) = hecmat%AU((j-1)*9 + (idof-1)*3 + jdof)
56  m = m+1
57  enddo
58  enddo
59  row_lengths(i) = m - start
60  enddo
61  ierr = 1
62 end subroutine hecmw_ml_getrow_33
63 
64 subroutine hecmw_ml_matvec_33(id, in_length, p, out_length, ap, ierr)
66  use hecmw_mat_id
68  implicit none
69  integer(kind=kint), intent(in) :: id
70  integer(kind=kint), intent(in) :: in_length
71  real(kind=kreal), intent(in) :: p(in_length)
72  integer(kind=kint), intent(in) :: out_length
73  real(kind=kreal), intent(out) :: ap(out_length)
74  integer(kind=kint), intent(out) :: ierr
75  type(hecmwst_matrix), pointer :: hecMAT
76  type(hecmwst_local_mesh), pointer :: hecMESH
77  real(kind=kreal), allocatable :: w(:)
78  integer(kind=kint) :: i
79  call hecmw_mat_id_get(id, hecmat, hecmesh)
80  allocate(w(hecmat%NP*hecmat%NDOF))
81  do i = 1, hecmat%N*hecmat%NDOF
82  w(i) = p(i)
83  enddo
84  call hecmw_matvec(hecmesh, hecmat, w, ap)
85  deallocate(w)
86  ierr = 0
87 end subroutine hecmw_ml_matvec_33
88 
89 subroutine hecmw_ml_comm_33(id, x, ierr)
91  use hecmw_mat_id
92  use m_hecmw_comm_f
93  implicit none
94  integer(kind=kint), intent(in) :: id
95  real(kind=kreal), intent(inout) :: x(*)
96  integer(kind=kint), intent(out) :: ierr
97  type(hecmwst_matrix), pointer :: hecMAT
98  type(hecmwst_local_mesh), pointer :: hecMESH
99  call hecmw_mat_id_get(id, hecmat, hecmesh)
100  call hecmw_update_r (hecmesh, x, hecmesh%n_node, 3)
101  ierr = 0
102 end subroutine hecmw_ml_comm_33
103 
104 subroutine hecmw_ml_smoother_diag_setup_33(id, ierr)
106  use hecmw_mat_id
108  implicit none
109  integer(kind=kint), intent(in) :: id
110  integer(kind=kint), intent(out) :: ierr
111  type(hecmwst_matrix), pointer :: hecMAT
112  type(hecmwst_local_mesh), pointer :: hecMESH
113  call hecmw_mat_id_get(id, hecmat, hecmesh)
114  call hecmw_precond_diag_33_setup(hecmat)
115  ierr = 0
116 end subroutine hecmw_ml_smoother_diag_setup_33
117 
118 subroutine hecmw_ml_smoother_diag_apply_33(id, x_length, x, rhs_length, rhs, ierr)
120  use hecmw_mat_id
122  use hecmw_solver_las
124  implicit none
125  integer(kind=kint), intent(in) :: id
126  integer(kind=kint), intent(in) :: x_length
127  real(kind=kreal), intent(inout) :: x(x_length)
128  integer(kind=kint), intent(in) :: rhs_length
129  real(kind=kreal), intent(in) :: rhs(rhs_length)
130  integer(kind=kint), intent(out) :: ierr
131  type(hecmwst_matrix), pointer :: hecMAT
132  type(hecmwst_local_mesh), pointer :: hecMESH
133 
134  real(kind=kreal), allocatable :: resid(:)
135  integer(kind=kint) :: i
136  real(kind=kreal) :: commtime
137  integer(kind=kint) :: num_sweeps, i_sweep
138  integer(kind=kint) :: opt(10)
139 
140  call hecmw_mat_id_get(id, hecmat, hecmesh)
141  call hecmw_mat_get_solver_opt(hecmat, opt)
142  num_sweeps = opt(6)
143  allocate(resid(hecmat%NP * hecmat%NDOF))
144  do i_sweep = 1, num_sweeps
145  ! {resid} = {rhs} - [A] {x}
146  call hecmw_matresid(hecmesh, hecmat, x, rhs, resid, commtime)
147  ! {delta_x} = [M]^-1 {resid}
148  call hecmw_precond_diag_33_apply(resid)
149  ! {x} = {x} + {delta_x}
150  do i=1,x_length
151  x(i) = x(i) + resid(i)
152  enddo
153  enddo
154  deallocate(resid)
155  ierr = 0
156 end subroutine hecmw_ml_smoother_diag_apply_33
157 
158 subroutine hecmw_ml_smoother_diag_clear_33(id, ierr)
160  use hecmw_mat_id
162  implicit none
163  integer(kind=kint), intent(in) :: id
164  integer(kind=kint), intent(out) :: ierr
165  type(hecmwst_matrix), pointer :: hecMAT
166  type(hecmwst_local_mesh), pointer :: hecMESH
167  call hecmw_mat_id_get(id, hecmat, hecmesh)
169  ierr = 0
170 end subroutine hecmw_ml_smoother_diag_clear_33
171 
172 subroutine hecmw_ml_smoother_ssor_setup_33(id, ierr)
174  use hecmw_mat_id
176  implicit none
177  integer(kind=kint), intent(in) :: id
178  integer(kind=kint), intent(out) :: ierr
179  type(hecmwst_matrix), pointer :: hecMAT
180  type(hecmwst_local_mesh), pointer :: hecMESH
181  call hecmw_mat_id_get(id, hecmat, hecmesh)
182  call hecmw_precond_ssor_33_setup(hecmat)
183  ierr = 0
184 end subroutine hecmw_ml_smoother_ssor_setup_33
185 
186 subroutine hecmw_ml_smoother_ssor_apply_33(id, x_length, x, rhs_length, rhs, ierr)
188  use hecmw_mat_id
190  use hecmw_solver_las
192  implicit none
193  integer(kind=kint), intent(in) :: id
194  integer(kind=kint), intent(in) :: x_length
195  real(kind=kreal), intent(inout) :: x(x_length)
196  integer(kind=kint), intent(in) :: rhs_length
197  real(kind=kreal), intent(in) :: rhs(rhs_length)
198  integer(kind=kint), intent(out) :: ierr
199  type(hecmwst_matrix), pointer :: hecMAT
200  type(hecmwst_local_mesh), pointer :: hecMESH
201 
202  real(kind=kreal), allocatable :: resid(:)
203  integer(kind=kint) :: i
204  real(kind=kreal) :: commtime
205  integer(kind=kint) :: num_sweeps, i_sweep
206  integer(kind=kint) :: opt(10)
207 
208  call hecmw_mat_id_get(id, hecmat, hecmesh)
209  call hecmw_mat_get_solver_opt(hecmat, opt)
210  num_sweeps = opt(6)
211  allocate(resid(hecmat%NP * hecmat%NDOF))
212  do i_sweep = 1, num_sweeps
213  ! {resid} = {rhs} - [A] {x}
214  call hecmw_matresid(hecmesh, hecmat, x, rhs, resid, commtime)
215  ! {delta_x} = [M]^-1 {resid}
216  call hecmw_precond_ssor_33_apply(resid)
217  ! {x} = {x} + {delta_x}
218  do i=1,x_length
219  x(i) = x(i) + resid(i)
220  enddo
221  enddo
222  deallocate(resid)
223  ierr = 0
224 end subroutine hecmw_ml_smoother_ssor_apply_33
225 
226 subroutine hecmw_ml_smoother_ssor_clear_33(id, ierr)
228  use hecmw_mat_id
230  implicit none
231  integer(kind=kint), intent(in) :: id
232  integer(kind=kint), intent(out) :: ierr
233  type(hecmwst_matrix), pointer :: hecMAT
234  type(hecmwst_local_mesh), pointer :: hecMESH
235  call hecmw_mat_id_get(id, hecmat, hecmesh)
236  call hecmw_precond_ssor_33_clear(hecmat)
237  ierr = 0
238 end subroutine hecmw_ml_smoother_ssor_clear_33
hecmw_ml_smoother_diag_apply_33
subroutine hecmw_ml_smoother_diag_apply_33(id, x_length, x, rhs_length, rhs, ierr)
Definition: hecmw_ML_helper_33_f.f90:119
hecmw_ml_smoother_ssor_apply_33
subroutine hecmw_ml_smoother_ssor_apply_33(id, x_length, x, rhs_length, rhs, ierr)
Definition: hecmw_ML_helper_33_f.f90:187
hecmw_ml_matvec_33
subroutine hecmw_ml_matvec_33(id, in_length, p, out_length, ap, ierr)
Definition: hecmw_ML_helper_33_f.f90:65
hecmw_ml_getrow_33
subroutine hecmw_ml_getrow_33(id, n_requested_rows, requested_rows, allocated_space, cols, values, row_lengths, ierr)
Definition: hecmw_ML_helper_33_f.f90:8
hecmw_solver_las::hecmw_matvec
subroutine, public hecmw_matvec(hecMESH, hecMAT, X, Y, COMMtime)
Definition: hecmw_solver_las.f90:43
hecmw_matrix_misc::hecmw_mat_get_solver_opt
subroutine, public hecmw_mat_get_solver_opt(hecMAT, solver_opt)
Definition: hecmw_matrix_misc.f90:657
hecmw_precond_ssor_33::hecmw_precond_ssor_33_apply
subroutine, public hecmw_precond_ssor_33_apply(ZP)
Definition: hecmw_precond_SSOR_33.f90:245
hecmw_ml_comm_33
subroutine hecmw_ml_comm_33(id, x, ierr)
Definition: hecmw_ML_helper_33_f.f90:90
hecmw_precond_diag_33::hecmw_precond_diag_33_apply
subroutine, public hecmw_precond_diag_33_apply(WW)
Definition: hecmw_precond_DIAG_33.f90:107
hecmw_precond_ssor_33::hecmw_precond_ssor_33_setup
subroutine, public hecmw_precond_ssor_33_setup(hecMAT)
Definition: hecmw_precond_SSOR_33.f90:56
hecmw_ml_smoother_diag_clear_33
subroutine hecmw_ml_smoother_diag_clear_33(id, ierr)
Definition: hecmw_ML_helper_33_f.f90:159
hecmw_ml_smoother_ssor_clear_33
subroutine hecmw_ml_smoother_ssor_clear_33(id, ierr)
Definition: hecmw_ML_helper_33_f.f90:227
hecmw_solver_las
Definition: hecmw_solver_las.f90:6
hecmw_solver_las::hecmw_matresid
subroutine, public hecmw_matresid(hecMESH, hecMAT, X, B, R, COMMtime)
Definition: hecmw_solver_las.f90:95
hecmw_precond_ssor_33
Definition: hecmw_precond_SSOR_33.f90:11
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_diag_33::hecmw_precond_diag_33_clear
subroutine, public hecmw_precond_diag_33_clear()
Definition: hecmw_precond_DIAG_33.f90:136
m_hecmw_comm_f
Definition: hecmw_comm_f.F90:6
hecmw_precond_diag_33
Definition: hecmw_precond_DIAG_33.f90:11
hecmw_util::kreal
integer(kind=4), parameter kreal
Definition: hecmw_util_f.F90:16
hecmw_ml_smoother_ssor_setup_33
subroutine hecmw_ml_smoother_ssor_setup_33(id, ierr)
Definition: hecmw_ML_helper_33_f.f90:173
hecmw_mat_id
Definition: hecmw_mat_id.f90:6
hecmw_matrix_misc
Definition: hecmw_matrix_misc.f90:6
hecmw_ml_smoother_diag_setup_33
subroutine hecmw_ml_smoother_diag_setup_33(id, ierr)
Definition: hecmw_ML_helper_33_f.f90:105
hecmw_precond_ssor_33::hecmw_precond_ssor_33_clear
subroutine, public hecmw_precond_ssor_33_clear(hecMAT)
Definition: hecmw_precond_SSOR_33.f90:361
m_hecmw_comm_f::hecmw_update_r
subroutine hecmw_update_r(hecMESH, val, n, m)
Definition: hecmw_comm_f.F90:683
hecmw_precond_diag_33::hecmw_precond_diag_33_setup
subroutine, public hecmw_precond_diag_33_setup(hecMAT)
Definition: hecmw_precond_DIAG_33.f90:28
hecmw_mat_id::hecmw_mat_id_get
subroutine, public hecmw_mat_id_get(id, hecMAT, hecMESH)
Definition: hecmw_mat_id.f90:49
hecmw_util::hecmwst_matrix
Definition: hecmw_util_f.F90:444