FrontISTR  6.0.0
Large-scale structural analysis program with finit element method
fstr_freq_setup.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 !-------------------------------------------------------------------------------
11  use m_fstr
12  use hecmw_setup_util, only &
16  use fstr_setup_util, only &
17  : fstr_param_pack &
22  implicit none
23 
24 contains
25 
27  implicit none
28  type( fstr_freqanalysis ), intent(inout) :: f
29  if(associated(f%FLOAD_ngrp_GRPID)) deallocate(f%FLOAD_ngrp_GRPID)
30  if(associated(f%FLOAD_ngrp_ID)) deallocate(f%FLOAD_ngrp_ID)
31  if(associated(f%FLOAD_ngrp_TYPE)) deallocate(f%FLOAD_ngrp_TYPE)
32  if(associated(f%FLOAD_ngrp_DOF)) deallocate(f%FLOAD_ngrp_DOF)
33  if(associated(f%FLOAD_ngrp_valre)) deallocate(f%FLOAD_ngrp_valre)
34  if(associated(f%FLOAD_ngrp_valim)) deallocate(f%FLOAD_ngrp_valim)
35  if(associated(f%FACC_ngrp_ID)) deallocate(f%FACC_ngrp_ID)
36  if(associated(f%FACC_ngrp_type)) deallocate(f%FACC_ngrp_type)
37  if(associated(f%FACC_ngrp_valre)) deallocate(f%FACC_ngrp_valre)
38  if(associated(f%FACC_ngrp_valim)) deallocate(f%FACC_ngrp_valim)
39  end subroutine fstr_freqanalysis_finalize
40 
42  implicit none
43  type( fstr_freqanalysis_data ), intent(inout) :: f
44  if(associated(f%eigOmega)) deallocate(f%eigOmega)
45  if(associated(f%eigVector)) deallocate(f%eigVector)
46  end subroutine fstr_freqanalysis_data_finalize
47 
48  !-----------------------------------------------------------------------------!
50  !-----------------------------------------------------------------------------!
51  subroutine fstr_setup_fload( ctrl, P )
52  implicit none
53  !---- args
54  integer(kind=kint) :: ctrl
55  type(fstr_param_pack) :: P
56  !---- vals
57  integer(kind=kint) :: rcode
58  character(HECMW_NAME_LEN), pointer :: grp_id_name(:)
59  real(kind=kreal), pointer :: val_ptr(:)
60  integer(kind=kint), pointer :: id_ptr(:)
61  integer(kind=kint) :: n
62  integer(kind=kint) :: gid, loadcase
63  !---- body
64 
65  if( p%SOLID%file_type /= kbcffstr) return
66 
67  !read grpid
68  gid = 1
69  rcode = fstr_ctrl_get_param_ex( ctrl, 'GRPID ', '# ', 0, 'I', gid )
70  !read loadcase (real=1:default, img=2)
71  loadcase = kfloadcase_re
72  rcode = fstr_ctrl_get_param_ex( ctrl, 'LOAD CASE ', '# ', 0, 'I', loadcase)
73  !write(*,*) "loadcase=", loadcase
74  !pause
75 
76  !read the num of dataline
77  n = fstr_ctrl_get_data_line_n( ctrl )
78  if( n == 0 ) return
79 
80  !fill bc data
81  allocate( grp_id_name(n) )
82  allocate( id_ptr(n) )
83  allocate( val_ptr(n) )
84  id_ptr = 0
85  val_ptr = 0.0d0
86  rcode = fstr_ctrl_get_fload( ctrl, grp_id_name, hecmw_name_len, id_ptr, val_ptr)
87  if( rcode /= 0 ) call fstr_ctrl_err_stop
88  if(loadcase /= kfloadcase_re .and. loadcase /= kfloadcase_im) then
89  !error
90  write(*,*) "Error this load set is not defined!"
91  write(ilog,*) "Error this load set is not defined!"
92  stop hecmw_exit_model
93  end if
94  call fstr_freq_append_fload( p%MESH, p%FREQ, '!FLOAD', gid, loadcase, &
95  n, grp_id_name, id_ptr, val_ptr )
96 
97  deallocate( grp_id_name )
98  deallocate( id_ptr )
99  deallocate( val_ptr )
100  nullify( grp_id_name )
101  nullify( id_ptr )
102  nullify( val_ptr )
103  return
104 
105  contains
106 
107  function fstr_ctrl_get_fload(ctrl, node_id, node_id_len, dof_id, value)
108  integer(kind=kint) :: ctrl
109  character(len=HECMW_NAME_LEN) :: node_id(:) !Node group name
110  integer(kind=kint), pointer :: dof_id(:)
111  integer(kind=kint) :: node_id_len
112  real(kind=kreal), pointer :: value(:)
113  integer(kind=kint) :: fstr_ctrl_get_fload !return value
114  character(len=HECMW_NAME_LEN) :: data_fmt, ss
115 
116  write(ss,*) node_id_len
117  write(data_fmt, '(a,a,a)') 'S', trim(adjustl(ss)), 'IR '
118 
119  fstr_ctrl_get_fload = fstr_ctrl_get_data_array_ex(ctrl, data_fmt, node_id, dof_id, value)
120  end function
121 
122  end subroutine
123 
124  !-----------------------------------------------------------------------------!
126  !-----------------------------------------------------------------------------!
130  subroutine fstr_setup_facceleration( ctrl, P )
131  implicit none
132  !---- args
133  integer(kind=kint) :: ctrl
134  type(fstr_param_pack) :: P
135  !---- vals
136  integer(kind=kint) :: rcode
137  character(HECMW_NAME_LEN), pointer :: grp_id_name(:)
138  integer(kind=kint), pointer :: dof_ids(:)
139  integer(kind=kint), pointer :: dof_ide(:)
140  real(kind=kreal), pointer :: val_ptr(:)
141  integer(kind=kint) :: n
142  integer(kind=kint) :: loadcase
143  !---- body
144 
145  !only the FrontISTR format is supported
146  if( p%SOLID%file_type /= kbcffstr) return
147 
148  !read loadcase (real=1:default, img=2)
149  loadcase = kfloadcase_re
150  rcode = fstr_ctrl_get_param_ex( ctrl, 'LOAD CASE ', '# ', 0, 'I', loadcase)
151  if( loadcase /= kfloadcase_re .and. loadcase /= kfloadcase_im ) then
152  write(*,*) 'fstr control file error : !FACCELERATION : LOAD CASE must be 1 or 2'
153  write(ilog,*) 'fstr control file error : !FACCELERATION : LOAD CASE must be 1 or 2'
154  stop hecmw_exit_input
155  end if
156 
157  n = fstr_ctrl_get_data_line_n( ctrl )
158  if( n == 0 ) return
159 
160  !read the data lines into temporary arrays
161  allocate( grp_id_name(n) )
162  allocate( dof_ids(n) )
163  allocate( dof_ide(n) )
164  allocate( val_ptr(n) )
165  val_ptr = 0.0d0
166  rcode = fstr_ctrl_get_facceleration( ctrl, grp_id_name, hecmw_name_len, dof_ids, dof_ide, val_ptr )
167  if( rcode /= 0 ) call fstr_ctrl_err_stop
168  !append the data lines of this header to the entries read so far
169  call fstr_freq_append_facceleration( p%MESH, p%FREQ, '!FACCELERATION', loadcase, &
170  n, grp_id_name, dof_ids, dof_ide, val_ptr )
171 
172  deallocate( grp_id_name )
173  deallocate( dof_ids )
174  deallocate( dof_ide )
175  deallocate( val_ptr )
176  return
177 
178  contains
179 
180  !read all data lines in the format of NODE_ID, DOF_idS, DOF_idE, Value
181  function fstr_ctrl_get_facceleration(ctrl, node_id, node_id_len, dof_ids, dof_ide, value)
182  integer(kind=kint) :: ctrl
183  character(len=HECMW_NAME_LEN) :: node_id(:)
184  integer(kind=kint) :: node_id_len
185  integer(kind=kint), pointer :: dof_ids(:)
186  integer(kind=kint), pointer :: dof_ide(:)
187  real(kind=kreal), pointer :: value(:)
188  integer(kind=kint) :: fstr_ctrl_get_facceleration
189  character(len=HECMW_NAME_LEN) :: data_fmt, ss
190 
191  !format: string of node_id_len characters, two integers and a real
192  write(ss,*) node_id_len
193  write(data_fmt, '(a,a,a)') 'S', trim(adjustl(ss)), 'IIr '
194 
195  fstr_ctrl_get_facceleration = fstr_ctrl_get_data_array_ex(ctrl, data_fmt, node_id, dof_ids, dof_ide, value)
196  end function
197 
198  end subroutine
199 
200  !-----------------------------------------------------------------------------!
202  !-----------------------------------------------------------------------------!
203  subroutine fstr_setup_eigenread( ctrl, P )
204  !---- args
205  integer(kind=kint) :: ctrl
206  type(fstr_param_pack) :: P
207  !---- vals
208  integer(kind=kint) :: filename_len
209  character(len=HECMW_NAME_LEN) :: datafmt, ss
210  !---- body
211 
212  filename_len = hecmw_filename_len
213  write(ss,*) filename_len
214  write(datafmt, '(a,a,a)') 'F', trim(adjustl(ss)), ' '
215 
216  if( fstr_ctrl_get_data_ex( ctrl, 1, datafmt, p%FREQ%eigenlog_filename ) /= 0) return
217  if( fstr_ctrl_get_data_ex( ctrl, 2, 'ii ', p%FREQ%start_mode, p%FREQ%end_mode ) /= 0) return
218 
219  return
220 
221  end subroutine
222 
223  !-----------------------------------------------------------------------------!
225  !-----------------------------------------------------------------------------!
226  subroutine fstr_freq_append_fload( hecMESH, fstrFREQ, header_name, gid, loadcase, &
227  n, grp_names, dofs, vals )
228  implicit none
229  type(hecmwst_local_mesh), target :: hecMESH
230  type(fstr_freqanalysis) :: fstrFREQ
231  character(len=*), intent(in) :: header_name
232  integer(kind=kint), intent(in) :: gid
233  integer(kind=kint), intent(in) :: loadcase
234  integer(kind=kint), intent(in) :: n
235  character(len=HECMW_NAME_LEN), intent(in) :: grp_names(:)
236  integer(kind=kint), intent(in) :: dofs(:)
237  real(kind=kreal), intent(in) :: vals(:)
238 
239  integer(kind=kint) :: i, old_size, new_size
240 
241  if( n == 0 ) return
242  old_size = fstrfreq%FLOAD_ngrp_tot
243  new_size = old_size + n
244 
245  !expand data array
246  fstrfreq%FLOAD_ngrp_tot = new_size
247  call hecmw_expand_integer_array( fstrfreq%FLOAD_ngrp_GRPID, old_size, new_size )
248  call hecmw_expand_integer_array( fstrfreq%FLOAD_ngrp_ID, old_size, new_size )
249  call hecmw_expand_integer_array( fstrfreq%FLOAD_ngrp_TYPE, old_size, new_size )
250  call hecmw_expand_integer_array( fstrfreq%FLOAD_ngrp_DOF, old_size, new_size )
251  call hecmw_expand_real_array ( fstrfreq%FLOAD_ngrp_valre, old_size, new_size )
252  call hecmw_expand_real_array ( fstrfreq%FLOAD_ngrp_valim, old_size, new_size )
253 
254  !fill bc data
255  if(loadcase == kfloadcase_re) then
256  do i = 1, n
257  fstrfreq%FLOAD_ngrp_DOF(old_size+i) = dofs(i)
258  fstrfreq%FLOAD_ngrp_valre(old_size+i) = vals(i)
259  enddo
260  else if(loadcase == kfloadcase_im) then
261  do i = 1, n
262  fstrfreq%FLOAD_ngrp_DOF(old_size+i) = dofs(i)
263  fstrfreq%FLOAD_ngrp_valim(old_size+i) = vals(i)
264  enddo
265  end if
266  fstrfreq%FLOAD_ngrp_GRPID(old_size+1:new_size) = gid
267  call nodesurf_grp_name_to_id_ex( hecmesh, header_name, n, grp_names, &
268  fstrfreq%FLOAD_ngrp_ID(old_size+1:), fstrfreq%FLOAD_ngrp_TYPE(old_size+1:))
269 
270  end subroutine fstr_freq_append_fload
271 
272  !-----------------------------------------------------------------------------!
274  !-----------------------------------------------------------------------------!
275  subroutine fstr_freq_append_facceleration( hecMESH, fstrFREQ, header_name, loadcase, &
276  n, grp_names, dof_ids, dof_ide, vals )
277  implicit none
278  type(hecmwst_local_mesh), target :: hecMESH
279  type(fstr_freqanalysis) :: fstrFREQ
280  character(len=*), intent(in) :: header_name
281  integer(kind=kint), intent(in) :: loadcase
282  integer(kind=kint), intent(in) :: n
283  character(len=HECMW_NAME_LEN), intent(in) :: grp_names(:)
284  integer(kind=kint), intent(in) :: dof_ids(:)
285  integer(kind=kint), intent(in) :: dof_ide(:)
286  real(kind=kreal), intent(in) :: vals(:)
287 
288  integer(kind=kint) :: i, old_size, new_size
289 
290  if( n == 0 ) return
291  old_size = fstrfreq%FACC_ngrp_tot
292  new_size = old_size + n
293 
294  !the expanded part is zero, so the part not given by loadcase stays zero
295  fstrfreq%FACC_ngrp_tot = new_size
296  call hecmw_expand_integer_array( fstrfreq%FACC_ngrp_ID, old_size, new_size )
297  call hecmw_expand_integer_array( fstrfreq%FACC_ngrp_type, old_size, new_size )
298  call hecmw_expand_real_array ( fstrfreq%FACC_ngrp_valre, old_size, new_size )
299  call hecmw_expand_real_array ( fstrfreq%FACC_ngrp_valim, old_size, new_size )
300 
301  !node ID or node group name -> node group ID
302  call node_grp_name_to_id_ex( hecmesh, header_name, n, grp_names, fstrfreq%FACC_ngrp_ID(old_size+1:) )
303 
304  do i = 1, n
305  !check the range of the DOFs as !ACCELERATION does
306  if( (dof_ids(i) < 1).or.(6 < dof_ids(i)).or.(dof_ide(i) < dof_ids(i)).or.(6 < dof_ide(i)) ) then
307  call fstr_setup_util_err_stop( 'fstr control file error : '//header_name// &
308  ' : range of dof_ids and dof_ide is from 1 to 6' )
309  end if
310  !encode the DOF range as !ACCELERATION does
311  fstrfreq%FACC_ngrp_type(old_size+i) = 10 * dof_ids(i) + dof_ide(i)
312  !store the amplitude in the part selected by loadcase
313  if( loadcase == kfloadcase_re ) then
314  fstrfreq%FACC_ngrp_valre(old_size+i) = vals(i)
315  else
316  fstrfreq%FACC_ngrp_valim(old_size+i) = vals(i)
317  end if
318  end do
319 
320  end subroutine fstr_freq_append_facceleration
321 
322 end module m_fstr_freq_setup
int fstr_ctrl_get_param_ex(int *ctrl, const char *param_name, const char *value_list, int *necessity, char *type, void *val)
int fstr_ctrl_get_data_array_ex(int *ctrl, const char *format,...)
int fstr_ctrl_get_data_ex(int *ctrl, int *line_no, const char *format,...)
integer(kind=kint) function fstr_ctrl_get_fload(ctrl, node_id, node_id_len, dof_id, value)
integer(kind=kint) function fstr_ctrl_get_facceleration(ctrl, node_id, node_id_len, dof_ids, dof_ide, value)
This module contains auxiliary functions in calculation setup.
subroutine fstr_ctrl_err_stop
subroutine nodesurf_grp_name_to_id_ex(hecMESH, header_name, n, grp_id_name, grp_ID, grp_TYPE)
subroutine fstr_setup_util_err_stop(msg)
This module contains auxiliary functions in calculation setup.
subroutine hecmw_expand_integer_array(array, old_size, new_size)
subroutine node_grp_name_to_id_ex(hecMESH, header_name, n, grp_id_name, grp_ID)
subroutine hecmw_expand_real_array(array, old_size, new_size)
This module provides subroutines to read the cards of frequency response analysis into fstr_freqanaly...
subroutine fstr_setup_facceleration(ctrl, P)
Read in !FACCELERATION !
subroutine fstr_freq_append_facceleration(hecMESH, fstrFREQ, header_name, loadcase, n, grp_names, dof_ids, dof_ide, vals)
Append !FACCELERATION !
subroutine fstr_freqanalysis_data_finalize(f)
subroutine fstr_freq_append_fload(hecMESH, fstrFREQ, header_name, gid, loadcase, n, grp_names, dofs, vals)
Append !FLOAD !
subroutine fstr_setup_fload(ctrl, P)
Read in !FLOAD !
subroutine fstr_freqanalysis_finalize(f)
subroutine fstr_setup_eigenread(ctrl, P)
Read in !EIGENREAD !
This module defines common data and basic structures for analysis.
Definition: m_fstr.F90:15
integer(kind=kint), parameter kbcffstr
boundary condition file type (bcf)
Definition: m_fstr.F90:66
integer(kind=kint), parameter kfloadcase_im
Definition: m_fstr.F90:97
integer(kind=kint), parameter ilog
FILE HANDLER.
Definition: m_fstr.F90:118
integer(kind=kint), parameter kfloadcase_re
Definition: m_fstr.F90:96
Package of all data needs to initialize.