Apply coupling imports in explicit step
This commit is contained in:
@@ -0,0 +1,152 @@
|
||||
program test_coupling_noop_regression_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, coupling_region_disabled_count
|
||||
use sph_coupling_interface, only: coupling_external_force, &
|
||||
coupling_motion_flag, sph_coupling_get_extended_diagnostics
|
||||
implicit none
|
||||
|
||||
integer :: ierr
|
||||
|
||||
call check_single_phase_noop('tests/data/water_minimal_021.inp', 'Water-only')
|
||||
call check_single_phase_noop('tests/data/gas_air_ideal_031.inp', 'Gas-only')
|
||||
call check_single_phase_noop('tests/data/explosive_minimal_040.inp', &
|
||||
'Explosive-only')
|
||||
call check_single_phase_noop('tests/data/solid_elastic_minimal_050.inp', &
|
||||
'Solid-only')
|
||||
call check_single_phase_noop('tests/data/shell_minimal_060.inp', 'Shell-only')
|
||||
call check_active_region_empty_import()
|
||||
call check_disabled_region_noop()
|
||||
|
||||
contains
|
||||
|
||||
subroutine check_single_phase_noop(filename, label)
|
||||
character(len=*), intent(in) :: filename
|
||||
character(len=*), intent(in) :: label
|
||||
|
||||
call sph_initialize(ierr)
|
||||
call assert_ok(ierr, trim(label) // ' initialize failed')
|
||||
call sph_read_inp(filename, ierr)
|
||||
call assert_ok(ierr, trim(label) // ' read failed')
|
||||
call sph_build_model(ierr)
|
||||
call assert_ok(ierr, trim(label) // ' build failed')
|
||||
call sph_advance_explicit(1.0e-7_rk, ierr)
|
||||
call assert_ok(ierr, trim(label) // ' advance failed')
|
||||
call assert_no_coupling_load(trim(label))
|
||||
call sph_finalize(ierr)
|
||||
call assert_ok(ierr, trim(label) // ' finalize failed')
|
||||
end subroutine check_single_phase_noop
|
||||
|
||||
subroutine check_active_region_empty_import()
|
||||
real(rk) :: velocity_before(SPH_NDIM)
|
||||
|
||||
call sph_initialize(ierr)
|
||||
call assert_ok(ierr, 'active empty initialize failed')
|
||||
call sph_read_inp('tests/data/coupling_region_080.inp', ierr)
|
||||
call assert_ok(ierr, 'active empty read failed')
|
||||
call sph_build_model(ierr)
|
||||
call assert_ok(ierr, 'active empty build failed')
|
||||
velocity_before = v(:,1)
|
||||
call sph_advance_explicit(1.0e-7_rk, ierr)
|
||||
call assert_ok(ierr, 'active empty advance failed')
|
||||
call assert_no_coupling_load('active empty import')
|
||||
if (maxval(abs(v(:,1) - velocity_before)) > 1.0e-12_rk .and. &
|
||||
maxval(abs(a(:,1))) > 0.0_rk) then
|
||||
call fail('empty Coupling import produced structural acceleration')
|
||||
end if
|
||||
call sph_finalize(ierr)
|
||||
call assert_ok(ierr, 'active empty finalize failed')
|
||||
end subroutine check_active_region_empty_import
|
||||
|
||||
subroutine check_disabled_region_noop()
|
||||
call sph_initialize(ierr)
|
||||
call assert_ok(ierr, 'disabled noop initialize failed')
|
||||
call sph_read_inp('tests/data/coupling_disabled_only_080.inp', ierr)
|
||||
call assert_ok(ierr, 'disabled noop read failed')
|
||||
call sph_build_model(ierr)
|
||||
call assert_ok(ierr, 'disabled noop build failed')
|
||||
if (coupling_region_disabled_count <= 0) call fail('disabled region missing')
|
||||
call sph_advance_explicit(1.0e-7_rk, ierr)
|
||||
call assert_ok(ierr, 'disabled noop advance failed')
|
||||
call assert_no_coupling_load('disabled region')
|
||||
call sph_finalize(ierr)
|
||||
call assert_ok(ierr, 'disabled noop finalize failed')
|
||||
end subroutine check_disabled_region_noop
|
||||
|
||||
subroutine assert_no_coupling_load(label)
|
||||
character(len=*), intent(in) :: label
|
||||
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_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, trim(label) // ' diagnostics failed')
|
||||
if (maxval(abs(total_force)) > 0.0_rk) then
|
||||
call fail(trim(label) // ' reported Coupling force')
|
||||
end if
|
||||
if (maxval(abs(total_moment)) > 0.0_rk) then
|
||||
call fail(trim(label) // ' reported Coupling moment')
|
||||
end if
|
||||
if (maxval(abs(current_impulse)) > 0.0_rk) then
|
||||
call fail(trim(label) // ' reported Coupling impulse')
|
||||
end if
|
||||
if (max_force > 0.0_rk .or. max_acceleration > 0.0_rk) then
|
||||
call fail(trim(label) // ' reported Coupling acceleration')
|
||||
end if
|
||||
if (max_velocity_error > 0.0_rk .or. max_position_error > 0.0_rk) then
|
||||
call fail(trim(label) // ' reported Coupling motion error')
|
||||
end if
|
||||
if (stale_count /= 0 .or. skipped_count /= 0 .or. &
|
||||
nonfinite_count /= 0) then
|
||||
call fail(trim(label) // ' changed Coupling counters')
|
||||
end if
|
||||
if (step_load_consumed /= 0) then
|
||||
call fail(trim(label) // ' consumed empty Coupling load')
|
||||
end if
|
||||
if (allocated(coupling_external_force)) then
|
||||
if (maxval(abs(coupling_external_force)) > 0.0_rk) then
|
||||
call fail(trim(label) // ' left Coupling force cache')
|
||||
end if
|
||||
end if
|
||||
if (allocated(coupling_motion_flag)) then
|
||||
if (maxval(coupling_motion_flag) /= 0) then
|
||||
call fail(trim(label) // ' left Coupling motion cache')
|
||||
end if
|
||||
end if
|
||||
end subroutine assert_no_coupling_load
|
||||
|
||||
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_coupling_noop_regression_080
|
||||
Reference in New Issue
Block a user