program test_input_coupling_region_080 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_set_name, coupling_region_surface_name, & coupling_region_type, coupling_region_export_mode, & coupling_region_import_mode, coupling_region_enabled, & coupling_region_phase_filter, coupling_region_material_filter, & coupling_region_section_filter, coupling_region_particle_count, & coupling_region_particles, coupling_region_disabled_count, & SPH_REGION_COUPLING_CONTACT, SPH_REGION_COUPLING_CONTINUUM, & 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_PHASE_SOLID implicit none integer :: ierr call check_contact_regions() call check_legacy_continuum_compatibility() contains subroutine check_contact_regions() call sph_initialize(ierr) call assert_ok(ierr, 'initialize failed for coupling region input') call sph_read_inp('tests/data/coupling_region_080.inp', ierr) call assert_ok(ierr, 'read failed for coupling region input') if (coupling_region_count /= 3) call fail('coupling region count mismatch') call assert_region_name(1, 'CONTACT_PARTICLES') call assert_region_name(2, 'CONTACT_FACETS') call assert_region_name(3, 'CONTACT_DISABLED') call assert_string(coupling_region_set_name(1), 'SOLID_A', & 'first coupling set mismatch') call assert_string(coupling_region_set_name(2), 'SOLID_B', & 'second coupling set mismatch') call assert_string(coupling_region_surface_name(2), 'PANEL_SURFACE', & 'facet surface placeholder mismatch') call assert_string(coupling_region_surface_name(3), 'DISABLED_SURFACE', & 'disabled surface placeholder mismatch') if (coupling_region_type(1) /= SPH_REGION_COUPLING_CONTACT) then call fail('first coupling type mismatch') end if if (coupling_region_export_mode(1) /= SPH_COUPLING_EXPORT_PARTICLE) then call fail('particle export mode mismatch') end if if (coupling_region_export_mode(2) /= SPH_COUPLING_EXPORT_FACET) then call fail('facet export mode mismatch') end if if (coupling_region_export_mode(3) /= SPH_COUPLING_EXPORT_BOTH) then call fail('combined export mode mismatch') end if if (coupling_region_import_mode(1) /= SPH_COUPLING_IMPORT_FORCE) then call fail('force import mode mismatch') end if if (coupling_region_import_mode(2) /= SPH_COUPLING_IMPORT_FACET_LOAD) then call fail('facet load import mode mismatch') end if if (coupling_region_import_mode(3) /= SPH_COUPLING_IMPORT_MOTION) then call fail('motion import mode mismatch') end if if (coupling_region_enabled(1) /= 1) call fail('enabled flag mismatch') if (coupling_region_enabled(2) /= 1) call fail('second enabled flag mismatch') if (coupling_region_enabled(3) /= 0) call fail('disabled flag mismatch') if (coupling_region_phase_filter(1) /= SPH_PHASE_SOLID) then call fail('phase filter mismatch') end if if (coupling_region_material_filter(1) <= 0) then call fail('material filter was not resolved') end if if (coupling_region_section_filter(1) <= 0) then call fail('section filter was not resolved') end if call sph_build_model(ierr) call assert_ok(ierr, 'build failed for coupling region input') if (coupling_region_disabled_count /= 1) then call fail('disabled coupling region count mismatch') end if if (coupling_region_particle_count(1) /= 3) then call fail('first active coupling particle count mismatch') end if if (coupling_region_particle_count(2) /= 3) then call fail('second active coupling particle count mismatch') end if if (coupling_region_particle_count(3) /= 0) then call fail('disabled coupling region exported particles') end if if (coupling_region_particles(1,1) /= 1) call fail('first particle index mismatch') if (coupling_region_particles(3,1) /= 3) call fail('third particle index mismatch') if (coupling_region_particles(1,2) /= 4) call fail('fourth particle index mismatch') if (coupling_region_particles(3,2) /= 6) call fail('sixth particle index mismatch') call sph_finalize(ierr) call assert_ok(ierr, 'finalize failed for coupling region input') end subroutine check_contact_regions subroutine check_legacy_continuum_compatibility() call sph_initialize(ierr) call assert_ok(ierr, 'initialize failed for legacy continuum input') call sph_read_inp('tests/data/coupling_region_011.inp', ierr) call assert_ok(ierr, 'read failed for legacy continuum input') call sph_build_model(ierr) call assert_ok(ierr, 'build failed for legacy continuum input') if (coupling_region_count /= 1) call fail('legacy continuum region missing') if (coupling_region_type(1) /= SPH_REGION_COUPLING_CONTINUUM) then call fail('legacy continuum type mismatch') end if if (coupling_region_enabled(1) /= 0) then call fail('legacy continuum region should stay disabled') end if if (coupling_region_disabled_count /= 1) then call fail('legacy continuum disabled count mismatch') end if call sph_finalize(ierr) call assert_ok(ierr, 'finalize failed for legacy continuum input') end subroutine check_legacy_continuum_compatibility subroutine assert_region_name(index, expected) integer, intent(in) :: index character(len=*), intent(in) :: expected call assert_string(coupling_region_name(index), expected, & 'coupling region name mismatch') end subroutine assert_region_name subroutine assert_string(actual, expected, message) character(len=*), intent(in) :: actual character(len=*), intent(in) :: expected character(len=*), intent(in) :: message if (trim(actual) /= trim(expected)) call fail(message) end subroutine assert_string 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_region_080