Apply coupling imports in explicit step
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
program test_coupling_shell_response_080
|
||||
use sph_precision, only: rk, SPH_NDIM
|
||||
use sph_error, only: SPH_SUCCESS
|
||||
use sph_api, only: sph_initialize, sph_finalize, sph_read_inp, &
|
||||
sph_build_model, sph_advance_explicit
|
||||
use sph_database, only: a, v, mass
|
||||
use sph_shell, only: shell_director, shell_omega
|
||||
use sph_coupling_interface, only: &
|
||||
sph_coupling_import_region_facet_load, &
|
||||
sph_coupling_get_extended_diagnostics
|
||||
implicit none
|
||||
|
||||
integer :: ierr
|
||||
|
||||
call check_shell_facet_response()
|
||||
|
||||
contains
|
||||
|
||||
subroutine check_shell_facet_response()
|
||||
real(rk) :: load(SPH_NDIM)
|
||||
real(rk) :: director_before(SPH_NDIM)
|
||||
real(rk) :: omega_before(SPH_NDIM)
|
||||
real(rk) :: total_force(SPH_NDIM)
|
||||
real(rk) :: total_moment(SPH_NDIM)
|
||||
real(rk) :: current_impulse(SPH_NDIM)
|
||||
real(rk) :: cumulative_impulse(SPH_NDIM)
|
||||
real(rk) :: momentum_exchange(SPH_NDIM)
|
||||
real(rk) :: current_work
|
||||
real(rk) :: cumulative_work
|
||||
real(rk) :: energy_exchange
|
||||
real(rk) :: max_force
|
||||
real(rk) :: max_acceleration
|
||||
real(rk) :: max_velocity_error
|
||||
real(rk) :: max_position_error
|
||||
integer :: stale_count
|
||||
integer :: skipped_count
|
||||
integer :: nonfinite_count
|
||||
integer :: imported_force_count
|
||||
integer :: step_load_consumed
|
||||
|
||||
call sph_initialize(ierr)
|
||||
call assert_ok(ierr, 'initialize failed for Shell response')
|
||||
call sph_read_inp('tests/data/coupling_shell_region_080.inp', ierr)
|
||||
call assert_ok(ierr, 'read failed for Shell response')
|
||||
call sph_build_model(ierr)
|
||||
call assert_ok(ierr, 'build failed for Shell response')
|
||||
director_before = shell_director(:,1)
|
||||
omega_before = shell_omega(:,1)
|
||||
load = (/0.0_rk, 0.0_rk, mass(1) * 1.0e8_rk/)
|
||||
call sph_coupling_import_region_facet_load('SHELL_FACETS', 1, load, ierr)
|
||||
call assert_ok(ierr, 'Shell facet load import failed')
|
||||
call sph_advance_explicit(1.0e-7_rk, ierr)
|
||||
call assert_ok(ierr, 'Shell force advance failed')
|
||||
if (a(3,1) <= 0.0_rk) call fail('Shell coupling acceleration missing')
|
||||
if (v(3,1) <= 0.0_rk) call fail('Shell coupling velocity missing')
|
||||
if (maxval(abs(shell_director(:,1) - director_before)) > 1.0e-12_rk) then
|
||||
call fail('Shell director changed through Coupling force path')
|
||||
end if
|
||||
if (maxval(abs(shell_omega(:,1) - omega_before)) > 1.0e-12_rk) then
|
||||
call fail('Shell rotation state changed through Coupling force path')
|
||||
end if
|
||||
call sph_coupling_get_extended_diagnostics(total_force, total_moment, &
|
||||
current_impulse, cumulative_impulse, current_work, cumulative_work, &
|
||||
momentum_exchange, energy_exchange, max_force, max_acceleration, &
|
||||
max_velocity_error, max_position_error, stale_count, skipped_count, &
|
||||
nonfinite_count, imported_force_count, step_load_consumed, ierr)
|
||||
call assert_ok(ierr, 'Shell diagnostics failed')
|
||||
call assert_close(total_force(3), load(3), 'Shell force diagnostic mismatch')
|
||||
if (max_acceleration <= 0.0_rk) call fail('Shell max acceleration missing')
|
||||
if (step_load_consumed /= 1) call fail('Shell load not consumed')
|
||||
call sph_finalize(ierr)
|
||||
call assert_ok(ierr, 'finalize failed for Shell response')
|
||||
end subroutine check_shell_facet_response
|
||||
|
||||
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 assert_close(actual, expected, message)
|
||||
real(rk), intent(in) :: actual
|
||||
real(rk), intent(in) :: expected
|
||||
character(len=*), intent(in) :: message
|
||||
|
||||
if (abs(actual - expected) > max(1.0e-10_rk, abs(expected) * 1.0e-8_rk)) then
|
||||
call fail(message)
|
||||
end if
|
||||
end subroutine assert_close
|
||||
|
||||
subroutine fail(message)
|
||||
character(len=*), intent(in) :: message
|
||||
|
||||
write(*, '(A)') trim(message)
|
||||
stop 1
|
||||
end subroutine fail
|
||||
|
||||
end program test_coupling_shell_response_080
|
||||
Reference in New Issue
Block a user