diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ae0d21..e46b2dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -144,6 +144,24 @@ set_target_properties(test_input PROPERTIES Fortran_MODULE_DIRECTORY "${SPHLITE_ add_test(NAME input COMMAND test_input) set_tests_properties(input PROPERTIES WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") +add_executable(test_input_coupling_region_080 tests/module/test_input_coupling_region_080.f90) +target_link_libraries(test_input_coupling_region_080 PRIVATE sphlite_core) +set_target_properties(test_input_coupling_region_080 PROPERTIES Fortran_MODULE_DIRECTORY "${SPHLITE_MODULE_DIR}") +add_test(NAME input_coupling_region_080 COMMAND test_input_coupling_region_080) +set_tests_properties(input_coupling_region_080 PROPERTIES WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") + +add_executable(test_input_coupling_errors_080 tests/module/test_input_coupling_errors_080.f90) +target_link_libraries(test_input_coupling_errors_080 PRIVATE sphlite_core) +set_target_properties(test_input_coupling_errors_080 PROPERTIES Fortran_MODULE_DIRECTORY "${SPHLITE_MODULE_DIR}") +add_test(NAME input_coupling_errors_080 COMMAND test_input_coupling_errors_080) +set_tests_properties(input_coupling_errors_080 PROPERTIES WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") + +add_executable(test_coupling_region_build_080 tests/module/test_coupling_region_build_080.f90) +target_link_libraries(test_coupling_region_build_080 PRIVATE sphlite_core) +set_target_properties(test_coupling_region_build_080 PROPERTIES Fortran_MODULE_DIRECTORY "${SPHLITE_MODULE_DIR}") +add_test(NAME coupling_region_build_080 COMMAND test_coupling_region_build_080) +set_tests_properties(coupling_region_build_080 PROPERTIES WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") + add_executable(test_input_gas tests/module/test_input_gas.f90) target_link_libraries(test_input_gas PRIVATE sphlite_core) set_target_properties(test_input_gas PROPERTIES Fortran_MODULE_DIRECTORY "${SPHLITE_MODULE_DIR}") diff --git a/src/database/sph_database.f90 b/src/database/sph_database.f90 index edf24f5..04cac04 100644 --- a/src/database/sph_database.f90 +++ b/src/database/sph_database.f90 @@ -30,6 +30,14 @@ module sph_database integer, parameter :: SPH_REGION_COUPLING_CONTACT = 1 integer, parameter :: SPH_REGION_COUPLING_CONTINUUM = 2 + integer, parameter :: SPH_COUPLING_EXPORT_PARTICLE = 1 + integer, parameter :: SPH_COUPLING_EXPORT_FACET = 2 + integer, parameter :: SPH_COUPLING_EXPORT_BOTH = 3 + + integer, parameter :: SPH_COUPLING_IMPORT_FORCE = 1 + integer, parameter :: SPH_COUPLING_IMPORT_FACET_LOAD = 2 + integer, parameter :: SPH_COUPLING_IMPORT_MOTION = 3 + integer :: npart = 0 integer, allocatable :: particle_id_ext(:) integer, allocatable :: particle_phase(:) @@ -148,8 +156,20 @@ module sph_database integer :: coupling_region_count = 0 character(len=SPH_NAME_LEN) :: coupling_region_name(SPH_MAX_REGIONS) character(len=SPH_NAME_LEN) :: coupling_region_set_name(SPH_MAX_REGIONS) + character(len=SPH_NAME_LEN) :: coupling_region_surface_name(SPH_MAX_REGIONS) + character(len=SPH_NAME_LEN) :: coupling_region_material_name(SPH_MAX_REGIONS) + character(len=SPH_NAME_LEN) :: coupling_region_section_name(SPH_MAX_REGIONS) integer :: coupling_region_type(SPH_MAX_REGIONS) + integer :: coupling_region_export_mode(SPH_MAX_REGIONS) + integer :: coupling_region_import_mode(SPH_MAX_REGIONS) + integer :: coupling_region_enabled(SPH_MAX_REGIONS) + integer :: coupling_region_phase_filter(SPH_MAX_REGIONS) + integer :: coupling_region_material_filter(SPH_MAX_REGIONS) + integer :: coupling_region_section_filter(SPH_MAX_REGIONS) integer :: coupling_region_internal_id(SPH_MAX_REGIONS) + integer :: coupling_region_particle_count(SPH_MAX_REGIONS) + integer :: coupling_region_particles(SPH_MAX_SET_MEMBERS,SPH_MAX_REGIONS) + integer :: coupling_region_disabled_count = 0 contains @@ -292,8 +312,20 @@ contains coupling_region_count = 0 coupling_region_name = ' ' coupling_region_set_name = ' ' + coupling_region_surface_name = ' ' + coupling_region_material_name = ' ' + coupling_region_section_name = ' ' coupling_region_type = 0 + coupling_region_export_mode = 0 + coupling_region_import_mode = 0 + coupling_region_enabled = 0 + coupling_region_phase_filter = 0 + coupling_region_material_filter = 0 + coupling_region_section_filter = 0 coupling_region_internal_id = 0 + coupling_region_particle_count = 0 + coupling_region_particles = 0 + coupling_region_disabled_count = 0 end subroutine sph_db_clear_metadata subroutine sph_db_clear_water_diagnostics() @@ -560,6 +592,19 @@ contains end do end function sph_db_find_material + integer function sph_db_find_section(name) + character(len=*), intent(in) :: name + integer :: i + + sph_db_find_section = 0 + do i = 1, section_count + if (sph_db_name_equal(section_name(i), name)) then + sph_db_find_section = i + return + end if + end do + end function sph_db_find_section + logical function sph_db_name_equal(left, right) character(len=*), intent(in) :: left character(len=*), intent(in) :: right @@ -663,13 +708,95 @@ contains if (n > 0) element_conn(1:n,element_count) = conn_values(1:n) end subroutine sph_db_add_element - subroutine sph_db_add_coupling_region(name, set_name, region_type, ierr) + subroutine sph_db_add_coupling_region(name, set_name, region_type, & + export_mode, import_mode, enabled, surface_name, phase_filter, & + material_filter_name, section_filter_name, ierr) character(len=*), intent(in) :: name character(len=*), intent(in) :: set_name integer, intent(in) :: region_type + integer, intent(in) :: export_mode + integer, intent(in) :: import_mode + logical, intent(in) :: enabled + character(len=*), intent(in) :: surface_name + integer, intent(in) :: phase_filter + character(len=*), intent(in) :: material_filter_name + character(len=*), intent(in) :: section_filter_name integer, intent(out) :: ierr + integer :: i + integer :: mat_index + integer :: sec_index + integer :: set_index ierr = SPH_SUCCESS + if (len_trim(name) == 0) then + call sph_error_set(SPH_ERROR_DATABASE, 'coupling region name is empty') + ierr = SPH_ERROR_DATABASE + return + end if + do i = 1, coupling_region_count + if (sph_db_name_equal(coupling_region_name(i), name)) then + call sph_error_set(SPH_ERROR_DATABASE, 'duplicate coupling region name') + ierr = SPH_ERROR_DATABASE + return + end if + end do + if (len_trim(set_name) == 0) then + call sph_error_set(SPH_ERROR_DATABASE, 'coupling region set is missing') + ierr = SPH_ERROR_DATABASE + return + end if + set_index = sph_db_find_nset(set_name) + if (set_index <= 0) set_index = sph_db_find_elset(set_name) + if (set_index <= 0 .and. .not. sph_db_name_equal(set_name, 'ALL')) then + call sph_error_set(SPH_ERROR_DATABASE, 'coupling region references unknown set') + ierr = SPH_ERROR_DATABASE + return + end if + if (region_type /= SPH_REGION_COUPLING_CONTACT .and. & + region_type /= SPH_REGION_COUPLING_CONTINUUM) then + call sph_error_set(SPH_ERROR_DATABASE, 'invalid coupling region type') + ierr = SPH_ERROR_DATABASE + return + end if + if (export_mode /= SPH_COUPLING_EXPORT_PARTICLE .and. & + export_mode /= SPH_COUPLING_EXPORT_FACET .and. & + export_mode /= SPH_COUPLING_EXPORT_BOTH) then + call sph_error_set(SPH_ERROR_DATABASE, 'invalid coupling export mode') + ierr = SPH_ERROR_DATABASE + return + end if + if (import_mode /= SPH_COUPLING_IMPORT_FORCE .and. & + import_mode /= SPH_COUPLING_IMPORT_FACET_LOAD .and. & + import_mode /= SPH_COUPLING_IMPORT_MOTION) then + call sph_error_set(SPH_ERROR_DATABASE, 'invalid coupling import mode') + ierr = SPH_ERROR_DATABASE + return + end if + if (phase_filter < 0 .or. phase_filter > SPH_PHASE_SHELL_FAILED) then + call sph_error_set(SPH_ERROR_DATABASE, 'invalid coupling phase filter') + ierr = SPH_ERROR_DATABASE + return + end if + mat_index = 0 + if (len_trim(material_filter_name) > 0) then + mat_index = sph_db_find_material(material_filter_name) + if (mat_index <= 0) then + call sph_error_set(SPH_ERROR_DATABASE, & + 'coupling region references unknown material') + ierr = SPH_ERROR_DATABASE + return + end if + end if + sec_index = 0 + if (len_trim(section_filter_name) > 0) then + sec_index = sph_db_find_section(section_filter_name) + if (sec_index <= 0) then + call sph_error_set(SPH_ERROR_DATABASE, & + 'coupling region references unknown section') + ierr = SPH_ERROR_DATABASE + return + end if + end if if (coupling_region_count >= SPH_MAX_REGIONS) then call sph_error_set(SPH_ERROR_DATABASE, 'too many coupling region records') ierr = SPH_ERROR_DATABASE @@ -678,10 +805,133 @@ contains coupling_region_count = coupling_region_count + 1 coupling_region_name(coupling_region_count) = name coupling_region_set_name(coupling_region_count) = set_name + coupling_region_surface_name(coupling_region_count) = surface_name + coupling_region_material_name(coupling_region_count) = material_filter_name + coupling_region_section_name(coupling_region_count) = section_filter_name coupling_region_type(coupling_region_count) = region_type + coupling_region_export_mode(coupling_region_count) = export_mode + coupling_region_import_mode(coupling_region_count) = import_mode + coupling_region_enabled(coupling_region_count) = 0 + if (enabled) coupling_region_enabled(coupling_region_count) = 1 + coupling_region_phase_filter(coupling_region_count) = phase_filter + coupling_region_material_filter(coupling_region_count) = mat_index + coupling_region_section_filter(coupling_region_count) = sec_index coupling_region_internal_id(coupling_region_count) = coupling_region_count + coupling_region_particle_count(coupling_region_count) = 0 + coupling_region_particles(:,coupling_region_count) = 0 end subroutine sph_db_add_coupling_region + subroutine sph_db_build_coupling_regions(ierr) + integer, intent(out) :: ierr + integer :: region + integer :: count + integer :: set_index + integer :: member_index + integer :: elem_index + integer :: conn_index + integer :: node_index + + ierr = SPH_SUCCESS + coupling_region_particle_count = 0 + coupling_region_particles = 0 + coupling_region_disabled_count = 0 + do region = 1, coupling_region_count + coupling_region_internal_id(region) = region + if (coupling_region_enabled(region) == 0) then + coupling_region_disabled_count = coupling_region_disabled_count + 1 + cycle + end if + + count = 0 + if (sph_db_name_equal(coupling_region_set_name(region), 'ALL')) then + do node_index = 1, npart + call sph_db_add_coupling_particle(region, node_index, count, ierr) + if (ierr /= SPH_SUCCESS) return + end do + else + set_index = sph_db_find_nset(coupling_region_set_name(region)) + if (set_index > 0) then + do member_index = 1, nset_member_count(set_index) + node_index = sph_db_find_node(nset_members(member_index,set_index)) + if (node_index > 0) then + call sph_db_add_coupling_particle(region, node_index, count, ierr) + if (ierr /= SPH_SUCCESS) return + end if + end do + else + set_index = sph_db_find_elset(coupling_region_set_name(region)) + if (set_index <= 0) then + call sph_error_set(SPH_ERROR_DATABASE, & + 'coupling region references unknown set') + ierr = SPH_ERROR_DATABASE + return + end if + do member_index = 1, elset_member_count(set_index) + elem_index = sph_db_find_element(elset_members(member_index,set_index)) + if (elem_index <= 0) cycle + do conn_index = 1, element_conn_count(elem_index) + node_index = sph_db_find_node(element_conn(conn_index,elem_index)) + if (node_index > 0) then + call sph_db_add_coupling_particle(region, node_index, count, ierr) + if (ierr /= SPH_SUCCESS) return + end if + end do + end do + end if + end if + + coupling_region_particle_count(region) = count + if (count <= 0) then + call sph_error_set(SPH_ERROR_DATABASE, & + 'active coupling region selected no particles') + ierr = SPH_ERROR_DATABASE + return + end if + end do + end subroutine sph_db_build_coupling_regions + + subroutine sph_db_add_coupling_particle(region, node_index, count, ierr) + integer, intent(in) :: region + integer, intent(in) :: node_index + integer, intent(inout) :: count + integer, intent(out) :: ierr + integer :: i + + ierr = SPH_SUCCESS + if (.not. sph_db_coupling_accepts_particle(region, node_index)) return + do i = 1, count + if (coupling_region_particles(i,region) == node_index) return + end do + if (count >= SPH_MAX_SET_MEMBERS) then + call sph_error_set(SPH_ERROR_DATABASE, & + 'too many particles in coupling region') + ierr = SPH_ERROR_DATABASE + return + end if + count = count + 1 + coupling_region_particles(count,region) = node_index + end subroutine sph_db_add_coupling_particle + + logical function sph_db_coupling_accepts_particle(region, node_index) + integer, intent(in) :: region + integer, intent(in) :: node_index + + sph_db_coupling_accepts_particle = .false. + if (region < 1 .or. region > coupling_region_count) return + if (node_index < 1 .or. node_index > npart) return + if (particle_status(node_index) /= SPH_STATUS_ACTIVE) return + if (coupling_region_phase_filter(region) > 0) then + if (particle_phase(node_index) /= coupling_region_phase_filter(region)) return + end if + if (coupling_region_material_filter(region) > 0) then + if (material_id(node_index) /= coupling_region_material_filter(region)) return + end if + if (coupling_region_section_filter(region) > 0) then + if (section_id(node_index) /= coupling_region_section_filter(region)) return + end if + sph_db_coupling_accepts_particle = .true. + end function sph_db_coupling_accepts_particle + subroutine sph_db_apply_sections_to_particles(ierr) integer, intent(out) :: ierr integer :: sec diff --git a/src/input/sph_input_reader.f90 b/src/input/sph_input_reader.f90 index 4440cd3..5782804 100644 --- a/src/input/sph_input_reader.f90 +++ b/src/input/sph_input_reader.f90 @@ -6,9 +6,16 @@ module sph_input_reader use sph_output_csv, only: sph_output_set_directory, sph_output_set_interval use sph_database, only: npart, SPH_MAX_ELEMENT_NODES, & 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_WATER, SPH_PHASE_GAS, SPH_PHASE_EXPLOSIVE, & + SPH_PHASE_SOLID, SPH_PHASE_SHELL, SPH_PHASE_BOUNDARY, & + SPH_PHASE_COUPLING, SPH_PHASE_SOLID_FAILED, SPH_PHASE_SHELL_FAILED, & sph_db_allocate, sph_db_free, sph_db_set_node, sph_db_add_material, & sph_db_add_section, sph_db_add_nset, sph_db_add_elset, & - sph_db_add_element, sph_db_add_coupling_region, sph_db_apply_sections_to_particles + sph_db_add_element, sph_db_add_coupling_region, & + sph_db_apply_sections_to_particles, sph_db_build_coupling_regions use sph_database, only: sph_db_set_material_density, material_count, & material_name, material_type use sph_water, only: sph_water_note_material, sph_water_set_eos, & @@ -128,6 +135,8 @@ contains end if call sph_db_apply_sections_to_particles(ierr) if (ierr /= SPH_SUCCESS) return + call sph_db_build_coupling_regions(ierr) + if (ierr /= SPH_SUCCESS) return call sph_solid_build_state(ierr) if (ierr /= SPH_SUCCESS) return call sph_shell_build_state(ierr) @@ -1106,23 +1115,175 @@ contains integer, intent(out) :: ierr character(len=SPH_INPUT_FIELD_LEN) :: name character(len=SPH_INPUT_FIELD_LEN) :: set_name + character(len=SPH_INPUT_FIELD_LEN) :: surface_name character(len=SPH_INPUT_FIELD_LEN) :: type_name + character(len=SPH_INPUT_FIELD_LEN) :: phase_name + character(len=SPH_INPUT_FIELD_LEN) :: material_name + character(len=SPH_INPUT_FIELD_LEN) :: section_name + character(len=SPH_INPUT_FIELD_LEN) :: export_name + character(len=SPH_INPUT_FIELD_LEN) :: import_name + character(len=SPH_INPUT_FIELD_LEN) :: enabled_name integer :: region_type + integer :: export_mode + integer :: import_mode + integer :: phase_filter + logical :: enabled + logical :: has_modern_continuum_option ierr = SPH_SUCCESS call sph_input_get_option(line, 'NAME', name) - if (len_trim(name) == 0) name = 'COUPLING' + if (len_trim(name) == 0) then + call sph_input_set_error('Coupling region is missing NAME option') + ierr = SPH_ERROR_INPUT + return + end if call sph_input_get_option(line, 'SET', set_name) if (len_trim(set_name) == 0) call sph_input_get_option(line, 'NSET', set_name) if (len_trim(set_name) == 0) call sph_input_get_option(line, 'ELSET', set_name) - if (len_trim(set_name) == 0) set_name = 'ALL' + if (len_trim(set_name) == 0) then + call sph_input_set_error('Coupling region is missing SET option') + ierr = SPH_ERROR_INPUT + return + end if call sph_input_get_option(line, 'TYPE', type_name) type_name = sph_inp_upper(type_name) region_type = SPH_REGION_COUPLING_CONTACT - if (index(type_name, 'CONTINUUM') > 0) region_type = SPH_REGION_COUPLING_CONTINUUM - call sph_db_add_coupling_region(name, set_name, region_type, ierr) + if (len_trim(type_name) == 0 .or. trim(type_name) == 'CONTACT') then + region_type = SPH_REGION_COUPLING_CONTACT + else if (trim(type_name) == 'CONTINUUM') then + region_type = SPH_REGION_COUPLING_CONTINUUM + else + call sph_input_set_error('invalid coupling region TYPE option') + ierr = SPH_ERROR_INPUT + return + end if + + call sph_input_get_option(line, 'SURFACE', surface_name) + call sph_input_get_option(line, 'PHASE', phase_name) + call sph_input_get_option(line, 'MATERIAL', material_name) + call sph_input_get_option(line, 'SECTION', section_name) + + export_mode = SPH_COUPLING_EXPORT_PARTICLE + call sph_input_get_option(line, 'EXPORT', export_name) + if (len_trim(export_name) > 0) then + call sph_input_parse_coupling_export(export_name, export_mode, ierr) + if (ierr /= SPH_SUCCESS) return + end if + + import_mode = SPH_COUPLING_IMPORT_FORCE + call sph_input_get_option(line, 'IMPORT', import_name) + if (len_trim(import_name) > 0) then + call sph_input_parse_coupling_import(import_name, import_mode, ierr) + if (ierr /= SPH_SUCCESS) return + end if + + enabled = .true. + call sph_input_get_option(line, 'ENABLED', enabled_name) + if (len_trim(enabled_name) > 0) then + call sph_input_parse_logical_value(enabled_name, enabled, & + 'invalid coupling region ENABLED option', ierr) + if (ierr /= SPH_SUCCESS) return + end if + + phase_filter = 0 + if (len_trim(phase_name) > 0) then + call sph_input_parse_coupling_phase(phase_name, phase_filter, ierr) + if (ierr /= SPH_SUCCESS) return + end if + + has_modern_continuum_option = sph_input_option_present(line, 'SURFACE') .or. & + sph_input_option_present(line, 'PHASE') .or. & + sph_input_option_present(line, 'MATERIAL') .or. & + sph_input_option_present(line, 'SECTION') .or. & + sph_input_option_present(line, 'EXPORT') .or. & + sph_input_option_present(line, 'IMPORT') .or. & + sph_input_option_present(line, 'ENABLED') + if (region_type == SPH_REGION_COUPLING_CONTINUUM) then + if (has_modern_continuum_option) then + call sph_input_set_error('TYPE=CONTINUUM is reserved for a later version') + ierr = SPH_ERROR_INPUT + return + end if + enabled = .false. + end if + + call sph_db_add_coupling_region(name, set_name, region_type, & + export_mode, import_mode, enabled, surface_name, phase_filter, & + material_name, section_name, ierr) end subroutine sph_input_parse_coupling_region + subroutine sph_input_parse_coupling_export(text, mode, ierr) + character(len=*), intent(in) :: text + integer, intent(out) :: mode + integer, intent(out) :: ierr + character(len=SPH_INPUT_FIELD_LEN) :: upper_text + + ierr = SPH_SUCCESS + upper_text = sph_inp_upper(adjustl(text)) + if (trim(upper_text) == 'PARTICLE') then + mode = SPH_COUPLING_EXPORT_PARTICLE + else if (trim(upper_text) == 'FACET') then + mode = SPH_COUPLING_EXPORT_FACET + else if (trim(upper_text) == 'BOTH') then + mode = SPH_COUPLING_EXPORT_BOTH + else + call sph_input_set_error('invalid coupling region EXPORT option') + ierr = SPH_ERROR_INPUT + end if + end subroutine sph_input_parse_coupling_export + + subroutine sph_input_parse_coupling_import(text, mode, ierr) + character(len=*), intent(in) :: text + integer, intent(out) :: mode + integer, intent(out) :: ierr + character(len=SPH_INPUT_FIELD_LEN) :: upper_text + + ierr = SPH_SUCCESS + upper_text = sph_inp_upper(adjustl(text)) + if (trim(upper_text) == 'FORCE') then + mode = SPH_COUPLING_IMPORT_FORCE + else if (trim(upper_text) == 'FACET_LOAD') then + mode = SPH_COUPLING_IMPORT_FACET_LOAD + else if (trim(upper_text) == 'MOTION') then + mode = SPH_COUPLING_IMPORT_MOTION + else + call sph_input_set_error('invalid coupling region IMPORT option') + ierr = SPH_ERROR_INPUT + end if + end subroutine sph_input_parse_coupling_import + + subroutine sph_input_parse_coupling_phase(text, phase_id, ierr) + character(len=*), intent(in) :: text + integer, intent(out) :: phase_id + integer, intent(out) :: ierr + character(len=SPH_INPUT_FIELD_LEN) :: upper_text + + ierr = SPH_SUCCESS + upper_text = sph_inp_upper(adjustl(text)) + if (trim(upper_text) == 'WATER') then + phase_id = SPH_PHASE_WATER + else if (trim(upper_text) == 'GAS') then + phase_id = SPH_PHASE_GAS + else if (trim(upper_text) == 'EXPLOSIVE') then + phase_id = SPH_PHASE_EXPLOSIVE + else if (trim(upper_text) == 'SOLID') then + phase_id = SPH_PHASE_SOLID + else if (trim(upper_text) == 'SHELL') then + phase_id = SPH_PHASE_SHELL + else if (trim(upper_text) == 'BOUNDARY') then + phase_id = SPH_PHASE_BOUNDARY + else if (trim(upper_text) == 'COUPLING') then + phase_id = SPH_PHASE_COUPLING + else if (trim(upper_text) == 'SOLID_FAILED') then + phase_id = SPH_PHASE_SOLID_FAILED + else if (trim(upper_text) == 'SHELL_FAILED') then + phase_id = SPH_PHASE_SHELL_FAILED + else + call sph_input_set_error('invalid coupling region PHASE option') + ierr = SPH_ERROR_INPUT + end if + end subroutine sph_input_parse_coupling_phase + integer function sph_input_find_material(name) character(len=*), intent(in) :: name integer :: i @@ -1314,6 +1475,30 @@ contains end do end subroutine sph_input_get_option + logical function sph_input_option_present(line, option_name) + character(len=*), intent(in) :: line + character(len=*), intent(in) :: option_name + character(len=SPH_INPUT_FIELD_LEN) :: fields(SPH_INPUT_MAX_FIELDS) + character(len=SPH_INPUT_FIELD_LEN) :: item + character(len=SPH_INPUT_FIELD_LEN) :: key + integer :: nfields + integer :: i + integer :: eq_pos + + sph_input_option_present = .false. + call sph_inp_split_csv(line, fields, nfields) + do i = 1, nfields + item = adjustl(fields(i)) + eq_pos = index(item, '=') + if (eq_pos <= 0) cycle + key = sph_inp_upper(adjustl(item(1:eq_pos-1))) + if (trim(key) == trim(sph_inp_upper(option_name))) then + sph_input_option_present = .true. + return + end if + end do + end function sph_input_option_present + subroutine sph_input_get_required_real(line, option_name, value, ierr) character(len=*), intent(in) :: line character(len=*), intent(in) :: option_name diff --git a/tests/data/coupling_region_080.inp b/tests/data/coupling_region_080.inp new file mode 100644 index 0000000..3d39f69 --- /dev/null +++ b/tests/data/coupling_region_080.inp @@ -0,0 +1,35 @@ +*NODE +1, 0.0, 0.0, 0.0 +2, 0.1, 0.0, 0.0 +3, 0.0, 0.1, 0.0 +4, 0.0, 0.0, 0.1 +5, 0.2, 0.0, 0.0 +6, 0.2, 0.1, 0.0 +*ELEMENT, TYPE=SPH3D +1, 1 +2, 2 +3, 3 +4, 4 +5, 5 +6, 6 +*ELSET, ELSET=SOLID_A +1, 2, 3 +*ELSET, ELSET=SOLID_B +4, 5, 6 +*MATERIAL, NAME=STEEL_A, TYPE=SOLID +*DENSITY +7850.0 +*ELASTIC +210.0E9, 0.30 +*MATERIAL, NAME=ALLOY_B, TYPE=SOLID +*DENSITY +2700.0 +*ELASTIC +70.0E9, 0.33 +*SOLID SECTION, ELSET=SOLID_A, MATERIAL=STEEL_A +*SOLID SECTION, ELSET=SOLID_B, MATERIAL=ALLOY_B +*SPHLITE PARTICLE CONTROL, H=0.15, MASS=1.0, VOLUME=0.001 +*SPHLITE TIME CONTROL, DT=1.0E-7, TIME=1.0E-7, STEPS=1, SAFETY=0.5 +*SPHLITE COUPLING REGION, NAME=CONTACT_PARTICLES, SET=SOLID_A, TYPE=CONTACT, EXPORT=PARTICLE, IMPORT=FORCE, ENABLED=YES, PHASE=SOLID, MATERIAL=STEEL_A, SECTION=SOLID_A +*SPHLITE COUPLING REGION, NAME=CONTACT_FACETS, SET=SOLID_B, TYPE=CONTACT, EXPORT=FACET, IMPORT=FACET_LOAD, ENABLED=ON, PHASE=SOLID, MATERIAL=ALLOY_B, SECTION=SOLID_B, SURFACE=PANEL_SURFACE +*SPHLITE COUPLING REGION, NAME=CONTACT_DISABLED, SET=SOLID_B, TYPE=CONTACT, EXPORT=BOTH, IMPORT=MOTION, ENABLED=NO, PHASE=SOLID, MATERIAL=ALLOY_B, SECTION=SOLID_B, SURFACE=DISABLED_SURFACE diff --git a/tests/data/coupling_region_bad_duplicate_080.inp b/tests/data/coupling_region_bad_duplicate_080.inp new file mode 100644 index 0000000..195d2e6 --- /dev/null +++ b/tests/data/coupling_region_bad_duplicate_080.inp @@ -0,0 +1,13 @@ +*NODE +1, 0.0, 0.0, 0.0 +*NSET, NSET=SOLID_SET +1 +*MATERIAL, NAME=STEEL, TYPE=SOLID +*DENSITY +7850.0 +*ELASTIC +210.0E9, 0.30 +*SOLID SECTION, NSET=SOLID_SET, MATERIAL=STEEL +*SPHLITE TIME CONTROL, DT=1.0E-7, TIME=1.0E-7, STEPS=1 +*SPHLITE COUPLING REGION, NAME=DUPLICATE, SET=SOLID_SET, TYPE=CONTACT +*SPHLITE COUPLING REGION, NAME=DUPLICATE, SET=SOLID_SET, TYPE=CONTACT diff --git a/tests/data/coupling_region_bad_enabled_080.inp b/tests/data/coupling_region_bad_enabled_080.inp new file mode 100644 index 0000000..8497035 --- /dev/null +++ b/tests/data/coupling_region_bad_enabled_080.inp @@ -0,0 +1,12 @@ +*NODE +1, 0.0, 0.0, 0.0 +*NSET, NSET=SOLID_SET +1 +*MATERIAL, NAME=STEEL, TYPE=SOLID +*DENSITY +7850.0 +*ELASTIC +210.0E9, 0.30 +*SOLID SECTION, NSET=SOLID_SET, MATERIAL=STEEL +*SPHLITE TIME CONTROL, DT=1.0E-7, TIME=1.0E-7, STEPS=1 +*SPHLITE COUPLING REGION, NAME=BAD_ENABLED, SET=SOLID_SET, TYPE=CONTACT, ENABLED=MAYBE diff --git a/tests/data/coupling_region_bad_export_080.inp b/tests/data/coupling_region_bad_export_080.inp new file mode 100644 index 0000000..d30650b --- /dev/null +++ b/tests/data/coupling_region_bad_export_080.inp @@ -0,0 +1,12 @@ +*NODE +1, 0.0, 0.0, 0.0 +*NSET, NSET=SOLID_SET +1 +*MATERIAL, NAME=STEEL, TYPE=SOLID +*DENSITY +7850.0 +*ELASTIC +210.0E9, 0.30 +*SOLID SECTION, NSET=SOLID_SET, MATERIAL=STEEL +*SPHLITE TIME CONTROL, DT=1.0E-7, TIME=1.0E-7, STEPS=1 +*SPHLITE COUPLING REGION, NAME=BAD_EXPORT, SET=SOLID_SET, TYPE=CONTACT, EXPORT=NODAL diff --git a/tests/data/coupling_region_bad_import_080.inp b/tests/data/coupling_region_bad_import_080.inp new file mode 100644 index 0000000..7da64e2 --- /dev/null +++ b/tests/data/coupling_region_bad_import_080.inp @@ -0,0 +1,12 @@ +*NODE +1, 0.0, 0.0, 0.0 +*NSET, NSET=SOLID_SET +1 +*MATERIAL, NAME=STEEL, TYPE=SOLID +*DENSITY +7850.0 +*ELASTIC +210.0E9, 0.30 +*SOLID SECTION, NSET=SOLID_SET, MATERIAL=STEEL +*SPHLITE TIME CONTROL, DT=1.0E-7, TIME=1.0E-7, STEPS=1 +*SPHLITE COUPLING REGION, NAME=BAD_IMPORT, SET=SOLID_SET, TYPE=CONTACT, IMPORT=PRESSURE diff --git a/tests/data/coupling_region_bad_name_080.inp b/tests/data/coupling_region_bad_name_080.inp new file mode 100644 index 0000000..a35d47b --- /dev/null +++ b/tests/data/coupling_region_bad_name_080.inp @@ -0,0 +1,12 @@ +*NODE +1, 0.0, 0.0, 0.0 +*NSET, NSET=SOLID_SET +1 +*MATERIAL, NAME=STEEL, TYPE=SOLID +*DENSITY +7850.0 +*ELASTIC +210.0E9, 0.30 +*SOLID SECTION, NSET=SOLID_SET, MATERIAL=STEEL +*SPHLITE TIME CONTROL, DT=1.0E-7, TIME=1.0E-7, STEPS=1 +*SPHLITE COUPLING REGION, NAME=, SET=SOLID_SET, TYPE=CONTACT diff --git a/tests/data/coupling_region_bad_type_080.inp b/tests/data/coupling_region_bad_type_080.inp new file mode 100644 index 0000000..7574c18 --- /dev/null +++ b/tests/data/coupling_region_bad_type_080.inp @@ -0,0 +1,12 @@ +*NODE +1, 0.0, 0.0, 0.0 +*NSET, NSET=SOLID_SET +1 +*MATERIAL, NAME=STEEL, TYPE=SOLID +*DENSITY +7850.0 +*ELASTIC +210.0E9, 0.30 +*SOLID SECTION, NSET=SOLID_SET, MATERIAL=STEEL +*SPHLITE TIME CONTROL, DT=1.0E-7, TIME=1.0E-7, STEPS=1 +*SPHLITE COUPLING REGION, NAME=BAD_TYPE, SET=SOLID_SET, TYPE=THERMAL diff --git a/tests/data/coupling_region_continuum_active_080.inp b/tests/data/coupling_region_continuum_active_080.inp new file mode 100644 index 0000000..b109255 --- /dev/null +++ b/tests/data/coupling_region_continuum_active_080.inp @@ -0,0 +1,12 @@ +*NODE +1, 0.0, 0.0, 0.0 +*NSET, NSET=SOLID_SET +1 +*MATERIAL, NAME=STEEL, TYPE=SOLID +*DENSITY +7850.0 +*ELASTIC +210.0E9, 0.30 +*SOLID SECTION, NSET=SOLID_SET, MATERIAL=STEEL +*SPHLITE TIME CONTROL, DT=1.0E-7, TIME=1.0E-7, STEPS=1 +*SPHLITE COUPLING REGION, NAME=ACTIVE_CONTINUUM, SET=SOLID_SET, TYPE=CONTINUUM, EXPORT=PARTICLE diff --git a/tests/data/coupling_region_empty_active_080.inp b/tests/data/coupling_region_empty_active_080.inp new file mode 100644 index 0000000..71ceaf3 --- /dev/null +++ b/tests/data/coupling_region_empty_active_080.inp @@ -0,0 +1,12 @@ +*NODE +1, 0.0, 0.0, 0.0 +*NSET, NSET=SOLID_SET +1 +*MATERIAL, NAME=STEEL, TYPE=SOLID +*DENSITY +7850.0 +*ELASTIC +210.0E9, 0.30 +*SOLID SECTION, NSET=SOLID_SET, MATERIAL=STEEL +*SPHLITE TIME CONTROL, DT=1.0E-7, TIME=1.0E-7, STEPS=1 +*SPHLITE COUPLING REGION, NAME=EMPTY_ACTIVE, SET=SOLID_SET, TYPE=CONTACT, PHASE=GAS diff --git a/tests/data/coupling_region_missing_set_080.inp b/tests/data/coupling_region_missing_set_080.inp new file mode 100644 index 0000000..5c4e356 --- /dev/null +++ b/tests/data/coupling_region_missing_set_080.inp @@ -0,0 +1,12 @@ +*NODE +1, 0.0, 0.0, 0.0 +*NSET, NSET=SOLID_SET +1 +*MATERIAL, NAME=STEEL, TYPE=SOLID +*DENSITY +7850.0 +*ELASTIC +210.0E9, 0.30 +*SOLID SECTION, NSET=SOLID_SET, MATERIAL=STEEL +*SPHLITE TIME CONTROL, DT=1.0E-7, TIME=1.0E-7, STEPS=1 +*SPHLITE COUPLING REGION, NAME=MISSING_SET, TYPE=CONTACT diff --git a/tests/data/coupling_region_unknown_set_080.inp b/tests/data/coupling_region_unknown_set_080.inp new file mode 100644 index 0000000..8e1834b --- /dev/null +++ b/tests/data/coupling_region_unknown_set_080.inp @@ -0,0 +1,12 @@ +*NODE +1, 0.0, 0.0, 0.0 +*NSET, NSET=SOLID_SET +1 +*MATERIAL, NAME=STEEL, TYPE=SOLID +*DENSITY +7850.0 +*ELASTIC +210.0E9, 0.30 +*SOLID SECTION, NSET=SOLID_SET, MATERIAL=STEEL +*SPHLITE TIME CONTROL, DT=1.0E-7, TIME=1.0E-7, STEPS=1 +*SPHLITE COUPLING REGION, NAME=UNKNOWN_SET, SET=NOT_DEFINED, TYPE=CONTACT diff --git a/tests/module/test_coupling_region_build_080.f90 b/tests/module/test_coupling_region_build_080.f90 new file mode 100644 index 0000000..1e82172 --- /dev/null +++ b/tests/module/test_coupling_region_build_080.f90 @@ -0,0 +1,69 @@ +program test_coupling_region_build_080 + 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_blast, only: blast_region_count + use sph_gas, only: sph_gas_get_source_summary + use sph_database, only: coupling_region_count, coupling_region_internal_id, & + coupling_region_particle_count, coupling_region_disabled_count + implicit none + + integer :: ierr + real(rk) :: gas_mass_source + real(rk) :: gas_energy_source + real(rk) :: gas_momentum_source(3) + + call sph_initialize(ierr) + call assert_ok(ierr, 'initialize failed for coupling region build') + call sph_read_inp('tests/data/coupling_region_080.inp', ierr) + call assert_ok(ierr, 'read failed for coupling region build') + if (blast_region_count /= 0) call fail('coupling input polluted Blast regions') + call sph_build_model(ierr) + call assert_ok(ierr, 'build failed for coupling region build') + + if (coupling_region_count /= 3) call fail('runtime region count mismatch') + if (coupling_region_internal_id(1) /= 1) call fail('first internal id mismatch') + if (coupling_region_internal_id(2) /= 2) call fail('second internal id mismatch') + if (coupling_region_internal_id(3) /= 3) call fail('third internal id mismatch') + if (coupling_region_particle_count(1) /= 3) call fail('first runtime count mismatch') + if (coupling_region_particle_count(2) /= 3) call fail('second runtime count mismatch') + if (coupling_region_particle_count(3) /= 0) call fail('disabled runtime count mismatch') + if (coupling_region_disabled_count /= 1) call fail('runtime disabled count mismatch') + if (blast_region_count /= 0) call fail('coupling build polluted Blast regions') + + call sph_gas_get_source_summary(gas_mass_source, gas_momentum_source, & + gas_energy_source, ierr) + call assert_ok(ierr, 'Gas source summary failed after coupling build') + call assert_close(gas_mass_source, 0.0_rk, 'Gas mass source was polluted') + call assert_close(gas_energy_source, 0.0_rk, 'Gas energy source was polluted') + call assert_close(maxval(abs(gas_momentum_source)), 0.0_rk, & + 'Gas momentum source was polluted') + + call sph_finalize(ierr) + call assert_ok(ierr, 'finalize failed for coupling region build') + +contains + + 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) > 1.0e-12_rk) call fail(message) + 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_region_build_080 diff --git a/tests/module/test_input_coupling_errors_080.f90 b/tests/module/test_input_coupling_errors_080.f90 new file mode 100644 index 0000000..d8b0d04 --- /dev/null +++ b/tests/module/test_input_coupling_errors_080.f90 @@ -0,0 +1,49 @@ +program test_input_coupling_errors_080 + use sph_error, only: SPH_SUCCESS + use sph_api, only: sph_initialize, sph_finalize, sph_read_inp, sph_build_model + implicit none + + integer :: ierr + + call expect_fails('tests/data/coupling_region_bad_name_080.inp') + call expect_fails('tests/data/coupling_region_bad_duplicate_080.inp') + call expect_fails('tests/data/coupling_region_bad_type_080.inp') + call expect_fails('tests/data/coupling_region_bad_export_080.inp') + call expect_fails('tests/data/coupling_region_bad_import_080.inp') + call expect_fails('tests/data/coupling_region_bad_enabled_080.inp') + call expect_fails('tests/data/coupling_region_missing_set_080.inp') + call expect_fails('tests/data/coupling_region_unknown_set_080.inp') + call expect_fails('tests/data/coupling_region_empty_active_080.inp') + call expect_fails('tests/data/coupling_region_continuum_active_080.inp') + +contains + + subroutine expect_fails(filename) + character(len=*), intent(in) :: filename + + call sph_initialize(ierr) + call assert_ok(ierr, 'initialize failed for failing coupling input') + call sph_read_inp(filename, ierr) + if (ierr == SPH_SUCCESS) then + call sph_build_model(ierr) + if (ierr == SPH_SUCCESS) call fail('coupling input unexpectedly built') + end if + call sph_finalize(ierr) + call assert_ok(ierr, 'finalize failed after failing coupling input') + end subroutine expect_fails + + 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_errors_080 diff --git a/tests/module/test_input_coupling_region_080.f90 b/tests/module/test_input_coupling_region_080.f90 new file mode 100644 index 0000000..9baaee1 --- /dev/null +++ b/tests/module/test_input_coupling_region_080.f90 @@ -0,0 +1,152 @@ +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 diff --git a/todo.md b/todo.md index 5aab846..27371e8 100644 --- a/todo.md +++ b/todo.md @@ -38,52 +38,52 @@ ## 阶段 B:Coupling Region 输入语义和运行时表 -- [ ] 复核现有 `*SPHLITE COUPLING REGION` 关键词字段。 -- [ ] 定义 `TYPE=CONTACT` 为 0.8.0 唯一启用耦合类型。 -- [ ] 定义 `TYPE=CONTINUUM` 的预留错误路径。 -- [ ] 定义 coupling region 名称唯一性规则。 -- [ ] 定义 `EXPORT=PARTICLE` 的输入语义。 -- [ ] 定义 `EXPORT=FACET` 的输入语义。 -- [ ] 定义 `EXPORT=BOTH` 的输入语义。 -- [ ] 定义 `IMPORT=FORCE` 的输入语义。 -- [ ] 定义 `IMPORT=FACET_LOAD` 的输入语义。 -- [ ] 定义 `IMPORT=MOTION` 的输入语义。 -- [ ] 定义 `ENABLED` 字段的默认值和布尔解析规则。 -- [ ] 支持读取 coupling region 的 `NAME` 字段。 -- [ ] 支持读取 coupling region 的 `TYPE` 字段。 -- [ ] 支持读取 coupling region 的 `SET` 字段。 -- [ ] 支持读取 coupling region 的 `SURFACE` 字段占位。 -- [ ] 支持读取 coupling region 的 `PHASE` 过滤字段。 -- [ ] 支持读取 coupling region 的 `MATERIAL` 过滤字段。 -- [ ] 支持读取 coupling region 的 `SECTION` 过滤字段。 -- [ ] 支持读取 coupling region 的 `EXPORT` 字段。 -- [ ] 支持读取 coupling region 的 `IMPORT` 字段。 -- [ ] 支持读取 coupling region 的 `ENABLED` 字段。 -- [ ] 对空 region 名称报 error。 -- [ ] 对重复 region 名称报 error。 -- [ ] 对非法 `TYPE` 报 error。 -- [ ] 对非法 `EXPORT` 报 error。 -- [ ] 对非法 `IMPORT` 报 error。 -- [ ] 对非法 `ENABLED` 报 error。 -- [ ] 对缺失或不存在的 `SET` 报 error。 -- [ ] 对无法选中粒子的 active region 报 error。 -- [ ] 对 disabled region 保留输入记录但不参与导出。 -- [ ] 保持 `tests/data/coupling_region_011.inp` 兼容。 -- [ ] 在数据库中保存 region type、export mode、import mode 和 enabled 状态。 -- [ ] 在数据库中保存 region set、surface、phase、material 和 section 过滤条件。 -- [ ] 建立运行时 region 内部 id。 -- [ ] 建立运行时 region 粒子索引表。 -- [ ] 建立运行时 region active 粒子计数。 -- [ ] 建立运行时 region 禁用状态计数。 -- [ ] 确认 coupling region 构建不污染 Blast region。 -- [ ] 确认 coupling region 构建不污染 Gas source region。 -- [ ] 新增 `input_coupling_region_080` 测试。 -- [ ] 新增 `input_coupling_errors_080` 测试。 -- [ ] 新增 `coupling_region_build_080` 测试。 -- [ ] 将阶段 B 新测试接入 CTest。 -- [ ] 运行阶段 B coupling 输入专项测试。 -- [ ] 运行 `git diff --check`。 -- [ ] 准备阶段 B 本地提交说明。 +- [x] 复核现有 `*SPHLITE COUPLING REGION` 关键词字段。 +- [x] 定义 `TYPE=CONTACT` 为 0.8.0 唯一启用耦合类型。 +- [x] 定义 `TYPE=CONTINUUM` 的预留错误路径。 +- [x] 定义 coupling region 名称唯一性规则。 +- [x] 定义 `EXPORT=PARTICLE` 的输入语义。 +- [x] 定义 `EXPORT=FACET` 的输入语义。 +- [x] 定义 `EXPORT=BOTH` 的输入语义。 +- [x] 定义 `IMPORT=FORCE` 的输入语义。 +- [x] 定义 `IMPORT=FACET_LOAD` 的输入语义。 +- [x] 定义 `IMPORT=MOTION` 的输入语义。 +- [x] 定义 `ENABLED` 字段的默认值和布尔解析规则。 +- [x] 支持读取 coupling region 的 `NAME` 字段。 +- [x] 支持读取 coupling region 的 `TYPE` 字段。 +- [x] 支持读取 coupling region 的 `SET` 字段。 +- [x] 支持读取 coupling region 的 `SURFACE` 字段占位。 +- [x] 支持读取 coupling region 的 `PHASE` 过滤字段。 +- [x] 支持读取 coupling region 的 `MATERIAL` 过滤字段。 +- [x] 支持读取 coupling region 的 `SECTION` 过滤字段。 +- [x] 支持读取 coupling region 的 `EXPORT` 字段。 +- [x] 支持读取 coupling region 的 `IMPORT` 字段。 +- [x] 支持读取 coupling region 的 `ENABLED` 字段。 +- [x] 对空 region 名称报 error。 +- [x] 对重复 region 名称报 error。 +- [x] 对非法 `TYPE` 报 error。 +- [x] 对非法 `EXPORT` 报 error。 +- [x] 对非法 `IMPORT` 报 error。 +- [x] 对非法 `ENABLED` 报 error。 +- [x] 对缺失或不存在的 `SET` 报 error。 +- [x] 对无法选中粒子的 active region 报 error。 +- [x] 对 disabled region 保留输入记录但不参与导出。 +- [x] 保持 `tests/data/coupling_region_011.inp` 兼容。 +- [x] 在数据库中保存 region type、export mode、import mode 和 enabled 状态。 +- [x] 在数据库中保存 region set、surface、phase、material 和 section 过滤条件。 +- [x] 建立运行时 region 内部 id。 +- [x] 建立运行时 region 粒子索引表。 +- [x] 建立运行时 region active 粒子计数。 +- [x] 建立运行时 region 禁用状态计数。 +- [x] 确认 coupling region 构建不污染 Blast region。 +- [x] 确认 coupling region 构建不污染 Gas source region。 +- [x] 新增 `input_coupling_region_080` 测试。 +- [x] 新增 `input_coupling_errors_080` 测试。 +- [x] 新增 `coupling_region_build_080` 测试。 +- [x] 将阶段 B 新测试接入 CTest。 +- [x] 运行阶段 B coupling 输入专项测试。 +- [x] 运行 `git diff --check`。 +- [x] 准备阶段 B 本地提交说明。 ## 阶段 C:粒子导出和 Facet Proxy 导出