Add contact property inp support

This commit is contained in:
shenw
2026-06-24 19:01:13 +08:00
parent aff82622f0
commit 7c16004a60
10 changed files with 666 additions and 194 deletions
+1
View File
@@ -24,4 +24,5 @@ module fem_inp_defs
integer, parameter :: MODE_STATIC = 19
integer, parameter :: MODE_SURFACE = 20
integer, parameter :: MODE_CONTACT_PAIR = 21
integer, parameter :: MODE_CONTACT_FRICTION = 22
end module fem_inp_defs
+120 -7
View File
@@ -855,6 +855,7 @@ subroutine start_nset(set_index, item_pos, set_name_value)
character(len=NAME_LEN) :: slave_value
character(len=NAME_LEN) :: master_value
character(len=NAME_LEN) :: value
character(len=NAME_LEN) :: interaction_value
has_targets = .false.
if (pair_index .le. 0 .or. pair_index .gt. ncontact_pair) then
@@ -881,15 +882,27 @@ subroutine start_nset(set_index, item_pos, set_name_value)
contact_pair_master(pair_index) = ' '
end if
call get_keyword_value(line, 'INTERACTION', interaction_value)
if (len_trim(interaction_value) .eq. 0) then
call get_keyword_value(line, 'PROPERTY', interaction_value)
end if
if (len_trim(interaction_value) .gt. 0) then
contact_pair_property(pair_index) = interaction_value
end if
call get_keyword_value(line, 'PENALTY', value)
if (len_trim(value) .eq. 0) then
call error_set(FEM_ERR_INPUT, '*CONTACT PAIR is missing PENALTY parameter', ierr)
return
end if
read(value,*,iostat=ios) contact_pair_penalty(pair_index)
if (ios .ne. 0) then
call error_set(FEM_ERR_INPUT, 'failed to parse *CONTACT PAIR PENALTY', ierr)
return
if (len_trim(interaction_value) .eq. 0) then
call error_set(FEM_ERR_INPUT, '*CONTACT PAIR is missing PENALTY parameter', ierr)
return
end if
else
read(value,*,iostat=ios) contact_pair_penalty(pair_index)
if (ios .ne. 0) then
call error_set(FEM_ERR_INPUT, 'failed to parse *CONTACT PAIR PENALTY', ierr)
return
end if
contact_pair_penalty_set(pair_index) = .true.
end if
call get_keyword_value(line, 'DAMPING', value)
@@ -899,6 +912,7 @@ subroutine start_nset(set_index, item_pos, set_name_value)
call error_set(FEM_ERR_INPUT, 'failed to parse *CONTACT PAIR DAMPING', ierr)
return
end if
contact_pair_damping_set(pair_index) = .true.
end if
call get_keyword_value(line, 'SEARCH', value)
@@ -908,6 +922,7 @@ subroutine start_nset(set_index, item_pos, set_name_value)
call error_set(FEM_ERR_INPUT, 'failed to parse *CONTACT PAIR SEARCH', ierr)
return
end if
contact_pair_search_set(pair_index) = .true.
end if
call get_keyword_value(line, 'FRICTION', value)
@@ -917,11 +932,109 @@ subroutine start_nset(set_index, item_pos, set_name_value)
call error_set(FEM_ERR_INPUT, 'failed to parse *CONTACT PAIR FRICTION', ierr)
return
end if
contact_pair_friction_set(pair_index) = .true.
end if
ierr = FEM_SUCCESS
end subroutine parse_contact_pair_header
subroutine parse_contact_property_header(line, prop_index, ierr)
character(len=*), intent(in) :: line
integer, intent(in) :: prop_index
integer, intent(out) :: ierr
character(len=NAME_LEN) :: name_value
if (prop_index .le. 0 .or. prop_index .gt. n_contact_property) then
call error_set(FEM_ERR_INPUT, 'contact property index is out of range', ierr)
return
end if
call get_keyword_value(line, 'NAME', name_value)
if (len_trim(name_value) .eq. 0) then
call error_set(FEM_ERR_INPUT, 'contact property is missing NAME parameter', ierr)
return
end if
contact_property_name(prop_index) = name_value
call parse_contact_prop_real(line, prop_index, 'PENALTY', ierr)
if (ierr .ne. FEM_SUCCESS) return
call parse_contact_prop_real(line, prop_index, 'DAMPING', ierr)
if (ierr .ne. FEM_SUCCESS) return
call parse_contact_prop_real(line, prop_index, 'SEARCH', ierr)
if (ierr .ne. FEM_SUCCESS) return
call parse_contact_prop_real(line, prop_index, 'FRICTION', ierr)
end subroutine parse_contact_property_header
subroutine parse_contact_prop_real(line, prop_index, key, ierr)
character(len=*), intent(in) :: line
integer, intent(in) :: prop_index
character(len=*), intent(in) :: key
integer, intent(out) :: ierr
character(len=NAME_LEN) :: value
integer :: ios
real(rk) :: parsed
call get_keyword_value(line, key, value)
if (len_trim(value) .eq. 0) then
ierr = FEM_SUCCESS
return
end if
read(value,*,iostat=ios) parsed
if (ios .ne. 0) then
call error_set(FEM_ERR_INPUT, 'failed to parse contact property '//trim(key), ierr)
return
end if
call set_contact_property_value(prop_index, key, parsed)
ierr = FEM_SUCCESS
end subroutine parse_contact_prop_real
subroutine parse_contact_friction_line(line, prop_index, ierr)
character(len=*), intent(in) :: line
integer, intent(in) :: prop_index
integer, intent(out) :: ierr
character(len=LINE_LEN) :: token
integer :: ios
real(rk) :: mu
if (prop_index .le. 0 .or. prop_index .gt. n_contact_property) then
call error_set(FEM_ERR_INPUT, '*FRICTION must follow a contact property', ierr)
return
end if
call csv_token(line, 1, token)
if (len_trim(token) .eq. 0) then
call error_set(FEM_ERR_INPUT, '*FRICTION data line is missing coefficient', ierr)
return
end if
read(token,*,iostat=ios) mu
if (ios .ne. 0) then
call error_set(FEM_ERR_INPUT, 'failed to parse *FRICTION coefficient', ierr)
return
end if
call set_contact_property_value(prop_index, 'FRICTION', mu)
ierr = FEM_SUCCESS
end subroutine parse_contact_friction_line
subroutine set_contact_property_value(prop_index, key, value)
integer, intent(in) :: prop_index
character(len=*), intent(in) :: key
real(rk), intent(in) :: value
select case (trim(key))
case ('PENALTY')
contact_property_penalty(prop_index) = value
contact_property_penalty_set(prop_index) = .true.
case ('DAMPING')
contact_property_damping(prop_index) = value
contact_property_damping_set(prop_index) = .true.
case ('SEARCH')
contact_property_search(prop_index) = value
contact_property_search_set(prop_index) = .true.
case ('FRICTION')
contact_property_friction(prop_index) = value
contact_property_friction_set(prop_index) = .true.
end select
end subroutine set_contact_property_value
subroutine parse_contact_pair_data_line(line, pair_index, ierr)
character(len=*), intent(in) :: line
integer, intent(in) :: pair_index
+67 -18
View File
@@ -27,6 +27,7 @@ contains
integer :: surface_count_total
integer :: surface_item_count_total
integer :: contact_pair_count
integer :: contact_property_count
integer :: bc_count
integer :: cload_count
integer :: dload_count
@@ -36,8 +37,8 @@ contains
material_count, plastic_item_count, section_count, &
amplitude_count, amplitude_item_count, &
surface_count_total, surface_item_count_total, &
contact_pair_count, bc_count, cload_count, dload_count, &
ierr)
contact_pair_count, contact_property_count, bc_count, &
cload_count, dload_count, ierr)
if (ierr .ne. FEM_SUCCESS) return
call database_allocate_model(node_count, elem_count, nset_count_total, &
@@ -55,6 +56,9 @@ contains
call database_allocate_contact_pair(contact_pair_count, ierr)
if (ierr .ne. FEM_SUCCESS) return
call database_allocate_contact_props(contact_property_count, ierr)
if (ierr .ne. FEM_SUCCESS) return
call inp_fill_model(filename, ierr)
if (ierr .ne. FEM_SUCCESS) return
@@ -72,8 +76,8 @@ contains
material_count, plastic_item_count, section_count, &
amplitude_count, amplitude_item_count, &
surface_count_total, surface_item_count_total, &
contact_pair_count, bc_count, cload_count, &
dload_count, ierr)
contact_pair_count, contact_property_count, &
bc_count, cload_count, dload_count, ierr)
character(len=*), intent(in) :: filename
integer, intent(out) :: node_count
integer, intent(out) :: elem_count
@@ -89,6 +93,7 @@ contains
integer, intent(out) :: surface_count_total
integer, intent(out) :: surface_item_count_total
integer, intent(out) :: contact_pair_count
integer, intent(out) :: contact_property_count
integer, intent(out) :: bc_count
integer, intent(out) :: cload_count
integer, intent(out) :: dload_count
@@ -116,6 +121,7 @@ contains
surface_count_total = 0
surface_item_count_total = 0
contact_pair_count = 0
contact_property_count = 0
bc_count = 0
cload_count = 0
dload_count = 0
@@ -141,7 +147,8 @@ contains
call count_keyword(clean, mode, generate_mode, element_elset_active, &
nset_count_total, elset_count_total, &
material_count, section_count, amplitude_count, &
surface_count_total, contact_pair_count)
surface_count_total, contact_pair_count, &
contact_property_count)
else if (mode .eq. MODE_NODE) then
node_count = node_count + 1
else if (mode .eq. MODE_ELEMENT) then
@@ -185,7 +192,8 @@ contains
subroutine count_keyword(line, mode, generate_mode, element_elset_active, &
nset_count_total, elset_count_total, &
material_count, section_count, amplitude_count, &
surface_count_total, contact_pair_count)
surface_count_total, contact_pair_count, &
contact_property_count)
character(len=*), intent(in) :: line
integer, intent(out) :: mode
logical, intent(out) :: generate_mode
@@ -197,6 +205,7 @@ contains
integer, intent(inout) :: amplitude_count
integer, intent(inout) :: surface_count_total
integer, intent(inout) :: contact_pair_count
integer, intent(inout) :: contact_property_count
character(len=LINE_LEN) :: upper
character(len=NAME_LEN) :: name_value
@@ -255,6 +264,9 @@ contains
else if (starts_with(upper, '*AMPLITUDE')) then
mode = MODE_AMPLITUDE
amplitude_count = amplitude_count + 1
else if (starts_with(upper, '*SURFACE INTERACTION') .or. &
starts_with(upper, '*CONTACT PROPERTY')) then
contact_property_count = contact_property_count + 1
else if (starts_with(upper, '*SURFACE')) then
mode = MODE_SURFACE
surface_count_total = surface_count_total + 1
@@ -270,6 +282,7 @@ contains
integer :: current_nset, current_elset, current_material, current_section
integer :: current_amp, current_load_amp, current_bc, current_cload
integer :: current_dload, current_contact_pair, current_surface
integer :: current_contact_property
integer :: used_surface_count, plastic_pos, amp_pos, nset_pos, elset_pos
integer :: surface_pos
character(len=LINE_LEN) :: line
@@ -283,6 +296,7 @@ contains
current_material, current_section, current_amp, &
current_load_amp, current_bc, current_cload, &
current_dload, current_contact_pair, current_surface, &
current_contact_property, &
used_surface_count, plastic_pos, amp_pos, nset_pos, &
elset_pos, surface_pos, current_elem_type, &
generate_mode, current_element_elset_active)
@@ -307,7 +321,8 @@ contains
current_material, current_section, current_amp, &
current_load_amp, current_bc, current_cload, &
current_dload, current_contact_pair, &
current_surface, used_surface_count, plastic_pos, &
current_surface, current_contact_property, &
used_surface_count, plastic_pos, &
amp_pos, nset_pos, elset_pos, surface_pos, ierr)
if (ierr .ne. FEM_SUCCESS) exit
end do
@@ -321,7 +336,8 @@ contains
current_material, current_section, current_amp, &
current_load_amp, current_bc, current_cload, &
current_dload, current_contact_pair, &
current_surface, used_surface_count, plastic_pos, &
current_surface, current_contact_property, &
used_surface_count, plastic_pos, &
amp_pos, nset_pos, elset_pos, surface_pos, &
current_elem_type, generate_mode, &
current_element_elset_active)
@@ -329,6 +345,7 @@ contains
integer, intent(out) :: current_material, current_section, current_amp
integer, intent(out) :: current_load_amp, current_bc, current_cload
integer, intent(out) :: current_dload, current_contact_pair, current_surface
integer, intent(out) :: current_contact_property
integer, intent(out) :: used_surface_count, plastic_pos, amp_pos, nset_pos
integer, intent(out) :: elset_pos, surface_pos
character(len=*), intent(out) :: current_elem_type
@@ -349,6 +366,7 @@ contains
current_dload = 0
current_contact_pair = 0
current_surface = 0
current_contact_property = 0
used_surface_count = 0
plastic_pos = 0
amp_pos = 0
@@ -366,13 +384,15 @@ contains
current_material, current_section, current_amp, &
current_load_amp, current_bc, current_cload, &
current_dload, current_contact_pair, &
current_surface, used_surface_count, plastic_pos, &
current_surface, current_contact_property, &
used_surface_count, plastic_pos, &
amp_pos, nset_pos, elset_pos, surface_pos, ierr)
character(len=*), intent(in) :: clean
integer, intent(inout) :: mode, inode, ielem, current_nset, current_elset
integer, intent(inout) :: current_material, current_section, current_amp
integer, intent(inout) :: current_load_amp, current_bc, current_cload
integer, intent(inout) :: current_dload, current_contact_pair, current_surface
integer, intent(inout) :: current_contact_property
integer, intent(inout) :: used_surface_count, plastic_pos, amp_pos, nset_pos
integer, intent(inout) :: elset_pos, surface_pos
logical, intent(inout) :: generate_mode, current_element_elset_active
@@ -387,6 +407,7 @@ contains
current_nset, current_elset, current_material, &
current_section, current_amp, current_load_amp, &
current_contact_pair, current_surface, &
current_contact_property, &
used_surface_count, nset_pos, elset_pos, surface_pos, &
amp_pos, ierr)
else
@@ -396,6 +417,7 @@ contains
current_material, current_section, current_amp, &
current_load_amp, current_bc, current_cload, &
current_dload, current_contact_pair, current_surface, &
current_contact_property, &
plastic_pos, amp_pos, nset_pos, elset_pos, &
surface_pos, ierr)
end if
@@ -407,6 +429,7 @@ contains
current_material, current_section, current_amp, &
current_load_amp, current_bc, current_cload, &
current_dload, current_contact_pair, current_surface, &
current_contact_property, &
plastic_pos, amp_pos, nset_pos, elset_pos, &
surface_pos, ierr)
character(len=*), intent(in) :: clean
@@ -414,6 +437,7 @@ contains
integer, intent(inout) :: current_material, current_section, current_amp
integer, intent(inout) :: current_load_amp, current_bc, current_cload
integer, intent(inout) :: current_dload, current_contact_pair, current_surface
integer, intent(inout) :: current_contact_property
integer, intent(inout) :: plastic_pos, amp_pos, nset_pos, elset_pos, surface_pos
logical, intent(in) :: generate_mode, current_element_elset_active
character(len=*), intent(in) :: current_elem_type
@@ -433,8 +457,8 @@ contains
call fill_control_data_line(clean, mode, current_section, current_amp, &
current_load_amp, current_bc, current_cload, &
current_dload, current_contact_pair, &
current_surface, amp_pos, surface_pos, handled, &
ierr)
current_surface, current_contact_property, &
amp_pos, surface_pos, handled, ierr)
end subroutine fill_data_line
subroutine fill_mesh_data_line(clean, mode, generate_mode, &
@@ -530,12 +554,13 @@ contains
subroutine fill_control_data_line(clean, mode, current_section, current_amp, &
current_load_amp, current_bc, current_cload, &
current_dload, current_contact_pair, &
current_surface, amp_pos, surface_pos, &
handled, ierr)
current_surface, current_contact_property, &
amp_pos, surface_pos, handled, ierr)
character(len=*), intent(in) :: clean
integer, intent(inout) :: mode, current_section, current_amp, current_load_amp
integer, intent(inout) :: current_bc, current_cload, current_dload
integer, intent(inout) :: current_contact_pair, current_surface
integer, intent(inout) :: current_contact_property
integer, intent(inout) :: amp_pos, surface_pos
logical, intent(out) :: handled
integer, intent(out) :: ierr
@@ -566,6 +591,9 @@ contains
else if (mode .eq. MODE_CONTACT_PAIR) then
call parse_contact_pair_data_line(clean, current_contact_pair, ierr)
mode = MODE_NONE
else if (mode .eq. MODE_CONTACT_FRICTION) then
call parse_contact_friction_line(clean, current_contact_property, ierr)
mode = MODE_NONE
else
handled = .false.
ierr = FEM_SUCCESS
@@ -576,8 +604,9 @@ contains
current_elem_type, current_nset, current_elset, &
current_material, current_section, current_amp, &
current_load_amp, current_contact_pair, &
current_surface, used_surface_count, nset_pos, &
elset_pos, surface_pos, amp_pos, ierr)
current_surface, current_contact_property, &
used_surface_count, nset_pos, elset_pos, surface_pos, &
amp_pos, ierr)
character(len=*), intent(in) :: line
integer, intent(out) :: mode
logical, intent(out) :: generate_mode
@@ -591,6 +620,7 @@ contains
integer, intent(out) :: current_load_amp
integer, intent(inout) :: current_contact_pair
integer, intent(inout) :: current_surface
integer, intent(inout) :: current_contact_property
integer, intent(inout) :: used_surface_count
integer, intent(inout) :: nset_pos
integer, intent(inout) :: elset_pos
@@ -620,6 +650,7 @@ contains
if (.not. handled) call fill_surface_contact_keyword(line, mode, &
current_contact_pair, &
current_surface, &
current_contact_property, &
used_surface_count, &
surface_pos, handled, &
ierr)
@@ -838,18 +869,27 @@ contains
end subroutine fill_section_control_keyword
subroutine fill_surface_contact_keyword(line, mode, current_contact_pair, &
current_surface, used_surface_count, &
surface_pos, handled, ierr)
current_surface, &
current_contact_property, &
used_surface_count, surface_pos, &
handled, ierr)
character(len=*), intent(in) :: line
integer, intent(out) :: mode
integer, intent(inout) :: current_contact_pair, current_surface
integer, intent(inout) :: current_contact_property
integer, intent(inout) :: used_surface_count, surface_pos
logical, intent(out) :: handled
integer, intent(out) :: ierr
handled = .true.
ierr = FEM_SUCCESS
if (starts_with(line, '*SURFACE')) then
if (starts_with(line, '*SURFACE INTERACTION') .or. &
starts_with(line, '*CONTACT PROPERTY')) then
mode = MODE_NONE
call fill_contact_property_keyword(line, current_contact_property, ierr)
else if (starts_with(line, '*FRICTION')) then
mode = MODE_CONTACT_FRICTION
else if (starts_with(line, '*SURFACE')) then
mode = MODE_SURFACE
call fill_surface_keyword(line, current_surface, used_surface_count, &
surface_pos, ierr)
@@ -860,6 +900,15 @@ contains
end if
end subroutine fill_surface_contact_keyword
subroutine fill_contact_property_keyword(line, current_contact_property, ierr)
character(len=*), intent(in) :: line
integer, intent(inout) :: current_contact_property
integer, intent(out) :: ierr
current_contact_property = current_contact_property + 1
call parse_contact_property_header(line, current_contact_property, ierr)
end subroutine fill_contact_property_keyword
subroutine fill_surface_keyword(line, current_surface, used_surface_count, &
surface_pos, ierr)
character(len=*), intent(in) :: line