Implement Shell input parsing stage

This commit is contained in:
Codex
2026-07-03 19:36:28 +08:00
parent 7e24ea2697
commit b5fd7724cc
20 changed files with 1065 additions and 72 deletions
+205 -37
View File
@@ -24,6 +24,10 @@ module sph_input_reader
sph_solid_set_johnson_cook, sph_solid_set_failure, &
sph_solid_set_control, sph_solid_build_state, &
sph_solid_count_unbound_materials
use sph_shell, only: sph_shell_note_material, sph_shell_set_elastic, &
sph_shell_set_johnson_cook, sph_shell_set_failure, &
sph_shell_set_control, sph_shell_build_state, &
sph_shell_count_unbound_materials
use sph_solid_dynamics, only: sph_solid_set_body_force, &
sph_solid_build_reference_state, sph_solid_update_diagnostics
use sph_neighbor, only: sph_neighbor_rebuild
@@ -88,6 +92,7 @@ contains
integer :: gas_unbound_count
integer :: explosive_unbound_count
integer :: solid_unbound_count
integer :: shell_unbound_count
ierr = SPH_SUCCESS
if (npart <= 0) then
@@ -114,6 +119,8 @@ contains
if (ierr /= SPH_SUCCESS) return
call sph_solid_build_state(ierr)
if (ierr /= SPH_SUCCESS) return
call sph_shell_build_state(ierr)
if (ierr /= SPH_SUCCESS) return
call sph_water_apply_initial_conditions(ierr)
if (ierr /= SPH_SUCCESS) return
call sph_gas_apply_initial_conditions(ierr)
@@ -126,6 +133,8 @@ contains
input_warning_count = input_warning_count + explosive_unbound_count
call sph_solid_count_unbound_materials(solid_unbound_count)
input_warning_count = input_warning_count + solid_unbound_count
call sph_shell_count_unbound_materials(shell_unbound_count)
input_warning_count = input_warning_count + shell_unbound_count
call sph_solid_build_reference_state(ierr)
if (ierr /= SPH_SUCCESS) return
call sph_solid_update_diagnostics(ierr)
@@ -284,11 +293,13 @@ contains
character(len=SPH_INPUT_FIELD_LEN) :: section_type_value
character(len=SPH_INPUT_FIELD_LEN) :: type_value
real(rk) :: thickness
real(rk) :: shear_correction
integer :: points
integer :: ios
integer :: local_ierr
integer :: mat_index
logical :: is_solid_section
logical :: is_shell_section
character(len=SPH_INPUT_LINE_LEN) :: upper_line
ierr = SPH_SUCCESS
@@ -305,40 +316,9 @@ contains
call sph_gas_note_material(value, type_value)
call sph_explosive_note_material(value, type_value)
call sph_solid_note_material(value, type_value)
call sph_shell_note_material(value, type_value)
else if (key_id == SPH_KEY_SECTION) then
input_has_section = .true.
call sph_input_get_option(line, 'ELSET', section_value)
if (len_trim(section_value) == 0) call sph_input_get_option(line, 'NSET', section_value)
if (len_trim(section_value) == 0) section_value = 'SECTION'
call sph_input_get_option(line, 'MATERIAL', material_value)
thickness = 0.0_rk
points = 3
call sph_input_get_option(line, 'THICKNESS', value)
if (len_trim(value) > 0) read(value, *, iostat=ios) thickness
call sph_input_get_option(line, 'POINTS', value)
if (len_trim(value) > 0) read(value, *, iostat=ios) points
section_type_value = 'SECTION'
is_solid_section = index(upper_line, '*SOLID SECTION') == 1
if (is_solid_section) then
section_type_value = 'SOLID'
if (len_trim(material_value) == 0) then
call sph_input_set_error('Solid section is missing MATERIAL option')
ierr = SPH_ERROR_INPUT
return
end if
mat_index = sph_input_find_material(material_value)
if (mat_index > 0) then
if (sph_input_is_explicit_non_solid_type(material_type(mat_index))) then
call sph_input_set_error('Solid section references non-Solid material')
ierr = SPH_ERROR_INPUT
return
end if
end if
else
if (len_trim(material_value) == 0) material_value = 'MATERIAL'
end if
call sph_db_add_section(section_value, section_type_value, material_value, &
thickness, points, ierr)
call sph_input_parse_section_keyword(line, upper_line, ierr)
else if (key_id == SPH_KEY_SPHLITE) then
if (index(upper_line, 'TIME CONTROL') > 0) then
input_has_time_control = .true.
@@ -360,6 +340,8 @@ contains
call sph_input_parse_explosive_control(line, ierr)
else if (index(upper_line, 'IGNITION') > 0) then
call sph_input_parse_ignition(line, ierr)
else if (index(upper_line, 'SHELL CONTROL') > 0) then
call sph_input_parse_shell_control(line, ierr)
else if (index(upper_line, 'SOLID CONTROL') > 0) then
call sph_input_parse_solid_control(line, ierr)
else
@@ -380,6 +362,138 @@ contains
if (ierr /= SPH_SUCCESS) call sph_input_prefix_current_error(ierr)
end subroutine sph_input_record_keyword
subroutine sph_input_parse_section_keyword(line, upper_line, ierr)
character(len=*), intent(in) :: line
character(len=*), intent(in) :: upper_line
integer, intent(out) :: ierr
character(len=SPH_INPUT_FIELD_LEN) :: value
character(len=SPH_INPUT_FIELD_LEN) :: material_value
character(len=SPH_INPUT_FIELD_LEN) :: section_value
character(len=SPH_INPUT_FIELD_LEN) :: section_type_value
real(rk) :: thickness
real(rk) :: shear_correction
integer :: points
integer :: ios
integer :: mat_index
logical :: is_solid_section
logical :: is_shell_section
ierr = SPH_SUCCESS
input_has_section = .true.
call sph_input_get_option(line, 'ELSET', section_value)
if (len_trim(section_value) == 0) call sph_input_get_option(line, 'NSET', section_value)
if (len_trim(section_value) == 0) section_value = 'SECTION'
call sph_input_get_option(line, 'MATERIAL', material_value)
thickness = 0.0_rk
points = 3
shear_correction = 5.0_rk / 6.0_rk
call sph_input_get_option(line, 'THICKNESS', value)
if (len_trim(value) > 0) then
call sph_input_parse_real_value(value, thickness, &
'invalid section THICKNESS', ierr)
if (ierr /= SPH_SUCCESS) return
end if
call sph_input_get_option(line, 'POINTS', value)
if (len_trim(value) > 0) then
read(value, *, iostat=ios) points
if (ios /= 0) then
call sph_input_set_error('invalid section POINTS')
ierr = SPH_ERROR_INPUT
return
end if
end if
call sph_input_get_option(line, 'SHEAR_CORRECTION', value)
if (len_trim(value) == 0) call sph_input_get_option(line, 'SHEAR', value)
if (len_trim(value) > 0) then
call sph_input_parse_real_value(value, shear_correction, &
'invalid section SHEAR_CORRECTION', ierr)
if (ierr /= SPH_SUCCESS) return
end if
section_type_value = 'SECTION'
is_solid_section = index(upper_line, '*SOLID SECTION') == 1
is_shell_section = index(upper_line, '*SHELL SECTION') == 1
if (is_solid_section) then
call sph_input_validate_solid_section(material_value, section_type_value, ierr)
if (ierr /= SPH_SUCCESS) return
else if (is_shell_section) then
call sph_input_validate_shell_section(material_value, thickness, &
points, shear_correction, section_type_value, ierr)
if (ierr /= SPH_SUCCESS) return
else
if (len_trim(material_value) == 0) material_value = 'MATERIAL'
end if
call sph_db_add_section(section_value, section_type_value, material_value, &
thickness, points, shear_correction, ierr)
end subroutine sph_input_parse_section_keyword
subroutine sph_input_validate_solid_section(material_value, section_type_value, ierr)
character(len=*), intent(in) :: material_value
character(len=*), intent(out) :: section_type_value
integer, intent(out) :: ierr
integer :: mat_index
ierr = SPH_SUCCESS
section_type_value = 'SOLID'
if (len_trim(material_value) == 0) then
call sph_input_set_error('Solid section is missing MATERIAL option')
ierr = SPH_ERROR_INPUT
return
end if
mat_index = sph_input_find_material(material_value)
if (mat_index > 0) then
if (sph_input_is_explicit_non_solid_type(material_type(mat_index))) then
call sph_input_set_error('Solid section references non-Solid material')
ierr = SPH_ERROR_INPUT
return
end if
end if
end subroutine sph_input_validate_solid_section
subroutine sph_input_validate_shell_section(material_value, thickness, &
points, shear_correction, section_type_value, ierr)
character(len=*), intent(in) :: material_value
real(rk), intent(in) :: thickness
integer, intent(in) :: points
real(rk), intent(in) :: shear_correction
character(len=*), intent(out) :: section_type_value
integer, intent(out) :: ierr
integer :: mat_index
ierr = SPH_SUCCESS
section_type_value = 'SHELL'
if (len_trim(material_value) == 0) then
call sph_input_set_error('Shell section is missing MATERIAL option')
ierr = SPH_ERROR_INPUT
return
end if
mat_index = sph_input_find_material(material_value)
if (mat_index <= 0) then
call sph_input_set_error('Shell section references unknown material')
ierr = SPH_ERROR_INPUT
return
end if
if (.not. sph_input_material_type_is_shell(mat_index)) then
call sph_input_set_error('Shell section references non-Shell material')
ierr = SPH_ERROR_INPUT
return
end if
if (.not. sph_input_real_is_finite(thickness) .or. thickness <= 0.0_rk) then
call sph_input_set_error('Shell section THICKNESS must be positive')
ierr = SPH_ERROR_INPUT
return
end if
if (points /= 3 .and. points /= 5) then
call sph_input_set_error('Shell section POINTS must be 3 or 5')
ierr = SPH_ERROR_INPUT
return
end if
if (.not. sph_input_real_is_finite(shear_correction) .or. &
shear_correction <= 0.0_rk .or. shear_correction > 1.0_rk) then
call sph_input_set_error('Shell section SHEAR_CORRECTION is invalid')
ierr = SPH_ERROR_INPUT
end if
end subroutine sph_input_validate_shell_section
subroutine sph_input_parse_eos(line, ierr)
character(len=*), intent(in) :: line
integer, intent(out) :: ierr
@@ -575,6 +689,22 @@ contains
call sph_solid_set_control(material_name, softening_name, width, ierr)
end subroutine sph_input_parse_solid_control
subroutine sph_input_parse_shell_control(line, ierr)
character(len=*), intent(in) :: line
integer, intent(out) :: ierr
character(len=SPH_INPUT_FIELD_LEN) :: material_name
character(len=SPH_INPUT_FIELD_LEN) :: softening_name
real(rk) :: width
ierr = SPH_SUCCESS
width = 1.0_rk
call sph_input_get_option(line, 'MATERIAL', material_name)
call sph_input_get_option(line, 'SOFTENING', softening_name)
call sph_input_get_optional_real(line, 'WIDTH', width, ierr)
if (ierr /= SPH_SUCCESS) return
call sph_shell_set_control(material_name, softening_name, width, ierr)
end subroutine sph_input_parse_shell_control
subroutine sph_input_parse_explosive_control(line, ierr)
character(len=*), intent(in) :: line
integer, intent(out) :: ierr
@@ -678,7 +808,11 @@ contains
ierr = SPH_ERROR_INPUT
return
end if
call sph_solid_set_elastic(active_material_name, e_value, nu_value, ierr)
if (sph_input_active_material_is_shell()) then
call sph_shell_set_elastic(active_material_name, e_value, nu_value, ierr)
else
call sph_solid_set_elastic(active_material_name, e_value, nu_value, ierr)
end if
end subroutine sph_input_parse_elastic
subroutine sph_input_parse_plastic(line, ierr)
@@ -706,8 +840,13 @@ contains
return
end if
end do
call sph_solid_set_johnson_cook(active_material_name, values(1), values(2), &
values(3), values(4), values(5), values(6), values(7), values(8), ierr)
if (sph_input_active_material_is_shell()) then
call sph_shell_set_johnson_cook(active_material_name, values(1), values(2), &
values(3), values(4), values(5), values(6), values(7), values(8), ierr)
else
call sph_solid_set_johnson_cook(active_material_name, values(1), values(2), &
values(3), values(4), values(5), values(6), values(7), values(8), ierr)
end if
end subroutine sph_input_parse_plastic
subroutine sph_input_parse_damage_initiation(line, ierr)
@@ -735,7 +874,11 @@ contains
return
end if
end do
call sph_solid_set_failure(active_material_name, d_values, ierr)
if (sph_input_active_material_is_shell()) then
call sph_shell_set_failure(active_material_name, d_values, ierr)
else
call sph_solid_set_failure(active_material_name, d_values, ierr)
end if
end subroutine sph_input_parse_damage_initiation
subroutine sph_input_parse_output_control(line, ierr)
@@ -794,6 +937,31 @@ contains
end do
end function sph_input_find_material
logical function sph_input_material_type_is_shell(mat_index)
integer, intent(in) :: mat_index
character(len=SPH_INPUT_FIELD_LEN) :: upper_type
sph_input_material_type_is_shell = .false.
if (mat_index < 1 .or. mat_index > material_count) return
upper_type = sph_inp_upper(material_type(mat_index))
if (index(upper_type, 'SHELL') > 0) sph_input_material_type_is_shell = .true.
end function sph_input_material_type_is_shell
logical function sph_input_active_material_is_shell()
integer :: mat_index
mat_index = sph_input_find_material(active_material_name)
sph_input_active_material_is_shell = sph_input_material_type_is_shell(mat_index)
end function sph_input_active_material_is_shell
logical function sph_input_real_is_finite(value)
real(rk), intent(in) :: value
sph_input_real_is_finite = .true.
if (value /= value) sph_input_real_is_finite = .false.
if (abs(value) > huge(value) * 0.5_rk) sph_input_real_is_finite = .false.
end function sph_input_real_is_finite
logical function sph_input_is_explicit_non_solid_type(type_name)
character(len=*), intent(in) :: type_name
character(len=SPH_INPUT_FIELD_LEN) :: upper_type