Add Solid input parsing

This commit is contained in:
Codex
2026-07-03 14:40:39 +08:00
parent a5728e021a
commit 56f37dea77
19 changed files with 777 additions and 29 deletions
+140 -2
View File
@@ -19,11 +19,16 @@ module sph_input_reader
use sph_explosive, only: sph_explosive_note_material, &
sph_explosive_set_control, sph_explosive_set_ignition, &
sph_explosive_build, sph_explosive_count_unbound_materials
use sph_solid, only: sph_solid_note_material, sph_solid_set_elastic, &
sph_solid_set_johnson_cook, sph_solid_set_failure, &
sph_solid_set_control, sph_solid_validate_input, &
sph_solid_count_unbound_materials
use sph_neighbor, only: sph_neighbor_rebuild
use sph_inp_defs, only: SPH_INPUT_LINE_LEN, SPH_INPUT_FIELD_LEN, &
SPH_INPUT_MAX_FIELDS, SPH_KEY_NODE, SPH_KEY_ELEMENT, SPH_KEY_NSET, &
SPH_KEY_ELSET, SPH_KEY_MATERIAL, SPH_KEY_SECTION, SPH_KEY_SPHLITE, &
SPH_KEY_DENSITY, SPH_KEY_UNKNOWN
SPH_KEY_DENSITY, SPH_KEY_ELASTIC, SPH_KEY_PLASTIC, &
SPH_KEY_DAMAGE_INITIATION, SPH_KEY_UNKNOWN
use sph_inp_helpers, only: sph_inp_clean_line, sph_inp_split_csv, &
sph_inp_keyword_id, sph_inp_upper
implicit none
@@ -79,6 +84,7 @@ contains
integer, intent(out) :: ierr
integer :: gas_unbound_count
integer :: explosive_unbound_count
integer :: solid_unbound_count
ierr = SPH_SUCCESS
if (npart <= 0) then
@@ -103,6 +109,8 @@ contains
end if
call sph_db_apply_sections_to_particles(ierr)
if (ierr /= SPH_SUCCESS) return
call sph_solid_validate_input(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)
@@ -113,6 +121,8 @@ contains
input_warning_count = input_warning_count + gas_unbound_count
call sph_explosive_count_unbound_materials(explosive_unbound_count)
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_neighbor_rebuild(ierr)
end subroutine sph_input_build_model
@@ -233,6 +243,24 @@ contains
close(unit=SPH_INPUT_UNIT)
return
end if
else if (active_key == SPH_KEY_ELASTIC) then
call sph_input_parse_elastic(line, ierr)
if (ierr /= SPH_SUCCESS) then
close(unit=SPH_INPUT_UNIT)
return
end if
else if (active_key == SPH_KEY_PLASTIC) then
call sph_input_parse_plastic(line, ierr)
if (ierr /= SPH_SUCCESS) then
close(unit=SPH_INPUT_UNIT)
return
end if
else if (active_key == SPH_KEY_DAMAGE_INITIATION) then
call sph_input_parse_damage_initiation(line, ierr)
if (ierr /= SPH_SUCCESS) then
close(unit=SPH_INPUT_UNIT)
return
end if
end if
end do
@@ -246,6 +274,7 @@ contains
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
character(len=SPH_INPUT_FIELD_LEN) :: type_value
real(rk) :: thickness
integer :: points
@@ -266,6 +295,7 @@ contains
call sph_water_note_material(value, type_value)
call sph_gas_note_material(value, type_value)
call sph_explosive_note_material(value, type_value)
call sph_solid_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)
@@ -279,7 +309,9 @@ contains
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
call sph_db_add_section(section_value, 'SECTION', material_value, &
section_type_value = 'SECTION'
if (index(upper_line, '*SOLID SECTION') == 1) section_type_value = 'SOLID'
call sph_db_add_section(section_value, section_type_value, material_value, &
thickness, points, ierr)
else if (key_id == SPH_KEY_SPHLITE) then
if (index(upper_line, 'TIME CONTROL') > 0) then
@@ -302,6 +334,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, 'SOLID CONTROL') > 0) then
call sph_input_parse_solid_control(line, ierr)
else
input_warning_count = input_warning_count + 1
end if
@@ -497,6 +531,22 @@ contains
call sph_gas_set_body_force(force, ierr)
end subroutine sph_input_parse_body_force
subroutine sph_input_parse_solid_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_solid_set_control(material_name, softening_name, width, ierr)
end subroutine sph_input_parse_solid_control
subroutine sph_input_parse_explosive_control(line, ierr)
character(len=*), intent(in) :: line
integer, intent(out) :: ierr
@@ -572,6 +622,94 @@ contains
call sph_db_set_material_density(active_material_name, density_value, ierr)
end subroutine sph_input_parse_density
subroutine sph_input_parse_elastic(line, ierr)
character(len=*), intent(in) :: line
integer, intent(out) :: ierr
character(len=SPH_INPUT_FIELD_LEN) :: fields(SPH_INPUT_MAX_FIELDS)
integer :: nfields
integer :: ios
real(rk) :: e_value
real(rk) :: nu_value
ierr = SPH_SUCCESS
call sph_inp_split_csv(line, fields, nfields)
if (nfields < 2) then
call sph_input_set_error('invalid *ELASTIC record')
ierr = SPH_ERROR_INPUT
return
end if
read(fields(1), *, iostat=ios) e_value
if (ios /= 0) then
call sph_input_set_error('invalid elastic modulus')
ierr = SPH_ERROR_INPUT
return
end if
read(fields(2), *, iostat=ios) nu_value
if (ios /= 0) then
call sph_input_set_error('invalid Poisson ratio')
ierr = SPH_ERROR_INPUT
return
end if
call sph_solid_set_elastic(active_material_name, e_value, nu_value, ierr)
end subroutine sph_input_parse_elastic
subroutine sph_input_parse_plastic(line, ierr)
character(len=*), intent(in) :: line
integer, intent(out) :: ierr
character(len=SPH_INPUT_FIELD_LEN) :: fields(SPH_INPUT_MAX_FIELDS)
integer :: nfields
integer :: i
integer :: ios
real(rk) :: values(8)
ierr = SPH_SUCCESS
values = 0.0_rk
call sph_inp_split_csv(line, fields, nfields)
if (nfields < 8) then
call sph_input_set_error('invalid Johnson-Cook plastic record')
ierr = SPH_ERROR_INPUT
return
end if
do i = 1, 8
read(fields(i), *, iostat=ios) values(i)
if (ios /= 0) then
call sph_input_set_error('invalid Johnson-Cook plastic value')
ierr = SPH_ERROR_INPUT
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)
end subroutine sph_input_parse_plastic
subroutine sph_input_parse_damage_initiation(line, ierr)
character(len=*), intent(in) :: line
integer, intent(out) :: ierr
character(len=SPH_INPUT_FIELD_LEN) :: fields(SPH_INPUT_MAX_FIELDS)
integer :: nfields
integer :: i
integer :: ios
real(rk) :: d_values(5)
ierr = SPH_SUCCESS
d_values = 0.0_rk
call sph_inp_split_csv(line, fields, nfields)
if (nfields < 5) then
call sph_input_set_error('invalid Johnson-Cook damage record')
ierr = SPH_ERROR_INPUT
return
end if
do i = 1, 5
read(fields(i), *, iostat=ios) d_values(i)
if (ios /= 0) then
call sph_input_set_error('invalid Johnson-Cook damage value')
ierr = SPH_ERROR_INPUT
return
end if
end do
call sph_solid_set_failure(active_material_name, d_values, ierr)
end subroutine sph_input_parse_damage_initiation
subroutine sph_input_parse_output_control(line, ierr)
character(len=*), intent(in) :: line
integer, intent(out) :: ierr