FrontISTR  6.0.0
Large-scale structural analysis program with finit element method
fstr_EIG_lanczos_util.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 !-------------------------------------------------------------------------------
6 
7 contains
8 
10  subroutine lanczos_set_initial_value(hecMESH, hecMAT, fstrEIG, eigvec, p, q, beta)
11  use m_fstr
12  use hecmw_util
13  implicit none
14  type(hecmwst_local_mesh) :: hecMESH
15  type(hecmwst_matrix) :: hecMAT
16  type(fstr_eigen) :: fstrEIG
17  integer(kind=kint) :: N, NP, NDOF, NDOF2, NNDOF, NPNDOF
18  integer(kind=kint) :: i, j
19  real(kind=kreal) :: eigvec(:, :), p(:), beta, chk, sigma
20  real(kind=kreal), allocatable :: temp(:)
21  real(kind=kreal), pointer :: q(:), mass(:), filter(:)
22 
23  n = hecmat%N
24  np = hecmat%NP
25  ndof = hecmesh%n_dof
26  ndof2 = ndof*ndof
27  nndof = n *ndof
28  npndof = np*ndof
29 
30  sigma = fstreig%sigma
31  mass => fstreig%mass
32  filter => fstreig%filter
33 
34  allocate(temp(nndof))
35  temp = 0.0d0
36 
38  if(fstreig%is_free)then
39  do i = 1, np
40  do j = 1, ndof
41  hecmat%D(ndof2*(i-1) + (ndof+1)*(j-1) + 1) = hecmat%D(ndof2*(i-1) + (ndof+1)*(j-1) + 1) + sigma * mass(ndof*(i-1) + j)
42  enddo
43  enddo
44  endif
45 
46  call urand1(nndof, temp, hecmesh%my_rank)
47 
48  do i = 1, nndof
49  temp(i) = temp(i) * filter(i)
50  enddo
51 
53  do i = 1, nndof
54  eigvec(i,1) = mass(i) * temp(i)
55  enddo
56 
57  chk = 0.0d0
58  do i = 1, nndof
59  chk = chk + temp(i) * eigvec(i,1)
60  enddo
61  call hecmw_allreduce_r1(hecmesh, chk, hecmw_sum)
62  beta = dsqrt(chk)
63 
64  if(beta == 0.0d0)then
65  call hecmw_finalize()
66  stop "Self-orthogonal"
67  endif
68 
69  chk = 1.0d0/beta
70  do i = 1, nndof
71  q(i) = temp(i) * chk
72  enddo
73 
74  do i = 1, nndof
75  p(i) = mass(i) * q(i)
76  enddo
77  end subroutine lanczos_set_initial_value
78 
80  subroutine evsort(EIG, NEW, NEIG)
81  use hecmw
82  implicit none
83  integer(kind=kint) :: i, j, n, ip, minloc, NEIG, IBAF, NEW(NEIG)
84  real(kind=kreal) :: emin, eig(neig)
85 
86  do i = 1, neig
87  new(i) = i
88  enddo
89 
90  n = neig-1
91  do i = 1, n
92  minloc = i
93  emin = dabs(eig(new(i)))
94  ip = i+1
95  do j=ip,neig
96  if(dabs(eig(new(j))).LT.emin)then
97  minloc = j
98  emin = dabs(eig(new(j)))
99  endif
100  enddo
101  ibaf = new(i)
102  new(i) = new(minloc)
103  new(minloc) = ibaf
104  enddo
105  end subroutine evsort
106 
107  subroutine urand1(N, X, SHIFT)
108  use hecmw
109  implicit none
110  real(kind=kreal) :: x(n), invm
111  integer(kind=kint), parameter :: MM = 1664501
112  integer(kind=kint), parameter :: LAMBDA = 1229
113  integer(kind=kint), parameter :: MU = 351750
114  integer(kind=kint) :: i, N, IR, SHIFT
115 
116  ir = 0
117  invm = 1.0d0 / mm
118  do i = 1, shift
119  ir = mod( lambda * ir + mu, mm)
120  enddo
121  do i = shift+1, shift+n
122  ir = mod( lambda * ir + mu, mm)
123  x(i-shift) = invm * ir
124  enddo
125  end subroutine urand1
126 
127 end module m_fstr_eig_lanczos_util
128 
I/O and Utility.
Definition: hecmw_util_f.F90:7
integer(kind=kint), parameter hecmw_sum
integer(kind=4), parameter kreal
subroutine hecmw_finalize
Definition: hecmw.f90:6
subroutine lanczos_set_initial_value(hecMESH, hecMAT, fstrEIG, eigvec, p, q, beta)
Initialize Lanczos iterations.
subroutine evsort(EIG, NEW, NEIG)
Sort eigenvalues.
subroutine urand1(N, X, SHIFT)
This module defines common data and basic structures for analysis.
Definition: m_fstr.F90:15
Package of data used by Lanczos eigenvalue solver.
Definition: m_fstr.F90:623