74 lines
2.9 KiB
Fortran
74 lines
2.9 KiB
Fortran
program test_shell_director_step
|
|
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
|
|
use sph_shell, only: shell_director, shell_local_e3, shell_local_frame_status, &
|
|
shell_max_angular_velocity, SPH_SHELL_FRAME_OK, &
|
|
sph_shell_set_particle_angular_velocity, sph_shell_update_directors
|
|
implicit none
|
|
|
|
integer :: ierr
|
|
|
|
call check_director_update()
|
|
call check_no_active_shell_update()
|
|
|
|
contains
|
|
|
|
subroutine check_director_update()
|
|
real(rk) :: omega_value(3)
|
|
real(rk) :: expected(3)
|
|
|
|
call sph_initialize(ierr)
|
|
call assert_ok(ierr, 'initialize failed for Shell director update')
|
|
call sph_read_inp('tests/data/shell_director_input_061.inp', ierr)
|
|
call assert_ok(ierr, 'read failed for Shell director update')
|
|
call sph_build_model(ierr)
|
|
call assert_ok(ierr, 'build failed for Shell director update')
|
|
omega_value = (/0.0_rk, 10.0_rk, 0.0_rk/)
|
|
call sph_shell_set_particle_angular_velocity(1, omega_value, ierr)
|
|
call assert_ok(ierr, 'set Shell angular velocity failed')
|
|
call sph_shell_update_directors(0.01_rk, ierr)
|
|
call assert_ok(ierr, 'Shell director update failed')
|
|
expected = (/0.1_rk, 0.0_rk, 1.0_rk/)
|
|
expected = expected / sqrt(sum(expected * expected))
|
|
if (any(abs(shell_director(:,1) - expected) > 1.0e-10_rk)) &
|
|
call fail('Shell director update mismatch')
|
|
if (any(abs(shell_local_e3(:,1) - shell_director(:,1)) > 1.0e-12_rk)) &
|
|
call fail('Shell local e3 not refreshed')
|
|
if (shell_local_frame_status(1) /= SPH_SHELL_FRAME_OK) &
|
|
call fail('Shell local frame status not OK after update')
|
|
if (abs(shell_max_angular_velocity - 10.0_rk) > 1.0e-12_rk) &
|
|
call fail('Shell max angular velocity mismatch after update')
|
|
call sph_finalize(ierr)
|
|
call assert_ok(ierr, 'finalize failed for Shell director update')
|
|
end subroutine check_director_update
|
|
|
|
subroutine check_no_active_shell_update()
|
|
call sph_initialize(ierr)
|
|
call assert_ok(ierr, 'initialize failed for no-Shell update')
|
|
call sph_read_inp('tests/data/solid_elastic_minimal_050.inp', ierr)
|
|
call assert_ok(ierr, 'read failed for no-Shell update')
|
|
call sph_build_model(ierr)
|
|
call assert_ok(ierr, 'build failed for no-Shell update')
|
|
call sph_shell_update_directors(0.01_rk, ierr)
|
|
call assert_ok(ierr, 'no-Shell update should be a no-op')
|
|
call sph_finalize(ierr)
|
|
call assert_ok(ierr, 'finalize failed for no-Shell update')
|
|
end subroutine check_no_active_shell_update
|
|
|
|
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_step
|