Strengthen water coupling interface placeholders
This commit is contained in:
@@ -1,14 +1,22 @@
|
||||
program test_coupling_interface
|
||||
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_database, only: SPH_PHASE_WATER
|
||||
use sph_api, only: sph_initialize, sph_finalize, sph_read_inp, sph_build_model, &
|
||||
sph_advance_explicit
|
||||
use sph_coupling_interface, only: sph_coupling_get_particle_count, &
|
||||
sph_coupling_export_particle, sph_coupling_get_facet_count, &
|
||||
sph_coupling_export_facet, sph_coupling_import_particle_force, &
|
||||
sph_coupling_import_facet_load, sph_coupling_get_diagnostics, &
|
||||
coupling_type
|
||||
sph_coupling_export_particle_state, coupling_type
|
||||
implicit none
|
||||
|
||||
call check_legacy_region()
|
||||
call check_water_runtime_state()
|
||||
|
||||
contains
|
||||
|
||||
subroutine check_legacy_region()
|
||||
integer :: ierr
|
||||
integer :: count
|
||||
integer :: ext_id
|
||||
@@ -51,8 +59,61 @@ program test_coupling_interface
|
||||
|
||||
call sph_finalize(ierr)
|
||||
call assert_ok(ierr, 'finalize failed')
|
||||
end subroutine check_legacy_region
|
||||
|
||||
contains
|
||||
subroutine check_water_runtime_state()
|
||||
integer :: ierr
|
||||
integer :: count
|
||||
integer :: ext_id
|
||||
integer :: phase
|
||||
integer :: material
|
||||
real(rk) :: position(3)
|
||||
real(rk) :: velocity(3)
|
||||
real(rk) :: particle_pressure
|
||||
real(rk) :: force(3)
|
||||
real(rk) :: work
|
||||
real(rk) :: energy
|
||||
real(rk) :: momentum(3)
|
||||
|
||||
call sph_initialize(ierr)
|
||||
call assert_ok(ierr, 'initialize water failed')
|
||||
call sph_read_inp('tests/data/water_minimal_020.inp', ierr)
|
||||
call assert_ok(ierr, 'read water input failed')
|
||||
call sph_build_model(ierr)
|
||||
call assert_ok(ierr, 'build water model failed')
|
||||
call sph_advance_explicit(1.0e-6_rk, ierr)
|
||||
call assert_ok(ierr, 'advance water model failed')
|
||||
|
||||
call sph_coupling_get_particle_count(count, ierr)
|
||||
call assert_ok(ierr, 'water coupling particle count failed')
|
||||
if (count /= 4) call fail('water coupling particle count mismatch')
|
||||
|
||||
call sph_coupling_export_particle_state(1, ext_id, phase, material, &
|
||||
position, velocity, particle_pressure, ierr)
|
||||
call assert_ok(ierr, 'water coupling particle state export failed')
|
||||
if (ext_id /= 1) call fail('water coupling export id mismatch')
|
||||
if (phase /= SPH_PHASE_WATER) call fail('water coupling phase mismatch')
|
||||
if (material <= 0) call fail('water coupling material mismatch')
|
||||
|
||||
force = (/0.0_rk, 0.0_rk, 2.0_rk/)
|
||||
call sph_coupling_import_particle_force(1, force, ierr)
|
||||
call assert_ok(ierr, 'water coupling force import failed')
|
||||
call sph_advance_explicit(1.0e-6_rk, ierr)
|
||||
call assert_ok(ierr, 'advance after coupling force failed')
|
||||
call sph_coupling_export_particle_state(1, ext_id, phase, material, &
|
||||
position, velocity, particle_pressure, ierr)
|
||||
call assert_ok(ierr, 'water coupling export after force failed')
|
||||
if (velocity(3) <= 0.0_rk) call fail('coupling force did not affect explicit step')
|
||||
if (.not. is_finite(particle_pressure)) call fail('water coupling pressure is not finite')
|
||||
|
||||
call sph_coupling_get_diagnostics(work, energy, momentum)
|
||||
if (work <= 0.0_rk) call fail('coupling work placeholder not updated')
|
||||
if (momentum(3) <= 0.0_rk) call fail('coupling momentum placeholder not updated')
|
||||
if (coupling_type /= 0) call fail('water coupling type should remain neutral')
|
||||
|
||||
call sph_finalize(ierr)
|
||||
call assert_ok(ierr, 'finalize water failed')
|
||||
end subroutine check_water_runtime_state
|
||||
|
||||
subroutine assert_ok(ierr_value, message)
|
||||
integer, intent(in) :: ierr_value
|
||||
@@ -68,4 +129,10 @@ contains
|
||||
stop 1
|
||||
end subroutine fail
|
||||
|
||||
logical function is_finite(value)
|
||||
real(rk), intent(in) :: value
|
||||
|
||||
is_finite = (value == value .and. abs(value) < huge(1.0_rk))
|
||||
end function is_finite
|
||||
|
||||
end program test_coupling_interface
|
||||
|
||||
Reference in New Issue
Block a user