FrontISTR  5.7.1
Large-scale structural analysis program with finit element method
fstr_element_activation.f90
Go to the documentation of this file.
1 !-------------------------------------------------------------------------------
2 ! Copyright (c) 2016 The University of Tokyo
3 ! This software is released under the MIT License, see LICENSE.txt
4 !-------------------------------------------------------------------------------
7  use hecmw
8  use m_fstr
9  use m_elemact
10 
11 contains
12 
13  subroutine fstr_update_elemact_solid( hecMESH, fstrSOLID, cstep, ctime )
14  type(hecmwst_local_mesh), intent(in) :: hecMESH
15  type(fstr_solid), intent(inout) :: fstrSOLID
16  integer(kind=kint), intent(in) :: cstep
17  real(kind=kreal), intent(in) :: ctime
18 
19  integer(kind=kint) :: idum, amp_id, gid
20  real(kind=kreal) :: amp_val
21  integer(kind=kint) :: state
22 
23  do idum = 1, fstrsolid%elemact%ELEMACT_egrp_tot
24  gid = fstrsolid%elemact%ELEMACT_egrp_GRPID(idum)
25  if( .not. fstr_iselemactivationactive( fstrsolid, gid, cstep ) ) then
26  call set_elemact_flag( hecmesh, fstrsolid%elemact, idum, fstrsolid%elements, kelact_active, .false. )
27  cycle
28  endif
29 
30  amp_id = fstrsolid%elemact%ELEMACT_egrp_amp(idum)
31  amp_val = 1.d0
32  if( amp_id > 0 ) then
33  call hecmw_get_amplitude_value(hecmesh%amp, amp_id, ctime, amp_val)
34  if( amp_val < 1.d0 ) then
35  call set_elemact_flag( hecmesh, fstrsolid%elemact, idum, fstrsolid%elements, kelact_active, .false. )
36  cycle
37  endif
38  end if
39 
40  ! Get the state and set the elemact flag
41  state = fstrsolid%elemact%ELEMACT_egrp_state(idum)
42 
43  if( fstrsolid%elemact%ELEMACT_egrp_depends(idum) == kelactd_none ) then
44  call set_elemact_flag( hecmesh, fstrsolid%elemact, idum, fstrsolid%elements, state, .false. )
45  else
46  call set_elemact_flag( hecmesh, fstrsolid%elemact, idum, fstrsolid%elements, state, .true. )
47  endif
48  end do
49 
50  end subroutine
51 
52  subroutine fstr_update_elemact_solid_by_value( hecMESH, fstrSOLID, cstep, ctime )
53  type(hecmwst_local_mesh), intent(in) :: hecMESH
54  type(fstr_solid), intent(inout) :: fstrSOLID
55  integer(kind=kint), intent(in) :: cstep
56  real(kind=kreal), intent(in) :: ctime
57 
58  integer(kind=kint) :: idum, amp_id, gid, dtype
59  real(kind=kreal) :: amp_val, thlow, thup
60  integer(kind=kint) :: state
61 
62  do idum = 1, fstrsolid%elemact%ELEMACT_egrp_tot
63  gid = fstrsolid%elemact%ELEMACT_egrp_GRPID(idum)
64  if( .not. fstr_iselemactivationactive( fstrsolid, gid, cstep ) ) cycle
65 
66  amp_id = fstrsolid%elemact%ELEMACT_egrp_amp(idum)
67  amp_val = 1.d0
68  if( amp_id > 0 ) then
69  call hecmw_get_amplitude_value(hecmesh%amp, amp_id, ctime, amp_val)
70  if( amp_val < 1.d0 ) cycle
71  end if
72 
73  state = fstrsolid%elemact%ELEMACT_egrp_state(idum)
74  call activate_elemact_flag_by_value( hecmesh, fstrsolid%elemact, idum, fstrsolid%elements )
75  end do
76 
77  end subroutine
78 
79  subroutine fstr_update_elemact_heat( hecMESH, elemact, ctime, elements )
80  type(hecmwst_local_mesh), intent(in) :: hecMESH
81  type(telemact), intent(in) :: elemact
82  real(kind=kreal), intent(in) :: ctime
83  type(telement), pointer, intent(inout) :: elements(:)
84 
85  integer(kind=kint) :: idum, amp_id
86  real(kind=kreal) :: amp_val
87 
88  call clear_elemact_flag_all( hecmesh, elemact, elements )
89 
90  do idum = 1, elemact%ELEMACT_egrp_tot
91  amp_id = elemact%ELEMACT_egrp_amp(idum)
92  amp_val = 1.d0
93  if( amp_id > 0 ) then
94  call hecmw_get_amplitude_value(hecmesh%amp, amp_id, ctime, amp_val)
95  if( amp_val < 1.d0 ) cycle
96  end if
97 
98  call activate_elemact_flag( hecmesh, elemact, idum, elements )
99  end do
100 
101  end subroutine
102 
103  subroutine fstr_updatedof_elemact( ndof, hecMESH, elemact, elements, vec_old, vec_new )
104  integer(kind=kint), intent(in) :: ndof
105  type(hecmwst_local_mesh), intent(in) :: hecMESH
106  type(telemact), intent(in) :: elemact
107  type(telement), pointer, intent(inout) :: elements(:)
108  real(kind=kreal), pointer, intent(in) :: vec_old(:)
109  real(kind=kreal), pointer, intent(inout) :: vec_new(:)
110 
111  integer(kind=kint) :: icel, in0
112  integer(kind=kint) :: iS, iE, ic_type, nodlocal, i
113  real(kind=kreal), pointer :: active(:)
114 
115  allocate(active(hecmesh%n_node))
116  active = -1.d0
117 
118  do itype = 1, hecmesh%n_elem_type
119  is = hecmesh%elem_type_index(itype-1) + 1
120  ie = hecmesh%elem_type_index(itype )
121  ic_type = hecmesh%elem_type_item(itype)
122 
123  if (hecmw_is_etype_link(ic_type)) cycle
124  if(ic_type == 3414) cycle
125 
126  do icel = is, ie
127  if( elements(icel)%elemact_flag == kelact_inactive ) cycle
128  in0 = hecmesh%elem_node_index(icel-1)
129  nn = hecmw_get_max_node(ic_type)
130  do i = 1, nn
131  nodlocal = hecmesh%elem_node_item(in0+i)
132  active(nodlocal) = 1.d0
133  enddo
134  enddo
135  enddo
136 
137  call hecmw_update_r(hecmesh,active,hecmesh%n_node,1)
138 
139  do i = 1, hecmesh%n_node
140  if( active(i) > 0.d0 ) cycle
141  vec_new(ndof*(i-1)+1:ndof*i) = vec_old(ndof*(i-1)+1:ndof*i)
142  end do
143 
144  deallocate(active)
145 
146  end subroutine
147 
148  subroutine output_elemact_flag( hecMESH, elements, outval )
149  type(hecmwst_local_mesh), intent(in) :: hecmesh
150  type(telement), pointer, intent(in) :: elements(:)
151  real(kind=kreal), pointer, intent(inout) :: outval(:)
152 
153  integer(kind=kint) :: icel
154 
155  outval = 0.d0
156  do icel = 1, hecmesh%n_elem
157  if( elements(icel)%elemact_flag == kelact_inactive ) outval(icel) = 1.d0
158  end do
159 
160  end subroutine
161 
162  subroutine activate_elemact_flag( hecMESH, elemact, dumid, elements )
163  type(hecmwst_local_mesh), intent(in) :: hecMESH
164  type(telemact), intent(in) :: elemact
165  integer(kind=kint), intent(in) :: dumid
166  type(telement), pointer, intent(inout) :: elements(:)
167 
168  integer(kind=kint) :: ig, iS0, iE0, ik, icel
169 
170  if( dumid < 0 .or. dumid > elemact%ELEMACT_egrp_tot ) return
171 
172  ig = elemact%ELEMACT_egrp_ID(dumid)
173  is0 = hecmesh%elem_group%grp_index(ig-1) + 1
174  ie0 = hecmesh%elem_group%grp_index(ig )
175 
176  do ik=is0,ie0
177  icel = hecmesh%elem_group%grp_item(ik)
178  elements(icel)%elemact_flag = kelact_inactive
179  elements(icel)%elemact_coeff = elemact%ELEMACT_egrp_eps(dumid)
180  end do
181 
182  end subroutine
183 
184  subroutine activate_elemact_flag_by_value( hecMESH, elemact, dumid, elements )
185  type(hecmwst_local_mesh), intent(in) :: hecMESH
186  type(telemact), intent(in) :: elemact
187  integer(kind=kint), intent(in) :: dumid
188  type(telement), pointer, intent(inout) :: elements(:)
189 
190  integer(kind=kint) :: ig, iS0, iE0, ik, icel, dtype, ig0
191  real(kind=kreal) :: thlow, thup, stress(6), mises, ps
192  integer(kind=kint) :: state
193 
194  if( dumid < 0 .or. dumid > elemact%ELEMACT_egrp_tot ) return
195  if( elemact%ELEMACT_egrp_depends(dumid) == kelactd_none ) return
196 
197  ig = elemact%ELEMACT_egrp_ID(dumid)
198  is0 = hecmesh%elem_group%grp_index(ig-1) + 1
199  ie0 = hecmesh%elem_group%grp_index(ig )
200 
201  thlow = elemact%ELEMACT_egrp_ts_lower(dumid)
202  thup = elemact%ELEMACT_egrp_ts_upper(dumid)
203 
204  ! Get the state (if not present, use INACTIVE for backward compatibility)
205  state = kelact_inactive ! Default is INACTIVE
206  if (associated(elemact%ELEMACT_egrp_state)) then
207  state = elemact%ELEMACT_egrp_state(dumid)
208  endif
209 
210  do ik=is0,ie0
211  icel = hecmesh%elem_group%grp_item(ik)
212 
213  if( elements(icel)%elemact_flag == state ) cycle
214 
215  do ig0=1,size(elements(icel)%gausses)
216  ! get mises
217  if( elemact%ELEMACT_egrp_depends(dumid) == kelactd_stress ) then
218  stress(1:6) = elements(icel)%gausses(ig0)%stress(1:6)
219  elseif( elemact%ELEMACT_egrp_depends(dumid) == kelactd_strain ) then
220  stress(1:6) = elements(icel)%gausses(ig0)%strain(1:6)
221  else
222  write(*,*) "Error: Unknown elemact dependency type"
223  return
224  endif
225  ps = ( stress(1) + stress(2) + stress(3) ) / 3.0d0
226  mises = 0.5d0 * ( (stress(1)-ps)**2 + (stress(2)-ps)**2 + (stress(3)-ps)**2 )
227  mises = mises + stress(4)**2 + stress(5)**2 + stress(6)**2
228  mises = dsqrt( 3.0d0 * mises )
229  ! Check if value is between threshold
230  if(thlow <= mises .and. mises <= thup) then
231  elements(icel)%elemact_flag = state
232  else
233  ! Toggle state
234  if (state == kelact_inactive) then
235  elements(icel)%elemact_flag = kelact_active
236  else
237  elements(icel)%elemact_flag = kelact_inactive
238  endif
239  endif
240  elements(icel)%elemact_coeff = elemact%ELEMACT_egrp_eps(dumid)
241  exit
242  enddo
243  end do
244 
245  end subroutine
246 
247  subroutine set_elemact_flag( hecMESH, elemact, dumid, elements, flag, init_only )
248  type(hecmwst_local_mesh), intent(in) :: hecMESH
249  type(telemact), intent(in) :: elemact
250  integer(kind=kint), intent(in) :: dumid
251  type(telement), pointer, intent(inout) :: elements(:)
252  integer(kind=kint), intent(in) :: flag
253  logical, intent(in) :: init_only
254 
255  integer(kind=kint) :: ig, iS0, iE0, ik, icel
256 
257  if( dumid < 0 .or. dumid > elemact%ELEMACT_egrp_tot ) return
258 
259  ig = elemact%ELEMACT_egrp_ID(dumid)
260  is0 = hecmesh%elem_group%grp_index(ig-1) + 1
261  ie0 = hecmesh%elem_group%grp_index(ig )
262 
263  do ik=is0,ie0
264  icel = hecmesh%elem_group%grp_item(ik)
265  if( init_only ) then
266  if( elements(icel)%elemact_flag == kelact_undefined ) elements(icel)%elemact_flag = flag
267  else
268  elements(icel)%elemact_flag = flag
269  endif
270  elements(icel)%elemact_coeff = elemact%ELEMACT_egrp_eps(dumid)
271  end do
272 
273  end subroutine
274 
275  subroutine clear_elemact_flag_all( hecMESH, elemact, elements )
276  type(hecmwst_local_mesh), intent(in) :: hecMESH
277  type(telemact), intent(in) :: elemact
278  type(telement), pointer, intent(inout) :: elements(:)
279 
280  integer(kind=kint) :: idum, ig, iS0, iE0, ik, icel
281 
282  do idum = 1, elemact%ELEMACT_egrp_tot
283  ig = elemact%ELEMACT_egrp_GRPID(idum)
284  is0 = hecmesh%elem_group%grp_index(ig-1) + 1
285  ie0 = hecmesh%elem_group%grp_index(ig )
286 
287  do ik=is0,ie0
288  icel = hecmesh%elem_group%grp_item(ik)
289  elements(icel)%elemact_flag = kelact_undefined
290  end do
291  end do
292 
293  end subroutine
294 
295 end module m_fstr_elemact
Definition: hecmw.f90:6
This module defined elemact data and function.
integer, parameter kelactd_none
integer, parameter kelact_active
integer, parameter kelactd_stress
integer, parameter kelact_undefined
integer, parameter kelact_inactive
integer, parameter kelactd_strain
This module provide a function to elemact elements.
subroutine output_elemact_flag(hecMESH, elements, outval)
subroutine fstr_update_elemact_solid_by_value(hecMESH, fstrSOLID, cstep, ctime)
subroutine fstr_update_elemact_heat(hecMESH, elemact, ctime, elements)
subroutine set_elemact_flag(hecMESH, elemact, dumid, elements, flag, init_only)
subroutine activate_elemact_flag(hecMESH, elemact, dumid, elements)
subroutine fstr_updatedof_elemact(ndof, hecMESH, elemact, elements, vec_old, vec_new)
subroutine clear_elemact_flag_all(hecMESH, elemact, elements)
subroutine activate_elemact_flag_by_value(hecMESH, elemact, dumid, elements)
subroutine fstr_update_elemact_solid(hecMESH, fstrSOLID, cstep, ctime)
This module defines common data and basic structures for analysis.
Definition: m_fstr.f90:15
logical function fstr_iselemactivationactive(fstrSOLID, nbc, cstep)
Definition: m_fstr.f90:1080