Files
SPHLite/tests/module/test_shell_director_input.f90
T

102 lines
4.3 KiB
Fortran
Raw Normal View History

program test_shell_director_input
use sph_precision, only: rk
use sph_error, only: SPH_SUCCESS
use sph_api, only: sph_initialize, sph_finalize, sph_read_inp, &
sph_build_model, sph_get_input_warning_count
use sph_database, only: section_orientation_name
use sph_shell, only: shell_director, shell_director_status, &
shell_director_max_length_error, SPH_SHELL_DIRECTOR_INPUT, &
SPH_SHELL_DIRECTOR_ORIENTATION
implicit none
integer :: ierr
integer :: warnings
call check_explicit_director()
call check_section_orientation()
call check_unused_orientation_warning()
call check_bad_input('tests/data/shell_director_zero_061.inp')
call check_bad_input('tests/data/shell_director_nan_061.inp')
call check_bad_input('tests/data/shell_orientation_parallel_061.inp')
call check_bad_input('tests/data/shell_local_frame_degenerate_061.inp')
contains
subroutine check_explicit_director()
call sph_initialize(ierr)
call assert_ok(ierr, 'initialize failed for explicit Shell director')
call sph_read_inp('tests/data/shell_director_input_061.inp', ierr)
call assert_ok(ierr, 'read failed for explicit Shell director')
call sph_build_model(ierr)
call assert_ok(ierr, 'build failed for explicit Shell director')
if (any(abs(shell_director(:,1) - (/0.0_rk, 0.0_rk, 1.0_rk/)) > &
1.0e-12_rk)) call fail('explicit Shell director mismatch')
if (shell_director_status(1) /= SPH_SHELL_DIRECTOR_INPUT) &
call fail('explicit Shell director status mismatch')
if (shell_director_max_length_error < 0.9_rk) &
call fail('explicit Shell director length diagnostic missing')
call sph_finalize(ierr)
call assert_ok(ierr, 'finalize failed for explicit Shell director')
end subroutine check_explicit_director
subroutine check_section_orientation()
call sph_initialize(ierr)
call assert_ok(ierr, 'initialize failed for Shell orientation')
call sph_read_inp('tests/data/shell_section_orientation_061.inp', ierr)
call assert_ok(ierr, 'read failed for Shell orientation')
call sph_build_model(ierr)
call assert_ok(ierr, 'build failed for Shell orientation')
if (trim(section_orientation_name(1)) /= 'SHELL_Z') &
call fail('Shell section orientation name not stored')
if (any(abs(shell_director(:,1) - (/0.0_rk, 0.0_rk, 1.0_rk/)) > &
1.0e-12_rk)) call fail('Shell orientation director mismatch')
if (shell_director_status(1) /= SPH_SHELL_DIRECTOR_ORIENTATION) &
call fail('Shell orientation director status mismatch')
call sph_finalize(ierr)
call assert_ok(ierr, 'finalize failed for Shell orientation')
end subroutine check_section_orientation
subroutine check_unused_orientation_warning()
call sph_initialize(ierr)
call assert_ok(ierr, 'initialize failed for unused Shell orientation')
call sph_read_inp('tests/data/shell_unused_orientation_warning_061.inp', ierr)
call assert_ok(ierr, 'read failed for unused Shell orientation')
call sph_build_model(ierr)
call assert_ok(ierr, 'build failed for unused Shell orientation')
call sph_get_input_warning_count(warnings, ierr)
call assert_ok(ierr, 'warning count failed for unused Shell orientation')
if (warnings <= 0) call fail('unused Shell orientation warning missing')
call sph_finalize(ierr)
call assert_ok(ierr, 'finalize failed for unused Shell orientation')
end subroutine check_unused_orientation_warning
subroutine check_bad_input(filename)
character(len=*), intent(in) :: filename
call sph_initialize(ierr)
call assert_ok(ierr, 'initialize failed for bad Shell director input')
call sph_read_inp(filename, ierr)
if (ierr == SPH_SUCCESS) then
call sph_build_model(ierr)
if (ierr == SPH_SUCCESS) call fail('bad Shell director input built')
end if
call sph_finalize(ierr)
call assert_ok(ierr, 'finalize failed after bad Shell director input')
end subroutine check_bad_input
subroutine assert_ok(ierr_value, message)
integer, intent(in) :: ierr_value
character(len=*), intent(in) :: message
if (ierr_value /= SPH_SUCCESS) call fail(message)
end subroutine assert_ok
subroutine fail(message)
character(len=*), intent(in) :: message
write(*, '(A)') trim(message)
stop 1
end subroutine fail
end program test_shell_director_input