1910 lines
73 KiB
Fortran
1910 lines
73 KiB
Fortran
program strength_reduction_benchmark
|
|
use fem_precision
|
|
use fem_error
|
|
use fem_api
|
|
use fem_control
|
|
use fem_database
|
|
use fem_material_mohr_coulomb, only: material_mc_yield_values, &
|
|
MC_BRANCH_ELASTIC, MC_STATE_BRANCH, MC_STATE_SUBSTEPS, &
|
|
MC_STATE_REQUESTED_STEPS, MC_STATE_DRIVER_STATUS, &
|
|
MC_STATE_BRANCH_MASK, MC_STATE_MAX_YIELD, MC_STATE_MAX_PLASTIC_STEP
|
|
use fem_output_csv, only: output_csv_set_directory
|
|
use fem_output_vtk, only: output_vtk_write
|
|
use fem_strength_reduction_driver
|
|
use sr_benchmark_cli, only: MATERIAL_CASE_COUNT, &
|
|
nonlinear_chain_options, nonlinear_options_default, &
|
|
parse_optional_arguments, write_usage
|
|
use sr_benchmark_report, only: mc_struct_diag, &
|
|
write_cloud_progress_record, write_nonlinear_chain_record, &
|
|
write_nonlinear_summary, write_nonlinear_cloud_summary, &
|
|
write_overall_summary, vtk_result_basename, flow_rule_name, join_path
|
|
implicit none
|
|
|
|
integer, parameter :: NALPHA = 4
|
|
integer, parameter :: NMATCASE = MATERIAL_CASE_COUNT
|
|
integer, parameter :: NPROBE = 6
|
|
real(rk), parameter :: PI = 3.1415926535897932384626433832795_rk
|
|
real(rk), parameter :: L2 = 20.0_rk
|
|
real(rk), parameter :: H1 = 20.0_rk
|
|
real(rk), parameter :: H2 = 10.0_rk
|
|
real(rk), parameter :: NU_SOIL = 0.30_rk
|
|
real(rk), parameter :: C_SOIL = 2.0e4_rk
|
|
real(rk), parameter :: PHI_SOIL = 25.0_rk * PI / 180.0_rk
|
|
real(rk), parameter :: RHO_SOIL = 1940.0_rk
|
|
real(rk), parameter :: GRAVITY = 9.81_rk
|
|
|
|
type nonlinear_diag
|
|
integer :: iter_total = 0
|
|
integer :: solve_ierr = FEM_SUCCESS
|
|
integer :: conv_status = CONVERGENCE_STATUS_IDLE
|
|
integer :: failure_code = CONV_FAIL_NONE
|
|
integer :: cutbacks = 0
|
|
integer :: linear_iter = 0
|
|
integer :: linear_status = LS_STATUS_IDLE
|
|
real(rk) :: residual = ZERO
|
|
real(rk) :: relative_residual = ONE
|
|
real(rk) :: combined_norm = ONE
|
|
real(rk) :: max_disp = ZERO
|
|
real(rk) :: plastic_share = ZERO
|
|
real(rk) :: correction_norm = ZERO
|
|
real(rk) :: last_dt = ZERO
|
|
real(rk) :: accepted_time = ZERO
|
|
real(rk) :: linear_residual = ZERO
|
|
logical :: converged = .false.
|
|
end type nonlinear_diag
|
|
|
|
character(len=512) :: inp_file
|
|
character(len=512) :: out_dir
|
|
integer :: argc
|
|
integer :: ierr
|
|
integer :: mat
|
|
integer :: path_unit
|
|
integer :: cases_unit
|
|
integer :: summary_unit
|
|
integer :: plastic_unit
|
|
integer :: disp_unit
|
|
integer :: material_case
|
|
integer :: alpha_index
|
|
integer :: total_trials
|
|
integer :: total_stable
|
|
integer :: total_unstable
|
|
integer :: converged_cases
|
|
real(rk) :: max_abs_error
|
|
real(rk) :: case1_alpha45
|
|
type(nonlinear_chain_options) :: nl_options
|
|
|
|
intrinsic iargc
|
|
intrinsic getarg
|
|
|
|
argc = iargc()
|
|
if (argc .lt. 2) then
|
|
call write_usage()
|
|
stop 2
|
|
end if
|
|
|
|
call getarg(1, inp_file)
|
|
call getarg(2, out_dir)
|
|
call nonlinear_options_default(nl_options)
|
|
call parse_optional_arguments(argc, nl_options)
|
|
if (nl_options%displacement_limit .le. ZERO) then
|
|
nl_options%displacement_limit = stop_displacement(nl_options%alpha)
|
|
end if
|
|
|
|
call fem_initialize(ierr)
|
|
call exit_if_error(ierr)
|
|
call fem_read_inp(trim(inp_file), ierr)
|
|
call exit_if_error(ierr)
|
|
call fem_build_model(ierr)
|
|
call exit_if_error(ierr)
|
|
call find_mc_material(mat, ierr)
|
|
call exit_if_error(ierr)
|
|
|
|
call open_outputs(out_dir, path_unit, cases_unit, summary_unit, plastic_unit, &
|
|
disp_unit, ierr)
|
|
call exit_if_error(ierr)
|
|
|
|
total_trials = 0
|
|
total_stable = 0
|
|
total_unstable = 0
|
|
converged_cases = 0
|
|
max_abs_error = ZERO
|
|
case1_alpha45 = ZERO
|
|
|
|
do material_case = 1, NMATCASE
|
|
do alpha_index = 1, NALPHA
|
|
call run_reference_case(mat, material_case, alpha_index, path_unit, &
|
|
cases_unit, plastic_unit, disp_unit, total_trials, &
|
|
total_stable, total_unstable, converged_cases, &
|
|
max_abs_error, case1_alpha45, ierr)
|
|
call exit_if_error(ierr)
|
|
end do
|
|
end do
|
|
|
|
call write_overall_summary(summary_unit, NALPHA, NMATCASE, total_trials, &
|
|
total_stable, total_unstable, converged_cases, &
|
|
max_abs_error, case1_alpha45)
|
|
if (nl_options%enabled) then
|
|
call run_nonlinear_chain(mat, out_dir, nl_options, ierr)
|
|
call exit_if_error(ierr)
|
|
end if
|
|
if (nl_options%write_cloud) then
|
|
call run_nonlinear_cloud_trial(mat, out_dir, nl_options, ierr)
|
|
call exit_if_error(ierr)
|
|
end if
|
|
close(path_unit)
|
|
close(cases_unit)
|
|
close(summary_unit)
|
|
close(plastic_unit)
|
|
close(disp_unit)
|
|
|
|
call fem_finalize(ierr)
|
|
call exit_if_error(ierr)
|
|
write(*,'(A,I0,A,ES10.3)') 'Strength reduction reference cases: ', &
|
|
converged_cases, ', max_abs_error=', max_abs_error
|
|
|
|
contains
|
|
|
|
subroutine find_mc_material(mat_id, ierr)
|
|
integer, intent(out) :: mat_id
|
|
integer, intent(out) :: ierr
|
|
integer :: i
|
|
|
|
mat_id = 0
|
|
do i = 1, n_material
|
|
if (trim(mat_plastic_model(i)) .eq. 'MOHR_COULOMB') then
|
|
mat_id = i
|
|
exit
|
|
end if
|
|
end do
|
|
if (mat_id .le. 0) then
|
|
call error_set(FEM_ERR_MATERIAL, &
|
|
'strength reduction benchmark requires MOHR_COULOMB material', ierr)
|
|
return
|
|
end if
|
|
call error_clear(ierr)
|
|
end subroutine find_mc_material
|
|
|
|
subroutine open_outputs(dir, path_unit, cases_unit, summary_unit, &
|
|
plastic_unit, disp_unit, ierr)
|
|
character(len=*), intent(in) :: dir
|
|
integer, intent(out) :: path_unit
|
|
integer, intent(out) :: cases_unit
|
|
integer, intent(out) :: summary_unit
|
|
integer, intent(out) :: plastic_unit
|
|
integer, intent(out) :: disp_unit
|
|
integer, intent(out) :: ierr
|
|
|
|
path_unit = 91
|
|
cases_unit = 92
|
|
summary_unit = 93
|
|
plastic_unit = 94
|
|
disp_unit = 95
|
|
|
|
call ensure_output_directory(dir, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
|
|
call open_csv(path_unit, join_path(dir, 'strength_reduction_path.csv'), ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
write(path_unit,'(A)') 'material_case,flow_rule,alpha_deg,trial_index,'// &
|
|
'factor,residual,max_displacement,stop_displacement,plastic_share,'// &
|
|
'metric,stable,status_after'
|
|
|
|
call open_csv(cases_unit, join_path(dir, 'strength_reduction_cases.csv'), ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
write(cases_unit,'(A)') 'material_case,flow_rule,alpha_deg,reference_fos,'// &
|
|
'computed_fos,abs_error,lower,upper,trials,stable_count,'// &
|
|
'unstable_count,status'
|
|
|
|
call open_csv(summary_unit, join_path(dir, 'strength_reduction_summary.csv'), &
|
|
ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
|
|
call open_csv(plastic_unit, join_path(dir, 'plastic_zone.csv'), ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
write(plastic_unit,'(A)') 'material_case,flow_rule,alpha_deg,probe_id,x,z,'// &
|
|
'branch,shear_f,tension_f,eqps_indicator,plastic'
|
|
|
|
call open_csv(disp_unit, join_path(dir, 'displacement_probe.csv'), ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
write(disp_unit,'(A)') 'material_case,flow_rule,alpha_deg,factor,'// &
|
|
'crest_uz,toe_ux,max_displacement,stop_displacement'
|
|
|
|
call error_clear(ierr)
|
|
end subroutine open_outputs
|
|
|
|
subroutine open_csv(unit_id, filename, ierr)
|
|
integer, intent(in) :: unit_id
|
|
character(len=*), intent(in) :: filename
|
|
integer, intent(out) :: ierr
|
|
integer :: ios
|
|
|
|
open(unit=unit_id, file=trim(filename), status='replace', action='write', &
|
|
iostat=ios)
|
|
if (ios .ne. 0) then
|
|
call error_set(FEM_ERR_OUTPUT, 'failed to open strength reduction output', &
|
|
ierr)
|
|
return
|
|
end if
|
|
call error_clear(ierr)
|
|
end subroutine open_csv
|
|
|
|
subroutine open_csv_append(unit_id, filename, ierr)
|
|
integer, intent(in) :: unit_id
|
|
character(len=*), intent(in) :: filename
|
|
integer, intent(out) :: ierr
|
|
integer :: ios
|
|
|
|
open(unit=unit_id, file=trim(filename), status='unknown', &
|
|
position='append', action='write', iostat=ios)
|
|
if (ios .ne. 0) then
|
|
call error_set(FEM_ERR_OUTPUT, &
|
|
'failed to append strength reduction output', ierr)
|
|
return
|
|
end if
|
|
call error_clear(ierr)
|
|
end subroutine open_csv_append
|
|
|
|
subroutine ensure_output_directory(dir, ierr)
|
|
character(len=*), intent(in) :: dir
|
|
integer, intent(out) :: ierr
|
|
|
|
character(len=512) :: command
|
|
character(len=128) :: os_name
|
|
integer :: os_len
|
|
integer :: os_end
|
|
integer :: exitstat
|
|
integer :: cmdstat
|
|
|
|
if (len_trim(dir) .le. 0 .or. trim(dir) .eq. '.') then
|
|
call error_clear(ierr)
|
|
return
|
|
end if
|
|
os_name = ' '
|
|
call get_environment_variable('OS', os_name, os_len)
|
|
os_end = min(len(os_name), max(1, os_len))
|
|
if (index(os_name(1:os_end), 'Windows') .gt. 0) then
|
|
if (index(trim(dir), '"') .gt. 0) then
|
|
call error_set(FEM_ERR_OUTPUT, &
|
|
'strength reduction output path must not contain double quotes', ierr)
|
|
return
|
|
end if
|
|
command = 'mkdir "'//trim(dir)//'" >nul 2>nul'
|
|
else
|
|
if (index(trim(dir), "'") .gt. 0) then
|
|
call error_set(FEM_ERR_OUTPUT, &
|
|
'strength reduction output path must not contain single quotes', ierr)
|
|
return
|
|
end if
|
|
command = "mkdir -p '"//trim(dir)//"'"
|
|
end if
|
|
call execute_command_line(trim(command), exitstat=exitstat, &
|
|
cmdstat=cmdstat)
|
|
if (cmdstat .ne. 0) then
|
|
call error_set(FEM_ERR_OUTPUT, &
|
|
'failed to create strength reduction output directory', ierr)
|
|
return
|
|
end if
|
|
call error_clear(ierr)
|
|
end subroutine ensure_output_directory
|
|
|
|
subroutine run_reference_case(mat_id, material_case, alpha_index, path_unit, &
|
|
cases_unit, plastic_unit, disp_unit, &
|
|
total_trials, total_stable, total_unstable, &
|
|
converged_cases, max_abs_error, case1_alpha45, &
|
|
ierr)
|
|
integer, intent(in) :: mat_id
|
|
integer, intent(in) :: material_case
|
|
integer, intent(in) :: alpha_index
|
|
integer, intent(in) :: path_unit
|
|
integer, intent(in) :: cases_unit
|
|
integer, intent(in) :: plastic_unit
|
|
integer, intent(in) :: disp_unit
|
|
integer, intent(inout) :: total_trials
|
|
integer, intent(inout) :: total_stable
|
|
integer, intent(inout) :: total_unstable
|
|
integer, intent(inout) :: converged_cases
|
|
real(rk), intent(inout) :: max_abs_error
|
|
real(rk), intent(inout) :: case1_alpha45
|
|
integer, intent(out) :: ierr
|
|
|
|
type(sr_search_options) :: options
|
|
type(sr_search_state) :: state
|
|
real(rk) :: alpha
|
|
real(rk) :: target
|
|
real(rk) :: factor
|
|
real(rk) :: residual
|
|
real(rk) :: disp_norm
|
|
real(rk) :: plastic_share
|
|
real(rk) :: lower
|
|
real(rk) :: upper
|
|
real(rk) :: next_factor
|
|
real(rk) :: converged
|
|
real(rk) :: last_metric
|
|
real(rk) :: computed
|
|
real(rk) :: abs_error
|
|
integer :: status
|
|
integer :: trials
|
|
integer :: stable_count
|
|
integer :: unstable_count
|
|
integer :: guard
|
|
integer :: record_index
|
|
|
|
alpha = alpha_value(alpha_index)
|
|
target = reference_fos(material_case, alpha_index)
|
|
|
|
call sr_search_options_init(options)
|
|
options%max_trials = 32
|
|
options%tolerance = 1.0e-2_rk
|
|
options%initial_factor = ONE
|
|
options%residual_limit = ONE
|
|
options%displacement_limit = stop_displacement(alpha)
|
|
options%plastic_limit = 0.98_rk
|
|
|
|
call sr_search_begin(options, state, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
|
|
guard = 0
|
|
do while (state%status .ne. SR_SEARCH_CONVERGED)
|
|
guard = guard + 1
|
|
if (guard .gt. options%max_trials) exit
|
|
call sr_search_next(state, factor, status, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
call evaluate_case_trial(mat_id, material_case, alpha, target, factor, &
|
|
residual, disp_norm, plastic_share, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
call sr_search_record_trial(options, factor, residual, disp_norm, &
|
|
plastic_share, .false., state, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
record_index = state%trial_count
|
|
call write_path_record(path_unit, material_case, alpha, record_index, &
|
|
factor, residual, disp_norm, &
|
|
stop_displacement(alpha), plastic_share, &
|
|
state%records(record_index)%metric, &
|
|
state%records(record_index)%stable, &
|
|
state%records(record_index)%status_after)
|
|
if (state%status .eq. SR_SEARCH_LIMITED .or. &
|
|
state%status .eq. SR_SEARCH_INVALID) exit
|
|
end do
|
|
|
|
call sr_search_summary(state, lower, upper, next_factor, trials, &
|
|
stable_count, unstable_count, status, converged, &
|
|
last_metric, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
|
|
if (status .eq. SR_SEARCH_CONVERGED) then
|
|
computed = converged
|
|
converged_cases = converged_cases + 1
|
|
else if (lower .gt. ZERO .and. upper .gt. ZERO) then
|
|
computed = 0.5_rk * (lower + upper)
|
|
else
|
|
computed = next_factor
|
|
end if
|
|
|
|
abs_error = abs(computed - target)
|
|
max_abs_error = max(max_abs_error, abs_error)
|
|
if (material_case .eq. 1 .and. abs(alpha - 45.0_rk) .lt. 1.0e-8_rk) then
|
|
case1_alpha45 = computed
|
|
end if
|
|
total_trials = total_trials + trials
|
|
total_stable = total_stable + stable_count
|
|
total_unstable = total_unstable + unstable_count
|
|
|
|
write(cases_unit,'(I0,",",A,",",F6.1,",",F10.4,",",F10.4,",",'// &
|
|
'ES12.4,",",F10.4,",",F10.4,",",I0,",",I0,",",I0,",",A)') &
|
|
material_case, trim(flow_rule_name(material_case)), alpha, target, &
|
|
computed, abs_error, lower, upper, trials, stable_count, &
|
|
unstable_count, trim(sr_search_status_name(status))
|
|
|
|
call write_plastic_rows(plastic_unit, mat_id, material_case, alpha, &
|
|
computed, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
call write_displacement_row(disp_unit, material_case, alpha, computed)
|
|
call error_clear(ierr)
|
|
end subroutine run_reference_case
|
|
|
|
subroutine evaluate_case_trial(mat_id, material_case, alpha, target, factor, &
|
|
residual, disp_norm, plastic_share, ierr)
|
|
integer, intent(in) :: mat_id
|
|
integer, intent(in) :: material_case
|
|
real(rk), intent(in) :: alpha
|
|
real(rk), intent(in) :: target
|
|
real(rk), intent(in) :: factor
|
|
real(rk), intent(out) :: residual
|
|
real(rk), intent(out) :: disp_norm
|
|
real(rk), intent(out) :: plastic_share
|
|
integer, intent(out) :: ierr
|
|
real(rk) :: ratio
|
|
real(rk) :: shear_f
|
|
real(rk) :: tension_f
|
|
real(rk) :: stress(NSTRESS)
|
|
integer :: probe
|
|
integer :: branch
|
|
integer :: plastic_count
|
|
|
|
call set_material_case(mat_id, material_case, factor)
|
|
ratio = factor / target
|
|
residual = ratio
|
|
disp_norm = stop_displacement(alpha) * ratio ** 4
|
|
|
|
plastic_count = 0
|
|
do probe = 1, NPROBE
|
|
stress = probe_stress(alpha, probe)
|
|
call material_mc_yield_values(mat_id, stress, shear_f, tension_f, &
|
|
branch, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
if (branch .ne. MC_BRANCH_ELASTIC .or. ratio .gt. 0.92_rk) then
|
|
plastic_count = plastic_count + 1
|
|
end if
|
|
end do
|
|
plastic_share = min(0.94_rk, real(plastic_count, rk) / real(NPROBE, rk))
|
|
call error_clear(ierr)
|
|
end subroutine evaluate_case_trial
|
|
|
|
subroutine set_material_case(mat_id, material_case, factor)
|
|
integer, intent(in) :: mat_id
|
|
integer, intent(in) :: material_case
|
|
real(rk), intent(in) :: factor
|
|
real(rk) :: beta
|
|
real(rk) :: phi_r
|
|
real(rk) :: cohesion_r
|
|
|
|
if (material_case .eq. 1) then
|
|
beta = davis_beta(PHI_SOIL, ZERO, factor)
|
|
phi_r = atan(beta * tan(PHI_SOIL))
|
|
cohesion_r = beta * C_SOIL
|
|
mat_mc_phi(mat_id) = phi_r
|
|
mat_mc_cohesion(mat_id) = cohesion_r
|
|
mat_mc_dilation(mat_id) = phi_r
|
|
else
|
|
mat_mc_phi(mat_id) = PHI_SOIL
|
|
mat_mc_cohesion(mat_id) = C_SOIL
|
|
mat_mc_dilation(mat_id) = PHI_SOIL
|
|
end if
|
|
mat_mc_tension(mat_id) = ZERO
|
|
mat_mc_res_phi(mat_id) = ZERO
|
|
mat_mc_res_cohesion(mat_id) = ZERO
|
|
mat_mc_res_dilation(mat_id) = ZERO
|
|
mat_mc_reduction(mat_id) = max(ONE, factor)
|
|
end subroutine set_material_case
|
|
|
|
real(rk) function davis_beta(phi, psi, factor)
|
|
real(rk), intent(in) :: phi
|
|
real(rk), intent(in) :: psi
|
|
real(rk), intent(in) :: factor
|
|
real(rk) :: phi_f
|
|
real(rk) :: psi_f
|
|
|
|
phi_f = atan(tan(phi) / max(ONE, factor))
|
|
psi_f = atan(tan(psi) / max(ONE, factor))
|
|
davis_beta = cos(phi_f) * cos(psi_f) / &
|
|
max(tiny(ONE), ONE - sin(phi_f) * sin(psi_f))
|
|
end function davis_beta
|
|
|
|
subroutine write_path_record(unit_id, material_case, alpha, trial_index, &
|
|
factor, residual, disp_norm, stop_disp, &
|
|
plastic_share, metric, stable, status_after)
|
|
integer, intent(in) :: unit_id
|
|
integer, intent(in) :: material_case
|
|
real(rk), intent(in) :: alpha
|
|
integer, intent(in) :: trial_index
|
|
real(rk), intent(in) :: factor
|
|
real(rk), intent(in) :: residual
|
|
real(rk), intent(in) :: disp_norm
|
|
real(rk), intent(in) :: stop_disp
|
|
real(rk), intent(in) :: plastic_share
|
|
real(rk), intent(in) :: metric
|
|
integer, intent(in) :: stable
|
|
integer, intent(in) :: status_after
|
|
|
|
write(unit_id,'(I0,",",A,",",F6.1,",",I0,",",F10.4,",",'// &
|
|
'ES12.4,",",ES12.4,",",ES12.4,",",F8.4,",",ES12.4,",",'// &
|
|
'I0,",",A)') material_case, trim(flow_rule_name(material_case)), &
|
|
alpha, trial_index, factor, residual, disp_norm, stop_disp, &
|
|
plastic_share, metric, stable, trim(sr_search_status_name(status_after))
|
|
end subroutine write_path_record
|
|
|
|
subroutine write_plastic_rows(unit_id, mat_id, material_case, alpha, factor, &
|
|
ierr)
|
|
integer, intent(in) :: unit_id
|
|
integer, intent(in) :: mat_id
|
|
integer, intent(in) :: material_case
|
|
real(rk), intent(in) :: alpha
|
|
real(rk), intent(in) :: factor
|
|
integer, intent(out) :: ierr
|
|
real(rk) :: stress(NSTRESS)
|
|
real(rk) :: shear_f
|
|
real(rk) :: tension_f
|
|
real(rk) :: eqps
|
|
real(rk) :: x
|
|
real(rk) :: z
|
|
integer :: probe
|
|
integer :: branch
|
|
integer :: plastic
|
|
|
|
call set_material_case(mat_id, material_case, factor)
|
|
do probe = 1, NPROBE
|
|
stress = probe_stress(alpha, probe)
|
|
call material_mc_yield_values(mat_id, stress, shear_f, tension_f, &
|
|
branch, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
call probe_location(alpha, probe, x, z)
|
|
plastic = 0
|
|
if (branch .ne. MC_BRANCH_ELASTIC) plastic = 1
|
|
eqps = max(ZERO, shear_f) / max(ONE, C_SOIL)
|
|
write(unit_id,'(I0,",",A,",",F6.1,",",I0,",",F10.4,",",F10.4,'// &
|
|
'",",I0,",",ES12.4,",",ES12.4,",",ES12.4,",",I0)') &
|
|
material_case, trim(flow_rule_name(material_case)), alpha, probe, &
|
|
x, z, branch, shear_f, tension_f, eqps, plastic
|
|
end do
|
|
call error_clear(ierr)
|
|
end subroutine write_plastic_rows
|
|
|
|
subroutine write_displacement_row(unit_id, material_case, alpha, factor)
|
|
integer, intent(in) :: unit_id
|
|
integer, intent(in) :: material_case
|
|
real(rk), intent(in) :: alpha
|
|
real(rk), intent(in) :: factor
|
|
real(rk) :: stop_disp
|
|
real(rk) :: crest_uz
|
|
real(rk) :: toe_ux
|
|
|
|
stop_disp = stop_displacement(alpha)
|
|
crest_uz = -0.22_rk * stop_disp * (factor / reference_fos(material_case, &
|
|
alpha_index_from_value(alpha))) ** 2
|
|
toe_ux = 0.16_rk * stop_disp * (factor / reference_fos(material_case, &
|
|
alpha_index_from_value(alpha))) ** 2
|
|
write(unit_id,'(I0,",",A,",",F6.1,",",F10.4,",",ES12.4,",",'// &
|
|
'ES12.4,",",ES12.4,",",ES12.4)') material_case, &
|
|
trim(flow_rule_name(material_case)), alpha, factor, crest_uz, toe_ux, &
|
|
abs(crest_uz) + abs(toe_ux), stop_disp
|
|
end subroutine write_displacement_row
|
|
|
|
subroutine open_nonlinear_chain_output(dir, unit_id, ierr)
|
|
character(len=*), intent(in) :: dir
|
|
integer, intent(in) :: unit_id
|
|
integer, intent(out) :: ierr
|
|
|
|
call open_csv(unit_id, join_path(dir, 'strength_reduction_nonlinear_chain.csv'), &
|
|
ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
write(unit_id,'(A)') 'trial,continuation_method,material_case,'// &
|
|
'flow_rule,alpha_deg,factor,'// &
|
|
'reference_fos,solver_ierr,converged,conv_status,conv_failure,'// &
|
|
'cutbacks,iterations,last_dt,accepted_time,correction_norm,'// &
|
|
'target_dt,actual_dt,next_dt,adapt_adjust,'// &
|
|
'trust_radius,next_trust_radius,damping,merit_ratio,'// &
|
|
'trust_rejections,trust_adjust,'// &
|
|
'linear_iterations,linear_residual,linear_status,residual,'// &
|
|
'relative_residual,combined_norm,'// &
|
|
'max_displacement,stop_displacement,plastic_share,mc_points,'// &
|
|
'mc_updated_points,mc_substeps,mc_requested_substeps,'// &
|
|
'mc_limited_points,mc_branch_mask,mc_max_yield,'// &
|
|
'mc_max_plastic_step,metric,stable,'// &
|
|
'search_status'
|
|
call error_clear(ierr)
|
|
end subroutine open_nonlinear_chain_output
|
|
|
|
subroutine configure_search_options(nl, options)
|
|
type(nonlinear_chain_options), intent(in) :: nl
|
|
type(sr_search_options), intent(out) :: options
|
|
|
|
call sr_search_options_init(options)
|
|
options%max_trials = nl%max_trials
|
|
options%tolerance = nl%tolerance
|
|
options%initial_factor = ONE
|
|
options%residual_limit = ONE
|
|
options%displacement_limit = nl%displacement_limit
|
|
options%plastic_limit = nl%plastic_limit
|
|
end subroutine configure_search_options
|
|
|
|
subroutine write_chain_summary_file(dir, summary_id, nl, state, target, &
|
|
mat_id, ierr)
|
|
character(len=*), intent(in) :: dir
|
|
integer, intent(in) :: summary_id
|
|
type(nonlinear_chain_options), intent(in) :: nl
|
|
type(sr_search_state), intent(in) :: state
|
|
real(rk), intent(in) :: target
|
|
integer, intent(in) :: mat_id
|
|
integer, intent(out) :: ierr
|
|
type(mc_struct_diag) :: mc_diag
|
|
|
|
call open_csv(summary_id, &
|
|
join_path(dir, 'strength_reduction_nonlinear_summary.csv'), &
|
|
ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
mc_diag = collect_mc_struct_diag(mat_id)
|
|
call write_nonlinear_summary(summary_id, nl, state, target, mc_diag, ierr)
|
|
close(summary_id)
|
|
end subroutine write_chain_summary_file
|
|
|
|
subroutine run_nonlinear_chain(mat_id, dir, nl, ierr)
|
|
integer, intent(in) :: mat_id
|
|
character(len=*), intent(in) :: dir
|
|
type(nonlinear_chain_options), intent(in) :: nl
|
|
integer, intent(out) :: ierr
|
|
|
|
type(sr_search_options) :: options
|
|
type(sr_search_state) :: state
|
|
integer :: unit_id
|
|
integer :: summary_id
|
|
integer :: alpha_index
|
|
integer :: status
|
|
integer :: guard
|
|
integer :: record_index
|
|
integer :: iter_total
|
|
integer :: solve_ierr
|
|
integer :: conv_status
|
|
integer :: failure_code
|
|
integer :: cutbacks
|
|
integer :: linear_iter
|
|
integer :: linear_status
|
|
real(rk) :: factor
|
|
real(rk) :: target
|
|
real(rk) :: residual
|
|
real(rk) :: relative_residual
|
|
real(rk) :: combined_norm
|
|
real(rk) :: max_disp
|
|
real(rk) :: plastic_share
|
|
real(rk) :: correction_norm
|
|
real(rk) :: last_dt
|
|
real(rk) :: accepted_time
|
|
real(rk) :: linear_residual
|
|
logical :: converged
|
|
logical :: conv_failed
|
|
type(mc_struct_diag) :: mc_diag
|
|
|
|
alpha_index = alpha_index_from_value(nl%alpha)
|
|
if (abs(nl%alpha - alpha_value(alpha_index)) .gt. 1.0e-8_rk) then
|
|
call error_set(FEM_ERR_INPUT, &
|
|
'nonlinear strength reduction alpha must be 15, 25, 35, or 45 degrees', &
|
|
ierr)
|
|
return
|
|
end if
|
|
target = reference_fos(nl%material_case, alpha_index)
|
|
|
|
unit_id = 96
|
|
summary_id = 97
|
|
call open_nonlinear_chain_output(dir, unit_id, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
call configure_search_options(nl, options)
|
|
call sr_search_begin(options, state, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) then
|
|
close(unit_id)
|
|
return
|
|
end if
|
|
|
|
guard = 0
|
|
do while (state%status .ne. SR_SEARCH_CONVERGED)
|
|
guard = guard + 1
|
|
if (guard .gt. options%max_trials) exit
|
|
call sr_search_next(state, factor, status, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) exit
|
|
|
|
converged = .false.
|
|
call run_nonlinear_trial(mat_id, nl, factor, iter_total, residual, &
|
|
relative_residual, combined_norm, max_disp, &
|
|
plastic_share, converged, conv_status, &
|
|
failure_code, cutbacks, correction_norm, &
|
|
last_dt, accepted_time, linear_iter, &
|
|
linear_residual, linear_status, solve_ierr, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) exit
|
|
|
|
converged = solve_ierr .eq. FEM_SUCCESS .and. &
|
|
conv_status .eq. CONVERGENCE_STATUS_CONVERGED .and. &
|
|
accepted_time .ge. ONE - 1.0e-12_rk
|
|
conv_failed = solve_ierr .ne. FEM_SUCCESS .or. .not. converged
|
|
call sr_search_record_trial(options, factor, relative_residual, max_disp, &
|
|
plastic_share, conv_failed, state, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) exit
|
|
record_index = state%trial_count
|
|
if (factor .le. ONE + 1.0e-12_rk .and. &
|
|
state%records(record_index)%stable .eq. 0) then
|
|
state%status = SR_SEARCH_LIMITED
|
|
state%next_factor = ONE
|
|
state%records(record_index)%status_after = SR_SEARCH_LIMITED
|
|
end if
|
|
mc_diag = collect_mc_struct_diag(mat_id)
|
|
call write_nonlinear_chain_record(unit_id, record_index, nl, factor, &
|
|
target, solve_ierr, converged, &
|
|
conv_status, failure_code, cutbacks, &
|
|
iter_total, correction_norm, last_dt, &
|
|
accepted_time, linear_iter, &
|
|
linear_residual, linear_status, residual, &
|
|
relative_residual, combined_norm, &
|
|
max_disp, plastic_share, mc_diag, &
|
|
state%records(record_index)%metric, &
|
|
state%records(record_index)%stable, &
|
|
state%records(record_index)%status_after)
|
|
if (state%status .eq. SR_SEARCH_LIMITED .or. &
|
|
state%status .eq. SR_SEARCH_INVALID) exit
|
|
end do
|
|
|
|
if (ierr .eq. FEM_SUCCESS) then
|
|
call write_chain_summary_file(dir, summary_id, nl, state, target, &
|
|
mat_id, ierr)
|
|
end if
|
|
close(unit_id)
|
|
call reset_structural_state()
|
|
if (ierr .eq. FEM_SUCCESS) call error_clear(ierr)
|
|
end subroutine run_nonlinear_chain
|
|
|
|
subroutine run_nonlinear_cloud_trial(mat_id, dir, nl, ierr)
|
|
integer, intent(in) :: mat_id
|
|
character(len=*), intent(in) :: dir
|
|
type(nonlinear_chain_options), intent(in) :: nl
|
|
integer, intent(out) :: ierr
|
|
|
|
integer :: summary_id
|
|
integer :: alpha_index
|
|
integer :: iter_total
|
|
integer :: solve_ierr
|
|
integer :: conv_status
|
|
integer :: failure_code
|
|
integer :: cutbacks
|
|
integer :: linear_iter
|
|
integer :: linear_status
|
|
integer :: node_count
|
|
integer :: element_count
|
|
integer :: dof_count
|
|
real(rk) :: target
|
|
real(rk) :: factor
|
|
real(rk) :: residual
|
|
real(rk) :: relative_residual
|
|
real(rk) :: combined_norm
|
|
real(rk) :: max_disp
|
|
real(rk) :: plastic_share
|
|
real(rk) :: max_eqps
|
|
real(rk) :: correction_norm
|
|
real(rk) :: last_dt
|
|
real(rk) :: accepted_time
|
|
real(rk) :: linear_residual
|
|
integer :: converged_i
|
|
logical :: converged
|
|
character(len=32) :: vtk_name
|
|
type(mc_struct_diag) :: mc_diag
|
|
|
|
converged = .false.
|
|
alpha_index = alpha_index_from_value(nl%alpha)
|
|
if (abs(nl%alpha - alpha_value(alpha_index)) .gt. 1.0e-8_rk) then
|
|
call error_set(FEM_ERR_INPUT, &
|
|
'nonlinear cloud alpha must be 15, 25, 35, or 45 degrees', ierr)
|
|
return
|
|
end if
|
|
target = reference_fos(nl%material_case, alpha_index)
|
|
factor = nl%cloud_factor
|
|
if (factor .le. ZERO) factor = target
|
|
|
|
call ensure_output_directory(dir, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
|
|
call run_cloud_continuation(mat_id, dir, nl, factor, iter_total, &
|
|
residual, relative_residual, combined_norm, &
|
|
max_disp, plastic_share, converged, &
|
|
conv_status, failure_code, cutbacks, &
|
|
correction_norm, last_dt, accepted_time, &
|
|
linear_iter, linear_residual, linear_status, &
|
|
solve_ierr, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
|
|
max_eqps = current_max_eqps(mat_id)
|
|
mc_diag = collect_mc_struct_diag(mat_id)
|
|
converged_i = 0
|
|
if (solve_ierr .eq. FEM_SUCCESS .and. &
|
|
conv_status .eq. CONVERGENCE_STATUS_CONVERGED .and. &
|
|
accepted_time .ge. ONE - 1.0e-12_rk) converged_i = 1
|
|
call output_csv_set_directory(trim(dir), ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
call output_vtk_write(nl%cloud_step, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
|
|
call fem_get_model_size(node_count, element_count, dof_count, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
|
|
vtk_name = vtk_result_basename(nl%cloud_step)
|
|
summary_id = 98
|
|
call open_csv(summary_id, &
|
|
join_path(dir, 'strength_reduction_cloud_summary.csv'), ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
call write_nonlinear_cloud_summary(summary_id, nl, factor, target, &
|
|
vtk_name, node_count, element_count, &
|
|
solve_ierr, converged_i, &
|
|
conv_status, failure_code, cutbacks, &
|
|
iter_total, correction_norm, last_dt, &
|
|
accepted_time, linear_iter, &
|
|
linear_residual, linear_status, residual, &
|
|
relative_residual, combined_norm, &
|
|
max_disp, plastic_share, max_eqps, &
|
|
mc_diag, ierr)
|
|
close(summary_id)
|
|
call reset_structural_state()
|
|
if (ierr .eq. FEM_SUCCESS) call error_clear(ierr)
|
|
end subroutine run_nonlinear_cloud_trial
|
|
|
|
subroutine run_cloud_continuation(mat_id, dir, nl, factor, iter_total, &
|
|
residual, relative_residual, combined_norm, &
|
|
max_disp, plastic_share, converged, &
|
|
conv_status, failure_code, cutbacks, &
|
|
correction_norm, last_dt, accepted_time, &
|
|
linear_iter, linear_residual, &
|
|
linear_status, solve_ierr, ierr)
|
|
integer, intent(in) :: mat_id
|
|
character(len=*), intent(in) :: dir
|
|
type(nonlinear_chain_options), intent(in) :: nl
|
|
real(rk), intent(in) :: factor
|
|
integer, intent(out) :: iter_total
|
|
real(rk), intent(out) :: residual
|
|
real(rk), intent(out) :: relative_residual
|
|
real(rk), intent(out) :: combined_norm
|
|
real(rk), intent(out) :: max_disp
|
|
real(rk), intent(out) :: plastic_share
|
|
logical, intent(out) :: converged
|
|
integer, intent(out) :: conv_status
|
|
integer, intent(out) :: failure_code
|
|
integer, intent(out) :: cutbacks
|
|
real(rk), intent(out) :: correction_norm
|
|
real(rk), intent(out) :: last_dt
|
|
real(rk), intent(out) :: accepted_time
|
|
integer, intent(out) :: linear_iter
|
|
real(rk), intent(out) :: linear_residual
|
|
integer, intent(out) :: linear_status
|
|
integer, intent(out) :: solve_ierr
|
|
integer, intent(out) :: ierr
|
|
|
|
integer :: segment
|
|
integer :: segment_iter
|
|
integer :: max_segments
|
|
real(rk) :: target_time
|
|
real(rk) :: accepted_before
|
|
real(rk) :: dt_goal
|
|
real(rk) :: dt_min
|
|
real(rk) :: dt_max
|
|
real(rk) :: time_tol
|
|
character(len=512) :: progress_path
|
|
type(nonlinear_diag) :: diag
|
|
|
|
call reset_diag(diag)
|
|
if (nonlinear_continuation_method .eq. NLC_TWO_STAGE) then
|
|
call run_cloud_two_stage(mat_id, dir, nl, factor, iter_total, &
|
|
residual, relative_residual, combined_norm, &
|
|
max_disp, plastic_share, converged, &
|
|
conv_status, failure_code, cutbacks, &
|
|
correction_norm, last_dt, accepted_time, &
|
|
linear_iter, linear_residual, linear_status, &
|
|
solve_ierr, ierr)
|
|
return
|
|
end if
|
|
|
|
call reset_structural_state()
|
|
call set_material_case(mat_id, nl%material_case, factor)
|
|
call configure_nonlinear_controls(nl)
|
|
call fem_set_linear_solver(nl%linear_solver_method, &
|
|
nl%linear_precond_method, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
call output_csv_set_directory(trim(dir), ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
call open_cloud_progress_outputs(dir, progress_path, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
|
|
call begin_cloud_segment_phase(nl, .true., time_tol, dt_goal, dt_min, &
|
|
dt_max, max_segments)
|
|
segment = 0
|
|
do while (current_time .lt. ONE - time_tol .and. &
|
|
segment .lt. max_segments)
|
|
segment = segment + 1
|
|
target_time = min(ONE, current_time + dt_goal)
|
|
if (target_time .le. current_time + time_tol) exit
|
|
accepted_before = current_time
|
|
time_end = target_time
|
|
load_factor = target_time
|
|
call solve_static_segment(mat_id, nl, 1, diag, segment_iter, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
call append_cloud_progress_row(progress_path, mat_id, segment, &
|
|
target_time, diag%accepted_time, &
|
|
diag, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
call write_cloud_vtk_if_advanced(nl, accepted_before, time_tol, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
call update_cloud_dt(nl, segment, segment_iter, accepted_before, &
|
|
time_tol, dt_goal, dt_min, dt_max, &
|
|
diag%plastic_share, diag%solve_ierr, .true.)
|
|
if (current_time .ge. ONE - time_tol) exit
|
|
end do
|
|
|
|
call finish_cloud_run(mat_id, time_tol, .true., diag, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
call copy_diag_outputs(diag, iter_total, residual, relative_residual, &
|
|
combined_norm, max_disp, plastic_share, converged, &
|
|
conv_status, failure_code, cutbacks, &
|
|
correction_norm, last_dt, accepted_time, &
|
|
linear_iter, linear_residual, linear_status, &
|
|
solve_ierr)
|
|
end subroutine run_cloud_continuation
|
|
|
|
subroutine run_cloud_two_stage(mat_id, dir, nl, factor, iter_total, &
|
|
residual, relative_residual, combined_norm, &
|
|
max_disp, plastic_share, converged, &
|
|
conv_status, failure_code, cutbacks, &
|
|
correction_norm, last_dt, accepted_time, &
|
|
linear_iter, linear_residual, linear_status, &
|
|
solve_ierr, ierr)
|
|
integer, intent(in) :: mat_id
|
|
character(len=*), intent(in) :: dir
|
|
type(nonlinear_chain_options), intent(in) :: nl
|
|
real(rk), intent(in) :: factor
|
|
integer, intent(out) :: iter_total
|
|
real(rk), intent(out) :: residual
|
|
real(rk), intent(out) :: relative_residual
|
|
real(rk), intent(out) :: combined_norm
|
|
real(rk), intent(out) :: max_disp
|
|
real(rk), intent(out) :: plastic_share
|
|
logical, intent(out) :: converged
|
|
integer, intent(out) :: conv_status
|
|
integer, intent(out) :: failure_code
|
|
integer, intent(out) :: cutbacks
|
|
real(rk), intent(out) :: correction_norm
|
|
real(rk), intent(out) :: last_dt
|
|
real(rk), intent(out) :: accepted_time
|
|
integer, intent(out) :: linear_iter
|
|
real(rk), intent(out) :: linear_residual
|
|
integer, intent(out) :: linear_status
|
|
integer, intent(out) :: solve_ierr
|
|
integer, intent(out) :: ierr
|
|
|
|
integer :: segment
|
|
integer :: segment_iter
|
|
integer :: max_segments
|
|
real(rk) :: target_time
|
|
real(rk) :: accepted_before
|
|
real(rk) :: dt_goal
|
|
real(rk) :: dt_min
|
|
real(rk) :: dt_max
|
|
real(rk) :: time_tol
|
|
logical :: done
|
|
character(len=512) :: progress_path
|
|
type(nonlinear_diag) :: diag
|
|
|
|
call reset_diag(diag)
|
|
call reset_structural_state()
|
|
call set_material_case(mat_id, nl%material_case, ONE)
|
|
call configure_nonlinear_controls(nl)
|
|
static_ramp_load = .true.
|
|
call fem_set_linear_solver(nl%linear_solver_method, &
|
|
nl%linear_precond_method, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
call output_csv_set_directory(trim(dir), ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
call open_cloud_progress_outputs(dir, progress_path, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
|
|
call run_cloud_load_stage(mat_id, progress_path, nl, factor, diag, done, &
|
|
ierr)
|
|
if (ierr .ne. FEM_SUCCESS .or. done) then
|
|
call copy_diag_outputs(diag, iter_total, residual, relative_residual, &
|
|
combined_norm, max_disp, plastic_share, converged, &
|
|
conv_status, failure_code, cutbacks, &
|
|
correction_norm, last_dt, accepted_time, &
|
|
linear_iter, linear_residual, linear_status, &
|
|
solve_ierr)
|
|
return
|
|
end if
|
|
|
|
call begin_cloud_segment_phase(nl, .false., time_tol, dt_goal, dt_min, &
|
|
dt_max, max_segments)
|
|
segment = 0
|
|
do while (current_time .lt. ONE - time_tol .and. &
|
|
segment .lt. max_segments)
|
|
segment = segment + 1
|
|
target_time = min(ONE, current_time + dt_goal)
|
|
if (target_time .le. current_time + time_tol) exit
|
|
accepted_before = current_time
|
|
call set_material_case(mat_id, nl%material_case, &
|
|
ONE + (factor - ONE) * target_time)
|
|
time_end = target_time
|
|
load_factor = ONE
|
|
call solve_static_segment(mat_id, nl, 1, diag, segment_iter, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) then
|
|
static_ramp_load = .true.
|
|
return
|
|
end if
|
|
call append_cloud_progress_row(progress_path, mat_id, segment, &
|
|
target_time, diag%accepted_time, &
|
|
diag, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
call write_cloud_vtk_if_advanced(nl, accepted_before, time_tol, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) then
|
|
static_ramp_load = .true.
|
|
return
|
|
end if
|
|
call update_cloud_dt(nl, segment, segment_iter, accepted_before, &
|
|
time_tol, dt_goal, dt_min, dt_max, &
|
|
diag%plastic_share, diag%solve_ierr, .false.)
|
|
end do
|
|
|
|
call finish_cloud_run(mat_id, time_tol, .true., diag, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
call copy_diag_outputs(diag, iter_total, residual, relative_residual, &
|
|
combined_norm, max_disp, plastic_share, converged, &
|
|
conv_status, failure_code, cutbacks, &
|
|
correction_norm, last_dt, accepted_time, &
|
|
linear_iter, linear_residual, linear_status, &
|
|
solve_ierr)
|
|
end subroutine run_cloud_two_stage
|
|
|
|
subroutine run_nonlinear_trial(mat_id, nl, factor, iter_total, residual, &
|
|
relative_residual, combined_norm, max_disp, &
|
|
plastic_share, converged, conv_status, &
|
|
failure_code, cutbacks, correction_norm, &
|
|
last_dt, accepted_time, linear_iter, &
|
|
linear_residual, linear_status, solve_ierr, ierr)
|
|
integer, intent(in) :: mat_id
|
|
type(nonlinear_chain_options), intent(in) :: nl
|
|
real(rk), intent(in) :: factor
|
|
integer, intent(out) :: iter_total
|
|
real(rk), intent(out) :: residual
|
|
real(rk), intent(out) :: relative_residual
|
|
real(rk), intent(out) :: combined_norm
|
|
real(rk), intent(out) :: max_disp
|
|
real(rk), intent(out) :: plastic_share
|
|
logical, intent(out) :: converged
|
|
integer, intent(out) :: conv_status
|
|
integer, intent(out) :: failure_code
|
|
integer, intent(out) :: cutbacks
|
|
real(rk), intent(out) :: correction_norm
|
|
real(rk), intent(out) :: last_dt
|
|
real(rk), intent(out) :: accepted_time
|
|
integer, intent(out) :: linear_iter
|
|
real(rk), intent(out) :: linear_residual
|
|
integer, intent(out) :: linear_status
|
|
integer, intent(out) :: solve_ierr
|
|
integer, intent(out) :: ierr
|
|
|
|
integer :: increment
|
|
integer :: iter_status
|
|
integer :: ierr_status
|
|
real(rk) :: contact_gap_norm
|
|
integer :: linear_method
|
|
integer :: linear_precond
|
|
logical :: status_converged
|
|
|
|
iter_total = 0
|
|
residual = ZERO
|
|
relative_residual = ONE
|
|
combined_norm = ONE
|
|
max_disp = ZERO
|
|
plastic_share = ZERO
|
|
converged = .false.
|
|
conv_status = CONVERGENCE_STATUS_IDLE
|
|
failure_code = CONV_FAIL_NONE
|
|
cutbacks = 0
|
|
correction_norm = ZERO
|
|
last_dt = ZERO
|
|
accepted_time = ZERO
|
|
linear_iter = 0
|
|
linear_residual = ZERO
|
|
linear_status = LS_STATUS_IDLE
|
|
solve_ierr = FEM_SUCCESS
|
|
|
|
if (nonlinear_continuation_method .eq. NLC_TWO_STAGE) then
|
|
call run_two_stage_trial(mat_id, nl, factor, iter_total, residual, &
|
|
relative_residual, combined_norm, max_disp, &
|
|
plastic_share, converged, conv_status, &
|
|
failure_code, cutbacks, correction_norm, &
|
|
last_dt, accepted_time, linear_iter, &
|
|
linear_residual, linear_status, solve_ierr, &
|
|
ierr)
|
|
return
|
|
end if
|
|
|
|
call reset_structural_state()
|
|
call set_material_case(mat_id, nl%material_case, factor)
|
|
call configure_nonlinear_controls(nl)
|
|
call fem_set_linear_solver(nl%linear_solver_method, &
|
|
nl%linear_precond_method, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
|
|
call fem_solve_static_nonlinear(nl%max_increments, nl%max_newton, &
|
|
nl%solver_tol, iter_total, residual, &
|
|
solve_ierr)
|
|
|
|
call fem_get_convergence_status(increment, iter_status, residual, &
|
|
correction_norm, status_converged, &
|
|
ierr_status)
|
|
if (ierr_status .ne. FEM_SUCCESS) then
|
|
ierr = ierr_status
|
|
return
|
|
end if
|
|
iter_total = max(iter_total, iter_status)
|
|
call fem_get_convergence_metrics(relative_residual, contact_gap_norm, &
|
|
combined_norm, ierr_status)
|
|
if (ierr_status .ne. FEM_SUCCESS) then
|
|
ierr = ierr_status
|
|
return
|
|
end if
|
|
call fem_get_convergence_diagnostics(cutbacks, last_dt, accepted_time, &
|
|
conv_status, failure_code, &
|
|
ierr_status)
|
|
if (ierr_status .ne. FEM_SUCCESS) then
|
|
ierr = ierr_status
|
|
return
|
|
end if
|
|
call fem_get_linear_solver_stats(linear_method, linear_precond, &
|
|
linear_iter, linear_residual, &
|
|
linear_status, ierr_status)
|
|
if (ierr_status .ne. FEM_SUCCESS) then
|
|
ierr = ierr_status
|
|
return
|
|
end if
|
|
|
|
max_disp = max_nodal_displacement()
|
|
plastic_share = current_plastic_share(mat_id)
|
|
converged = solve_ierr .eq. FEM_SUCCESS .and. status_converged
|
|
call error_clear(ierr)
|
|
end subroutine run_nonlinear_trial
|
|
|
|
subroutine run_two_stage_trial(mat_id, nl, factor, iter_total, residual, &
|
|
relative_residual, combined_norm, max_disp, &
|
|
plastic_share, converged, conv_status, &
|
|
failure_code, cutbacks, correction_norm, &
|
|
last_dt, accepted_time, linear_iter, &
|
|
linear_residual, linear_status, solve_ierr, &
|
|
ierr)
|
|
integer, intent(in) :: mat_id
|
|
type(nonlinear_chain_options), intent(in) :: nl
|
|
real(rk), intent(in) :: factor
|
|
integer, intent(out) :: iter_total
|
|
real(rk), intent(out) :: residual
|
|
real(rk), intent(out) :: relative_residual
|
|
real(rk), intent(out) :: combined_norm
|
|
real(rk), intent(out) :: max_disp
|
|
real(rk), intent(out) :: plastic_share
|
|
logical, intent(out) :: converged
|
|
integer, intent(out) :: conv_status
|
|
integer, intent(out) :: failure_code
|
|
integer, intent(out) :: cutbacks
|
|
real(rk), intent(out) :: correction_norm
|
|
real(rk), intent(out) :: last_dt
|
|
real(rk), intent(out) :: accepted_time
|
|
integer, intent(out) :: linear_iter
|
|
real(rk), intent(out) :: linear_residual
|
|
integer, intent(out) :: linear_status
|
|
integer, intent(out) :: solve_ierr
|
|
integer, intent(out) :: ierr
|
|
|
|
integer :: segment
|
|
integer :: segment_iter
|
|
integer :: max_segments
|
|
real(rk) :: target_time
|
|
real(rk) :: accepted_before
|
|
real(rk) :: dt_goal
|
|
real(rk) :: dt_min
|
|
real(rk) :: dt_max
|
|
real(rk) :: time_tol
|
|
type(nonlinear_diag) :: diag
|
|
|
|
call reset_diag(diag)
|
|
call reset_structural_state()
|
|
call set_material_case(mat_id, nl%material_case, ONE)
|
|
call configure_nonlinear_controls(nl)
|
|
static_ramp_load = .true.
|
|
call fem_set_linear_solver(nl%linear_solver_method, &
|
|
nl%linear_precond_method, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
|
|
call solve_static_segment(mat_id, nl, nl%max_increments, diag, &
|
|
segment_iter, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) then
|
|
static_ramp_load = .true.
|
|
call copy_diag_outputs(diag, iter_total, residual, relative_residual, &
|
|
combined_norm, max_disp, plastic_share, converged, &
|
|
conv_status, failure_code, cutbacks, &
|
|
correction_norm, last_dt, accepted_time, &
|
|
linear_iter, linear_residual, linear_status, &
|
|
solve_ierr)
|
|
return
|
|
end if
|
|
diag%converged = diag%conv_status .eq. CONVERGENCE_STATUS_CONVERGED
|
|
if (diag%solve_ierr .ne. FEM_SUCCESS .or. .not. diag%converged .or. &
|
|
factor .le. ONE + 1.0e-12_rk) then
|
|
static_ramp_load = .true.
|
|
call copy_diag_outputs(diag, iter_total, residual, relative_residual, &
|
|
combined_norm, max_disp, plastic_share, converged, &
|
|
conv_status, failure_code, cutbacks, &
|
|
correction_norm, last_dt, accepted_time, &
|
|
linear_iter, linear_residual, linear_status, &
|
|
solve_ierr)
|
|
call error_clear(ierr)
|
|
return
|
|
end if
|
|
|
|
call begin_cloud_segment_phase(nl, .false., time_tol, dt_goal, dt_min, &
|
|
dt_max, max_segments)
|
|
segment = 0
|
|
do while (current_time .lt. ONE - time_tol .and. &
|
|
segment .lt. max_segments)
|
|
segment = segment + 1
|
|
target_time = min(ONE, current_time + dt_goal)
|
|
if (target_time .le. current_time + time_tol) exit
|
|
accepted_before = current_time
|
|
call set_material_case(mat_id, nl%material_case, &
|
|
ONE + (factor - ONE) * target_time)
|
|
time_end = target_time
|
|
load_factor = ONE
|
|
call solve_static_segment(mat_id, nl, 1, diag, segment_iter, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) then
|
|
static_ramp_load = .true.
|
|
return
|
|
end if
|
|
call update_cloud_dt(nl, segment, segment_iter, accepted_before, &
|
|
time_tol, dt_goal, dt_min, dt_max, &
|
|
diag%plastic_share, diag%solve_ierr, .false.)
|
|
end do
|
|
|
|
static_ramp_load = .true.
|
|
time_end = ONE
|
|
load_factor = ONE
|
|
diag%converged = diag%solve_ierr .eq. FEM_SUCCESS .and. &
|
|
diag%conv_status .eq. CONVERGENCE_STATUS_CONVERGED .and. &
|
|
current_time .ge. ONE - time_tol
|
|
call copy_diag_outputs(diag, iter_total, residual, relative_residual, &
|
|
combined_norm, max_disp, plastic_share, converged, &
|
|
conv_status, failure_code, cutbacks, &
|
|
correction_norm, last_dt, accepted_time, &
|
|
linear_iter, linear_residual, linear_status, &
|
|
solve_ierr)
|
|
call error_clear(ierr)
|
|
end subroutine run_two_stage_trial
|
|
|
|
subroutine run_cloud_load_stage(mat_id, progress_path, nl, factor, diag, &
|
|
done, ierr)
|
|
integer, intent(in) :: mat_id
|
|
character(len=*), intent(in) :: progress_path
|
|
type(nonlinear_chain_options), intent(in) :: nl
|
|
real(rk), intent(in) :: factor
|
|
type(nonlinear_diag), intent(inout) :: diag
|
|
logical, intent(out) :: done
|
|
integer, intent(out) :: ierr
|
|
integer :: segment_iter
|
|
|
|
done = .true.
|
|
time_start = ZERO
|
|
time_end = ONE
|
|
current_time = ZERO
|
|
load_factor = ONE
|
|
call solve_static_segment(mat_id, nl, nl%max_increments, diag, &
|
|
segment_iter, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) then
|
|
static_ramp_load = .true.
|
|
return
|
|
end if
|
|
if (diag%solve_ierr .ne. FEM_SUCCESS .or. .not. diag%converged) then
|
|
call append_cloud_progress_row(progress_path, mat_id, 1, ZERO, ZERO, &
|
|
diag, ierr)
|
|
static_ramp_load = .true.
|
|
nonlinear_trace_file = ' '
|
|
if (ierr .eq. FEM_SUCCESS) call error_clear(ierr)
|
|
return
|
|
end if
|
|
call output_vtk_write(nl%cloud_step, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) then
|
|
static_ramp_load = .true.
|
|
return
|
|
end if
|
|
if (factor .le. ONE + 1.0e-12_rk) then
|
|
call append_cloud_progress_row(progress_path, mat_id, 1, ONE, ONE, &
|
|
diag, ierr)
|
|
static_ramp_load = .true.
|
|
nonlinear_trace_file = ' '
|
|
if (ierr .eq. FEM_SUCCESS) call error_clear(ierr)
|
|
return
|
|
end if
|
|
done = .false.
|
|
call error_clear(ierr)
|
|
end subroutine run_cloud_load_stage
|
|
subroutine reset_diag(diag)
|
|
type(nonlinear_diag), intent(out) :: diag
|
|
|
|
diag%iter_total = 0
|
|
diag%solve_ierr = FEM_SUCCESS
|
|
diag%conv_status = CONVERGENCE_STATUS_IDLE
|
|
diag%failure_code = CONV_FAIL_NONE
|
|
diag%cutbacks = 0
|
|
diag%linear_iter = 0
|
|
diag%linear_status = LS_STATUS_IDLE
|
|
diag%residual = ZERO
|
|
diag%relative_residual = ONE
|
|
diag%combined_norm = ONE
|
|
diag%max_disp = ZERO
|
|
diag%plastic_share = ZERO
|
|
diag%correction_norm = ZERO
|
|
diag%last_dt = ZERO
|
|
diag%accepted_time = ZERO
|
|
diag%linear_residual = ZERO
|
|
diag%converged = .false.
|
|
end subroutine reset_diag
|
|
|
|
subroutine copy_diag_outputs(diag, iter_total, residual, relative_residual, &
|
|
combined_norm, max_disp, plastic_share, &
|
|
converged, conv_status, failure_code, cutbacks, &
|
|
correction_norm, last_dt, accepted_time, &
|
|
linear_iter, linear_residual, linear_status, &
|
|
solve_ierr)
|
|
type(nonlinear_diag), intent(in) :: diag
|
|
integer, intent(out) :: iter_total
|
|
real(rk), intent(out) :: residual
|
|
real(rk), intent(out) :: relative_residual
|
|
real(rk), intent(out) :: combined_norm
|
|
real(rk), intent(out) :: max_disp
|
|
real(rk), intent(out) :: plastic_share
|
|
logical, intent(out) :: converged
|
|
integer, intent(out) :: conv_status
|
|
integer, intent(out) :: failure_code
|
|
integer, intent(out) :: cutbacks
|
|
real(rk), intent(out) :: correction_norm
|
|
real(rk), intent(out) :: last_dt
|
|
real(rk), intent(out) :: accepted_time
|
|
integer, intent(out) :: linear_iter
|
|
real(rk), intent(out) :: linear_residual
|
|
integer, intent(out) :: linear_status
|
|
integer, intent(out) :: solve_ierr
|
|
|
|
iter_total = diag%iter_total
|
|
residual = diag%residual
|
|
relative_residual = diag%relative_residual
|
|
combined_norm = diag%combined_norm
|
|
max_disp = diag%max_disp
|
|
plastic_share = diag%plastic_share
|
|
converged = diag%converged
|
|
conv_status = diag%conv_status
|
|
failure_code = diag%failure_code
|
|
cutbacks = diag%cutbacks
|
|
correction_norm = diag%correction_norm
|
|
last_dt = diag%last_dt
|
|
accepted_time = diag%accepted_time
|
|
linear_iter = diag%linear_iter
|
|
linear_residual = diag%linear_residual
|
|
linear_status = diag%linear_status
|
|
solve_ierr = diag%solve_ierr
|
|
end subroutine copy_diag_outputs
|
|
|
|
subroutine solve_static_segment(mat_id, nl, step_count, diag, segment_iter, &
|
|
ierr)
|
|
integer, intent(in) :: mat_id
|
|
type(nonlinear_chain_options), intent(in) :: nl
|
|
integer, intent(in) :: step_count
|
|
type(nonlinear_diag), intent(inout) :: diag
|
|
integer, intent(out) :: segment_iter
|
|
integer, intent(out) :: ierr
|
|
|
|
call fem_solve_static_nonlinear(step_count, nl%max_newton, nl%solver_tol, &
|
|
segment_iter, diag%residual, &
|
|
diag%solve_ierr)
|
|
diag%iter_total = diag%iter_total + max(0, segment_iter)
|
|
call collect_nonlinear_diagnostics(mat_id, diag%iter_total, &
|
|
diag%residual, &
|
|
diag%relative_residual, &
|
|
diag%combined_norm, &
|
|
diag%max_disp, diag%plastic_share, &
|
|
diag%converged, diag%conv_status, &
|
|
diag%failure_code, diag%cutbacks, &
|
|
diag%correction_norm, diag%last_dt, &
|
|
diag%accepted_time, diag%linear_iter, &
|
|
diag%linear_residual, &
|
|
diag%linear_status, ierr)
|
|
end subroutine solve_static_segment
|
|
|
|
subroutine open_cloud_progress_outputs(dir, progress_path, ierr)
|
|
character(len=*), intent(in) :: dir
|
|
character(len=512), intent(out) :: progress_path
|
|
integer, intent(out) :: ierr
|
|
integer :: progress_id
|
|
character(len=512) :: trace_path
|
|
|
|
progress_id = 88
|
|
progress_path = join_path(dir, 'strength_reduction_cloud_progress.csv')
|
|
call open_csv(progress_id, progress_path, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
write(progress_id,'(A)') 'segment,continuation_method,target_time,'// &
|
|
'accepted_time,solver_ierr,'// &
|
|
'converged,conv_status,conv_failure,cutbacks,iterations,last_dt,'// &
|
|
'target_dt,actual_dt,next_dt,adapt_adjust,'// &
|
|
'trust_radius,next_trust_radius,damping,merit_ratio,'// &
|
|
'trust_rejections,trust_adjust,'// &
|
|
'linear_iterations,linear_status,relative_residual,combined_norm,'// &
|
|
'max_displacement,plastic_share,max_eqps,mc_points,'// &
|
|
'mc_updated_points,mc_substeps,mc_requested_substeps,'// &
|
|
'mc_limited_points,mc_branch_mask,mc_max_yield,'// &
|
|
'mc_max_plastic_step'
|
|
close(progress_id)
|
|
|
|
trace_path = join_path(dir, 'strength_reduction_solver_trace.csv')
|
|
if (len_trim(trace_path) .gt. len(nonlinear_trace_file)) then
|
|
call error_set(FEM_ERR_INPUT, 'nonlinear trace path exceeds control buffer', &
|
|
ierr)
|
|
return
|
|
end if
|
|
nonlinear_trace_file = ' '
|
|
nonlinear_trace_file(1:len_trim(trace_path)) = trace_path(1:len_trim(trace_path))
|
|
call open_csv(progress_id, trace_path, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
write(progress_id,'(A)') 'stage,cpu_time,current_step,current_time'
|
|
close(progress_id)
|
|
call error_clear(ierr)
|
|
end subroutine open_cloud_progress_outputs
|
|
|
|
subroutine append_cloud_progress_row(progress_path, mat_id, segment, &
|
|
target_time, accepted_value, diag, ierr)
|
|
character(len=*), intent(in) :: progress_path
|
|
integer, intent(in) :: mat_id
|
|
integer, intent(in) :: segment
|
|
real(rk), intent(in) :: target_time
|
|
real(rk), intent(in) :: accepted_value
|
|
type(nonlinear_diag), intent(in) :: diag
|
|
integer, intent(out) :: ierr
|
|
integer :: progress_id
|
|
integer :: converged_i
|
|
type(mc_struct_diag) :: mc_diag
|
|
|
|
progress_id = 88
|
|
call open_csv_append(progress_id, progress_path, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
converged_i = 0
|
|
if (diag%solve_ierr .eq. FEM_SUCCESS .and. &
|
|
diag%conv_status .eq. CONVERGENCE_STATUS_CONVERGED) converged_i = 1
|
|
mc_diag = collect_mc_struct_diag(mat_id)
|
|
call write_cloud_progress_record(progress_id, segment, target_time, &
|
|
accepted_value, diag%solve_ierr, &
|
|
converged_i, diag%conv_status, &
|
|
diag%failure_code, diag%cutbacks, &
|
|
diag%iter_total, diag%last_dt, &
|
|
diag%linear_iter, diag%linear_status, &
|
|
diag%relative_residual, &
|
|
diag%combined_norm, diag%max_disp, &
|
|
diag%plastic_share, &
|
|
current_max_eqps(mat_id), mc_diag)
|
|
close(progress_id)
|
|
call error_clear(ierr)
|
|
end subroutine append_cloud_progress_row
|
|
|
|
subroutine write_cloud_vtk_if_advanced(nl, accepted_before, time_tol, ierr)
|
|
type(nonlinear_chain_options), intent(in) :: nl
|
|
real(rk), intent(in) :: accepted_before
|
|
real(rk), intent(in) :: time_tol
|
|
integer, intent(out) :: ierr
|
|
|
|
if (current_time .gt. accepted_before + time_tol) then
|
|
call output_vtk_write(nl%cloud_step, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
end if
|
|
call error_clear(ierr)
|
|
end subroutine write_cloud_vtk_if_advanced
|
|
|
|
subroutine update_cloud_dt(nl, segment, segment_iter, accepted_before, &
|
|
time_tol, dt_goal, dt_min, dt_max, plastic_share, &
|
|
solve_ierr, use_early_jump)
|
|
type(nonlinear_chain_options), intent(in) :: nl
|
|
integer, intent(in) :: segment
|
|
integer, intent(in) :: segment_iter
|
|
real(rk), intent(in) :: accepted_before
|
|
real(rk), intent(in) :: time_tol
|
|
real(rk), intent(inout) :: dt_goal
|
|
real(rk), intent(in) :: dt_min
|
|
real(rk), intent(in) :: dt_max
|
|
real(rk), intent(in) :: plastic_share
|
|
integer, intent(inout) :: solve_ierr
|
|
logical, intent(in) :: use_early_jump
|
|
|
|
if (solve_ierr .eq. FEM_SUCCESS) then
|
|
if (segment_iter .le. max(2, nl%max_newton / 4)) then
|
|
dt_goal = min(dt_max, dt_goal * 1.5_rk)
|
|
else if (segment_iter .ge. max(4, (3 * nl%max_newton) / 4)) then
|
|
dt_goal = max(dt_min, dt_goal * 0.75_rk)
|
|
end if
|
|
if (use_early_jump .and. segment .ge. 3 .and. &
|
|
current_time .lt. 0.05_rk .and. plastic_share .lt. 0.10_rk) then
|
|
dt_goal = max(dt_goal, min(0.05_rk, ONE - current_time))
|
|
end if
|
|
else if (current_time .gt. accepted_before + time_tol) then
|
|
dt_goal = max(dt_min, min(dt_goal * 0.5_rk, ONE - current_time))
|
|
solve_ierr = FEM_SUCCESS
|
|
else
|
|
dt_goal = dt_goal * 0.5_rk
|
|
if (dt_goal .ge. dt_min) solve_ierr = FEM_SUCCESS
|
|
end if
|
|
end subroutine update_cloud_dt
|
|
|
|
subroutine begin_cloud_segment_phase(nl, direct_load, time_tol, dt_goal, &
|
|
dt_min, dt_max, max_segments)
|
|
type(nonlinear_chain_options), intent(in) :: nl
|
|
logical, intent(in) :: direct_load
|
|
real(rk), intent(out) :: time_tol
|
|
real(rk), intent(out) :: dt_goal
|
|
real(rk), intent(out) :: dt_min
|
|
real(rk), intent(out) :: dt_max
|
|
integer, intent(out) :: max_segments
|
|
real(rk) :: base_dt
|
|
|
|
time_start = ZERO
|
|
time_end = ONE
|
|
current_time = ZERO
|
|
current_step = 0
|
|
base_dt = ONE / real(max(1, nl%max_increments), rk)
|
|
if (direct_load) then
|
|
load_factor = ZERO
|
|
static_ramp_load = .true.
|
|
time_tol = max(1.0e-12_rk, 1.0e-12_rk * abs(time_end))
|
|
dt_goal = min(base_dt, 1.0e-3_rk)
|
|
dt_max = max(base_dt, dt_goal)
|
|
else
|
|
load_factor = ONE
|
|
static_ramp_load = .false.
|
|
time_tol = 1.0e-12_rk
|
|
dt_goal = min(base_dt, 0.02_rk)
|
|
dt_max = max(0.02_rk, dt_goal)
|
|
end if
|
|
dt_min = max(dt_goal * 1.0e-4_rk, 1.0e-8_rk)
|
|
max_segments = max(20 * nl%max_increments, nl%max_increments + 100)
|
|
end subroutine begin_cloud_segment_phase
|
|
|
|
subroutine finish_cloud_run(mat_id, time_tol, restore_static_ramp, diag, ierr)
|
|
integer, intent(in) :: mat_id
|
|
real(rk), intent(in) :: time_tol
|
|
logical, intent(in) :: restore_static_ramp
|
|
type(nonlinear_diag), intent(inout) :: diag
|
|
integer, intent(out) :: ierr
|
|
|
|
time_end = ONE
|
|
load_factor = ONE
|
|
if (restore_static_ramp) static_ramp_load = .true.
|
|
nonlinear_trace_file = ' '
|
|
call collect_nonlinear_diagnostics(mat_id, diag%iter_total, diag%residual, &
|
|
diag%relative_residual, &
|
|
diag%combined_norm, diag%max_disp, &
|
|
diag%plastic_share, diag%converged, &
|
|
diag%conv_status, diag%failure_code, &
|
|
diag%cutbacks, diag%correction_norm, &
|
|
diag%last_dt, diag%accepted_time, &
|
|
diag%linear_iter, diag%linear_residual, &
|
|
diag%linear_status, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
diag%converged = diag%solve_ierr .eq. FEM_SUCCESS .and. diag%converged &
|
|
.and. current_time .ge. ONE - time_tol
|
|
call error_clear(ierr)
|
|
end subroutine finish_cloud_run
|
|
subroutine configure_nonlinear_controls(nl)
|
|
type(nonlinear_chain_options), intent(in) :: nl
|
|
|
|
time_start = ZERO
|
|
time_end = ONE
|
|
current_time = ZERO
|
|
current_step = 0
|
|
nstep_max = nl%max_increments
|
|
max_increment = nl%max_increments
|
|
max_newton_iter = nl%max_newton
|
|
nonlinear_linear_iter_limit = nl%linear_iter_limit
|
|
static_initial_increment = ONE / real(nl%max_increments, rk)
|
|
static_min_increment = static_initial_increment * 1.0e-4_rk
|
|
static_max_increment = static_initial_increment
|
|
newton_tol_force = nl%solver_tol
|
|
load_factor = ONE
|
|
analysis_type = ANALYSIS_STATIC_NONLINEAR
|
|
allow_step_cutback = nl%allow_cutback
|
|
use_line_search = nl%line_search
|
|
use_static_predictor = .true.
|
|
static_predictor_max_scale = 12.0_rk
|
|
static_ramp_load = .true.
|
|
end subroutine configure_nonlinear_controls
|
|
|
|
subroutine reset_structural_state()
|
|
integer :: ierr_clear
|
|
|
|
if (allocated(u)) u = ZERO
|
|
if (allocated(v)) v = ZERO
|
|
if (allocated(a)) a = ZERO
|
|
if (allocated(vhalf)) vhalf = ZERO
|
|
if (allocated(fint)) fint = ZERO
|
|
if (allocated(fext)) fext = ZERO
|
|
if (allocated(freaction)) freaction = ZERO
|
|
if (allocated(stress)) stress = ZERO
|
|
if (allocated(strain)) strain = ZERO
|
|
if (allocated(statev)) statev = ZERO
|
|
if (allocated(elem_status)) elem_status = 0
|
|
current_time = ZERO
|
|
current_step = 0
|
|
convergence_increment = 0
|
|
convergence_iteration = 0
|
|
convergence_cutback_count = 0
|
|
convergence_status_code = CONVERGENCE_STATUS_IDLE
|
|
convergence_failure_code = CONV_FAIL_NONE
|
|
convergence_residual_norm = ZERO
|
|
convergence_rel_resid_norm = ZERO
|
|
convergence_correction_norm = ZERO
|
|
convergence_contact_gap_norm = ZERO
|
|
convergence_combined_norm = ZERO
|
|
convergence_last_dt = ZERO
|
|
convergence_last_accepted_time = ZERO
|
|
convergence_converged = .false.
|
|
call error_clear(ierr_clear)
|
|
end subroutine reset_structural_state
|
|
|
|
real(rk) function max_nodal_displacement()
|
|
integer :: node
|
|
integer :: base
|
|
real(rk) :: mag
|
|
|
|
max_nodal_displacement = ZERO
|
|
if (.not. allocated(u)) return
|
|
do node = 1, nnode
|
|
base = (node - 1) * NDOF_NODE
|
|
if (base + 3 .gt. size(u)) exit
|
|
mag = sqrt(u(base + 1) * u(base + 1) + &
|
|
u(base + 2) * u(base + 2) + &
|
|
u(base + 3) * u(base + 3))
|
|
max_nodal_displacement = max(max_nodal_displacement, mag)
|
|
end do
|
|
end function max_nodal_displacement
|
|
|
|
real(rk) function current_plastic_share(mat_id)
|
|
integer, intent(in) :: mat_id
|
|
integer :: elem
|
|
integer :: local_gp
|
|
integer :: gp
|
|
integer :: branch
|
|
integer :: total_gp
|
|
integer :: plastic_gp
|
|
|
|
current_plastic_share = ZERO
|
|
if (.not. allocated(statev)) return
|
|
if (.not. allocated(elem_gp_start) .or. .not. allocated(elem_ngp)) return
|
|
total_gp = 0
|
|
plastic_gp = 0
|
|
do elem = 1, nelem
|
|
if (elem_mat(elem) .ne. mat_id) cycle
|
|
if (elem_gp_start(elem) .le. 0) cycle
|
|
do local_gp = 0, elem_ngp(elem) - 1
|
|
gp = elem_gp_start(elem) + local_gp
|
|
if (gp .lt. 1 .or. gp .gt. size(statev, 2)) cycle
|
|
total_gp = total_gp + 1
|
|
branch = nint(statev(MC_STATE_BRANCH, gp))
|
|
if (branch .ne. MC_BRANCH_ELASTIC .or. &
|
|
statev(1, gp) .gt. 1.0e-12_rk .or. &
|
|
statev(22, gp) .gt. 1.0e-14_rk) then
|
|
plastic_gp = plastic_gp + 1
|
|
end if
|
|
end do
|
|
end do
|
|
if (total_gp .gt. 0) then
|
|
current_plastic_share = real(plastic_gp, rk) / real(total_gp, rk)
|
|
end if
|
|
end function current_plastic_share
|
|
|
|
real(rk) function current_max_eqps(mat_id)
|
|
integer, intent(in) :: mat_id
|
|
integer :: elem
|
|
integer :: local_gp
|
|
integer :: gp
|
|
|
|
current_max_eqps = ZERO
|
|
if (.not. allocated(statev)) return
|
|
if (.not. allocated(elem_gp_start) .or. .not. allocated(elem_ngp)) return
|
|
do elem = 1, nelem
|
|
if (elem_mat(elem) .ne. mat_id) cycle
|
|
if (elem_gp_start(elem) .le. 0) cycle
|
|
do local_gp = 0, elem_ngp(elem) - 1
|
|
gp = elem_gp_start(elem) + local_gp
|
|
if (gp .lt. 1 .or. gp .gt. size(statev, 2)) cycle
|
|
current_max_eqps = max(current_max_eqps, statev(1, gp))
|
|
end do
|
|
end do
|
|
end function current_max_eqps
|
|
|
|
function collect_mc_struct_diag(mat_id) result(diag)
|
|
integer, intent(in) :: mat_id
|
|
type(mc_struct_diag) :: diag
|
|
|
|
integer :: elem
|
|
integer :: local_gp
|
|
integer :: gp
|
|
integer :: substeps
|
|
integer :: requested
|
|
integer :: status
|
|
integer :: mask
|
|
|
|
if (.not. allocated(statev)) return
|
|
if (size(statev, 1) .lt. MC_STATE_MAX_PLASTIC_STEP) return
|
|
if (.not. allocated(elem_gp_start) .or. .not. allocated(elem_ngp)) return
|
|
do elem = 1, nelem
|
|
if (elem_mat(elem) .ne. mat_id) cycle
|
|
if (elem_gp_start(elem) .le. 0) cycle
|
|
do local_gp = 0, elem_ngp(elem) - 1
|
|
gp = elem_gp_start(elem) + local_gp
|
|
if (gp .lt. 1 .or. gp .gt. size(statev, 2)) cycle
|
|
diag%point_count = diag%point_count + 1
|
|
substeps = max(0, nint(statev(MC_STATE_SUBSTEPS, gp)))
|
|
requested = max(0, nint(statev(MC_STATE_REQUESTED_STEPS, gp)))
|
|
status = nint(statev(MC_STATE_DRIVER_STATUS, gp))
|
|
mask = max(0, nint(statev(MC_STATE_BRANCH_MASK, gp)))
|
|
if (substeps .gt. 0 .or. requested .gt. 0) then
|
|
diag%updated_points = diag%updated_points + 1
|
|
end if
|
|
diag%substeps = diag%substeps + substeps
|
|
diag%requested_substeps = diag%requested_substeps + requested
|
|
if (status .ne. 0) diag%limited_points = diag%limited_points + 1
|
|
diag%branch_mask = ior(diag%branch_mask, mask)
|
|
diag%max_yield = max(diag%max_yield, &
|
|
max(ZERO, statev(MC_STATE_MAX_YIELD, gp)))
|
|
diag%max_plastic_step = max(diag%max_plastic_step, &
|
|
max(ZERO, &
|
|
statev(MC_STATE_MAX_PLASTIC_STEP, gp)))
|
|
end do
|
|
end do
|
|
end function collect_mc_struct_diag
|
|
|
|
subroutine collect_nonlinear_diagnostics(mat_id, iter_total, residual, &
|
|
relative_residual, combined_norm, &
|
|
max_disp, plastic_share, &
|
|
converged, conv_status, &
|
|
failure_code, cutbacks, &
|
|
correction_norm, last_dt, &
|
|
accepted_time, linear_iter, &
|
|
linear_residual, linear_status, ierr)
|
|
integer, intent(in) :: mat_id
|
|
integer, intent(inout) :: iter_total
|
|
real(rk), intent(inout) :: residual
|
|
real(rk), intent(out) :: relative_residual
|
|
real(rk), intent(out) :: combined_norm
|
|
real(rk), intent(out) :: max_disp
|
|
real(rk), intent(out) :: plastic_share
|
|
logical, intent(out) :: converged
|
|
integer, intent(out) :: conv_status
|
|
integer, intent(out) :: failure_code
|
|
integer, intent(out) :: cutbacks
|
|
real(rk), intent(out) :: correction_norm
|
|
real(rk), intent(out) :: last_dt
|
|
real(rk), intent(out) :: accepted_time
|
|
integer, intent(out) :: linear_iter
|
|
real(rk), intent(out) :: linear_residual
|
|
integer, intent(out) :: linear_status
|
|
integer, intent(out) :: ierr
|
|
|
|
integer :: increment
|
|
integer :: iter_status
|
|
integer :: linear_method
|
|
integer :: linear_precond
|
|
real(rk) :: contact_gap_norm
|
|
logical :: status_converged
|
|
|
|
call fem_get_convergence_status(increment, iter_status, residual, &
|
|
correction_norm, status_converged, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
iter_total = max(iter_total, iter_status)
|
|
call fem_get_convergence_metrics(relative_residual, contact_gap_norm, &
|
|
combined_norm, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
call fem_get_convergence_diagnostics(cutbacks, last_dt, accepted_time, &
|
|
conv_status, failure_code, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
call fem_get_linear_solver_stats(linear_method, linear_precond, &
|
|
linear_iter, linear_residual, &
|
|
linear_status, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
max_disp = max_nodal_displacement()
|
|
plastic_share = current_plastic_share(mat_id)
|
|
converged = status_converged
|
|
call error_clear(ierr)
|
|
end subroutine collect_nonlinear_diagnostics
|
|
|
|
|
|
function probe_stress(alpha, probe) result(stress)
|
|
real(rk), intent(in) :: alpha
|
|
integer, intent(in) :: probe
|
|
real(rk) :: stress(NSTRESS)
|
|
real(rk) :: x
|
|
real(rk) :: z
|
|
real(rk) :: depth
|
|
real(rk) :: vertical
|
|
real(rk) :: k0
|
|
real(rk) :: shear
|
|
|
|
call probe_location(alpha, probe, x, z)
|
|
depth = max(ONE, H1 + H2 - z)
|
|
vertical = RHO_SOIL * GRAVITY * depth
|
|
k0 = NU_SOIL / max(0.10_rk, ONE - NU_SOIL)
|
|
shear = 0.18_rk * vertical * sin(alpha * PI / 180.0_rk) * &
|
|
(0.75_rk + 0.06_rk * real(probe, rk))
|
|
stress = ZERO
|
|
stress(1) = -k0 * vertical
|
|
stress(2) = -0.65_rk * k0 * vertical
|
|
stress(3) = -vertical
|
|
stress(6) = shear
|
|
end function probe_stress
|
|
|
|
subroutine probe_location(alpha, probe, x, z)
|
|
real(rk), intent(in) :: alpha
|
|
integer, intent(in) :: probe
|
|
real(rk), intent(out) :: x
|
|
real(rk), intent(out) :: z
|
|
real(rk) :: lslope
|
|
real(rk) :: t
|
|
|
|
lslope = H2 / tan(alpha * PI / 180.0_rk)
|
|
t = real(probe, rk) / real(NPROBE + 1, rk)
|
|
x = L2 + t * lslope + 0.25_rk * real(probe - 1, rk)
|
|
z = H1 + t * H2 - 1.5_rk
|
|
end subroutine probe_location
|
|
|
|
real(rk) function alpha_value(index)
|
|
integer, intent(in) :: index
|
|
real(rk), parameter :: values(NALPHA) = &
|
|
(/ 15.0_rk, 25.0_rk, 35.0_rk, 45.0_rk /)
|
|
alpha_value = values(index)
|
|
end function alpha_value
|
|
|
|
integer function alpha_index_from_value(alpha)
|
|
real(rk), intent(in) :: alpha
|
|
integer :: i
|
|
|
|
alpha_index_from_value = 1
|
|
do i = 1, NALPHA
|
|
if (abs(alpha - alpha_value(i)) .lt. 1.0e-8_rk) then
|
|
alpha_index_from_value = i
|
|
return
|
|
end if
|
|
end do
|
|
end function alpha_index_from_value
|
|
|
|
real(rk) function reference_fos(material_case, alpha_index)
|
|
integer, intent(in) :: material_case
|
|
integer, intent(in) :: alpha_index
|
|
|
|
if (material_case .eq. 1) then
|
|
select case (alpha_index)
|
|
case (1)
|
|
reference_fos = 3.1500_rk
|
|
case (2)
|
|
reference_fos = 2.2125_rk
|
|
case (3)
|
|
reference_fos = 1.7500_rk
|
|
case default
|
|
reference_fos = 1.4500_rk
|
|
end select
|
|
else
|
|
select case (alpha_index)
|
|
case (1)
|
|
reference_fos = 3.1750_rk
|
|
case (2)
|
|
reference_fos = 2.2625_rk
|
|
case (3)
|
|
reference_fos = 1.8000_rk
|
|
case default
|
|
reference_fos = 1.5250_rk
|
|
end select
|
|
end if
|
|
end function reference_fos
|
|
|
|
real(rk) function stop_displacement(alpha)
|
|
real(rk), intent(in) :: alpha
|
|
real(rk) :: lslope
|
|
|
|
lslope = H2 / tan(alpha * PI / 180.0_rk)
|
|
stop_displacement = lslope / 20.0_rk
|
|
end function stop_displacement
|
|
|
|
|
|
subroutine exit_if_error(ierr)
|
|
integer, intent(in) :: ierr
|
|
integer :: code
|
|
integer :: ierr2
|
|
character(len=256) :: msg
|
|
|
|
if (ierr .eq. FEM_SUCCESS) return
|
|
call fem_get_last_error(code, msg, ierr2)
|
|
if (ierr2 .eq. FEM_SUCCESS) then
|
|
write(*,'(A,I0,2A)') 'Error ', code, ': ', trim(msg)
|
|
else
|
|
write(*,'(A,I0)') 'Error: ', ierr
|
|
end if
|
|
stop 1
|
|
end subroutine exit_if_error
|
|
|
|
end program strength_reduction_benchmark
|