FrontISTR  6.0.0
Large-scale structural analysis program with finit element method
fstr_EIG_output.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 fstr_eigen_residual(hecMESH, hecMAT, fstrEIG)
11  use m_fstr
13  implicit none
14  type(hecmwst_local_mesh) :: hecMESH
15  type(hecmwst_matrix) :: hecMAT
16  type(fstr_eigen) :: fstrEIG
17 
18  integer(kind=kint) :: NNDOF, NPNDOF, i, j
19  real(kind=kreal) :: chk, shift
20  real(kind=kreal), allocatable :: t(:), u(:)
21 
22  nndof = hecmat%N *hecmat%NDOF
23  npndof = hecmat%NP*hecmat%NDOF
24 
25  allocate(fstreig%resid(fstreig%nget))
26  allocate(t(npndof))
27  allocate(u(npndof))
28 
29  ! the free-free case works on [K] + sigma [M], see lanczos_set_initial_value
30  shift = 0.0d0
31  if(fstreig%is_free) shift = fstreig%sigma
32 
33  do j = 1, fstreig%nget
34  u = 0.0d0
35  do i = 1, nndof
36  u(i) = fstreig%eigvec(i,j)
37  enddo
38  call hecmw_matvec(hecmesh, hecmat, u, t)
39 
40  chk = 0.0d0
41  do i = 1, nndof
42  chk = chk + (t(i) - (fstreig%eigval(j) + shift)*fstreig%mass(i)*u(i))**2
43  enddo
44  call hecmw_allreduce_r1(hecmesh, chk, hecmw_sum)
45  fstreig%resid(j) = dsqrt(chk)
46  enddo
47 
48  deallocate(t)
49  deallocate(u)
50  end subroutine fstr_eigen_residual
51 
52  subroutine fstr_eigen_output(hecMESH, hecMAT, fstrEIG)
53  use m_fstr
55  implicit none
56  type(hecmwst_local_mesh) :: hecmesh
57  type(hecmwst_matrix) :: hecMAT
58  type(fstr_eigen) :: fstrEIG
59 
60  integer(kind=kint) :: N, NDOF
61  integer(kind=kint) :: i, j, k, in, nget
62  real(kind=kreal) :: gm
63  real(kind=kreal), allocatable :: r(:)
64  real(kind=kreal), pointer :: mass(:), eigval(:), eigvec(:,:)
65 
66  n = hecmat%N
67  ndof = hecmesh%n_dof
68 
69  nget = fstreig%nget
70  mass => fstreig%mass
71  eigval => fstreig%eigval
72  eigvec => fstreig%eigvec
73 
74  allocate(fstreig%effmass(ndof*nget))
75  allocate(fstreig%partfactor(ndof*nget))
76  allocate(r(ndof))
77  fstreig%effmass = 0.0d0
78  fstreig%partfactor = 0.0d0
79 
80  do i = 1, nget
81  r = 0.0d0
82  gm = 0.0d0
83  do j = 1, n
84  do k = 1, ndof
85  in = ndof*(j-1) + k
86  r(k) = r(k) + mass(in)*eigvec(in,i)
87  gm = gm + mass(in)*eigvec(in,i)*eigvec(in,i)
88  enddo
89  enddo
90 
91  call hecmw_allreduce_r(hecmesh, r, ndof, hecmw_sum)
92  call hecmw_allreduce_r1(hecmesh, gm, hecmw_sum)
93 
94  gm = 1.0d0/gm
95  do j = 1, ndof
96  in = ndof*(i-1) + j
97  fstreig%partfactor(in) = gm*r(j)
98  fstreig%effmass(in) = gm*r(j)*r(j)
99  enddo
100  enddo
101 
102  call eglist(hecmesh, hecmat, fstreig)
103 
104  if(myrank == 0)then
105  write(imsg,*) ''
106  write(imsg,*) '*----------------------------------------------*'
107  write(imsg,*) '*--E I G E N V A L U E C O N V E R G E N C E--*'
108  write(imsg,*) 'Absolute residual = |(||Kx - lambda*Mx||)|'
109  write(imsg,*) ' Iter.# Eigenvalue Abs. Residual '
110  write(ilog,*) ' Iter.# Eigenvalue Abs. Residual '
111  write(imsg,*) ' *-----* *---------* *--------------*'
112  endif
113 
114  do j = 1, fstreig%nget
115  if(myrank == 0)then
116  write(imsg,'(2x,i5,2x,1p5e15.6)') j, eigval(j), fstreig%resid(j)
117  write(ilog,'(i5,1p5e12.4)') j, eigval(j), fstreig%resid(j)
118  endif
119  enddo
120 
121  if(myrank == 0)then
122  write(imsg,*)'* ---END Eigenvalue listing--- *'
123  endif
124 
125  deallocate(r)
126  end subroutine fstr_eigen_output
127 
128  subroutine fstr_eigen_make_result_step(hecMESH, fstrEIG, fstrRESULT, istep)
129  use m_fstr
131  use hecmw_util
132  implicit none
133  type(hecmwst_local_mesh) :: hecmesh
134  type(fstr_eigen) :: fstrEIG
135  type(hecmwst_result_data) :: fstrRESULT
136  integer(kind=kint) :: istep, i
137 
138  integer(kind=kint) :: NP, NDOF, NPNDOF
139  real(kind=kreal), pointer :: eigvec(:,:)
140  real(kind=kreal), allocatable :: x(:)
141 
142  np = hecmesh%n_node
143  ndof = hecmesh%n_dof
144  npndof = np * ndof
145 
146  eigvec => fstreig%eigvec
147  allocate(x(npndof))
148  x = 0.0d0
149 
150  do i=1,npndof
151  x(i) = eigvec(i,istep)
152  enddo
153  call hecmw_update_r(hecmesh, x, np, ndof)
154 
155  fstrresult%ng_component = 1
156  fstrresult%ne_component = 0
157  allocate(fstrresult%ng_dof(1))
158  allocate(fstrresult%global_label(1))
159  allocate(fstrresult%global_val_item(1))
160  fstrresult%ng_dof(1) = 1
161  fstrresult%global_label(1) = 'EIGENVALUE'
162  fstrresult%global_val_item(1) = fstreig%eigval(istep)
163 
164  if( ndof == 6 ) then
165  fstrresult%nn_component = 2
166  allocate(fstrresult%nn_dof(2))
167  allocate(fstrresult%node_label(2))
168  allocate(fstrresult%node_val_item(6*np))
169  fstrresult%nn_dof(1) = 3
170  fstrresult%nn_dof(2) = 3
171  fstrresult%node_label(1) = 'DISPLACEMENT'
172  fstrresult%node_label(2) = 'ROTATION'
173  do i = 1, np
174  fstrresult%node_val_item((i-1)*6+1:(i-1)*6+3) = x((i-1)*ndof+1:(i-1)*ndof+3)
175  fstrresult%node_val_item((i-1)*6+4:(i-1)*6+6) = x((i-1)*ndof+4:(i-1)*ndof+6)
176  enddo
177  else
178  fstrresult%nn_component = 1
179  allocate(fstrresult%nn_dof(1))
180  allocate(fstrresult%node_label(1))
181  allocate(fstrresult%node_val_item(ndof*np))
182  fstrresult%nn_dof(1) = ndof
183  fstrresult%node_label(1) = 'DISPLACEMENT'
184  fstrresult%node_val_item = x
185  endif
186 
187  deallocate(x)
188  end subroutine
189 
190  subroutine fstr_eigen_output_visual(hecMESH, fstrEIG, fstrRESULT)
191  use m_fstr
193  use hecmw_util
194  implicit none
195  type(hecmwst_local_mesh) :: hecmesh
196  type(fstr_eigen) :: fstrEIG
197  type(hecmwst_result_data) :: fstrRESULT
198  integer(kind=kint) :: istep, nget
199  nget = fstreig%nget
200  do istep = 1, nget
201  call hecmw_nullify_result_data(fstrresult)
202  call fstr_eigen_make_result_step(hecmesh, fstreig, fstrresult, istep)
203  call fstr2hecmw_mesh_conv(hecmesh)
204  call hecmw_visualize_init
205  call hecmw_visualize( hecmesh, fstrresult, istep )
206  call hecmw_visualize_finalize
207  call hecmw2fstr_mesh_conv(hecmesh)
208  call hecmw_result_free(fstrresult)
209  end do
210  end subroutine
211 
212  subroutine fstr_eigen_output_result(hecMESH, fstrEIG)
213  use m_fstr
215  use hecmw_util
216  implicit none
217  type(hecmwst_local_mesh) :: hecMESH
218  type(fstr_eigen) :: fstrEIG
219 
220  integer(kind=kint) :: NP, NDOF, NPNDOF, istep, nget, i
221  character(len=HECMW_HEADER_LEN) :: header
222  character(len=HECMW_MSG_LEN) :: comment
223  character(len=HECMW_NAME_LEN) :: label
224  character(len=HECMW_NAME_LEN) :: nameID
225 
226  real(kind=kreal), pointer :: eigvec(:,:)
227  real(kind=kreal), allocatable :: x(:), egval(:)
228  real(kind=kreal), allocatable :: disp3(:), rot3(:)
229 
230  nget = fstreig%nget
231  np = hecmesh%n_node
232  ndof = hecmesh%n_dof
233  npndof = np * ndof
234 
235  eigvec => fstreig%eigvec
236  allocate(x(npndof))
237  x = 0.0d0
238  allocate(egval(1))
239 
240  do istep = 1, nget
241  egval(1) = fstreig%eigval(istep)
242  do i=1,npndof
243  x(i) = eigvec(i,istep)
244  enddo
245  call hecmw_update_r(hecmesh, x, np, ndof)
246 
247  header = "*fstrresult"
248  comment = "eigen_result"
249  call hecmw_result_init(hecmesh,istep,header,comment)
250  label = "EIGENVALUE"
251  call hecmw_result_add(hecmw_result_dtype_global,1,label,egval)
252  if( ndof == 6 ) then
253  allocate(disp3(np*3))
254  allocate(rot3(np*3))
255  disp3 = 0.0d0
256  rot3 = 0.0d0
257  do i = 1, np
258  disp3((i-1)*3+1:(i-1)*3+3) = x((i-1)*ndof+1:(i-1)*ndof+3)
259  rot3((i-1)*3+1:(i-1)*3+3) = x((i-1)*ndof+4:(i-1)*ndof+6)
260  enddo
261  label = "DISPLACEMENT"
262  call hecmw_result_add(hecmw_result_dtype_node,3,label,disp3)
263  label = "ROTATION"
264  call hecmw_result_add(hecmw_result_dtype_node,3,label,rot3)
265  deallocate(disp3)
266  deallocate(rot3)
267  else
268  label = "DISPLACEMENT"
269  call hecmw_result_add(hecmw_result_dtype_node,ndof,label,x)
270  endif
271  nameid = "fstrRES"
272  call hecmw_result_write_by_name(nameid)
273  call hecmw_result_finalize
274  end do
275  deallocate(egval)
276  deallocate(x)
277  end subroutine
278 
280  subroutine eglist(hecMESH, hecMAT, fstrEIG)
281  use m_fstr
282  use hecmw_util
284  implicit none
285  type(hecmwst_local_mesh) :: hecmesh
286  type(hecmwst_matrix) :: hecMAT
287  type(fstr_eigen) :: fstrEIG
288 
289  integer(kind=kint) :: NDOF
290  integer(kind=kint) :: i, j, in, iter ,nget
291  real(kind=kreal) :: pi, angle, freq, pf(3), em(3)
292  real(kind=kreal), pointer :: eigval(:)
293 
294  ndof = hecmat%NDOF
295  nget = fstreig%nget
296  iter = fstreig%iter
297  pi = 4.0d0 * datan(1.0d0)
298  eigval => fstreig%eigval
299 
300  if(myrank == 0)then
301  write(ilog,*)""
302  write(ilog,"(a)")"********************************"
303  write(ilog,"(a)")"*RESULT OF EIGEN VALUE ANALYSIS*"
304  write(ilog,"(a)")"********************************"
305  write(ilog,"(a)")""
306  write(ilog,"(a,i8)")"NUMBER OF ITERATIONS = ",iter
307  write(ilog,"(a,1pe12.4)")"TOTAL MASS = ",fstreig%totalmass
308  write(ilog,"(a)")""
309  write(ilog,"(3a)")" ANGLE FREQUENCY ",&
310  "PARTICIPATION FACTOR EFFECTIVE MASS"
311  write(ilog,"(3a)")" NO. EIGENVALUE FREQUENCY (HZ) ",&
312  "X Y Z X Y Z"
313  write(ilog,"(3a)")" --- ---------- ---------- ---------- ",&
314  "---------- ---------- ---------- ---------- ---------- ----------"
315  write(*,*)""
316  write(*,"(a)")"#----------------------------------#"
317  write(*,"(a)")"# RESULT OF EIGEN VALUE ANALYSIS #"
318  write(*,"(a)")"#----------------------------------#"
319  write(*,"(a)")""
320  write(*,"(a,i8)")"### NUMBER OF ITERATIONS = ",iter
321  write(*,"(a,1pe12.4)")"### TOTAL MASS = ",fstreig%totalmass
322  write(*,"(a)")""
323  write(*,"(3a)")" PERIOD FREQUENCY ",&
324  "PARTICIPATION FACTOR EFFECTIVE MASS"
325  write(*,"(3a)")" NO. [Sec] [HZ] ",&
326  "X Y Z X Y Z"
327  write(*,"(3a)")" --- --------- --------- ",&
328  "--------- --------- --------- --------- --------- ---------"
329 
330  in = 0
331  do i = 1, nget
332  in = in + 1
333  if(eigval(i) < 0.0d0) eigval(i) = 0.0d0
334  angle = dsqrt(eigval(i))
335  freq = angle*0.5d0/pi
336 
337  pf = 0.0d0
338  em = 0.0d0
339  do j = 1, min(ndof, 3)
340  pf(j) = fstreig%partfactor(ndof*(i-1) + j)
341  em(j) = fstreig%effmass(ndof*(i-1) + j)
342  enddo
343 
344  write(ilog,'(I5,1P9E12.4)') in, eigval(i), angle, freq, pf(1), pf(2), pf(3), em(1), em(2), em(3)
345  write(* ,'(I5,1P8E11.3)') in, 1.0d0/freq, freq, pf(1), pf(2), pf(3), em(1), em(2), em(3)
346  enddo
347  write(ilog,*)""
348  write(*,*)""
349  endif
350 
351  end subroutine eglist
352 end module m_fstr_eig_output
353 
354 
subroutine, public hecmw_matvec(hecMESH, hecMAT, X, Y, COMMtime)
I/O and Utility.
Definition: hecmw_util_f.F90:7
integer(kind=4), parameter kreal
subroutine fstr_eigen_output(hecMESH, hecMAT, fstrEIG)
subroutine fstr_eigen_make_result_step(hecMESH, fstrEIG, fstrRESULT, istep)
subroutine fstr_eigen_residual(hecMESH, hecMAT, fstrEIG)
residual of the eigenproblem as solved, i.e. in the reduced space of the MPC elimination
subroutine fstr_eigen_output_result(hecMESH, fstrEIG)
subroutine eglist(hecMESH, hecMAT, fstrEIG)
Output eigenvalues and vectors.
subroutine fstr_eigen_output_visual(hecMESH, fstrEIG, fstrRESULT)
This module defines common data and basic structures for analysis.
Definition: m_fstr.F90:15
integer(kind=kint) myrank
PARALLEL EXECUTION.
Definition: m_fstr.F90:107
integer(kind=kint), parameter imsg
Definition: m_fstr.F90:121
integer(kind=kint), parameter ilog
FILE HANDLER.
Definition: m_fstr.F90:118
HECMW to FSTR Mesh Data Converter. Converting Connectivity of Element Type 232, 342 and 352.
subroutine fstr2hecmw_mesh_conv(hecMESH)
subroutine hecmw2fstr_mesh_conv(hecMESH)
Package of data used by Lanczos eigenvalue solver.
Definition: m_fstr.F90:623