FrontISTR  5.9.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 
9  subroutine fstr_eigen_output(hecMESH, hecMAT, fstrEIG)
10  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) :: N, NP, NDOF, NNDOF, NPNDOF
19  integer(kind=kint) :: i, j, k, in, jn, nget
20  real(kind=kreal) :: chk, gm
21  real(kind=kreal), allocatable :: s(:), t(:), u(:), r(:)
22  real(kind=kreal), pointer :: mass(:), eigval(:), eigvec(:,:)
23 
24  n = hecmat%N
25  np = hecmat%NP
26  ndof = hecmesh%n_dof
27  nndof = n *ndof
28  npndof = np*ndof
29 
30  nget = fstreig%nget
31  mass => fstreig%mass
32  eigval => fstreig%eigval
33  eigvec => fstreig%eigvec
34 
35  allocate(fstreig%effmass(ndof*nget))
36  allocate(fstreig%partfactor(ndof*nget))
37  allocate(s(npndof))
38  allocate(t(npndof))
39  allocate(u(npndof))
40  allocate(r(ndof))
41  fstreig%effmass = 0.0d0
42  fstreig%partfactor = 0.0d0
43 
44  do i = 1, nget
45  r = 0.0d0
46  gm = 0.0d0
47  do j = 1, n
48  do k = 1, ndof
49  in = ndof*(j-1) + k
50  r(k) = r(k) + mass(in)*eigvec(in,i)
51  gm = gm + mass(in)*eigvec(in,i)*eigvec(in,i)
52  enddo
53  enddo
54 
55  call hecmw_allreduce_r(hecmesh, r, ndof, hecmw_sum)
56  call hecmw_allreduce_r1(hecmesh, gm, hecmw_sum)
57 
58  gm = 1.0d0/gm
59  do j = 1, ndof
60  in = ndof*(i-1) + j
61  fstreig%partfactor(in) = gm*r(j)
62  fstreig%effmass(in) = gm*r(j)*r(j)
63  enddo
64  enddo
65 
66  call eglist(hecmesh, hecmat, fstreig)
67 
68  if(myrank == 0)then
69  write(imsg,*) ''
70  write(imsg,*) '*----------------------------------------------*'
71  write(imsg,*) '*--E I G E N V A L U E C O N V E R G E N C E--*'
72  write(imsg,*) 'Absolute residual = |(||Kx - lambda*Mx||)|'
73  write(imsg,*) ' Iter.# Eigenvalue Abs. Residual '
74  write(ilog,*) ' Iter.# Eigenvalue Abs. Residual '
75  write(imsg,*) ' *-----* *---------* *--------------*'
76  endif
77 
78  do j = 1, fstreig%nget
79  do i = 1, nndof
80  u(i) = eigvec(i,j)
81  enddo
82  call hecmw_matvec(hecmesh, hecmat, u, t)
83 
84  s = 0.0d0
85  do i = 1, nndof
86  s(i) = mass(i)*eigvec(i,j)
87  enddo
88 
89  chk = 0.0d0
90  do i = 1,nndof
91  chk = chk + (t(i) - (eigval(j)-fstreig%sigma)*s(i))**2
92  enddo
93  call hecmw_allreduce_r1(hecmesh, chk, hecmw_sum)
94  chk = dsqrt(chk)
95 
96  if(myrank == 0)then
97  write(imsg,'(2x,i5,2x,1p5e15.6)') j, eigval(j), chk
98  write(ilog,'(i5,1p5e12.4)') j, eigval(j), chk
99  endif
100  enddo
101 
102  if(myrank == 0)then
103  write(imsg,*)'* ---END Eigenvalue listing--- *'
104  endif
105 
106  deallocate(s)
107  deallocate(t)
108  deallocate(u)
109  deallocate(r)
110  end subroutine fstr_eigen_output
111 
112  subroutine fstr_eigen_make_result(hecMESH, hecMAT, fstrEIG, fstrRESULT)
113  use m_fstr
115  use hecmw_util
116  implicit none
117  type(hecmwst_local_mesh) :: hecmesh
118  type(hecmwst_matrix) :: hecMAT
119  type(fstr_eigen) :: fstrEIG
120  type(hecmwst_result_data) :: fstrRESULT
121 
122  integer(kind=kint) :: i, istep, nget, NP, NDOF, NPNDOF, totalmpc, MPC_METHOD
123  real(kind=kreal) :: t1
124  real(kind=kreal), pointer :: eigvec(:,:)
125  real(kind=kreal), allocatable :: x(:), egval(:)
126  real(kind=kreal), allocatable :: disp3(:), rot3(:)
127  character(len=HECMW_HEADER_LEN) :: header
128  character(len=HECMW_MSG_LEN) :: comment
129  character(len=HECMW_NAME_LEN) :: label
130  character(len=HECMW_NAME_LEN) :: nameID
131 
132  nget = fstreig%nget
133  np = hecmat%NP
134  ndof = hecmat%NDOF
135  npndof = hecmat%NP*hecmat%NDOF
136  !totalmpc = hecMESH%mpc%n_mpc
137  !call hecmw_allreduce_I1 (hecMESH, totalmpc, hecmw_sum)
138 
139  eigvec => fstreig%eigvec
140 
141  allocate(x(npndof))
142  x = 0.0d0
143  allocate(egval(1))
144 
145  do istep = 1, nget
146  egval(1) = fstreig%eigval(istep)
147  do i=1,npndof
148  x(i) = eigvec(i,istep)
149  enddo
150 
151  !if (totalmpc > 0) then
152  ! MPC_METHOD = hecmw_mat_get_mpc_method(hecMAT)
153  ! if (MPC_METHOD < 1 .or. 3 < MPC_METHOD) MPC_METHOD = 3
154  ! if (MPC_METHOD == 3) then ! elimination
155  ! call hecmw_tback_x_33(hecMESH, X, t1)
156  ! else
157  ! if (hecMESH%my_rank.eq.0) write(0,*) "### ERROR: MPC_METHOD must set to 3"
158  ! stop
159  ! endif
160  !endif
161 
162  call hecmw_update_r(hecmesh, x, hecmat%NP, ndof)
163 
164  ! For 6-DOF elements (e.g. shells 731/741), the eigenvector holds 3
165  ! translational + 3 rotational components per node. Writing all 6 as
166  ! DISPLACEMENT makes VTK/ParaView interpret it as a symmetric tensor
167  ! (NumberOfComponents=6), breaking Warp By Vector. Mirror the static
168  ! solver (make_result.f90, ndof==6) and split DISPLACEMENT (1:3) from
169  ! ROTATION (4:6). Other NDOF (e.g. solid 3) keep the pass-through.
170  if( ndof == 6 ) then
171  allocate(disp3(np*3))
172  allocate(rot3(np*3))
173  disp3 = 0.0d0
174  rot3 = 0.0d0
175  do i = 1, np
176  disp3((i-1)*3+1:(i-1)*3+3) = x((i-1)*ndof+1:(i-1)*ndof+3)
177  rot3((i-1)*3+1:(i-1)*3+3) = x((i-1)*ndof+4:(i-1)*ndof+6)
178  enddo
179  endif
180 
181  if( iresult.eq.1 ) then
182  header = "*fstrresult"
183  comment = "eigen_result"
184  call hecmw_result_init(hecmesh,istep,header,comment)
185  label = "EIGENVALUE"
186  call hecmw_result_add(hecmw_result_dtype_global,1,label,egval)
187  if( ndof == 6 ) then
188  label = "DISPLACEMENT"
189  call hecmw_result_add(hecmw_result_dtype_node,3,label,disp3)
190  label = "ROTATION"
191  call hecmw_result_add(hecmw_result_dtype_node,3,label,rot3)
192  else
193  label = "DISPLACEMENT"
194  call hecmw_result_add(hecmw_result_dtype_node,ndof,label,x)
195  endif
196  nameid = "fstrRES"
197  call hecmw_result_write_by_name(nameid)
198  call hecmw_result_finalize
199  endif
200 
201  if( ivisual.eq.1 ) then
202  call hecmw_nullify_result_data(fstrresult)
203  fstrresult%ng_component = 1
204  fstrresult%ne_component = 0
205  allocate(fstrresult%ng_dof(1))
206  allocate(fstrresult%global_label(1))
207  allocate(fstrresult%global_val_item(1))
208  fstrresult%ng_dof(1) = 1
209  fstrresult%global_label(1) = 'EIGENVALUE'
210  fstrresult%global_val_item(1) = egval(1)
211  if( ndof == 6 ) then
212  fstrresult%nn_component = 2
213  allocate(fstrresult%nn_dof(2))
214  allocate(fstrresult%node_label(2))
215  allocate(fstrresult%node_val_item(6*np))
216  fstrresult%nn_dof(1) = 3
217  fstrresult%nn_dof(2) = 3
218  fstrresult%node_label(1) = 'DISPLACEMENT'
219  fstrresult%node_label(2) = 'ROTATION'
220  do i = 1, np
221  fstrresult%node_val_item((i-1)*6+1:(i-1)*6+3) = disp3((i-1)*3+1:(i-1)*3+3)
222  fstrresult%node_val_item((i-1)*6+4:(i-1)*6+6) = rot3((i-1)*3+1:(i-1)*3+3)
223  enddo
224  else
225  fstrresult%nn_component = 1
226  allocate(fstrresult%nn_dof(1))
227  allocate(fstrresult%node_label(1))
228  allocate(fstrresult%node_val_item(ndof*np))
229  fstrresult%nn_dof(1) = ndof
230  fstrresult%node_label(1) = 'DISPLACEMENT'
231  fstrresult%node_val_item = x
232  endif
233  call fstr2hecmw_mesh_conv(hecmesh)
234  call hecmw_visualize_init
235  call hecmw_visualize( hecmesh, fstrresult, istep )
236  call hecmw_visualize_finalize
237  call hecmw2fstr_mesh_conv(hecmesh)
238  call hecmw_result_free(fstrresult)
239  endif
240 
241  if( ndof == 6 ) then
242  deallocate(disp3)
243  deallocate(rot3)
244  endif
245  enddo
246 
247  deallocate(x)
248 
249  end subroutine fstr_eigen_make_result
250 
252  subroutine eglist(hecMESH, hecMAT, fstrEIG)
253  use m_fstr
254  use hecmw_util
256  implicit none
257  type(hecmwst_local_mesh) :: hecMESH
258  type(hecmwst_matrix) :: hecMAT
259  type(fstr_eigen) :: fstrEIG
260 
261  integer(kind=kint) :: NDOF
262  integer(kind=kint) :: i, j, in, iter ,nget
263  real(kind=kreal) :: pi, angle, freq, pf(3), em(3)
264  real(kind=kreal), pointer :: eigval(:)
265 
266  ndof = hecmat%NDOF
267  nget = fstreig%nget
268  iter = fstreig%iter
269  pi = 4.0d0 * datan(1.0d0)
270  eigval => fstreig%eigval
271 
272  if(myrank == 0)then
273  write(ilog,*)""
274  write(ilog,"(a)")"********************************"
275  write(ilog,"(a)")"*RESULT OF EIGEN VALUE ANALYSIS*"
276  write(ilog,"(a)")"********************************"
277  write(ilog,"(a)")""
278  write(ilog,"(a,i8)")"NUMBER OF ITERATIONS = ",iter
279  write(ilog,"(a,1pe12.4)")"TOTAL MASS = ",fstreig%totalmass
280  write(ilog,"(a)")""
281  write(ilog,"(3a)")" ANGLE FREQUENCY ",&
282  "PARTICIPATION FACTOR EFFECTIVE MASS"
283  write(ilog,"(3a)")" NO. EIGENVALUE FREQUENCY (HZ) ",&
284  "X Y Z X Y Z"
285  write(ilog,"(3a)")" --- ---------- ---------- ---------- ",&
286  "---------- ---------- ---------- ---------- ---------- ----------"
287  write(*,*)""
288  write(*,"(a)")"#----------------------------------#"
289  write(*,"(a)")"# RESULT OF EIGEN VALUE ANALYSIS #"
290  write(*,"(a)")"#----------------------------------#"
291  write(*,"(a)")""
292  write(*,"(a,i8)")"### NUMBER OF ITERATIONS = ",iter
293  write(*,"(a,1pe12.4)")"### TOTAL MASS = ",fstreig%totalmass
294  write(*,"(a)")""
295  write(*,"(3a)")" PERIOD FREQUENCY ",&
296  "PARTICIPATION FACTOR EFFECTIVE MASS"
297  write(*,"(3a)")" NO. [Sec] [HZ] ",&
298  "X Y Z X Y Z"
299  write(*,"(3a)")" --- --------- --------- ",&
300  "--------- --------- --------- --------- --------- ---------"
301 
302  in = 0
303  do i = 1, nget
304  in = in + 1
305  if(eigval(i) < 0.0d0) eigval(i) = 0.0d0
306  angle = dsqrt(eigval(i))
307  freq = angle*0.5d0/pi
308 
309  pf = 0.0d0
310  em = 0.0d0
311  do j = 1, min(ndof, 3)
312  pf(j) = fstreig%partfactor(ndof*(i-1) + j)
313  em(j) = fstreig%effmass(ndof*(i-1) + j)
314  enddo
315 
316  write(ilog,'(I5,1P9E12.4)') in, eigval(i), angle, freq, pf(1), pf(2), pf(3), em(1), em(2), em(3)
317  write(* ,'(I5,1P8E11.3)') in, 1.0d0/freq, freq, pf(1), pf(2), pf(3), em(1), em(2), em(3)
318  enddo
319  write(ilog,*)""
320  write(*,*)""
321  endif
322 
323  end subroutine eglist
324 end module m_fstr_eig_output
325 
326 
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_make_result(hecMESH, hecMAT, fstrEIG, fstrRESULT)
subroutine fstr_eigen_output(hecMESH, hecMAT, fstrEIG)
subroutine eglist(hecMESH, hecMAT, fstrEIG)
Output eigenvalues and vectors.
This module defines common data and basic structures for analysis.
Definition: m_fstr.F90:15
integer(kind=kint), pointer iresult
Definition: m_fstr.F90:125
integer(kind=kint) myrank
PARALLEL EXECUTION.
Definition: m_fstr.F90:99
integer(kind=kint), parameter imsg
Definition: m_fstr.F90:113
integer(kind=kint), parameter ilog
FILE HANDLER.
Definition: m_fstr.F90:110
integer(kind=kint), pointer ivisual
Definition: m_fstr.F90:126
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