Implement Shell input parsing stage
This commit is contained in:
@@ -124,6 +124,7 @@ module sph_database
|
||||
integer :: section_material_id(SPH_MAX_SECTIONS)
|
||||
real(rk) :: section_thickness(SPH_MAX_SECTIONS)
|
||||
integer :: section_integration_points(SPH_MAX_SECTIONS)
|
||||
real(rk) :: section_shear_correction(SPH_MAX_SECTIONS)
|
||||
|
||||
integer :: nset_count = 0
|
||||
character(len=SPH_NAME_LEN) :: nset_name(SPH_MAX_SETS)
|
||||
@@ -270,6 +271,7 @@ contains
|
||||
section_material_id = 0
|
||||
section_thickness = 0.0_rk
|
||||
section_integration_points = 0
|
||||
section_shear_correction = 0.0_rk
|
||||
nset_count = 0
|
||||
nset_name = ' '
|
||||
nset_member_count = 0
|
||||
@@ -500,12 +502,14 @@ contains
|
||||
ierr = SPH_ERROR_DATABASE
|
||||
end subroutine sph_db_set_material_density
|
||||
|
||||
subroutine sph_db_add_section(name, stype, mat_name, thickness, points, ierr)
|
||||
subroutine sph_db_add_section(name, stype, mat_name, thickness, points, &
|
||||
shear_correction, ierr)
|
||||
character(len=*), intent(in) :: name
|
||||
character(len=*), intent(in) :: stype
|
||||
character(len=*), intent(in) :: mat_name
|
||||
real(rk), intent(in) :: thickness
|
||||
integer, intent(in) :: points
|
||||
real(rk), intent(in) :: shear_correction
|
||||
integer, intent(out) :: ierr
|
||||
integer :: mat_index
|
||||
integer :: set_index
|
||||
@@ -536,6 +540,7 @@ contains
|
||||
section_material_id(section_count) = mat_index
|
||||
section_thickness(section_count) = thickness
|
||||
section_integration_points(section_count) = points
|
||||
section_shear_correction(section_count) = shear_correction
|
||||
end subroutine sph_db_add_section
|
||||
|
||||
integer function sph_db_find_material(name)
|
||||
|
||||
+205
-37
@@ -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
|
||||
|
||||
@@ -1,15 +1,460 @@
|
||||
module sph_shell
|
||||
use sph_precision, only: rk
|
||||
use sph_error, only: SPH_SUCCESS, SPH_ERROR_ARGUMENT, SPH_ERROR_INPUT, &
|
||||
sph_error_set
|
||||
use sph_database, only: SPH_MAX_MATERIALS, SPH_NAME_LEN, material_count, &
|
||||
material_name, material_type, material_density, npart, particle_phase, &
|
||||
particle_status, material_id, section_count, section_id, section_type, &
|
||||
section_material_id, section_thickness, section_integration_points, &
|
||||
section_shear_correction, SPH_PHASE_SHELL, SPH_STATUS_ACTIVE
|
||||
implicit none
|
||||
|
||||
logical :: shell_module_initialized = .false.
|
||||
logical :: shell_material_seen = .false.
|
||||
integer :: shell_material_count = 0
|
||||
integer :: shell_material_ids(SPH_MAX_MATERIALS) = 0
|
||||
character(len=SPH_NAME_LEN) :: shell_material_names(SPH_MAX_MATERIALS) = ' '
|
||||
logical :: shell_elastic_defined(SPH_MAX_MATERIALS) = .false.
|
||||
logical :: shell_johnson_cook_defined(SPH_MAX_MATERIALS) = .false.
|
||||
logical :: shell_failure_defined(SPH_MAX_MATERIALS) = .false.
|
||||
logical :: shell_control_defined(SPH_MAX_MATERIALS) = .false.
|
||||
real(rk) :: shell_elastic_e(SPH_MAX_MATERIALS) = 0.0_rk
|
||||
real(rk) :: shell_elastic_nu(SPH_MAX_MATERIALS) = 0.0_rk
|
||||
real(rk) :: shell_jc_a(SPH_MAX_MATERIALS) = 0.0_rk
|
||||
real(rk) :: shell_jc_b(SPH_MAX_MATERIALS) = 0.0_rk
|
||||
real(rk) :: shell_jc_n(SPH_MAX_MATERIALS) = 0.0_rk
|
||||
real(rk) :: shell_jc_c(SPH_MAX_MATERIALS) = 0.0_rk
|
||||
real(rk) :: shell_jc_m(SPH_MAX_MATERIALS) = 0.0_rk
|
||||
real(rk) :: shell_jc_epsdot0(SPH_MAX_MATERIALS) = 1.0_rk
|
||||
real(rk) :: shell_jc_troom(SPH_MAX_MATERIALS) = 293.15_rk
|
||||
real(rk) :: shell_jc_tmelt(SPH_MAX_MATERIALS) = 1793.0_rk
|
||||
real(rk) :: shell_failure_d(5,SPH_MAX_MATERIALS) = 0.0_rk
|
||||
character(len=SPH_NAME_LEN) :: shell_softening_type(SPH_MAX_MATERIALS) = ' '
|
||||
real(rk) :: shell_softening_width(SPH_MAX_MATERIALS) = 0.0_rk
|
||||
|
||||
contains
|
||||
|
||||
subroutine sph_shell_initialize()
|
||||
shell_module_initialized = .true.
|
||||
call sph_shell_clear_material_table()
|
||||
end subroutine sph_shell_initialize
|
||||
|
||||
subroutine sph_shell_reset()
|
||||
shell_module_initialized = .false.
|
||||
call sph_shell_clear_material_table()
|
||||
end subroutine sph_shell_reset
|
||||
|
||||
subroutine sph_shell_clear_material_table()
|
||||
shell_material_seen = .false.
|
||||
shell_material_count = 0
|
||||
shell_material_ids = 0
|
||||
shell_material_names = ' '
|
||||
shell_elastic_defined = .false.
|
||||
shell_johnson_cook_defined = .false.
|
||||
shell_failure_defined = .false.
|
||||
shell_control_defined = .false.
|
||||
shell_elastic_e = 0.0_rk
|
||||
shell_elastic_nu = 0.0_rk
|
||||
shell_jc_a = 0.0_rk
|
||||
shell_jc_b = 0.0_rk
|
||||
shell_jc_n = 0.0_rk
|
||||
shell_jc_c = 0.0_rk
|
||||
shell_jc_m = 0.0_rk
|
||||
shell_jc_epsdot0 = 1.0_rk
|
||||
shell_jc_troom = 293.15_rk
|
||||
shell_jc_tmelt = 1793.0_rk
|
||||
shell_failure_d = 0.0_rk
|
||||
shell_softening_type = ' '
|
||||
shell_softening_width = 0.0_rk
|
||||
end subroutine sph_shell_clear_material_table
|
||||
|
||||
subroutine sph_shell_note_material(name, material_type_in)
|
||||
character(len=*), intent(in) :: name
|
||||
character(len=*), intent(in) :: material_type_in
|
||||
integer :: shell_index
|
||||
|
||||
if (index(sph_shell_upper(material_type_in), 'SHELL') > 0) then
|
||||
shell_material_seen = .true.
|
||||
shell_index = sph_shell_register_material(name)
|
||||
end if
|
||||
end subroutine sph_shell_note_material
|
||||
|
||||
subroutine sph_shell_set_elastic(material_name_in, e_value, nu_value, ierr)
|
||||
character(len=*), intent(in) :: material_name_in
|
||||
real(rk), intent(in) :: e_value
|
||||
real(rk), intent(in) :: nu_value
|
||||
integer, intent(out) :: ierr
|
||||
integer :: shell_index
|
||||
|
||||
ierr = SPH_SUCCESS
|
||||
if (.not. sph_shell_vector_is_finite((/ e_value, nu_value /))) then
|
||||
call sph_error_set(SPH_ERROR_ARGUMENT, 'Shell elastic parameter is not finite')
|
||||
ierr = SPH_ERROR_ARGUMENT
|
||||
return
|
||||
end if
|
||||
if (e_value <= 0.0_rk) then
|
||||
call sph_error_set(SPH_ERROR_ARGUMENT, 'Shell elastic modulus must be positive')
|
||||
ierr = SPH_ERROR_ARGUMENT
|
||||
return
|
||||
end if
|
||||
if (nu_value <= -1.0_rk .or. nu_value >= 0.5_rk) then
|
||||
call sph_error_set(SPH_ERROR_ARGUMENT, 'Shell Poisson ratio is invalid')
|
||||
ierr = SPH_ERROR_ARGUMENT
|
||||
return
|
||||
end if
|
||||
call sph_shell_prepare_material(material_name_in, shell_index, ierr)
|
||||
if (ierr /= SPH_SUCCESS) return
|
||||
shell_elastic_defined(shell_index) = .true.
|
||||
shell_elastic_e(shell_index) = e_value
|
||||
shell_elastic_nu(shell_index) = nu_value
|
||||
end subroutine sph_shell_set_elastic
|
||||
|
||||
subroutine sph_shell_set_johnson_cook(material_name_in, a_value, b_value, &
|
||||
n_value, c_value, m_value, epsdot0_value, troom_value, tmelt_value, ierr)
|
||||
character(len=*), intent(in) :: material_name_in
|
||||
real(rk), intent(in) :: a_value
|
||||
real(rk), intent(in) :: b_value
|
||||
real(rk), intent(in) :: n_value
|
||||
real(rk), intent(in) :: c_value
|
||||
real(rk), intent(in) :: m_value
|
||||
real(rk), intent(in) :: epsdot0_value
|
||||
real(rk), intent(in) :: troom_value
|
||||
real(rk), intent(in) :: tmelt_value
|
||||
integer, intent(out) :: ierr
|
||||
integer :: shell_index
|
||||
real(rk) :: jc_values(8)
|
||||
|
||||
ierr = SPH_SUCCESS
|
||||
jc_values = (/ a_value, b_value, n_value, c_value, m_value, &
|
||||
epsdot0_value, troom_value, tmelt_value /)
|
||||
if (.not. sph_shell_vector_is_finite(jc_values)) then
|
||||
call sph_error_set(SPH_ERROR_ARGUMENT, &
|
||||
'Shell Johnson-Cook flow parameter is not finite')
|
||||
ierr = SPH_ERROR_ARGUMENT
|
||||
return
|
||||
end if
|
||||
if (a_value < 0.0_rk .or. b_value < 0.0_rk .or. n_value < 0.0_rk) then
|
||||
call sph_error_set(SPH_ERROR_ARGUMENT, 'Shell Johnson-Cook strength is invalid')
|
||||
ierr = SPH_ERROR_ARGUMENT
|
||||
return
|
||||
end if
|
||||
if (c_value < 0.0_rk .or. m_value < 0.0_rk) then
|
||||
call sph_error_set(SPH_ERROR_ARGUMENT, 'Shell Johnson-Cook rate or thermal exponent is invalid')
|
||||
ierr = SPH_ERROR_ARGUMENT
|
||||
return
|
||||
end if
|
||||
if (epsdot0_value <= 0.0_rk) then
|
||||
call sph_error_set(SPH_ERROR_ARGUMENT, 'Shell Johnson-Cook reference strain rate must be positive')
|
||||
ierr = SPH_ERROR_ARGUMENT
|
||||
return
|
||||
end if
|
||||
if (tmelt_value <= troom_value) then
|
||||
call sph_error_set(SPH_ERROR_ARGUMENT, 'Shell Johnson-Cook melt temperature must exceed room temperature')
|
||||
ierr = SPH_ERROR_ARGUMENT
|
||||
return
|
||||
end if
|
||||
call sph_shell_prepare_material(material_name_in, shell_index, ierr)
|
||||
if (ierr /= SPH_SUCCESS) return
|
||||
shell_johnson_cook_defined(shell_index) = .true.
|
||||
shell_jc_a(shell_index) = a_value
|
||||
shell_jc_b(shell_index) = b_value
|
||||
shell_jc_n(shell_index) = n_value
|
||||
shell_jc_c(shell_index) = c_value
|
||||
shell_jc_m(shell_index) = m_value
|
||||
shell_jc_epsdot0(shell_index) = epsdot0_value
|
||||
shell_jc_troom(shell_index) = troom_value
|
||||
shell_jc_tmelt(shell_index) = tmelt_value
|
||||
end subroutine sph_shell_set_johnson_cook
|
||||
|
||||
subroutine sph_shell_set_failure(material_name_in, d_values, ierr)
|
||||
character(len=*), intent(in) :: material_name_in
|
||||
real(rk), intent(in) :: d_values(5)
|
||||
integer, intent(out) :: ierr
|
||||
integer :: shell_index
|
||||
|
||||
ierr = SPH_SUCCESS
|
||||
if (.not. sph_shell_vector_is_finite(d_values)) then
|
||||
call sph_error_set(SPH_ERROR_ARGUMENT, 'Shell Johnson-Cook failure parameter is not finite')
|
||||
ierr = SPH_ERROR_ARGUMENT
|
||||
return
|
||||
end if
|
||||
call sph_shell_prepare_material(material_name_in, shell_index, ierr)
|
||||
if (ierr /= SPH_SUCCESS) return
|
||||
shell_failure_defined(shell_index) = .true.
|
||||
shell_failure_d(:,shell_index) = d_values(:)
|
||||
end subroutine sph_shell_set_failure
|
||||
|
||||
subroutine sph_shell_set_control(material_name_in, softening_name, &
|
||||
softening_width_value, ierr)
|
||||
character(len=*), intent(in) :: material_name_in
|
||||
character(len=*), intent(in) :: softening_name
|
||||
real(rk), intent(in) :: softening_width_value
|
||||
integer, intent(out) :: ierr
|
||||
integer :: shell_index
|
||||
character(len=SPH_NAME_LEN) :: upper_softening
|
||||
|
||||
ierr = SPH_SUCCESS
|
||||
upper_softening = sph_shell_upper(softening_name)
|
||||
if (len_trim(upper_softening) == 0) upper_softening = 'LINEAR'
|
||||
if (index(upper_softening, 'LINEAR') <= 0) then
|
||||
call sph_error_set(SPH_ERROR_INPUT, 'Shell SOFTENING must be LINEAR')
|
||||
ierr = SPH_ERROR_INPUT
|
||||
return
|
||||
end if
|
||||
if (.not. sph_shell_vector_is_finite((/ softening_width_value /))) then
|
||||
call sph_error_set(SPH_ERROR_ARGUMENT, 'Shell softening WIDTH is not finite')
|
||||
ierr = SPH_ERROR_ARGUMENT
|
||||
return
|
||||
end if
|
||||
if (softening_width_value <= 0.0_rk) then
|
||||
call sph_error_set(SPH_ERROR_ARGUMENT, 'Shell softening WIDTH must be positive')
|
||||
ierr = SPH_ERROR_ARGUMENT
|
||||
return
|
||||
end if
|
||||
call sph_shell_prepare_material(material_name_in, shell_index, ierr)
|
||||
if (ierr /= SPH_SUCCESS) return
|
||||
shell_control_defined(shell_index) = .true.
|
||||
shell_softening_type(shell_index) = upper_softening
|
||||
shell_softening_width(shell_index) = softening_width_value
|
||||
end subroutine sph_shell_set_control
|
||||
|
||||
subroutine sph_shell_build_state(ierr)
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
ierr = SPH_SUCCESS
|
||||
if (.not. shell_material_seen) return
|
||||
call sph_shell_validate_input(ierr)
|
||||
end subroutine sph_shell_build_state
|
||||
|
||||
subroutine sph_shell_validate_input(ierr)
|
||||
integer, intent(out) :: ierr
|
||||
integer :: shell_index
|
||||
integer :: mat_index
|
||||
|
||||
ierr = SPH_SUCCESS
|
||||
do shell_index = 1, shell_material_count
|
||||
mat_index = shell_material_ids(shell_index)
|
||||
if (.not. sph_shell_has_active_particle(mat_index)) cycle
|
||||
if (material_density(mat_index) <= 0.0_rk) then
|
||||
call sph_error_set(SPH_ERROR_INPUT, 'active Shell material is missing density')
|
||||
ierr = SPH_ERROR_INPUT
|
||||
return
|
||||
end if
|
||||
if (.not. shell_elastic_defined(shell_index)) then
|
||||
call sph_error_set(SPH_ERROR_INPUT, 'active Shell material is missing elastic data')
|
||||
ierr = SPH_ERROR_INPUT
|
||||
return
|
||||
end if
|
||||
if (shell_failure_defined(shell_index) .and. &
|
||||
.not. shell_johnson_cook_defined(shell_index)) then
|
||||
call sph_error_set(SPH_ERROR_INPUT, 'Shell failure requires Johnson-Cook flow data')
|
||||
ierr = SPH_ERROR_INPUT
|
||||
return
|
||||
end if
|
||||
end do
|
||||
call sph_shell_validate_particle_sections(ierr)
|
||||
end subroutine sph_shell_validate_input
|
||||
|
||||
subroutine sph_shell_validate_particle_sections(ierr)
|
||||
integer, intent(out) :: ierr
|
||||
integer :: i
|
||||
integer :: sec
|
||||
|
||||
ierr = SPH_SUCCESS
|
||||
do i = 1, npart
|
||||
if (particle_status(i) /= SPH_STATUS_ACTIVE) cycle
|
||||
if (particle_phase(i) /= SPH_PHASE_SHELL) cycle
|
||||
sec = section_id(i)
|
||||
if (sec < 1 .or. sec > section_count) then
|
||||
call sph_error_set(SPH_ERROR_INPUT, &
|
||||
'active Shell particle is missing Shell section')
|
||||
ierr = SPH_ERROR_INPUT
|
||||
return
|
||||
end if
|
||||
if (index(sph_shell_upper(section_type(sec)), 'SHELL') <= 0) then
|
||||
call sph_error_set(SPH_ERROR_INPUT, &
|
||||
'active Shell particle is not bound to Shell section')
|
||||
ierr = SPH_ERROR_INPUT
|
||||
return
|
||||
end if
|
||||
if (section_material_id(sec) /= material_id(i)) then
|
||||
call sph_error_set(SPH_ERROR_INPUT, &
|
||||
'active Shell particle section material mismatch')
|
||||
ierr = SPH_ERROR_INPUT
|
||||
return
|
||||
end if
|
||||
call sph_shell_validate_section_values(sec, ierr)
|
||||
if (ierr /= SPH_SUCCESS) return
|
||||
end do
|
||||
end subroutine sph_shell_validate_particle_sections
|
||||
|
||||
subroutine sph_shell_validate_section_values(sec, ierr)
|
||||
integer, intent(in) :: sec
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
ierr = SPH_SUCCESS
|
||||
if (.not. sph_shell_scalar_is_finite(section_thickness(sec)) .or. &
|
||||
section_thickness(sec) <= 0.0_rk) then
|
||||
call sph_error_set(SPH_ERROR_INPUT, 'Shell section thickness must be positive')
|
||||
ierr = SPH_ERROR_INPUT
|
||||
return
|
||||
end if
|
||||
if (section_integration_points(sec) /= 3 .and. &
|
||||
section_integration_points(sec) /= 5) then
|
||||
call sph_error_set(SPH_ERROR_INPUT, 'Shell section POINTS must be 3 or 5')
|
||||
ierr = SPH_ERROR_INPUT
|
||||
return
|
||||
end if
|
||||
if (.not. sph_shell_scalar_is_finite(section_shear_correction(sec)) .or. &
|
||||
section_shear_correction(sec) <= 0.0_rk .or. &
|
||||
section_shear_correction(sec) > 1.0_rk) then
|
||||
call sph_error_set(SPH_ERROR_INPUT, 'Shell section SHEAR_CORRECTION is invalid')
|
||||
ierr = SPH_ERROR_INPUT
|
||||
return
|
||||
end if
|
||||
end subroutine sph_shell_validate_section_values
|
||||
|
||||
subroutine sph_shell_count_unbound_materials(count)
|
||||
integer, intent(out) :: count
|
||||
integer :: shell_index
|
||||
|
||||
count = 0
|
||||
do shell_index = 1, shell_material_count
|
||||
if (.not. sph_shell_has_active_particle(shell_material_ids(shell_index))) then
|
||||
count = count + 1
|
||||
end if
|
||||
end do
|
||||
end subroutine sph_shell_count_unbound_materials
|
||||
|
||||
integer function sph_shell_register_material(name)
|
||||
character(len=*), intent(in) :: name
|
||||
integer :: existing
|
||||
integer :: mat_index
|
||||
|
||||
existing = sph_shell_find_shell_material(name)
|
||||
if (existing > 0) then
|
||||
sph_shell_register_material = existing
|
||||
return
|
||||
end if
|
||||
if (shell_material_count >= SPH_MAX_MATERIALS) then
|
||||
sph_shell_register_material = 0
|
||||
return
|
||||
end if
|
||||
mat_index = sph_shell_find_material(name)
|
||||
if (mat_index <= 0) then
|
||||
sph_shell_register_material = 0
|
||||
return
|
||||
end if
|
||||
shell_material_count = shell_material_count + 1
|
||||
shell_material_ids(shell_material_count) = mat_index
|
||||
shell_material_names(shell_material_count) = material_name(mat_index)
|
||||
sph_shell_register_material = shell_material_count
|
||||
end function sph_shell_register_material
|
||||
|
||||
subroutine sph_shell_prepare_material(name, shell_index, ierr)
|
||||
character(len=*), intent(in) :: name
|
||||
integer, intent(out) :: shell_index
|
||||
integer, intent(out) :: ierr
|
||||
integer :: mat_index
|
||||
|
||||
ierr = SPH_SUCCESS
|
||||
shell_index = sph_shell_find_shell_material(name)
|
||||
if (shell_index <= 0) then
|
||||
mat_index = sph_shell_find_material(name)
|
||||
if (mat_index <= 0) then
|
||||
call sph_error_set(SPH_ERROR_INPUT, 'Shell material is unknown')
|
||||
ierr = SPH_ERROR_INPUT
|
||||
return
|
||||
end if
|
||||
if (index(sph_shell_upper(material_type(mat_index)), 'SHELL') <= 0) then
|
||||
call sph_error_set(SPH_ERROR_INPUT, 'Shell data references non-Shell material')
|
||||
ierr = SPH_ERROR_INPUT
|
||||
return
|
||||
end if
|
||||
shell_index = sph_shell_register_material(name)
|
||||
end if
|
||||
if (shell_index <= 0) then
|
||||
call sph_error_set(SPH_ERROR_INPUT, 'failed to register Shell material')
|
||||
ierr = SPH_ERROR_INPUT
|
||||
end if
|
||||
end subroutine sph_shell_prepare_material
|
||||
|
||||
integer function sph_shell_find_shell_material(name)
|
||||
character(len=*), intent(in) :: name
|
||||
integer :: i
|
||||
|
||||
sph_shell_find_shell_material = 0
|
||||
do i = 1, shell_material_count
|
||||
if (trim(sph_shell_upper(shell_material_names(i))) == &
|
||||
trim(sph_shell_upper(name))) then
|
||||
sph_shell_find_shell_material = i
|
||||
return
|
||||
end if
|
||||
end do
|
||||
end function sph_shell_find_shell_material
|
||||
|
||||
integer function sph_shell_find_material(name)
|
||||
character(len=*), intent(in) :: name
|
||||
integer :: i
|
||||
|
||||
sph_shell_find_material = 0
|
||||
do i = 1, material_count
|
||||
if (trim(sph_shell_upper(material_name(i))) == trim(sph_shell_upper(name))) then
|
||||
sph_shell_find_material = i
|
||||
return
|
||||
end if
|
||||
end do
|
||||
end function sph_shell_find_material
|
||||
|
||||
logical function sph_shell_has_active_particle(mat_index)
|
||||
integer, intent(in) :: mat_index
|
||||
integer :: i
|
||||
|
||||
sph_shell_has_active_particle = .false.
|
||||
if (mat_index <= 0) return
|
||||
do i = 1, npart
|
||||
if (material_id(i) /= mat_index) cycle
|
||||
if (particle_status(i) /= SPH_STATUS_ACTIVE) cycle
|
||||
if (particle_phase(i) /= SPH_PHASE_SHELL) cycle
|
||||
sph_shell_has_active_particle = .true.
|
||||
return
|
||||
end do
|
||||
end function sph_shell_has_active_particle
|
||||
|
||||
logical function sph_shell_vector_is_finite(values)
|
||||
real(rk), intent(in) :: values(:)
|
||||
integer :: i
|
||||
|
||||
sph_shell_vector_is_finite = .true.
|
||||
do i = 1, size(values)
|
||||
if (.not. sph_shell_scalar_is_finite(values(i))) then
|
||||
sph_shell_vector_is_finite = .false.
|
||||
return
|
||||
end if
|
||||
end do
|
||||
end function sph_shell_vector_is_finite
|
||||
|
||||
logical function sph_shell_scalar_is_finite(value)
|
||||
real(rk), intent(in) :: value
|
||||
|
||||
sph_shell_scalar_is_finite = .true.
|
||||
if (value /= value) sph_shell_scalar_is_finite = .false.
|
||||
if (abs(value) > huge(value) * 0.5_rk) sph_shell_scalar_is_finite = .false.
|
||||
end function sph_shell_scalar_is_finite
|
||||
|
||||
function sph_shell_upper(text) result(out)
|
||||
character(len=*), intent(in) :: text
|
||||
character(len=len(text)) :: out
|
||||
integer :: i
|
||||
integer :: code
|
||||
|
||||
out = text
|
||||
do i = 1, len(out)
|
||||
code = ichar(out(i:i))
|
||||
if (code >= ichar('a') .and. code <= ichar('z')) then
|
||||
out(i:i) = char(code - ichar('a') + ichar('A'))
|
||||
end if
|
||||
end do
|
||||
end function sph_shell_upper
|
||||
|
||||
end module sph_shell
|
||||
|
||||
Reference in New Issue
Block a user