141 lines
6.1 KiB
Fortran
141 lines
6.1 KiB
Fortran
program test_input_coupling_load_mode_081
|
|
use sph_error, only: SPH_SUCCESS
|
|
use sph_api, only: sph_initialize, sph_finalize, sph_read_inp, sph_build_model
|
|
use sph_database, only: coupling_region_count, coupling_region_name, &
|
|
coupling_region_export_mode, coupling_region_import_mode, &
|
|
coupling_region_load_mode, coupling_region_distribution_mode, &
|
|
coupling_region_contact_state_mode, coupling_region_enabled, &
|
|
coupling_region_particle_count, coupling_region_disabled_count, &
|
|
SPH_COUPLING_EXPORT_PARTICLE, SPH_COUPLING_EXPORT_FACET, &
|
|
SPH_COUPLING_EXPORT_BOTH, SPH_COUPLING_IMPORT_FORCE, &
|
|
SPH_COUPLING_IMPORT_FACET_LOAD, SPH_COUPLING_IMPORT_MOTION, &
|
|
SPH_COUPLING_LOAD_PARTICLE_FORCE, SPH_COUPLING_LOAD_FACET_FORCE, &
|
|
SPH_COUPLING_LOAD_PRESSURE, SPH_COUPLING_LOAD_TRACTION, &
|
|
SPH_COUPLING_DISTRIBUTION_UNIFORM, SPH_COUPLING_DISTRIBUTION_AREA, &
|
|
SPH_COUPLING_DISTRIBUTION_MASS, SPH_COUPLING_CONTACT_STATE_NONE, &
|
|
SPH_COUPLING_CONTACT_STATE_IMPORT
|
|
implicit none
|
|
|
|
integer :: ierr
|
|
|
|
call check_081_load_modes()
|
|
call check_080_defaults()
|
|
|
|
contains
|
|
|
|
subroutine check_081_load_modes()
|
|
call sph_initialize(ierr)
|
|
call assert_ok(ierr, 'initialize failed for 0.8.1 load modes')
|
|
call sph_read_inp('tests/data/coupling_load_mode_081.inp', ierr)
|
|
call assert_ok(ierr, 'read failed for 0.8.1 load modes')
|
|
|
|
if (coupling_region_count /= 3) call fail('0.8.1 coupling region count mismatch')
|
|
call assert_name(1, 'PRESSURE_CONTACT')
|
|
call assert_name(2, 'TRACTION_CONTACT')
|
|
call assert_name(3, 'DISABLED_PRESSURE')
|
|
if (coupling_region_export_mode(1) /= SPH_COUPLING_EXPORT_FACET) then
|
|
call fail('pressure export mode mismatch')
|
|
end if
|
|
if (coupling_region_export_mode(2) /= SPH_COUPLING_EXPORT_BOTH) then
|
|
call fail('traction export mode mismatch')
|
|
end if
|
|
if (coupling_region_export_mode(3) /= SPH_COUPLING_EXPORT_PARTICLE) then
|
|
call fail('disabled export mode mismatch')
|
|
end if
|
|
if (coupling_region_import_mode(1) /= SPH_COUPLING_IMPORT_FACET_LOAD) then
|
|
call fail('pressure import mode mismatch')
|
|
end if
|
|
if (coupling_region_load_mode(1) /= SPH_COUPLING_LOAD_PRESSURE) then
|
|
call fail('pressure load mode mismatch')
|
|
end if
|
|
if (coupling_region_load_mode(2) /= SPH_COUPLING_LOAD_TRACTION) then
|
|
call fail('traction load mode mismatch')
|
|
end if
|
|
if (coupling_region_load_mode(3) /= SPH_COUPLING_LOAD_PRESSURE) then
|
|
call fail('disabled load mode was not preserved')
|
|
end if
|
|
if (coupling_region_distribution_mode(1) /= SPH_COUPLING_DISTRIBUTION_AREA) then
|
|
call fail('pressure distribution mismatch')
|
|
end if
|
|
if (coupling_region_distribution_mode(2) /= SPH_COUPLING_DISTRIBUTION_MASS) then
|
|
call fail('traction distribution mismatch')
|
|
end if
|
|
if (coupling_region_distribution_mode(3) /= SPH_COUPLING_DISTRIBUTION_UNIFORM) then
|
|
call fail('disabled distribution mismatch')
|
|
end if
|
|
if (coupling_region_contact_state_mode(1) /= SPH_COUPLING_CONTACT_STATE_IMPORT) then
|
|
call fail('pressure contact state mismatch')
|
|
end if
|
|
if (coupling_region_contact_state_mode(2) /= SPH_COUPLING_CONTACT_STATE_IMPORT) then
|
|
call fail('traction contact state mismatch')
|
|
end if
|
|
if (coupling_region_enabled(3) /= 0) call fail('disabled flag mismatch')
|
|
|
|
call sph_build_model(ierr)
|
|
call assert_ok(ierr, 'build failed for 0.8.1 load modes')
|
|
if (coupling_region_particle_count(1) /= 3) call fail('pressure runtime count mismatch')
|
|
if (coupling_region_particle_count(2) /= 3) call fail('traction runtime count mismatch')
|
|
if (coupling_region_particle_count(3) /= 0) call fail('disabled region exported particles')
|
|
if (coupling_region_disabled_count /= 1) call fail('disabled count mismatch')
|
|
call sph_finalize(ierr)
|
|
call assert_ok(ierr, 'finalize failed for 0.8.1 load modes')
|
|
end subroutine check_081_load_modes
|
|
|
|
subroutine check_080_defaults()
|
|
call sph_initialize(ierr)
|
|
call assert_ok(ierr, 'initialize failed for 0.8.0 defaults')
|
|
call sph_read_inp('tests/data/coupling_region_080.inp', ierr)
|
|
call assert_ok(ierr, 'read failed for 0.8.0 defaults')
|
|
if (coupling_region_import_mode(1) /= SPH_COUPLING_IMPORT_FORCE) then
|
|
call fail('0.8.0 force import mode mismatch')
|
|
end if
|
|
if (coupling_region_load_mode(1) /= SPH_COUPLING_LOAD_PARTICLE_FORCE) then
|
|
call fail('0.8.0 force load default mismatch')
|
|
end if
|
|
if (coupling_region_import_mode(2) /= SPH_COUPLING_IMPORT_FACET_LOAD) then
|
|
call fail('0.8.0 facet import mode mismatch')
|
|
end if
|
|
if (coupling_region_load_mode(2) /= SPH_COUPLING_LOAD_FACET_FORCE) then
|
|
call fail('0.8.0 facet load default mismatch')
|
|
end if
|
|
if (coupling_region_import_mode(3) /= SPH_COUPLING_IMPORT_MOTION) then
|
|
call fail('0.8.0 motion import mode mismatch')
|
|
end if
|
|
if (coupling_region_load_mode(3) /= SPH_COUPLING_LOAD_PARTICLE_FORCE) then
|
|
call fail('0.8.0 motion load default mismatch')
|
|
end if
|
|
if (maxval(coupling_region_distribution_mode(1:3)) /= &
|
|
SPH_COUPLING_DISTRIBUTION_UNIFORM) then
|
|
call fail('0.8.0 distribution default mismatch')
|
|
end if
|
|
if (maxval(coupling_region_contact_state_mode(1:3)) /= &
|
|
SPH_COUPLING_CONTACT_STATE_NONE) then
|
|
call fail('0.8.0 contact state default mismatch')
|
|
end if
|
|
call sph_finalize(ierr)
|
|
call assert_ok(ierr, 'finalize failed for 0.8.0 defaults')
|
|
end subroutine check_080_defaults
|
|
|
|
subroutine assert_name(index, expected)
|
|
integer, intent(in) :: index
|
|
character(len=*), intent(in) :: expected
|
|
|
|
if (trim(coupling_region_name(index)) /= trim(expected)) call fail('region name mismatch')
|
|
end subroutine assert_name
|
|
|
|
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_input_coupling_load_mode_081
|