30 hecMESH, hecMAT, fstrSOLID, fstrPR, &
31 ndof, iter, sub_step, cstep, &
32 residual_vec, nresid, &
36 maxDLag, converg_dlag )
39 type(hecmwst_local_mesh),
intent(in) :: hecmesh
40 type(hecmwst_matrix),
intent(in) :: hecmat
43 integer(kind=kint),
intent(in) :: ndof
44 integer(kind=kint),
intent(in) :: iter
45 integer(kind=kint),
intent(in) :: sub_step
46 integer(kind=kint),
intent(in) :: cstep
47 real(kind=kreal),
intent(in) :: residual_vec(:)
48 integer(kind=kint),
intent(in) :: nresid
49 real(kind=kreal),
intent(inout) :: resb
50 real(kind=kreal),
intent(inout) :: res_prev
51 integer(kind=kint),
intent(in) :: n_node_global
52 integer(kind=kint),
intent(out) :: iterstatus
53 real(kind=kreal),
intent(in),
optional :: maxdlag
54 real(kind=kreal),
intent(in),
optional :: converg_dlag
56 real(kind=kreal) :: res_for_check
57 logical :: do_failure_check, is_dynamic, is_contact
60 is_contact = (n_node_global > 0)
64 hecmesh, hecmat, fstrsolid,
fstrpr, &
66 residual_vec, nresid, &
70 do_failure_check, res_for_check, &
71 maxdlag, converg_dlag )
74 if( .not. do_failure_check )
return
77 if( res_for_check /= res_for_check )
then
79 else if( iter == fstrsolid%step_ctrl(cstep)%max_iter .or. &
80 res_for_check > fstrsolid%step_ctrl(cstep)%maxres )
then
87 if( hecmesh%my_rank == 0 )
then
90 if( .not. is_dynamic .and. .not. is_contact )
then
91 write(
ilog,
'(a,i5,a,i5)')
'### Fail to Converge : at total_step=', cstep,
' sub_step=', sub_step
93 write( *,
'(a,i5,a,i5)')
' ### Fail to Converge : at total_step=', cstep,
' sub_step=', sub_step
95 fstrsolid%NRstat_i(knstmaxit) = max(fstrsolid%NRstat_i(knstmaxit), iter)
96 fstrsolid%NRstat_i(knstsumit) = fstrsolid%NRstat_i(knstsumit) + iter
97 fstrsolid%CutBack_stat = fstrsolid%CutBack_stat + 1
99 iter == fstrsolid%step_ctrl(cstep)%max_iter )
then
100 fstrsolid%NRstat_i(knstdresn) = 1
103 fstrsolid%NRstat_i(knstdresn) = 2
138 hecMESH, hecMAT, fstrSOLID, fstrPR, &
140 residual_vec, nresid, &
144 do_failure_check, res_for_check, &
145 maxDLag, converg_dlag )
148 type(hecmwst_local_mesh),
intent(in) :: hecmesh
149 type(hecmwst_matrix),
intent(in) :: hecmat
152 integer(kind=kint),
intent(in) :: ndof
153 integer(kind=kint),
intent(in) :: iter
154 integer(kind=kint),
intent(in) :: cstep
155 real(kind=kreal),
intent(in) :: residual_vec(:)
156 integer(kind=kint),
intent(in) :: nresid
157 real(kind=kreal),
intent(inout) :: resb
158 real(kind=kreal),
intent(inout) :: res_prev
159 integer(kind=kint),
intent(in) :: n_node_global
160 integer(kind=kint),
intent(out) :: iterstatus
161 logical,
intent(out) :: do_failure_check
162 real(kind=kreal),
intent(out) :: res_for_check
163 real(kind=kreal),
intent(in),
optional :: maxdlag
164 real(kind=kreal),
intent(in),
optional :: converg_dlag
166 real(kind=kreal) :: res_sq, res_nrm, qnrm, rres, xnrm, dunrm, rxnrm
167 real(kind=kreal) :: relres, res_normalized
168 logical :: is_dynamic, is_contact
171 do_failure_check = .false.
172 res_for_check = 0.0d0
175 is_contact = (n_node_global > 0)
180 if( .not. is_dynamic .and. .not. is_contact )
then
181 call hecmw_innerproduct_r(hecmesh, ndof, hecmat%B, hecmat%B, res_sq)
182 res_nrm = sqrt(res_sq)
184 call hecmw_innerproduct_r(hecmesh, ndof, hecmat%X, hecmat%X, xnrm)
187 call hecmw_innerproduct_r(hecmesh, ndof, fstrsolid%QFORCE, fstrsolid%QFORCE, qnrm)
189 if( qnrm < 1.0d-8 ) qnrm = 1.0d0
194 call hecmw_innerproduct_r(hecmesh, ndof, fstrsolid%dunode, fstrsolid%dunode, dunrm)
198 rres = res_nrm / qnrm
201 if( hecmesh%my_rank == 0 )
then
202 if( qnrm == 1.0d0 )
then
203 write(*,
"(a,i8,a,1pe11.4,a,1pe11.4)")
" iter:", iter,
", residual(abs):", rres,
", disp.corr.:", rxnrm
205 write(*,
"(a,i8,a,1pe11.4,a,1pe11.4)")
" iter:", iter,
", residual:", rres,
", disp.corr.:", rxnrm
210 if( hecmw_mat_get_flag_diverged(hecmat) ==
kno )
then
211 if( rres < fstrsolid%step_ctrl(cstep)%converg .or. &
212 rxnrm < fstrsolid%step_ctrl(cstep)%converg_ddisp )
then
218 do_failure_check = .true.
224 else if( .not. is_dynamic .and. is_contact )
then
225 res_sq = dot_product(residual_vec(1:nresid), residual_vec(1:nresid))
226 call hecmw_allreduce_r1(hecmesh, res_sq, hecmw_sum)
227 res_normalized = sqrt(res_sq) / dble(n_node_global)
229 if( iter == 1 ) resb = res_normalized
230 if( resb == 0.0d0 )
then
233 relres = dabs(res_prev - res_normalized) / resb
236 if( hecmesh%my_rank == 0 )
then
238 write(*,
'(a,i3,a,2e15.7)')
' - Residual(', iter,
') =', res_normalized, 0.0d0
240 write(*,
'(a,i3,a,2e15.7)')
' - Residual(', iter,
') =', res_normalized, relres
246 if( res_normalized < fstrsolid%step_ctrl(cstep)%converg .or. &
247 relres < fstrsolid%step_ctrl(cstep)%converg_ddisp )
then
249 res_prev = res_normalized
253 if( res_normalized < fstrsolid%step_ctrl(cstep)%converg )
then
255 res_prev = res_normalized
260 res_prev = res_normalized
262 do_failure_check = .true.
263 res_for_check = res_normalized
268 else if( is_dynamic .and. is_contact )
then
269 res_sq = dot_product(residual_vec(1:nresid), residual_vec(1:nresid))
270 call hecmw_allreduce_r1(hecmesh, res_sq, hecmw_sum)
272 if( iter == 1 ) resb = res_sq
273 res_normalized = dsqrt(res_sq / resb)
276 if(
fstrpr%nlgeom .and. ndof /= 4 )
then
277 if( hecmesh%my_rank == 0 )
then
278 write(*,
'(a,i5,a,1pe12.4)')
"iter: ", iter,
", res: ", res_normalized
279 write(
ista,
'(''iter='',I5,''- Residual'',E15.7)') iter, res_normalized
280 if(
present(maxdlag) )
then
281 write(*,
'(a,1e15.7)')
' - MaxDLag =', maxdlag
282 write(
ista,
'(a,1e15.7)')
' - MaxDLag =', maxdlag
285 if(
present(maxdlag) .and.
present(converg_dlag) )
then
286 if( res_normalized < fstrsolid%step_ctrl(cstep)%converg .and. &
287 maxdlag < converg_dlag )
then
292 if( res_normalized < fstrsolid%step_ctrl(cstep)%converg )
then
298 do_failure_check = .true.
299 res_for_check = res_normalized
This module provides a unified convergence check for Newton iteration.
subroutine, public fstr_check_convergence(hecMESH, hecMAT, fstrSOLID, fstrPR, ndof, iter, sub_step, cstep, residual_vec, nresid, resb, res_prev, n_node_global, iterStatus, maxDLag, converg_dlag)
Wrapper that calls fstr_check_convergence_main and applies the common divergence/NaN handling (status...
subroutine, public fstr_check_convergence_main(hecMESH, hecMAT, fstrSOLID, fstrPR, ndof, iter, cstep, residual_vec, nresid, resb, res_prev, n_node_global, iterStatus, do_failure_check, res_for_check, maxDLag, converg_dlag)
Core convergence check: computes residual norm, applies the per-path convergence criterion,...
This module defines common data and basic structures for analysis.
integer(kind=kint), parameter kitrfloatingerror
integer(kind=kint), parameter kstdynamic
integer(kind=kint), parameter kitrconverged
integer(kind=kint), parameter ilog
FILE HANDLER.
integer(kind=kint), parameter ista
type(fstr_param), target fstrpr
GLOBAL VARIABLE INITIALIZED IN FSTR_SETUP.
integer(kind=kint), parameter kitrcontinue
iteration control
integer(kind=kint), parameter kno
integer(kind=kint), parameter kitrdiverged
FSTR INNER CONTROL PARAMETERS (fstrPARAM)