Add Solid 0.5.1 input validation
This commit is contained in:
@@ -9,7 +9,8 @@ module sph_input_reader
|
||||
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
|
||||
use sph_database, only: sph_db_set_material_density
|
||||
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, &
|
||||
sph_water_set_viscosity, sph_water_set_particle_control, &
|
||||
sph_water_set_body_force, sph_water_apply_initial_conditions
|
||||
@@ -283,6 +284,8 @@ contains
|
||||
integer :: points
|
||||
integer :: ios
|
||||
integer :: local_ierr
|
||||
integer :: mat_index
|
||||
logical :: is_solid_section
|
||||
character(len=SPH_INPUT_LINE_LEN) :: upper_line
|
||||
|
||||
ierr = SPH_SUCCESS
|
||||
@@ -305,7 +308,6 @@ contains
|
||||
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)
|
||||
if (len_trim(material_value) == 0) material_value = 'MATERIAL'
|
||||
thickness = 0.0_rk
|
||||
points = 3
|
||||
call sph_input_get_option(line, 'THICKNESS', value)
|
||||
@@ -313,7 +315,25 @@ contains
|
||||
call sph_input_get_option(line, 'POINTS', value)
|
||||
if (len_trim(value) > 0) read(value, *, iostat=ios) points
|
||||
section_type_value = 'SECTION'
|
||||
if (index(upper_line, '*SOLID SECTION') == 1) section_type_value = 'SOLID'
|
||||
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)
|
||||
else if (key_id == SPH_KEY_SPHLITE) then
|
||||
@@ -758,6 +778,35 @@ contains
|
||||
call sph_db_add_coupling_region(name, set_name, region_type, ierr)
|
||||
end subroutine sph_input_parse_coupling_region
|
||||
|
||||
integer function sph_input_find_material(name)
|
||||
character(len=*), intent(in) :: name
|
||||
integer :: i
|
||||
|
||||
sph_input_find_material = 0
|
||||
do i = 1, material_count
|
||||
if (trim(sph_inp_upper(material_name(i))) == trim(sph_inp_upper(name))) then
|
||||
sph_input_find_material = i
|
||||
return
|
||||
end if
|
||||
end do
|
||||
end function sph_input_find_material
|
||||
|
||||
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
|
||||
|
||||
upper_type = sph_inp_upper(type_name)
|
||||
sph_input_is_explicit_non_solid_type = .false.
|
||||
if (len_trim(upper_type) == 0) return
|
||||
if (index(upper_type, 'UNSPECIFIED') > 0) return
|
||||
if (index(upper_type, 'SOLID') > 0) return
|
||||
if (index(upper_type, 'WATER') > 0) sph_input_is_explicit_non_solid_type = .true.
|
||||
if (index(upper_type, 'GAS') > 0) sph_input_is_explicit_non_solid_type = .true.
|
||||
if (index(upper_type, 'EXPLOSIVE') > 0) sph_input_is_explicit_non_solid_type = .true.
|
||||
if (index(upper_type, 'SHELL') > 0) sph_input_is_explicit_non_solid_type = .true.
|
||||
if (index(upper_type, 'BOUNDARY') > 0) sph_input_is_explicit_non_solid_type = .true.
|
||||
end function sph_input_is_explicit_non_solid_type
|
||||
|
||||
subroutine sph_input_parse_node(line, node_index, ierr)
|
||||
character(len=*), intent(in) :: line
|
||||
integer, intent(in) :: node_index
|
||||
|
||||
Reference in New Issue
Block a user