FrontISTR  5.9.0
Large-scale structural analysis program with finit element method
fstr_Restart.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 
9  use m_utilities
10  use m_fstr
11  use mmechgauss, only: tgaussstatus
12  use hecmw, only: hecmw_abort, hecmw_comm_get_comm
13  implicit none
14 
15 contains
16 
18  subroutine fstr_restart_abort(message)
19  character(len=*), intent(in) :: message
20 
21  if( myrank == 0 ) write(*,*) 'ERROR: ', trim(message)
22  call hecmw_abort(hecmw_comm_get_comm())
23  end subroutine fstr_restart_abort
24 
26  subroutine fstr_validate_shell_nodal_state(fstrSOLID, nnode)
27  type(fstr_solid), intent(in) :: fstrSOLID
28  integer(kind=kint), intent(in) :: nnode
29 
30  if( .not. associated(fstrsolid%shell_node_mode) ) then
31  call fstr_restart_abort('shell_node_mode is not allocated.')
32  else if( size(fstrsolid%shell_node_mode) /= nnode ) then
33  call fstr_restart_abort('shell_node_mode size does not match the mesh.')
34  endif
35  if( .not. associated(fstrsolid%shell_rot_state) ) then
36  call fstr_restart_abort('shell_rot_state is not allocated.')
37  else if( size(fstrsolid%shell_rot_state) /= nnode ) then
38  call fstr_restart_abort('shell_rot_state size does not match the mesh.')
39  endif
40  if( .not. associated(fstrsolid%shell_ref_triad) ) then
41  call fstr_restart_abort('shell_ref_triad is not allocated.')
42  else if( size(fstrsolid%shell_ref_triad) /= 9*nnode ) then
43  call fstr_restart_abort('shell_ref_triad size does not match the mesh.')
44  endif
45  if( .not. associated(fstrsolid%shell_triad) ) then
46  call fstr_restart_abort('shell_triad is not allocated.')
47  else if( size(fstrsolid%shell_triad) /= 9*nnode ) then
48  call fstr_restart_abort('shell_triad size does not match the mesh.')
49  endif
50  if( .not. associated(fstrsolid%shell_triad_bak) ) then
51  call fstr_restart_abort('shell_triad_bak is not allocated.')
52  else if( size(fstrsolid%shell_triad_bak) /= 9*nnode ) then
53  call fstr_restart_abort('shell_triad_bak size does not match the mesh.')
54  endif
55  if( .not. associated(fstrsolid%shell_dtriad) ) then
56  call fstr_restart_abort('shell_dtriad is not allocated.')
57  else if( size(fstrsolid%shell_dtriad) /= 9*nnode ) then
58  call fstr_restart_abort('shell_dtriad size does not match the mesh.')
59  endif
60  if( .not. associated(fstrsolid%shell_drill) ) then
61  call fstr_restart_abort('shell_drill is not allocated.')
62  else if( size(fstrsolid%shell_drill) /= nnode ) then
63  call fstr_restart_abort('shell_drill size does not match the mesh.')
64  endif
65  if( .not. associated(fstrsolid%shell_drill_bak) ) then
66  call fstr_restart_abort('shell_drill_bak is not allocated.')
67  else if( size(fstrsolid%shell_drill_bak) /= nnode ) then
68  call fstr_restart_abort('shell_drill_bak size does not match the mesh.')
69  endif
70  if( .not. associated(fstrsolid%shell_ddrill) ) then
71  call fstr_restart_abort('shell_ddrill is not allocated.')
72  else if( size(fstrsolid%shell_ddrill) /= nnode ) then
73  call fstr_restart_abort('shell_ddrill size does not match the mesh.')
74  endif
75  end subroutine fstr_validate_shell_nodal_state
76 
78  logical function fstr_requires_shell_restart_v6(fstrSOLID)
79  type(fstr_solid), intent(in) :: fstrsolid
80  integer :: i
81 
82  fstr_requires_shell_restart_v6 = fstrsolid%has_finite_rotation_kinematics
84  if( .not. associated(fstrsolid%elements) ) return
85  do i = 1, size(fstrsolid%elements)
86  if( associated(fstrsolid%elements(i)%shell_layer_gausses) ) then
88  return
89  endif
90  end do
92 
94  subroutine fstr_require_shell_restart_version(fstrSOLID, restart_version)
95  type(fstr_solid), intent(in) :: fstrSOLID
96  integer(kind=kint), intent(in) :: restart_version
97 
98  if( restart_version >= 6 ) return
99  if( .not. fstr_requires_shell_restart_v6(fstrsolid) ) return
100  call fstr_restart_abort( &
101  'restart VERSION >= 6 is required for finite-rotation or layered shell state.')
103 
106  type(tgaussstatus), intent(in) :: gauss
107  integer(kind=kint) :: nif(2)
108  real(kind=kreal) :: scalars(4)
109 
110  nif = 0
111  if( associated(gauss%istatus) ) nif(1) = size(gauss%istatus)
112  if( associated(gauss%fstatus) ) nif(2) = size(gauss%fstatus)
113  scalars = (/ gauss%plstrain, gauss%strain_energy, gauss%strain_energy_bak, gauss%plpotential /)
114  call hecmw_restart_add_int(nif, size(nif))
115  call hecmw_restart_add_real(gauss%strain, size(gauss%strain))
116  call hecmw_restart_add_real(gauss%strain_bak, size(gauss%strain_bak))
117  call hecmw_restart_add_real(gauss%stress, size(gauss%stress))
118  call hecmw_restart_add_real(gauss%stress_bak, size(gauss%stress_bak))
119  call hecmw_restart_add_real(gauss%nqm, size(gauss%nqm))
120  call hecmw_restart_add_real(gauss%strain_out, size(gauss%strain_out))
121  call hecmw_restart_add_real(gauss%stress_out, size(gauss%stress_out))
122  call hecmw_restart_add_real(scalars, size(scalars))
123  if( nif(1) > 0 ) call hecmw_restart_add_int(gauss%istatus, nif(1))
124  if( nif(2) > 0 ) call hecmw_restart_add_real(gauss%fstatus, nif(2))
125  end subroutine fstr_write_restart_shell_gauss
126 
129  type(tgaussstatus), intent(inout) :: gauss
130  integer(kind=kint) :: nif(2), current_nif(2)
131  real(kind=kreal) :: scalars(4)
132 
133  call hecmw_restart_read_int(nif)
134  current_nif = 0
135  if( associated(gauss%istatus) ) current_nif(1) = size(gauss%istatus)
136  if( associated(gauss%fstatus) ) current_nif(2) = size(gauss%fstatus)
137  if( any(current_nif /= nif) ) then
138  call fstr_restart_abort('shell material-state dimensions do not match the restart file.')
139  endif
140  call hecmw_restart_read_real(gauss%strain)
141  call hecmw_restart_read_real(gauss%strain_bak)
142  call hecmw_restart_read_real(gauss%stress)
143  call hecmw_restart_read_real(gauss%stress_bak)
144  call hecmw_restart_read_real(gauss%nqm)
145  call hecmw_restart_read_real(gauss%strain_out)
146  call hecmw_restart_read_real(gauss%stress_out)
147  call hecmw_restart_read_real(scalars)
148  gauss%plstrain = scalars(1)
149  gauss%strain_energy = scalars(2)
150  gauss%strain_energy_bak = scalars(3)
151  gauss%plpotential = scalars(4)
152  if( nif(1) > 0 ) call hecmw_restart_read_int(gauss%istatus)
153  if( nif(2) > 0 ) call hecmw_restart_read_real(gauss%fstatus)
154  end subroutine fstr_read_restart_shell_gauss
155 
157  subroutine fstr_write_restart_shell_state(hecMESH, fstrSOLID)
158  type(hecmwst_local_mesh), intent(in) :: hecmesh
159  type(fstr_solid), intent(in) :: fstrSOLID
160  integer(kind=kint) :: nodal_meta(2), layer_meta(3)
161  integer :: i, j
162 
163  nodal_meta = 0
164  if( fstrsolid%has_finite_rotation_kinematics ) then
165  call fstr_validate_shell_nodal_state(fstrsolid, int(hecmesh%n_node, kind=kint))
166  nodal_meta = (/ 1_kint, int(hecmesh%n_node, kind=kint) /)
167  endif
168  call hecmw_restart_add_int(nodal_meta, size(nodal_meta))
169  if( nodal_meta(1) == 1 ) then
170  call hecmw_restart_add_int(fstrsolid%shell_node_mode, size(fstrsolid%shell_node_mode))
171  call hecmw_restart_add_int(fstrsolid%shell_rot_state, size(fstrsolid%shell_rot_state))
172  call hecmw_restart_add_real(fstrsolid%shell_ref_triad, size(fstrsolid%shell_ref_triad))
173  call hecmw_restart_add_real(fstrsolid%shell_triad, size(fstrsolid%shell_triad))
174  call hecmw_restart_add_real(fstrsolid%shell_triad_bak, size(fstrsolid%shell_triad_bak))
175  call hecmw_restart_add_real(fstrsolid%shell_drill, size(fstrsolid%shell_drill))
176  call hecmw_restart_add_real(fstrsolid%shell_drill_bak, size(fstrsolid%shell_drill_bak))
177  endif
178 
179  do i = 1, hecmesh%n_elem
180  layer_meta = 0
181  if( associated(fstrsolid%elements(i)%shell_layer_gausses) ) then
182  layer_meta(1) = fstrsolid%elements(i)%shell_nlayer
183  layer_meta(2) = fstrsolid%elements(i)%shell_nthick
184  layer_meta(3) = size(fstrsolid%elements(i)%shell_layer_gausses)
185  endif
186  call hecmw_restart_add_int(layer_meta, size(layer_meta))
187  do j = 1, layer_meta(3)
188  call fstr_write_restart_shell_gauss(fstrsolid%elements(i)%shell_layer_gausses(j))
189  enddo
190  enddo
191  end subroutine fstr_write_restart_shell_state
192 
194  subroutine fstr_read_restart_shell_state(hecMESH, fstrSOLID)
195  type(hecmwst_local_mesh), intent(in) :: hecMESH
196  type(fstr_solid), intent(inout) :: fstrSOLID
197  integer(kind=kint) :: nodal_meta(2), layer_meta(3)
198  integer :: i, j
199 
200  call hecmw_restart_read_int(nodal_meta)
201  if( nodal_meta(1) == 1 ) then
202  if( .not. fstrsolid%has_finite_rotation_kinematics ) then
203  call fstr_restart_abort('restart contains finite-rotation shell state for an incompatible model.')
204  endif
205  if( nodal_meta(2) /= hecmesh%n_node ) then
206  call fstr_restart_abort('finite-rotation shell restart node count does not match the mesh.')
207  endif
208  call fstr_validate_shell_nodal_state(fstrsolid, int(hecmesh%n_node, kind=kint))
209  call hecmw_restart_read_int(fstrsolid%shell_node_mode)
210  call hecmw_restart_read_int(fstrsolid%shell_rot_state)
211  call hecmw_restart_read_real(fstrsolid%shell_ref_triad)
212  call hecmw_restart_read_real(fstrsolid%shell_triad)
213  call hecmw_restart_read_real(fstrsolid%shell_triad_bak)
214  call hecmw_restart_read_real(fstrsolid%shell_drill)
215  call hecmw_restart_read_real(fstrsolid%shell_drill_bak)
216  fstrsolid%shell_dtriad = fstrsolid%shell_triad
217  fstrsolid%shell_ddrill = fstrsolid%shell_drill
218  fstrsolid%finite_rotation_state_ready = .true.
219  else if( fstrsolid%has_finite_rotation_kinematics ) then
220  call fstr_restart_abort('restart file has no finite-rotation shell nodal state.')
221  endif
222 
223  do i = 1, hecmesh%n_elem
224  call hecmw_restart_read_int(layer_meta)
225  if( layer_meta(3) > 0 ) then
226  if( .not. associated(fstrsolid%elements(i)%shell_layer_gausses) ) then
227  call fstr_restart_abort( &
228  'restart contains shell layer state for an unallocated element.')
229  endif
230  if( layer_meta(1) /= fstrsolid%elements(i)%shell_nlayer .or. &
231  layer_meta(2) /= fstrsolid%elements(i)%shell_nthick .or. &
232  layer_meta(3) /= size(fstrsolid%elements(i)%shell_layer_gausses) ) then
233  call fstr_restart_abort( &
234  'shell layer restart dimensions do not match the current model.')
235  endif
236  else if( associated(fstrsolid%elements(i)%shell_layer_gausses) ) then
237  call fstr_restart_abort( &
238  'restart file has no shell layer state required by the current model.')
239  endif
240  do j = 1, layer_meta(3)
241  call fstr_read_restart_shell_gauss(fstrsolid%elements(i)%shell_layer_gausses(j))
242  enddo
243  enddo
244  end subroutine fstr_read_restart_shell_state
245 
247  !----------------------------------------------------------------------*
248  subroutine fstr_read_restart(cstep,substep,step_count,ctime,dtime,hecMESH,fstrSOLID,fstrPARAM,contactNode)
249  !----------------------------------------------------------------------*
250  integer, intent(out) :: cstep
251  integer, intent(out) :: substep
252  integer, intent(out) :: step_count
253  real(kind=kreal), intent(out) :: ctime
254  real(kind=kreal), intent(out) :: dtime
255  integer, intent(out) :: contactNode
256  type (hecmwST_local_mesh), intent(in) :: hecMESH
257  type (fstr_solid),intent(inout) :: fstrSOLID
258  type(fstr_param), intent(in) :: fstrPARAM
259 
260  integer :: i,j,restrt_step(3),nif(2),istat(1),nload_prev(1),naux(2)
261  real(kind=kreal) :: times(3)
262 
263  call hecmw_restart_open()
264 
265  call hecmw_restart_read_int(restrt_step)
266  if( fstrparam%restart_version >= 5 ) then
267  if( myrank == 0 ) write(*,*) 'Reading restart file as new format(>=ver5.0)'
268  call hecmw_restart_read_real(times)
269  call hecmw_restart_read_int(fstrsolid%NRstat_i)
270  call hecmw_restart_read_real(fstrsolid%NRstat_r)
271  call hecmw_restart_read_int(istat)
272  else
273  if( myrank == 0 ) write(*,*) 'Reading restart file as old format(<ver5.0)'
274  endif
275  call hecmw_restart_read_int(nload_prev) !load info at previous step
276  if( nload_prev(1)>0 ) then
277  allocate(fstrsolid%step_ctrl_restart%Load(nload_prev(1)))
278  call hecmw_restart_read_int(fstrsolid%step_ctrl_restart%Load)
279  endif
280 
281  call hecmw_restart_read_real(fstrsolid%unode)
282  call hecmw_restart_read_real(fstrsolid%unode_bak)
283  call hecmw_restart_read_real(fstrsolid%QFORCE)
284  call fstr_require_shell_restart_version(fstrsolid, fstrparam%restart_version)
285  if( fstrparam%restart_version >= 6 ) call fstr_read_restart_shell_state(hecmesh, fstrsolid)
286 
287  do i= 1, hecmesh%n_elem
288  if (hecmw_is_etype_link( fstrsolid%elements(i)%etype )) cycle
289  if (hecmw_is_etype_patch( fstrsolid%elements(i)%etype )) cycle
290  do j= 1, size(fstrsolid%elements(i)%gausses)
291  call hecmw_restart_read_int(nif)
292  call hecmw_restart_read_real(fstrsolid%elements(i)%gausses(j)%strain)
293  call hecmw_restart_read_real(fstrsolid%elements(i)%gausses(j)%strain_bak)
294  call hecmw_restart_read_real(fstrsolid%elements(i)%gausses(j)%stress)
295  call hecmw_restart_read_real(fstrsolid%elements(i)%gausses(j)%stress_bak)
296  if( nif(1)>0 ) call hecmw_restart_read_int(fstrsolid%elements(i)%gausses(j)%istatus)
297  if( nif(2)>0 ) call hecmw_restart_read_real(fstrsolid%elements(i)%gausses(j)%fstatus)
298  enddo
299  call hecmw_restart_read_int(naux)
300  do j= 1, naux(2)
301  call hecmw_restart_read_real(fstrsolid%elements(i)%aux(:,j))
302  enddo
303  enddo
304 
305  if( associated( fstrsolid%contacts ) ) then
306  call hecmw_restart_read_int(nif)
307  contactnode = nif(1)
308  do i= 1, fstrsolid%n_contacts
309  do j= 1, size(fstrsolid%contacts(i)%slave)
310  call hecmw_restart_read_int(nif)
311  fstrsolid%contacts(i)%states(j)%surface = nif(1)
312  fstrsolid%contacts(i)%states(j)%state = nif(2)
313  call hecmw_restart_read_real(fstrsolid%contacts(i)%states(j)%lpos)
314  call hecmw_restart_read_real(fstrsolid%contacts(i)%states(j)%direction)
315  call hecmw_restart_read_real(fstrsolid%contacts(i)%states(j)%multiplier)
316  call hecmw_restart_read_real(fstrsolid%contacts(i)%states(j)%tangentForce_trial)
317  call hecmw_restart_read_real(fstrsolid%contacts(i)%states(j)%tangentForce_final)
318  fstrsolid%contacts(i)%states(j)%tangentForce(1:3) = fstrsolid%contacts(i)%states(j)%tangentForce_final(1:3)
319  fstrsolid%contacts(i)%states(j)%tangentForce1(1:3) = fstrsolid%contacts(i)%states(j)%tangentForce_final(1:3)
320  enddo
321  enddo
322  endif
323 
324  call hecmw_restart_close()
325 
326  cstep = restrt_step(1)
327  substep = restrt_step(2) + 1
328  step_count = restrt_step(3)
329  if( fstrparam%restart_version >= 5 ) then
330  ctime = times(1)
331  dtime = times(2)
332  fstrsolid%AutoINC_stat = istat(1)
333  if( dabs(times(1)-times(3)) < 1.d-10 ) then
334  cstep = cstep + 1
335  substep = 1
336  endif
337  do i=1,size(fstrsolid%step_ctrl) !shift start time
338  fstrsolid%step_ctrl(i)%starttime = fstrsolid%step_ctrl(i)%starttime + times(3)
339  end do
340  else
341  ctime = fstrsolid%step_ctrl(cstep)%starttime
342  ctime = ctime + dble(substep-1)*fstrsolid%step_ctrl(cstep)%initdt
343  dtime = fstrsolid%step_ctrl(cstep)%initdt
344  if( dabs(ctime-fstrsolid%step_ctrl(cstep)%starttime-fstrsolid%step_ctrl(cstep)%elapsetime) < 1.d-10 ) then
345  cstep = cstep + 1
346  substep = 1
347  endif
348  endif
349 
350  end subroutine fstr_read_restart
351 
353  !----------------------------------------------------------------------*
354  subroutine fstr_write_restart(cstep,cstep_ext,substep,step_count,ctime,dtime,hecMESH, &
355  & fstrSOLID,fstrPARAM,is_StepFinished,contactNode)
356  !----------------------------------------------------------------------*
357  integer, intent(in) :: cstep
358  integer, intent(in) :: cstep_ext
359  integer, intent(in) :: substep
360  integer, intent(in) :: step_count
361  real(kind=kreal), intent(in) :: ctime
362  real(kind=kreal), intent(in) :: dtime
363  logical, intent(in) :: is_StepFinished
364  integer, intent(in) :: contactNode
365  type (hecmwST_local_mesh), intent(in) :: hecMESH
366  type (fstr_solid), intent(in) :: fstrSOLID
367  type(fstr_param), intent(in) :: fstrPARAM
368 
369  integer :: i,j,restrt_step(3),nif(2),istat(1),nload_prev(1),naux(2)
370  real(kind=kreal) :: times(3)
371 
372  restrt_step(1) = cstep_ext
373  restrt_step(2) = substep
374  restrt_step(3) = step_count
375  times(1) = ctime
376  times(2) = dtime
377  if( is_stepfinished ) then
378  times(3) = ctime
379  else
380  times(3) = fstrsolid%step_ctrl(cstep)%starttime
381  end if
382  istat(1) = fstrsolid%AutoINC_stat
383  call hecmw_restart_add_int(restrt_step,size(restrt_step))
384  if( fstrparam%restart_version >= 5 ) then
385  call hecmw_restart_add_real(times,size(times))
386  call hecmw_restart_add_int(fstrsolid%NRstat_i,size(fstrsolid%NRstat_i))
387  call hecmw_restart_add_real(fstrsolid%NRstat_r,size(fstrsolid%NRstat_r))
388  call hecmw_restart_add_int(istat,1)
389  endif
390  nload_prev(1) = 0
391  if( is_stepfinished ) then
392  if( associated(fstrsolid%step_ctrl(cstep)%Load) ) nload_prev(1) = size(fstrsolid%step_ctrl(cstep)%Load)
393  call hecmw_restart_add_int(nload_prev,1)
394  if( nload_prev(1)>0 ) call hecmw_restart_add_int(fstrsolid%step_ctrl(cstep)%Load,nload_prev(1))
395  else
396  if( cstep>1 ) then
397  if( associated(fstrsolid%step_ctrl(cstep-1)%Load) ) nload_prev(1) = size(fstrsolid%step_ctrl(cstep-1)%Load)
398  call hecmw_restart_add_int(nload_prev,1)
399  if( nload_prev(1)>0 ) call hecmw_restart_add_int(fstrsolid%step_ctrl(cstep-1)%Load,nload_prev(1))
400  else
401  if( associated(fstrsolid%step_ctrl_restart%Load) ) nload_prev(1) = size(fstrsolid%step_ctrl_restart%Load)
402  call hecmw_restart_add_int(nload_prev,1)
403  if( nload_prev(1)>0 ) call hecmw_restart_add_int(fstrsolid%step_ctrl_restart%Load,nload_prev(1))
404  endif
405  end if
406 
407  call hecmw_restart_add_real(fstrsolid%unode,size(fstrsolid%unode))
408  call hecmw_restart_add_real(fstrsolid%unode_bak,size(fstrsolid%unode_bak))
409  call hecmw_restart_add_real(fstrsolid%QFORCE,size(fstrsolid%QFORCE))
410  call fstr_require_shell_restart_version(fstrsolid, fstrparam%restart_version)
411  if( fstrparam%restart_version >= 6 ) call fstr_write_restart_shell_state(hecmesh, fstrsolid)
412 
413  do i= 1, hecmesh%n_elem
414  if (hecmw_is_etype_link( fstrsolid%elements(i)%etype )) cycle
415  if (hecmw_is_etype_patch( fstrsolid%elements(i)%etype )) cycle
416  do j= 1, size(fstrsolid%elements(i)%gausses)
417  nif = 0
418  if( associated(fstrsolid%elements(i)%gausses(j)%istatus) ) nif(1)=size(fstrsolid%elements(i)%gausses(j)%istatus)
419  if( associated(fstrsolid%elements(i)%gausses(j)%fstatus) ) nif(2)=size(fstrsolid%elements(i)%gausses(j)%fstatus)
420  call hecmw_restart_add_int(nif,size(nif))
421  call hecmw_restart_add_real(fstrsolid%elements(i)%gausses(j)%strain,size(fstrsolid%elements(i)%gausses(j)%strain))
422  call hecmw_restart_add_real(fstrsolid%elements(i)%gausses(j)%strain_bak,size(fstrsolid%elements(i)%gausses(j)%strain_bak))
423  call hecmw_restart_add_real(fstrsolid%elements(i)%gausses(j)%stress,size(fstrsolid%elements(i)%gausses(j)%stress))
424  call hecmw_restart_add_real(fstrsolid%elements(i)%gausses(j)%stress_bak,size(fstrsolid%elements(i)%gausses(j)%stress_bak))
425  if( nif(1)>0 ) then
426  call hecmw_restart_add_int(fstrsolid%elements(i)%gausses(j)%istatus,size(fstrsolid%elements(i)%gausses(j)%istatus))
427  endif
428  if( nif(2)>0 ) then
429  call hecmw_restart_add_real(fstrsolid%elements(i)%gausses(j)%fstatus,size(fstrsolid%elements(i)%gausses(j)%fstatus))
430  endif
431  enddo
432  naux = 0
433  if( associated(fstrsolid%elements(i)%aux) ) naux=shape(fstrsolid%elements(i)%aux)
434  call hecmw_restart_add_int(naux,size(naux))
435  do j= 1, naux(2)
436  call hecmw_restart_add_real(fstrsolid%elements(i)%aux(:,j),naux(1))
437  enddo
438  enddo
439 
440  if( associated( fstrsolid%contacts ) ) then
441  nif(1) = contactnode
442  call hecmw_restart_add_int(nif,size(nif))
443  do i= 1, fstrsolid%n_contacts
444  do j= 1, size(fstrsolid%contacts(i)%slave)
445  nif(1) = fstrsolid%contacts(i)%states(j)%surface
446  nif(2) = fstrsolid%contacts(i)%states(j)%state
447  call hecmw_restart_add_int(nif,size(nif))
448  call hecmw_restart_add_real(fstrsolid%contacts(i)%states(j)%lpos,size(fstrsolid%contacts(i)%states(j)%lpos))
449  call hecmw_restart_add_real(fstrsolid%contacts(i)%states(j)%direction,size(fstrsolid%contacts(i)%states(j)%direction))
450  call hecmw_restart_add_real(fstrsolid%contacts(i)%states(j)%multiplier,size(fstrsolid%contacts(i)%states(j)%multiplier))
451  call hecmw_restart_add_real(fstrsolid%contacts(i)%states(j)%tangentForce_trial, &
452  size(fstrsolid%contacts(i)%states(j)%tangentForce_trial))
453  call hecmw_restart_add_real(fstrsolid%contacts(i)%states(j)%tangentForce_final, &
454  size(fstrsolid%contacts(i)%states(j)%tangentForce_final))
455  enddo
456  enddo
457  endif
458 
459  call hecmw_restart_write()
460 
461  end subroutine fstr_write_restart
462 
464  !----------------------------------------------------------------------*
465  subroutine fstr_read_restart_dyna_nl(cstep,substep,hecMESH,fstrSOLID,fstrDYNAMIC,fstrPARAM,contactNode,step_count)
466  !----------------------------------------------------------------------*
467  integer, intent(out) :: cstep
468  integer, intent(out) :: substep
469  integer, intent(out), optional :: contactNode
470  integer, intent(out), optional :: step_count
471  type (hecmwST_local_mesh), intent(in) :: hecMESH
472  type (fstr_solid),intent(inout) :: fstrSOLID
473  type ( fstr_dynamic), intent(inout) :: fstrDYNAMIC
474  type(fstr_param), intent(in) :: fstrPARAM
475 
476  integer :: i,j,restrt_step(3),nif(2),istat(1),nload_prev(1),naux(2),dyna_int(1)
477  real(kind=kreal) :: times(3),dyna_data(1)
478 
479  call hecmw_restart_open()
480 
481  !--- Common header (same format as static restart) ---
482  call hecmw_restart_read_int(restrt_step)
483  if( fstrparam%restart_version >= 5 ) then
484  if( myrank == 0 ) write(*,*) 'Reading dynamic restart file as new format(>=ver5.0)'
485  call hecmw_restart_read_real(times)
486  call hecmw_restart_read_int(fstrsolid%NRstat_i)
487  call hecmw_restart_read_real(fstrsolid%NRstat_r)
488  call hecmw_restart_read_int(istat)
489  else
490  if( myrank == 0 ) write(*,*) 'Reading dynamic restart file as old format(<ver5.0)'
491  endif
492  call hecmw_restart_read_int(nload_prev)
493  if( nload_prev(1)>0 ) then
494  allocate(fstrsolid%step_ctrl_restart%Load(nload_prev(1)))
495  call hecmw_restart_read_int(fstrsolid%step_ctrl_restart%Load)
496  endif
497 
498  call hecmw_restart_read_real(fstrsolid%unode)
499  call hecmw_restart_read_real(fstrsolid%unode_bak)
500  call hecmw_restart_read_real(fstrsolid%QFORCE)
501  call fstr_require_shell_restart_version(fstrsolid, fstrparam%restart_version)
502  if( fstrparam%restart_version >= 6 ) call fstr_read_restart_shell_state(hecmesh, fstrsolid)
503 
504  do i= 1, hecmesh%n_elem
505  if (hecmw_is_etype_link( fstrsolid%elements(i)%etype )) cycle
506  if (hecmw_is_etype_patch( fstrsolid%elements(i)%etype )) cycle
507  do j= 1, size(fstrsolid%elements(i)%gausses)
508  call hecmw_restart_read_int(nif)
509  call hecmw_restart_read_real(fstrsolid%elements(i)%gausses(j)%strain)
510  call hecmw_restart_read_real(fstrsolid%elements(i)%gausses(j)%strain_bak)
511  call hecmw_restart_read_real(fstrsolid%elements(i)%gausses(j)%stress)
512  call hecmw_restart_read_real(fstrsolid%elements(i)%gausses(j)%stress_bak)
513  if( nif(1)>0 ) call hecmw_restart_read_int(fstrsolid%elements(i)%gausses(j)%istatus)
514  if( nif(2)>0 ) call hecmw_restart_read_real(fstrsolid%elements(i)%gausses(j)%fstatus)
515  enddo
516  call hecmw_restart_read_int(naux)
517  do j= 1, naux(2)
518  call hecmw_restart_read_real(fstrsolid%elements(i)%aux(:,j))
519  enddo
520  enddo
521 
522  if(present(contactnode)) then
523  call hecmw_restart_read_int(nif)
524  contactnode = nif(1)
525  do i= 1, fstrsolid%n_contacts
526  do j= 1, size(fstrsolid%contacts(i)%slave)
527  call hecmw_restart_read_int(nif)
528  fstrsolid%contacts(i)%states(j)%surface = nif(1)
529  fstrsolid%contacts(i)%states(j)%state = nif(2)
530  call hecmw_restart_read_real(fstrsolid%contacts(i)%states(j)%lpos)
531  call hecmw_restart_read_real(fstrsolid%contacts(i)%states(j)%direction)
532  call hecmw_restart_read_real(fstrsolid%contacts(i)%states(j)%multiplier)
533  call hecmw_restart_read_real(fstrsolid%contacts(i)%states(j)%tangentForce_trial)
534  call hecmw_restart_read_real(fstrsolid%contacts(i)%states(j)%tangentForce_final)
535  fstrsolid%contacts(i)%states(j)%tangentForce(1:3) = fstrsolid%contacts(i)%states(j)%tangentForce_final(1:3)
536  fstrsolid%contacts(i)%states(j)%tangentForce1(1:3) = fstrsolid%contacts(i)%states(j)%tangentForce_final(1:3)
537  enddo
538  enddo
539  endif
540 
541  !--- Dynamic-specific data ---
542  call hecmw_restart_read_int(dyna_int)
543  fstrdynamic%idx_eqa = dyna_int(1)
544  call hecmw_restart_read_real(dyna_data)
545  fstrdynamic%strainEnergy = dyna_data(1)
546  if( fstrdynamic%idx_eqa == 1 ) then
547  call hecmw_restart_read_real(fstrdynamic%DISP(:,1))
548  call hecmw_restart_read_real(fstrdynamic%VEL(:,1))
549  call hecmw_restart_read_real(fstrdynamic%ACC(:,1))
550  else
551  call hecmw_restart_read_real(fstrdynamic%DISP(:,1))
552  call hecmw_restart_read_real(fstrdynamic%DISP(:,3))
553  endif
554  do i= 1, hecmesh%n_elem
555  if (hecmw_is_etype_link( fstrsolid%elements(i)%etype )) cycle
556  if (hecmw_is_etype_patch( fstrsolid%elements(i)%etype )) cycle
557  call hecmw_restart_read_real(fstrsolid%elements(i)%equiForces)
558  enddo
559 
560  call hecmw_restart_close()
561 
562  !--- Restore step info (same logic as static restart) ---
563  cstep = restrt_step(1)
564  substep = restrt_step(2) + 1
565  if( present(step_count) ) step_count = restrt_step(3)
566  if( fstrparam%restart_version >= 5 ) then
567  fstrdynamic%t_curr = times(1)
568  fstrdynamic%t_delta = times(2)
569  fstrsolid%AutoINC_stat = istat(1)
570  if( dabs(times(1)-times(3)) < 1.d-10 ) then
571  cstep = cstep + 1
572  substep = 1
573  endif
574  do i=1,size(fstrsolid%step_ctrl)
575  fstrsolid%step_ctrl(i)%starttime = fstrsolid%step_ctrl(i)%starttime + times(3)
576  end do
577  else
578  fstrdynamic%t_curr = fstrsolid%step_ctrl(cstep)%starttime
579  fstrdynamic%t_curr = fstrdynamic%t_curr + dble(substep-1)*fstrsolid%step_ctrl(cstep)%initdt
580  fstrdynamic%t_delta = fstrsolid%step_ctrl(cstep)%initdt
581  if( dabs(fstrdynamic%t_curr-fstrsolid%step_ctrl(cstep)%starttime &
582  -fstrsolid%step_ctrl(cstep)%elapsetime) < 1.d-10 ) then
583  cstep = cstep + 1
584  substep = 1
585  endif
586  endif
587 
588  end subroutine fstr_read_restart_dyna_nl
589 
591  !----------------------------------------------------------------------*
592  subroutine fstr_write_restart_dyna_nl(cstep,substep,hecMESH,fstrSOLID, &
593  fstrDYNAMIC,fstrPARAM,is_StepFinished,contactNode,step_count)
594  !----------------------------------------------------------------------*
595  integer, intent(in) :: cstep
596  integer, intent(in) :: substep
597  logical, intent(in) :: is_StepFinished
598  integer, intent(in), optional :: contactNode
599  integer, intent(in), optional :: step_count
600  type (hecmwST_local_mesh), intent(in) :: hecMESH
601  type (fstr_solid), intent(in) :: fstrSOLID
602  type ( fstr_dynamic), intent(in) :: fstrDYNAMIC
603  type(fstr_param), intent(in) :: fstrPARAM
604 
605  integer :: i,j,restrt_step(3),nif(2),istat(1),nload_prev(1),naux(2),dyna_int(1)
606  real(kind=kreal) :: times(3),dyna_data(1)
607 
608  !--- Common header (same format as static restart) ---
609  restrt_step(1) = cstep
610  restrt_step(2) = substep
611  if( present(step_count) ) then
612  restrt_step(3) = step_count
613  else
614  restrt_step(3) = 0
615  endif
616  call hecmw_restart_add_int(restrt_step,size(restrt_step))
617  if( fstrparam%restart_version >= 5 ) then
618  times(1) = fstrdynamic%t_curr
619  times(2) = fstrdynamic%t_delta
620  if( is_stepfinished ) then
621  times(3) = fstrdynamic%t_curr
622  else
623  times(3) = fstrsolid%step_ctrl(cstep)%starttime
624  end if
625  call hecmw_restart_add_real(times,size(times))
626  call hecmw_restart_add_int(fstrsolid%NRstat_i,size(fstrsolid%NRstat_i))
627  call hecmw_restart_add_real(fstrsolid%NRstat_r,size(fstrsolid%NRstat_r))
628  istat(1) = fstrsolid%AutoINC_stat
629  call hecmw_restart_add_int(istat,1)
630  endif
631  nload_prev(1) = 0
632  call hecmw_restart_add_int(nload_prev,1)
633 
634  call hecmw_restart_add_real(fstrsolid%unode,size(fstrsolid%unode))
635  call hecmw_restart_add_real(fstrsolid%unode_bak,size(fstrsolid%unode_bak))
636  call hecmw_restart_add_real(fstrsolid%QFORCE,size(fstrsolid%QFORCE))
637  call fstr_require_shell_restart_version(fstrsolid, fstrparam%restart_version)
638  if( fstrparam%restart_version >= 6 ) call fstr_write_restart_shell_state(hecmesh, fstrsolid)
639 
640  do i= 1, hecmesh%n_elem
641  if (hecmw_is_etype_link( fstrsolid%elements(i)%etype )) cycle
642  if (hecmw_is_etype_patch( fstrsolid%elements(i)%etype )) cycle
643  do j= 1, size(fstrsolid%elements(i)%gausses)
644  nif = 0
645  if( associated(fstrsolid%elements(i)%gausses(j)%istatus) ) nif(1)=size(fstrsolid%elements(i)%gausses(j)%istatus)
646  if( associated(fstrsolid%elements(i)%gausses(j)%fstatus) ) nif(2)=size(fstrsolid%elements(i)%gausses(j)%fstatus)
647  call hecmw_restart_add_int(nif,size(nif))
648  call hecmw_restart_add_real(fstrsolid%elements(i)%gausses(j)%strain,size(fstrsolid%elements(i)%gausses(j)%strain))
649  call hecmw_restart_add_real(fstrsolid%elements(i)%gausses(j)%strain_bak,size(fstrsolid%elements(i)%gausses(j)%strain_bak))
650  call hecmw_restart_add_real(fstrsolid%elements(i)%gausses(j)%stress,size(fstrsolid%elements(i)%gausses(j)%stress))
651  call hecmw_restart_add_real(fstrsolid%elements(i)%gausses(j)%stress_bak,size(fstrsolid%elements(i)%gausses(j)%stress_bak))
652  if( nif(1)>0 ) then
653  call hecmw_restart_add_int(fstrsolid%elements(i)%gausses(j)%istatus,size(fstrsolid%elements(i)%gausses(j)%istatus))
654  endif
655  if( nif(2)>0 ) then
656  call hecmw_restart_add_real(fstrsolid%elements(i)%gausses(j)%fstatus,size(fstrsolid%elements(i)%gausses(j)%fstatus))
657  endif
658  enddo
659  naux = 0
660  if( associated(fstrsolid%elements(i)%aux) ) naux=shape(fstrsolid%elements(i)%aux)
661  call hecmw_restart_add_int(naux,size(naux))
662  do j= 1, naux(2)
663  call hecmw_restart_add_real(fstrsolid%elements(i)%aux(:,j),naux(1))
664  enddo
665  enddo
666 
667  if(present(contactnode)) then
668  nif(1) = contactnode
669  call hecmw_restart_add_int(nif,size(nif))
670  do i= 1, fstrsolid%n_contacts
671  do j= 1, size(fstrsolid%contacts(i)%slave)
672  nif(1) = fstrsolid%contacts(i)%states(j)%surface
673  nif(2) = fstrsolid%contacts(i)%states(j)%state
674  call hecmw_restart_add_int(nif,size(nif))
675  call hecmw_restart_add_real(fstrsolid%contacts(i)%states(j)%lpos,size(fstrsolid%contacts(i)%states(j)%lpos))
676  call hecmw_restart_add_real(fstrsolid%contacts(i)%states(j)%direction,size(fstrsolid%contacts(i)%states(j)%direction))
677  call hecmw_restart_add_real(fstrsolid%contacts(i)%states(j)%multiplier,size(fstrsolid%contacts(i)%states(j)%multiplier))
678  call hecmw_restart_add_real(fstrsolid%contacts(i)%states(j)%tangentForce_trial, &
679  size(fstrsolid%contacts(i)%states(j)%tangentForce_trial))
680  call hecmw_restart_add_real(fstrsolid%contacts(i)%states(j)%tangentForce_final, &
681  size(fstrsolid%contacts(i)%states(j)%tangentForce_final))
682  enddo
683  enddo
684  endif
685 
686  !--- Dynamic-specific data ---
687  dyna_int(1) = fstrdynamic%idx_eqa
688  call hecmw_restart_add_int(dyna_int,1)
689  dyna_data(1) = fstrdynamic%strainEnergy
690  call hecmw_restart_add_real(dyna_data,size(dyna_data))
691  if( fstrdynamic%idx_eqa == 1 ) then
692  call hecmw_restart_add_real(fstrdynamic%DISP(:,1),size(fstrdynamic%DISP(:,1)))
693  call hecmw_restart_add_real(fstrdynamic%VEL(:,1),size(fstrdynamic%VEL(:,1)))
694  call hecmw_restart_add_real(fstrdynamic%ACC(:,1),size(fstrdynamic%ACC(:,1)))
695  else
696  call hecmw_restart_add_real(fstrdynamic%DISP(:,1),size(fstrdynamic%DISP(:,1)))
697  call hecmw_restart_add_real(fstrdynamic%DISP(:,3),size(fstrdynamic%DISP(:,3)))
698  endif
699  do i= 1, hecmesh%n_elem
700  if (hecmw_is_etype_link( fstrsolid%elements(i)%etype )) cycle
701  if (hecmw_is_etype_patch( fstrsolid%elements(i)%etype )) cycle
702  call hecmw_restart_add_real(fstrsolid%elements(i)%equiForces,size(fstrsolid%elements(i)%equiForces))
703  enddo
704 
705  call hecmw_restart_write()
706 
707  end subroutine fstr_write_restart_dyna_nl
708 
709 end module m_fstr_restart
Definition: hecmw.f90:6
This module provides functions to read in and write out restart files.
Definition: fstr_Restart.f90:8
logical function fstr_requires_shell_restart_v6(fstrSOLID)
Return true when the model contains shell state that cannot be represented by restart version 5.
subroutine fstr_write_restart_shell_gauss(gauss)
Store one complete shell layer/thickness Gauss state.
subroutine fstr_read_restart_dyna_nl(cstep, substep, hecMESH, fstrSOLID, fstrDYNAMIC, fstrPARAM, contactNode, step_count)
Read in restart file for nonlinear dynamic analysis.
subroutine fstr_read_restart(cstep, substep, step_count, ctime, dtime, hecMESH, fstrSOLID, fstrPARAM, contactNode)
Read in restart file.
subroutine fstr_require_shell_restart_version(fstrSOLID, restart_version)
Abort instead of silently discarding finite-rotation or layer shell state.
subroutine fstr_write_restart_shell_state(hecMESH, fstrSOLID)
Write committed nodal shell kinematics and all layer/thickness material histories.
subroutine fstr_restart_abort(message)
Stop restart processing with a rank-zero diagnostic.
subroutine fstr_write_restart_dyna_nl(cstep, substep, hecMESH, fstrSOLID, fstrDYNAMIC, fstrPARAM, is_StepFinished, contactNode, step_count)
write out restart file for nonlinear dynamic analysis
subroutine fstr_write_restart(cstep, cstep_ext, substep, step_count, ctime, dtime, hecMESH, fstrSOLID, fstrPARAM, is_StepFinished, contactNode)
write out restart file
subroutine fstr_read_restart_shell_state(hecMESH, fstrSOLID)
Restore committed nodal shell kinematics and all layer/thickness material histories.
subroutine fstr_read_restart_shell_gauss(gauss)
Restore one complete shell layer/thickness Gauss state.
subroutine fstr_validate_shell_nodal_state(fstrSOLID, nnode)
Validate the allocated nodal arrays required by the version-6 shell block.
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:99
This module provides aux functions.
Definition: utilities.f90:6
This modules defines a structure to record history dependent parameter in static analysis.
Definition: mechgauss.f90:6
FSTR INNER CONTROL PARAMETERS (fstrPARAM)
Definition: m_fstr.F90:157
All data should be recorded in every quadrature points.
Definition: mechgauss.f90:15