FrontISTR  6.0.0
Large-scale structural analysis program with finit element method
hecmw_matrix_reorder.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
9  implicit none
10 
11  private
15 
16 contains
17 
18  subroutine hecmw_matrix_reorder_profile(N, perm, iperm, &
19  indexL, indexU, itemL, itemU, indexLp, indexUp, itemLp, itemUp)
20  implicit none
21  integer(kind=kint), intent(in) :: n
22  integer(kind=kint), intent(in) :: perm(:), iperm(:)
23  integer(kind=kint), intent(in) :: indexl(0:), indexu(0:)
24  integer(kind=kint), intent(in) :: iteml(:), itemu(:)
25  integer(kind=kint), intent(out) :: indexlp(0:), indexup(0:)
26  integer(kind=kint), intent(out) :: itemlp(:), itemup(:)
27  integer(kind=kint) :: cntl, cntu, inew, iold, j, jold, jnew
28  cntl = 0
29  cntu = 0
30  indexlp(0) = 0
31  indexup(0) = 0
32  do inew=1,n
33  iold = perm(inew)
34  ! original L
35  do j = indexl(iold-1)+1, indexl(iold)
36  jold = iteml(j)
37  jnew = iperm(jold)
38  if (jnew < inew) then
39  cntl = cntl + 1
40  itemlp(cntl) = jnew
41  else
42  cntu = cntu + 1
43  itemup(cntu) = jnew
44  end if
45  end do
46  ! original U
47  do j = indexu(iold-1)+1, indexu(iold)
48  jold = itemu(j)
49  if (jold > n) cycle
50  jnew = iperm(jold)
51  if (jnew < inew) then
52  cntl = cntl + 1
53  itemlp(cntl) = jnew
54  else
55  cntu = cntu + 1
56  itemup(cntu) = jnew
57  end if
58  end do
59  indexlp(inew) = cntl
60  indexup(inew) = cntu
61  call hecmw_qsort_int_array(itemlp, indexlp(inew-1)+1, indexlp(inew))
62  call hecmw_qsort_int_array(itemup, indexup(inew-1)+1, indexup(inew))
63  end do
64  end subroutine hecmw_matrix_reorder_profile
65 
66  subroutine hecmw_matrix_reorder_values(N, NDOF, perm, iperm, &
67  indexL, indexU, itemL, itemU, AL, AU, D, &
68  indexLp, indexUp, itemLp, itemUp, ALp, AUp, Dp)
69  implicit none
70  integer(kind=kint), intent(in) :: n, ndof
71  integer(kind=kint), intent(in) :: perm(:), iperm(:)
72  integer(kind=kint), intent(in) :: indexl(0:), indexu(0:)
73  integer(kind=kint), intent(in) :: iteml(:), itemu(:)
74  real(kind=kreal), intent(in) :: al(:), au(:), d(:)
75  integer(kind=kint), intent(in) :: indexlp(0:), indexup(0:)
76  integer(kind=kint), intent(in) :: itemlp(:), itemup(:)
77  real(kind=kreal), intent(out) :: alp(:), aup(:), dp(:)
78  dp = 0.d0
79  alp = 0.d0
80  aup = 0.d0
81  call reorder_diag2(n, ndof, iperm, d, dp)
82  call reorder_off_diag2(n, ndof, iperm, &
83  indexl, iteml, al, &
84  indexlp, indexup, itemlp, itemup, alp, aup)
85  call reorder_off_diag2(n, ndof, iperm, &
86  indexu, itemu, au, &
87  indexlp, indexup, itemlp, itemup, alp, aup)
88  end subroutine hecmw_matrix_reorder_values
89 
90  subroutine hecmw_matrix_reorder_renum_item(N, perm, indexXp, itemXp)
91  implicit none
92  integer(kind=kint), intent(in) :: n
93  integer(kind=kint), intent(in) :: perm(:)
94  integer(kind=kint), intent(in) :: indexxp(0:)
95  integer(kind=kint), intent(inout) :: itemxp(:)
96  integer(kind=kint) :: npx, i
97  npx = indexxp(n)
98  !$omp parallel default(none),private(i),shared(NPX,itemXp,perm)
99  !$omp do
100  do i=1,npx
101  itemxp(i) = perm( itemxp(i) )
102  end do
103  !$omp end do
104  !$omp end parallel
105  end subroutine hecmw_matrix_reorder_renum_item
106 
107  subroutine reorder_diag2(N, NDOF, iperm, D, Dp)
108  implicit none
109  integer(kind=kint), intent(in) :: n, ndof
110  integer(kind=kint), intent(in) :: iperm(:)
111  real(kind=kreal), intent(in) :: d(:)
112  real(kind=kreal), intent(out) :: dp(:)
113  integer(kind=kint) :: ndof2, inew, iold, j0new, j0old, j
114  ndof2 = ndof*ndof
115  ! diagonal
116  !$omp parallel default(none),private(iold,inew,j0old,j0new,j), &
117  !$omp& shared(N,iperm,NDOF2,Dp,D)
118  !$omp do
119  do iold=1,n
120  inew = iperm(iold)
121  j0old = (iold-1)*ndof2
122  j0new = (inew-1)*ndof2
123  do j=1,ndof2
124  dp(j0new + j) = d(j0old + j)
125  end do
126  end do
127  !$omp end do
128  !$omp end parallel
129  end subroutine reorder_diag2
130 
131  subroutine reorder_off_diag2(N, NDOF, iperm, &
132  indexX, itemX, AX, &
133  indexLp, indexUp, itemLp, itemUp, ALp, AUp)
134  implicit none
135  integer(kind=kint), intent(in) :: n, ndof
136  integer(kind=kint), intent(in) :: iperm(:)
137  integer(kind=kint), intent(in) :: indexx(0:)
138  integer(kind=kint), intent(in) :: itemx(:)
139  real(kind=kreal), intent(in) :: ax(:)
140  integer(kind=kint), intent(in) :: indexlp(0:), indexup(0:)
141  integer(kind=kint), intent(in) :: itemlp(:), itemup(:)
142  real(kind=kreal), intent(inout) :: alp(:), aup(:)
143  integer(kind=kint) :: ndof2, iold, inew
144  integer(kind=kint) :: jsnewl, jenewl, jsnewu, jenewu
145  integer(kind=kint) :: jold, kold, knew, jnew, l0old, l0new, l
146  ndof2 = ndof*ndof
147  ! new L
148  !$omp parallel default(none), &
149  !$omp private(iold,inew,jsnewL,jenewL,jsnewU,jenewU,jold,kold,knew,jnew,l0old,l0new,l), &
150  !$omp shared(N,iperm,indexLp,indexUp,indexX,itemX,itemLp,NDOF2,ALp,AX,itemUp,AUp)
151  !$omp do
152  do iold=1,n
153  inew = iperm(iold)
154  jsnewl = indexlp(inew-1)+1
155  jenewl = indexlp(inew)
156  jsnewu = indexup(inew-1)+1
157  jenewu = indexup(inew)
158  do jold = indexx(iold-1)+1, indexx(iold)
159  kold = itemx(jold)
160  if (kold > n) cycle
161  knew = iperm(kold)
162  if (knew < inew) then
163  call hecmw_bsearch_int_array(itemlp, jsnewl, jenewl, knew, jnew)
164  if (jnew < 0) then
165  !$omp critical
166  write(0,*) 'ERROR:: jnew < 0 in reorder_off_diag2'
167  !$omp end critical
169  end if
170  l0old = (jold-1)*ndof2
171  l0new = (jnew-1)*ndof2
172  do l=1,ndof2
173  alp(l0new + l) = ax(l0old + l)
174  end do
175  else
176  call hecmw_bsearch_int_array(itemup, jsnewu, jenewu, knew, jnew)
177  if (jnew < 0) then
178  !$omp critical
179  write(0,*) 'ERROR:: jnew < 0 in reorder_off_diag2'
180  !$omp end critical
182  end if
183  l0old = (jold-1)*ndof2
184  l0new = (jnew-1)*ndof2
185  do l=1,ndof2
186  aup(l0new + l) = ax(l0old + l)
187  end do
188  end if
189  end do
190  end do
191  !$omp end do
192  !$omp end parallel
193  end subroutine reorder_off_diag2
194 
195 end module hecmw_matrix_reorder
subroutine, public hecmw_bsearch_int_array(array, istart, iend, val, idx)
recursive subroutine, public hecmw_qsort_int_array(array, istart, iend)
subroutine, public hecmw_matrix_reorder_values(N, NDOF, perm, iperm, indexL, indexU, itemL, itemU, AL, AU, D, indexLp, indexUp, itemLp, itemUp, ALp, AUp, Dp)
subroutine, public hecmw_matrix_reorder_renum_item(N, perm, indexXp, itemXp)
subroutine, public hecmw_matrix_reorder_profile(N, perm, iperm, indexL, indexU, itemL, itemU, indexLp, indexUp, itemLp, itemUp)
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