237 lines
8.1 KiB
Fortran
237 lines
8.1 KiB
Fortran
program test_strength_reduction_driver
|
|
use fem_precision
|
|
use fem_error
|
|
use fem_strength_reduction_driver
|
|
implicit none
|
|
|
|
call check_options()
|
|
call check_trial_classification()
|
|
call check_search_convergence()
|
|
call check_limited_search()
|
|
call check_trial_history()
|
|
call check_error_paths()
|
|
|
|
contains
|
|
|
|
subroutine check_options()
|
|
type(sr_search_options) :: options
|
|
integer :: ierr
|
|
|
|
call sr_search_options_init(options)
|
|
call sr_search_options_valid(options, ierr)
|
|
call require_success(ierr, 10)
|
|
if (options%max_trials .le. 0) call fail(11)
|
|
if (options%initial_factor .le. ZERO) call fail(12)
|
|
if (trim(sr_search_status_name(SR_SEARCH_SEARCHING)) .ne. 'SEARCHING') &
|
|
call fail(13)
|
|
if (trim(sr_search_status_name(SR_SEARCH_BRACKETED)) .ne. 'BRACKETED') &
|
|
call fail(14)
|
|
if (trim(sr_search_status_name(SR_SEARCH_CONVERGED)) .ne. 'CONVERGED') &
|
|
call fail(15)
|
|
if (trim(sr_search_status_name(SR_SEARCH_LIMITED)) .ne. 'LIMITED') &
|
|
call fail(16)
|
|
end subroutine check_options
|
|
|
|
subroutine check_trial_classification()
|
|
type(sr_search_options) :: options
|
|
real(rk) :: metric
|
|
logical :: unstable
|
|
integer :: ierr
|
|
|
|
call sr_search_options_init(options)
|
|
options%residual_limit = 0.8_rk
|
|
options%displacement_limit = 2.0_rk
|
|
options%plastic_limit = 0.8_rk
|
|
|
|
call sr_search_classify_trial(options, 0.1_rk, 0.2_rk, 0.1_rk, &
|
|
.false., metric, unstable, ierr)
|
|
call require_success(ierr, 30)
|
|
if (unstable) call fail(31)
|
|
if (metric .le. ZERO) call fail(32)
|
|
|
|
call sr_search_classify_trial(options, 0.9_rk, 0.2_rk, 0.1_rk, &
|
|
.false., metric, unstable, ierr)
|
|
call require_success(ierr, 33)
|
|
if (.not. unstable) call fail(34)
|
|
|
|
call sr_search_classify_trial(options, 0.1_rk, 3.0_rk, 0.1_rk, &
|
|
.false., metric, unstable, ierr)
|
|
call require_success(ierr, 35)
|
|
if (.not. unstable) call fail(36)
|
|
|
|
call sr_search_classify_trial(options, 0.1_rk, 0.2_rk, 0.8_rk, &
|
|
.false., metric, unstable, ierr)
|
|
call require_success(ierr, 37)
|
|
if (.not. unstable) call fail(38)
|
|
end subroutine check_trial_classification
|
|
|
|
subroutine check_search_convergence()
|
|
type(sr_search_options) :: options
|
|
type(sr_search_state) :: state
|
|
real(rk) :: factor
|
|
real(rk) :: converged
|
|
integer :: status
|
|
integer :: ierr
|
|
integer :: guard
|
|
|
|
call sr_search_options_init(options)
|
|
options%tolerance = 2.0e-2_rk
|
|
options%max_trials = 20
|
|
call sr_search_begin(options, state, ierr)
|
|
call require_success(ierr, 50)
|
|
|
|
guard = 0
|
|
do while (state%status .ne. SR_SEARCH_CONVERGED)
|
|
guard = guard + 1
|
|
if (guard .gt. 20) call fail(51)
|
|
call sr_search_next(state, factor, status, ierr)
|
|
call require_success(ierr, 52)
|
|
if (factor .lt. 1.35_rk) then
|
|
call sr_search_record_trial(options, factor, 0.05_rk, 0.2_rk, &
|
|
0.2_rk, .false., state, ierr)
|
|
else
|
|
call sr_search_record_trial(options, factor, 1.2_rk, 0.2_rk, &
|
|
0.96_rk, .false., state, ierr)
|
|
end if
|
|
call require_success(ierr, 53)
|
|
if (state%status .eq. SR_SEARCH_LIMITED) call fail(54)
|
|
end do
|
|
|
|
call sr_search_require_converged(state, converged, ierr)
|
|
call require_success(ierr, 55)
|
|
if (converged .le. state%lower .or. converged .ge. state%upper) &
|
|
call fail(56)
|
|
if (abs(converged - 1.35_rk) .gt. 5.0e-2_rk) call fail(57)
|
|
if (state%stable_count .lt. 2) call fail(58)
|
|
if (state%unstable_count .lt. 1) call fail(59)
|
|
end subroutine check_search_convergence
|
|
|
|
subroutine check_limited_search()
|
|
type(sr_search_options) :: options
|
|
type(sr_search_state) :: state
|
|
real(rk) :: factor
|
|
integer :: status
|
|
integer :: ierr
|
|
|
|
call sr_search_options_init(options)
|
|
options%max_trials = 2
|
|
call sr_search_begin(options, state, ierr)
|
|
call require_success(ierr, 70)
|
|
call sr_search_next(state, factor, status, ierr)
|
|
call require_success(ierr, 71)
|
|
call sr_search_record_trial(options, factor, 0.05_rk, 0.1_rk, 0.1_rk, &
|
|
.false., state, ierr)
|
|
call require_success(ierr, 72)
|
|
call sr_search_next(state, factor, status, ierr)
|
|
call require_success(ierr, 73)
|
|
call sr_search_record_trial(options, factor, 0.05_rk, 0.1_rk, 0.1_rk, &
|
|
.false., state, ierr)
|
|
call require_success(ierr, 74)
|
|
if (state%status .ne. SR_SEARCH_LIMITED) call fail(75)
|
|
|
|
call sr_search_record_trial(options, factor, 0.05_rk, 0.1_rk, 0.1_rk, &
|
|
.false., state, ierr)
|
|
if (ierr .eq. FEM_SUCCESS) call fail(76)
|
|
end subroutine check_limited_search
|
|
|
|
subroutine check_trial_history()
|
|
type(sr_search_options) :: options
|
|
type(sr_search_state) :: state
|
|
real(rk) :: factor
|
|
real(rk) :: residual
|
|
real(rk) :: disp_norm
|
|
real(rk) :: plastic_share
|
|
real(rk) :: metric
|
|
real(rk) :: lower
|
|
real(rk) :: upper
|
|
real(rk) :: next_factor
|
|
real(rk) :: converged
|
|
real(rk) :: last_metric
|
|
integer :: trials
|
|
integer :: stable_count
|
|
integer :: unstable_count
|
|
integer :: stable
|
|
integer :: status
|
|
integer :: ierr
|
|
|
|
call sr_search_options_init(options)
|
|
call sr_search_begin(options, state, ierr)
|
|
call require_success(ierr, 90)
|
|
call sr_search_record_trial(options, state%next_factor, 0.05_rk, 0.1_rk, &
|
|
0.1_rk, .false., state, ierr)
|
|
call require_success(ierr, 91)
|
|
call sr_search_record_trial(options, state%next_factor, 1.5_rk, 0.1_rk, &
|
|
0.1_rk, .false., state, ierr)
|
|
call require_success(ierr, 92)
|
|
|
|
call sr_search_trial_values(state, 2, factor, residual, disp_norm, &
|
|
plastic_share, metric, stable, status, ierr)
|
|
call require_success(ierr, 93)
|
|
if (factor .le. ONE) call fail(94)
|
|
if (residual .le. ONE) call fail(95)
|
|
if (stable .ne. 0) call fail(96)
|
|
if (status .ne. SR_SEARCH_BRACKETED .and. &
|
|
status .ne. SR_SEARCH_CONVERGED) call fail(97)
|
|
|
|
call sr_search_summary(state, lower, upper, next_factor, trials, &
|
|
stable_count, unstable_count, status, converged, last_metric, ierr)
|
|
call require_success(ierr, 98)
|
|
if (trials .ne. 2) call fail(99)
|
|
if (stable_count .ne. 1 .or. unstable_count .ne. 1) call fail(100)
|
|
if (lower .le. ZERO .or. upper .le. lower) call fail(101)
|
|
if (last_metric .le. ZERO) call fail(102)
|
|
end subroutine check_trial_history
|
|
|
|
subroutine check_error_paths()
|
|
type(sr_search_options) :: options
|
|
type(sr_search_state) :: state
|
|
real(rk) :: factor
|
|
real(rk) :: residual
|
|
real(rk) :: disp_norm
|
|
real(rk) :: plastic_share
|
|
real(rk) :: metric
|
|
integer :: stable
|
|
integer :: status
|
|
integer :: ierr
|
|
|
|
call sr_search_options_init(options)
|
|
options%max_trials = 0
|
|
call sr_search_options_valid(options, ierr)
|
|
if (ierr .eq. FEM_SUCCESS) call fail(120)
|
|
|
|
call sr_search_options_init(options)
|
|
options%plastic_limit = 1.5_rk
|
|
call sr_search_options_valid(options, ierr)
|
|
if (ierr .eq. FEM_SUCCESS) call fail(121)
|
|
|
|
call sr_search_options_init(options)
|
|
call sr_search_begin(options, state, ierr)
|
|
call require_success(ierr, 122)
|
|
call sr_search_record_trial(options, -ONE, 0.1_rk, 0.1_rk, 0.1_rk, &
|
|
.false., state, ierr)
|
|
if (ierr .eq. FEM_SUCCESS) call fail(123)
|
|
|
|
call sr_search_trial_values(state, 1, factor, residual, disp_norm, &
|
|
plastic_share, metric, stable, status, ierr)
|
|
if (ierr .eq. FEM_SUCCESS) call fail(124)
|
|
|
|
call sr_search_require_converged(state, factor, ierr)
|
|
if (ierr .eq. FEM_SUCCESS) call fail(125)
|
|
end subroutine check_error_paths
|
|
|
|
subroutine require_success(ierr, code)
|
|
integer, intent(in) :: ierr
|
|
integer, intent(in) :: code
|
|
|
|
if (ierr .ne. FEM_SUCCESS) call fail(code)
|
|
end subroutine require_success
|
|
|
|
subroutine fail(code)
|
|
integer, intent(in) :: code
|
|
|
|
write(*,*) 'test_strength_reduction_driver failed:', code
|
|
stop 1
|
|
end subroutine fail
|
|
|
|
end program test_strength_reduction_driver
|