FrontISTR  5.9.0
Large-scale structural analysis program with finit element method
hecmw_solver_las_11.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 
8  private
9 
10  public :: hecmw_matvec_11
11  public :: hecmw_matresid_11
12  public :: hecmw_rel_resid_l2_11
13 
14 contains
15 
16  !C
17  !C***
18  !C*** hecmw_matvec_11
19  !C***
20  !C
21  subroutine hecmw_matvec_11 (hecMESH, hecMAT, X, Y, time_Ax, COMMtime)
22  use hecmw_util
23  use m_hecmw_comm_f
24 
25  implicit none
26  type (hecmwst_local_mesh), intent(in) :: hecmesh
27  type (hecmwst_matrix), intent(in) :: hecmat
28  real(kind=kreal), intent(in) :: x(:)
29  real(kind=kreal), intent(out) :: y(:)
30  real(kind=kreal), intent(inout) :: time_ax
31  real(kind=kreal), intent(inout), optional :: commtime
32 
33  real(kind=kreal) :: start_time, end_time
34  integer(kind=kint) :: i, j, js, je, in
35  real(kind=kreal) :: yv
36 
37  start_time= hecmw_wtime()
38  call hecmw_update_r (hecmesh, x, hecmat%NP, hecmat%NDOF)
39  end_time= hecmw_wtime()
40  if (present(commtime)) commtime = commtime + end_time - start_time
41 
42  start_time= hecmw_wtime()
43 #ifdef _OPENACC
44  !$acc kernels
45  !$acc loop independent
46  do i= 1, hecmat%N
47  yv= 0
48  js= hecmat%indexA(i) + 1
49  je= hecmat%indexA(i+1)
50  do j= js, je
51  in= hecmat%itemA(j)
52  yv= yv + hecmat%A(j) * x(in)
53  enddo
54  y(i)= yv
55  enddo
56  !$acc end kernels
57 #else
58  do i= 1, hecmat%N
59  yv= hecmat%D(i) * x(i)
60  js= hecmat%indexL(i-1) + 1
61  je= hecmat%indexL(i )
62  do j= js, je
63  in= hecmat%itemL(j)
64  yv= yv + hecmat%AL(j) * x(in)
65  enddo
66  js= hecmat%indexU(i-1) + 1
67  je= hecmat%indexU(i )
68  do j= js, je
69  in= hecmat%itemU(j)
70  yv= yv + hecmat%AU(j) * x(in)
71  enddo
72  y(i)= yv
73  enddo
74 #endif
75  end_time = hecmw_wtime()
76  time_ax = time_ax + end_time - start_time
77 
78  end subroutine hecmw_matvec_11
79 
80  !C
81  !C***
82  !C*** hecmw_matresid_11
83  !C***
84  !C
85  subroutine hecmw_matresid_11 (hecMESH, hecMAT, X, B, R, time_Ax, COMMtime)
86  use hecmw_util
87 
88  implicit none
89  real(kind=kreal) :: x(:), b(:), r(:)
90  type (hecmwst_matrix) :: hecmat
91  type (hecmwst_local_mesh) :: hecmesh
92  real(kind=kreal) :: time_ax
93  real(kind=kreal), optional :: commtime
94 
95  integer(kind=kint) :: i
96  real(kind=kreal) :: tcomm
97 
98  tcomm = 0.d0
99  call hecmw_matvec_11 (hecmesh, hecmat, x, r, time_ax, tcomm)
100  if (present(commtime)) commtime = commtime + tcomm
101 
102  !$acc kernels
103  !$acc loop independent
104  do i = 1, hecmat%N
105  r(i) = b(i) - r(i)
106  enddo
107  !$acc end kernels
108 
109  end subroutine hecmw_matresid_11
110 
111  !C
112  !C***
113  !C*** hecmw_rel_resid_L2_11
114  !C***
115  !C
116  function hecmw_rel_resid_l2_11 (hecMESH, hecMAT, time_Ax, COMMtime)
117  use hecmw_util
119 
120  implicit none
121  real(kind=kreal) :: hecmw_rel_resid_l2_11
122  type ( hecmwst_local_mesh ), intent(in) :: hecmesh
123  type ( hecmwst_matrix ), intent(in) :: hecmat
124  real(kind=kreal) :: time_ax
125  real(kind=kreal), optional :: commtime
126 
127  real(kind=kreal) :: r(hecmat%NDOF*hecmat%NP)
128  real(kind=kreal) :: bnorm2, rnorm2
129  real(kind=kreal) :: tcomm
130 
131  tcomm = 0.d0
132  call hecmw_innerproduct_r(hecmesh, hecmat%NDOF, hecmat%B, hecmat%B, bnorm2, tcomm)
133  if (bnorm2 == 0.d0) then
134  bnorm2 = 1.d0
135  endif
136  call hecmw_matresid_11(hecmesh, hecmat, hecmat%X, hecmat%B, r, time_ax, tcomm)
137  call hecmw_innerproduct_r(hecmesh, hecmat%NDOF, r, r, rnorm2, tcomm)
138  if (present(commtime)) commtime = commtime + tcomm
139  hecmw_rel_resid_l2_11 = sqrt(rnorm2 / bnorm2)
140 
141  end function hecmw_rel_resid_l2_11
142 
143 end module hecmw_solver_las_11
real(kind=kreal) function, public hecmw_rel_resid_l2_11(hecMESH, hecMAT, time_Ax, COMMtime)
subroutine, public hecmw_matresid_11(hecMESH, hecMAT, X, B, R, time_Ax, COMMtime)
subroutine, public hecmw_matvec_11(hecMESH, hecMAT, X, Y, time_Ax, COMMtime)
subroutine hecmw_innerproduct_r(hecMESH, ndof, X, Y, sum, COMMtime)
I/O and Utility.
Definition: hecmw_util_f.F90:7
integer(kind=4), parameter kreal
real(kind=kreal) function hecmw_wtime()
subroutine hecmw_update_r(hecMESH, val, n, m)