FrontISTR  5.7.0
Large-scale structural analysis program with finit element method
fstr_EIG_lanczos.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 !-------------------------------------------------------------------------------
7 contains
8 
10  subroutine fstr_solve_lanczos(hecMESH, hecMAT, fstrSOLID, fstrEIG)
11  use m_fstr
12  use hecmw_util
13  use m_eigen_lib
16 
17  implicit none
18 
19  type(hecmwst_local_mesh) :: hecmesh
20  type(hecmwst_matrix) :: hecMAT
21  type(fstr_solid) :: fstrSOLID
22  type(fstr_eigen) :: fstrEIG
23  type(fstr_tri_diag) :: Tri
24  type(fstr_eigen_vec), pointer :: Q(:)
25  integer(kind=kint) :: N, NP, NDOF, NNDOF, NPNDOF
26  integer(kind=kint) :: iter, maxiter, nget, ierr
27  integer(kind=kint) :: i, j, k, in, jn, kn, ik, it
28  integer(kind=kint) :: ig, ig0, is0, ie0, its0, ite0
29  real(kind=kreal) :: t1, t2, tolerance
30  real(kind=kreal) :: alpha, beta, beta0
31  real(kind=kreal), allocatable :: s(:), t(:), p(:)
32  logical :: is_converge
33 
34  n = hecmat%N
35  np = hecmat%NP
36  ndof = hecmesh%n_dof
37  nndof = n *ndof
38  npndof = np*ndof
39 
40  allocate(fstreig%filter(npndof))
41  fstreig%filter = 1.0d0
42  fstreig%sigma = 0.01d0
43 
44  jn = 0
45  do ig0 = 1, fstrsolid%BOUNDARY_ngrp_tot
46  ig = fstrsolid%BOUNDARY_ngrp_ID(ig0)
47  is0 = hecmesh%node_group%grp_index(ig-1) + 1
48  ie0 = hecmesh%node_group%grp_index(ig )
49  it = fstrsolid%BOUNDARY_ngrp_type(ig0)
50  its0 = (it - mod(it,10))/10
51  ite0 = mod(it,10)
52 
53  do ik = is0, ie0
54  in = hecmesh%node_group%grp_item(ik)
55  if(ndof < ite0) ite0 = ndof
56  do i = its0, ite0
57  jn = jn + 1
58  fstreig%filter((in-1)*ndof+i) = 0.0d0
59  enddo
60  enddo
61  enddo
62 
63  do ig0 = 1, fstrsolid%SPRING_ngrp_tot
64  ig = fstrsolid%SPRING_ngrp_ID(ig0)
65  is0 = hecmesh%node_group%grp_index(ig-1) + 1
66  ie0 = hecmesh%node_group%grp_index(ig )
67  do ik = is0, ie0
68  jn = jn + 1
69  enddo
70  enddo
71 
72  call hecmw_allreduce_i1(hecmesh, jn, hecmw_sum)
73  if(jn == 0)then
74  fstreig%is_free = .true.
75  if(myrank == 0)then
76  write(*,"(a,1pe12.4)") '** free modal analysis: shift factor =', fstreig%sigma
77  endif
78  endif
79 
80  call hecmw_update_r(hecmesh, fstreig%filter, np, ndof)
81 
82  in = 0
83  do i = 1, nndof
84  if(fstreig%filter(i) == 1.0d0) in = in + 1
85  enddo
86  call hecmw_allreduce_i1(hecmesh, in, hecmw_sum)
87 
88  fstreig%maxiter = fstreig%maxiter + 1
89  if(in < fstreig%maxiter)then
90  if(myrank == 0)then
91  write(imsg,*) '** changed maxiter to system matrix size.'
92  endif
93  fstreig%maxiter = in
94  endif
95 
96  if(in < fstreig%nget)then
97  fstreig%nget = in
98  endif
99 
100  maxiter = fstreig%maxiter
101 
102  allocate(q(0:maxiter))
103  allocate(q(0)%q(npndof))
104  allocate(q(1)%q(npndof))
105  allocate(fstreig%eigval(maxiter))
106  allocate(fstreig%eigvec(npndof, maxiter))
107  allocate(tri%alpha(maxiter))
108  allocate(tri%beta(maxiter))
109  allocate(t(npndof))
110  allocate(s(npndof))
111  allocate(p(npndof))
112 
113  fstreig%eigval = 0.0d0
114  fstreig%eigvec = 0.0d0
115  t = 0.0d0
116  p = 0.0d0
117  s = 0.0d0
118  q(0)%q = 0.0d0
119  q(1)%q = 0.0d0
120  tri%alpha = 0.0d0
121  tri%beta = 0.0d0
122  hecmat%X = 0.0d0
123 
124  call lanczos_set_initial_value(hecmesh, hecmat, fstreig, fstreig%eigvec, p, q(1)%q, tri%beta(1))
125 
126  hecmat%Iarray(98) = 1 !Assembly complete
127  hecmat%Iarray(97) = 1 !Need numerical factorization
128 
129  if(myrank == 0)then
130  write(imsg,*)
131  write(imsg,*) ' ***** STAGE Begin Lanczos loop **'
132  endif
133 
134  do iter = 1, maxiter-1
136  do i = 1, npndof
137  hecmat%B(i) = p(i)
138  enddo
139 
140  call solve_lineq(hecmesh, hecmat)
141 
142  allocate(q(iter+1)%q(npndof))
143 
144  do i = 1, npndof
145  t(i) = hecmat%X(i) * fstreig%filter(i)
146  enddo
147 
150  do i = 1, npndof
151  t(i) = t(i) - tri%beta(iter) * q(iter-1)%q(i)
152  enddo
153 
154  alpha = 0.0d0
155  do i = 1, nndof
156  alpha = alpha + p(i) * t(i)
157  enddo
158  call hecmw_allreduce_r1(hecmesh, alpha, hecmw_sum)
159  tri%alpha(iter) = alpha
160 
162  do i = 1, npndof
163  t(i) = t(i) - tri%alpha(iter) * q(iter)%q(i)
164  enddo
165 
167  s = 0.0d0
168 
169  do i = 1, npndof
170  s(i) = fstreig%mass(i) * t(i)
171  enddo
172 
173  do j = 0, iter
174  t1 = 0.0d0
175  do i = 1, nndof
176  t1 = t1 + q(j)%q(i) * s(i)
177  enddo
178  call hecmw_allreduce_r1(hecmesh, t1, hecmw_sum)
179  do i = 1, npndof
180  t(i) = t(i) - t1 * q(j)%q(i)
181  enddo
182  enddo
183 
185  do i = 1, npndof
186  s(i) = fstreig%mass(i) * t(i)
187  enddo
188 
189  beta = 0.0d0
190  do i = 1, nndof
191  beta = beta + s(i) * t(i)
192  enddo
193  call hecmw_allreduce_r1(hecmesh, beta, hecmw_sum)
194  tri%beta(iter+1) = dsqrt(beta)
195 
198  beta = 1.0d0/tri%beta(iter+1)
199  do i = 1, npndof
200  p(i) = s(i) * beta
201  q(iter+1)%q(i) = t(i) * beta
202  enddo
203 
204  fstreig%iter = iter
205  if(iter == 1) beta0 = tri%beta(iter+1)
206 
207  call tridiag(hecmesh, hecmat, fstreig, q, tri, iter, is_converge)
208 
209  if(is_converge) exit
210  enddo
211 
212  do i = 0, iter
213  if(associated(q(i)%q)) deallocate(q(i)%q)
214  enddo
215  deallocate(tri%alpha)
216  deallocate(tri%beta)
217  deallocate(t)
218  deallocate(s)
219  deallocate(p)
220 
221  t2 = hecmw_wtime()
222 
223  if(myrank == 0)then
224  write(imsg,*)
225  write(imsg,*) ' * STAGE Output and postprocessing **'
226  write(idbg,'(a,f10.2)') 'Lanczos loop (sec) :', t2 - t1
227  endif
228 
229  end subroutine fstr_solve_lanczos
230 
231 end module m_fstr_eig_lanczos
m_fstr_eig_lanczos_util::lanczos_set_initial_value
subroutine lanczos_set_initial_value(hecMESH, hecMAT, fstrEIG, eigvec, p, q, beta)
Initialize Lanczos iterations.
Definition: fstr_EIG_lanczos_util.f90:11
m_fstr_eig_lanczos_util
Definition: fstr_EIG_lanczos_util.f90:5
hecmw_util::hecmw_wtime
real(kind=kreal) function hecmw_wtime()
Definition: hecmw_util_f.F90:549
m_fstr_eig_lanczos
Lanczos iteration calculation.
Definition: fstr_EIG_lanczos.f90:6
m_fstr::myrank
integer(kind=kint) myrank
PARALLEL EXECUTION.
Definition: m_fstr.f90:96
hecmw_util::hecmw_sum
integer(kind=kint), parameter hecmw_sum
Definition: hecmw_util_f.F90:23
m_fstr::fstr_eigen
Package of data used by Lanczos eigenvalue solver.
Definition: m_fstr.f90:593
m_fstr::fstr_solid
Definition: m_fstr.f90:238
m_fstr::idbg
integer(kind=kint), parameter idbg
Definition: m_fstr.f90:111
m_fstr_eig_lanczos::fstr_solve_lanczos
subroutine fstr_solve_lanczos(hecMESH, hecMAT, fstrSOLID, fstrEIG)
SOLVE EIGENVALUE PROBLEM.
Definition: fstr_EIG_lanczos.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
m_fstr_eig_tridiag
This module provides a subroutine to find the eigenvalues and eigenvectors of a symmetric tridiagonal...
Definition: fstr_EIG_tridiag.f90:7
m_fstr
This module defines common data and basic structures for analysis.
Definition: m_fstr.f90:15
hecmw_util::kreal
integer(kind=4), parameter kreal
Definition: hecmw_util_f.F90:16
m_eigen_lib
This modules just summarizes all modules used in eigen analysis.
Definition: eigen_LIB.f90:6
m_fstr_eig_tridiag::fstr_eigen_vec
Definition: fstr_EIG_tridiag.f90:14
m_fstr_eig_tridiag::fstr_tri_diag
Definition: fstr_EIG_tridiag.f90:18
m_fstr_eig_tridiag::tridiag
subroutine tridiag(hecMESH, hecMAT, fstrEIG, Q, Tri, iter, is_converge)
Definition: fstr_EIG_tridiag.f90:26
hecmw_util::hecmwst_matrix
Definition: hecmw_util_f.F90:444
m_fstr::imsg
integer(kind=kint), parameter imsg
Definition: m_fstr.f90:110