diff --git a/CMakeLists.txt b/CMakeLists.txt index ba2c393..2403f4f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,6 +67,7 @@ add_library(femlite_core STATIC src/base/fem_log.f90 src/base/fem_control.f90 src/element/fem_element_topology.f90 + src/mesh/fem_database_state.f90 src/mesh/fem_database.f90 src/mesh/fem_database_surface.f90 src/input/fem_inp_defs.f90 diff --git a/docs/v4_development_plan.md b/docs/v4_development_plan.md index 6f2d041..64feab1 100644 --- a/docs/v4_development_plan.md +++ b/docs/v4_development_plan.md @@ -617,15 +617,21 @@ FemLite 0.4.x 定位为: - `TYPE=NODE` 数据行暂不允许 face label。 - contact pair 仍基于 facet 接触路径;若 contact pair 直接引用 node-based surface,数据库校验阶段报错,避免静默无效接触。 - facet 匹配函数仅对 `ELEMENT` surface 生效,避免把 node surface 的节点号误匹配为单元号。 +- 新增 `*SURFACE INTERACTION` / `*CONTACT PROPERTY` 子集,支持法向 penalty、damping、search 和 `*FRICTION` 摩擦系数。 +- `*CONTACT PAIR` 支持 `INTERACTION=` / `PROPERTY=` 名称绑定,pair 级显式参数优先,未显式给出的参数从 contact property 继承。 +- 数据库全局状态拆出到 `fem_database_state`,主数据库行为模块保持在源文件硬性尺寸限制内。 已补充测试: - `tests/data/s4_node_surface.inp`:node-based surface 解析和数据库校验。 +- `tests/data/s4_contact_property.inp`:contact property 解析、friction 读取和 contact pair 参数继承。 +- `tests/data/s4_contact_pair_unknown_property.inp`:未知 `INTERACTION` 名称在模型构建阶段报错。 - `implicit_inp`:检查 `surface_type`、node target、facet 匹配隔离和 `fem_build_model`。 - `contact`:确认旧 element surface/contact pair 路径不回退。 +- `source_size`:确认数据库状态拆分后源文件不超过硬性行数限制。 后续: - 增加 node-based surface 查询接口。 -- 增加 contact property 数据结构和解析。 - 在节点-面接触或后续 contact pair 扩展中接入 node-based slave surface。 +- 增加 analytic rigid surface 子集。 diff --git a/src/input/fem_inp_defs.f90 b/src/input/fem_inp_defs.f90 index 4f11d33..5748b47 100644 --- a/src/input/fem_inp_defs.f90 +++ b/src/input/fem_inp_defs.f90 @@ -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 diff --git a/src/input/fem_inp_helpers.f90 b/src/input/fem_inp_helpers.f90 index bfacd37..ea4695e 100644 --- a/src/input/fem_inp_helpers.f90 +++ b/src/input/fem_inp_helpers.f90 @@ -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 diff --git a/src/input/fem_inp_reader.f90 b/src/input/fem_inp_reader.f90 index 3b5b8c9..1c8eb01 100644 --- a/src/input/fem_inp_reader.f90 +++ b/src/input/fem_inp_reader.f90 @@ -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 diff --git a/src/mesh/fem_database.f90 b/src/mesh/fem_database.f90 index d07a352..9332868 100644 --- a/src/mesh/fem_database.f90 +++ b/src/mesh/fem_database.f90 @@ -2,175 +2,9 @@ module fem_database use fem_precision use fem_error use fem_element_topology + use fem_database_state implicit none - integer :: nnode = 0 - integer :: nelem = 0 - integer :: ndof = 0 - integer :: ngauss_total = 0 - integer :: n_nset = 0 - integer :: n_elset = 0 - integer :: n_surface = 0 - integer :: n_surface_item = 0 - integer :: n_material = 0 - integer :: n_section = 0 - integer :: n_plastic_item = 0 - integer :: n_amp = 0 - integer :: n_amp_item = 0 - integer :: nbc = 0 - integer :: ncload = 0 - integer :: ndload = 0 - integer :: nrobin = 0 - integer :: nmpc = 0 - integer :: nmpc_term = 0 - integer :: ncontact_plane = 0 - integer :: ncontact_pair = 0 - - real(rk), allocatable :: coord0(:,:) - real(rk), allocatable :: coord(:,:) - integer, allocatable :: node_id_ext(:) - integer, allocatable :: elem_conn(:,:) - integer, allocatable :: elem_id_ext(:) - integer, allocatable :: elem_nnode(:) - character(len=ELEM_TYPE_LEN), allocatable :: elem_type(:) - integer, allocatable :: elem_mat(:) - integer, allocatable :: elem_sec(:) - integer, allocatable :: elem_status(:) - integer, allocatable :: dof_id(:,:) - - real(rk), allocatable :: u(:) - real(rk), allocatable :: v(:) - real(rk), allocatable :: a(:) - real(rk), allocatable :: vhalf(:) - real(rk), allocatable :: mass_diag(:) - real(rk), allocatable :: fint(:) - real(rk), allocatable :: fext(:) - real(rk), allocatable :: fsph(:) - real(rk), allocatable :: fcontact(:) - real(rk), allocatable :: freaction(:) - - integer, allocatable :: elem_gp_start(:) - integer, allocatable :: elem_ngp(:) - real(rk), allocatable :: stress(:,:) - real(rk), allocatable :: strain(:,:) - real(rk), allocatable :: statev(:,:) - - character(len=NAME_LEN), allocatable :: nset_name(:) - integer, allocatable :: nset_start(:) - integer, allocatable :: nset_count(:) - integer, allocatable :: nset_items(:) - - character(len=NAME_LEN), allocatable :: elset_name(:) - integer, allocatable :: elset_start(:) - integer, allocatable :: elset_count(:) - integer, allocatable :: elset_items(:) - - character(len=NAME_LEN), allocatable :: surface_name(:) - integer, allocatable :: surface_start(:) - integer, allocatable :: surface_count(:) - integer, allocatable :: surface_owner(:) - character(len=16), allocatable :: surface_type(:) - character(len=NAME_LEN), allocatable :: surface_target(:) - character(len=16), allocatable :: surface_face(:) - - character(len=NAME_LEN), allocatable :: mat_name(:) - character(len=MAT_MODEL_LEN), allocatable :: mat_plastic_model(:) - character(len=MAT_MODEL_LEN), allocatable :: mat_rate_model(:) - character(len=MAT_MODEL_LEN), allocatable :: mat_temp_model(:) - character(len=MAT_MODEL_LEN), allocatable :: mat_failure_model(:) - real(rk), allocatable :: mat_density(:) - real(rk), allocatable :: mat_e(:) - real(rk), allocatable :: mat_nu(:) - real(rk), allocatable :: mat_yield0(:) - real(rk), allocatable :: mat_hardening_modulus(:) - real(rk), allocatable :: mat_eqps_fail(:) - real(rk), allocatable :: mat_jc_a(:) - real(rk), allocatable :: mat_jc_b(:) - real(rk), allocatable :: mat_jc_n(:) - real(rk), allocatable :: mat_jc_c(:) - real(rk), allocatable :: mat_jc_m(:) - real(rk), allocatable :: mat_jc_epsdot0(:) - real(rk), allocatable :: mat_jc_troom(:) - real(rk), allocatable :: mat_jc_tmelt(:) - real(rk), allocatable :: mat_jc_chi(:) - real(rk), allocatable :: mat_jc_cp(:) - real(rk), allocatable :: mat_jc_d1(:) - real(rk), allocatable :: mat_jc_d2(:) - real(rk), allocatable :: mat_jc_d3(:) - real(rk), allocatable :: mat_jc_d4(:) - real(rk), allocatable :: mat_jc_d5(:) - integer, allocatable :: mat_plastic_start(:) - integer, allocatable :: mat_plastic_count(:) - real(rk), allocatable :: mat_plastic_stress(:) - real(rk), allocatable :: mat_plastic_strain(:) - - character(len=NAME_LEN), allocatable :: amp_name(:) - integer, allocatable :: amp_start(:) - integer, allocatable :: amp_count(:) - real(rk), allocatable :: amp_time(:) - real(rk), allocatable :: amp_value(:) - - character(len=16), allocatable :: section_type(:) - character(len=NAME_LEN), allocatable :: section_elset_name(:) - character(len=NAME_LEN), allocatable :: section_material_name(:) - real(rk), allocatable :: section_thickness(:) - - character(len=NAME_LEN), allocatable :: bc_target(:) - integer, allocatable :: bc_dof_start(:) - integer, allocatable :: bc_dof_end(:) - real(rk), allocatable :: bc_value(:) - integer, allocatable :: bc_amp(:) - - character(len=NAME_LEN), allocatable :: cload_target(:) - integer, allocatable :: cload_dof(:) - real(rk), allocatable :: cload_value(:) - integer, allocatable :: cload_amp(:) - - character(len=NAME_LEN), allocatable :: dload_target(:) - character(len=16), allocatable :: dload_label(:) - real(rk), allocatable :: dload_value(:) - integer, allocatable :: dload_amp(:) - - character(len=NAME_LEN), allocatable :: robin_target(:) - integer, allocatable :: robin_dof(:) - real(rk), allocatable :: robin_stiffness(:) - real(rk), allocatable :: robin_damping(:) - real(rk), allocatable :: robin_reference(:) - integer, allocatable :: robin_amp(:) - - integer, allocatable :: mpc_start(:) - integer, allocatable :: mpc_count(:) - real(rk), allocatable :: mpc_rhs(:) - real(rk), allocatable :: mpc_penalty(:) - integer, allocatable :: mpc_node(:) - integer, allocatable :: mpc_dof(:) - real(rk), allocatable :: mpc_coeff(:) - - character(len=NAME_LEN), allocatable :: contact_target(:) - real(rk), allocatable :: contact_normal(:,:) - real(rk), allocatable :: contact_offset(:) - real(rk), allocatable :: contact_penalty(:) - real(rk), allocatable :: contact_damping(:) - character(len=NAME_LEN), allocatable :: contact_pair_slave(:) - character(len=NAME_LEN), allocatable :: contact_pair_master(:) - real(rk), allocatable :: contact_pair_penalty(:) - real(rk), allocatable :: contact_pair_damping(:) - real(rk), allocatable :: contact_pair_search(:) - real(rk), allocatable :: contact_pair_friction(:) - integer :: contact_active_count = 0 - real(rk) :: contact_work_step = ZERO - real(rk) :: contact_work_total = ZERO - real(rk) :: contact_max_penetration = ZERO - real(rk) :: contact_force_norm = ZERO - integer, allocatable :: contact_pair_active(:) - real(rk), allocatable :: contact_pair_work(:) - real(rk), allocatable :: contact_pair_max_penetration(:) - real(rk), allocatable :: contact_pair_force_norm(:) - real(rk), allocatable :: contact_pair_tangent_force(:,:) - real(rk), allocatable :: contact_pair_slip(:) - integer, allocatable :: contact_pair_stick_count(:) - integer, allocatable :: contact_pair_slip_count(:) - contains subroutine database_allocate_mesh(num_nodes, num_elems, ierr) @@ -633,10 +467,15 @@ contains if (allocated(contact_pair_slave)) deallocate(contact_pair_slave) if (allocated(contact_pair_master)) deallocate(contact_pair_master) + if (allocated(contact_pair_property)) deallocate(contact_pair_property) if (allocated(contact_pair_penalty)) deallocate(contact_pair_penalty) if (allocated(contact_pair_damping)) deallocate(contact_pair_damping) if (allocated(contact_pair_search)) deallocate(contact_pair_search) if (allocated(contact_pair_friction)) deallocate(contact_pair_friction) + if (allocated(contact_pair_penalty_set)) deallocate(contact_pair_penalty_set) + if (allocated(contact_pair_damping_set)) deallocate(contact_pair_damping_set) + if (allocated(contact_pair_search_set)) deallocate(contact_pair_search_set) + if (allocated(contact_pair_friction_set)) deallocate(contact_pair_friction_set) if (allocated(contact_pair_active)) deallocate(contact_pair_active) if (allocated(contact_pair_work)) deallocate(contact_pair_work) if (allocated(contact_pair_max_penetration)) deallocate(contact_pair_max_penetration) @@ -655,8 +494,13 @@ contains if (num_pairs .gt. 0) then allocate(contact_pair_slave(num_pairs), contact_pair_master(num_pairs), & + contact_pair_property(num_pairs), & contact_pair_penalty(num_pairs), contact_pair_damping(num_pairs), & contact_pair_search(num_pairs), contact_pair_friction(num_pairs), & + contact_pair_penalty_set(num_pairs), & + contact_pair_damping_set(num_pairs), & + contact_pair_search_set(num_pairs), & + contact_pair_friction_set(num_pairs), & contact_pair_active(num_pairs), contact_pair_work(num_pairs), & contact_pair_max_penetration(num_pairs), & contact_pair_force_norm(num_pairs), & @@ -672,10 +516,15 @@ contains end if contact_pair_slave = 'ALL' contact_pair_master = 'ALL' + contact_pair_property = ' ' contact_pair_penalty = ZERO contact_pair_damping = ZERO contact_pair_search = ZERO contact_pair_friction = ZERO + contact_pair_penalty_set = .false. + contact_pair_damping_set = .false. + contact_pair_search_set = .false. + contact_pair_friction_set = .false. contact_pair_active = 0 contact_pair_work = ZERO contact_pair_max_penetration = ZERO @@ -689,6 +538,48 @@ contains ierr = FEM_SUCCESS end subroutine database_allocate_contact_pair + subroutine database_allocate_contact_props(num_props, ierr) + integer, intent(in) :: num_props + integer, intent(out) :: ierr + integer :: stat + + if (num_props .lt. 0) then + call error_set(FEM_ERR_INPUT, 'number of contact properties must be non-negative', ierr) + return + end if + + call db_free_contact_property_arrays() + n_contact_property = num_props + + if (num_props .gt. 0) then + allocate(contact_property_name(num_props), & + contact_property_penalty(num_props), & + contact_property_damping(num_props), & + contact_property_search(num_props), & + contact_property_friction(num_props), & + contact_property_penalty_set(num_props), & + contact_property_damping_set(num_props), & + contact_property_search_set(num_props), & + contact_property_friction_set(num_props), stat=stat) + if (stat .ne. 0) then + n_contact_property = 0 + call error_set(FEM_ERR_INTERNAL, 'failed to allocate contact property arrays', ierr) + return + end if + contact_property_name = ' ' + contact_property_penalty = ZERO + contact_property_damping = ZERO + contact_property_search = ZERO + contact_property_friction = ZERO + contact_property_penalty_set = .false. + contact_property_damping_set = .false. + contact_property_search_set = .false. + contact_property_friction_set = .false. + end if + + ierr = FEM_SUCCESS + end subroutine database_allocate_contact_props + subroutine database_allocate_surfaces(num_surfaces, num_items, ierr) integer, intent(in) :: num_surfaces integer, intent(in) :: num_items @@ -943,10 +834,24 @@ contains if (allocated(contact_damping)) contact_damping = ZERO if (allocated(contact_pair_slave)) contact_pair_slave = 'ALL' if (allocated(contact_pair_master)) contact_pair_master = 'ALL' + if (allocated(contact_pair_property)) contact_pair_property = ' ' if (allocated(contact_pair_penalty)) contact_pair_penalty = ZERO if (allocated(contact_pair_damping)) contact_pair_damping = ZERO if (allocated(contact_pair_search)) contact_pair_search = ZERO if (allocated(contact_pair_friction)) contact_pair_friction = ZERO + if (allocated(contact_pair_penalty_set)) contact_pair_penalty_set = .false. + if (allocated(contact_pair_damping_set)) contact_pair_damping_set = .false. + if (allocated(contact_pair_search_set)) contact_pair_search_set = .false. + if (allocated(contact_pair_friction_set)) contact_pair_friction_set = .false. + if (allocated(contact_property_name)) contact_property_name = ' ' + if (allocated(contact_property_penalty)) contact_property_penalty = ZERO + if (allocated(contact_property_damping)) contact_property_damping = ZERO + if (allocated(contact_property_search)) contact_property_search = ZERO + if (allocated(contact_property_friction)) contact_property_friction = ZERO + if (allocated(contact_property_penalty_set)) contact_property_penalty_set = .false. + if (allocated(contact_property_damping_set)) contact_property_damping_set = .false. + if (allocated(contact_property_search_set)) contact_property_search_set = .false. + if (allocated(contact_property_friction_set)) contact_property_friction_set = .false. contact_active_count = 0 contact_work_step = ZERO contact_work_total = ZERO @@ -1158,6 +1063,21 @@ contains end do end function database_find_surface + integer function database_find_contact_property(name) + character(len=*), intent(in) :: name + integer :: i + + database_find_contact_property = 0 + if (.not. allocated(contact_property_name)) return + + do i = 1, n_contact_property + if (trim(contact_property_name(i)) .eq. trim(name)) then + database_find_contact_property = i + return + end if + end do + end function database_find_contact_property + integer function database_find_nset(name) character(len=*), intent(in) :: name integer :: i @@ -1206,6 +1126,12 @@ contains call validate_surface_data(ierr) if (ierr .ne. FEM_SUCCESS) return + call validate_contact_properties(ierr) + if (ierr .ne. FEM_SUCCESS) return + + call apply_contact_pair_properties(ierr) + if (ierr .ne. FEM_SUCCESS) return + call validate_contact_data(ierr) end subroutine database_validate_model @@ -1541,6 +1467,70 @@ contains ierr = FEM_SUCCESS end subroutine validate_mpc_data + subroutine validate_contact_properties(ierr) + integer, intent(out) :: ierr + integer :: prop + + do prop = 1, n_contact_property + if (len_trim(contact_property_name(prop)) .eq. 0) then + call error_set(FEM_ERR_INPUT, 'contact property is missing name', ierr) + return + end if + if (contact_property_penalty_set(prop) .and. & + contact_property_penalty(prop) .le. ZERO) then + call error_set(FEM_ERR_INPUT, 'contact property penalty must be positive', ierr) + return + end if + if (contact_property_damping(prop) .lt. ZERO) then + call error_set(FEM_ERR_INPUT, 'contact property damping must be non-negative', ierr) + return + end if + if (contact_property_search(prop) .lt. ZERO) then + call error_set(FEM_ERR_INPUT, 'contact property search must be non-negative', ierr) + return + end if + if (contact_property_friction(prop) .lt. ZERO) then + call error_set(FEM_ERR_INPUT, 'contact property friction must be non-negative', ierr) + return + end if + end do + + ierr = FEM_SUCCESS + end subroutine validate_contact_properties + + subroutine apply_contact_pair_properties(ierr) + integer, intent(out) :: ierr + integer :: pair + integer :: prop + + do pair = 1, ncontact_pair + if (len_trim(contact_pair_property(pair)) .eq. 0) cycle + prop = database_find_contact_property(contact_pair_property(pair)) + if (prop .eq. 0) then + call error_set(FEM_ERR_INPUT, 'contact pair references unknown interaction', ierr) + return + end if + if (.not. contact_pair_penalty_set(pair) .and. & + contact_property_penalty_set(prop)) then + contact_pair_penalty(pair) = contact_property_penalty(prop) + end if + if (.not. contact_pair_damping_set(pair) .and. & + contact_property_damping_set(prop)) then + contact_pair_damping(pair) = contact_property_damping(prop) + end if + if (.not. contact_pair_search_set(pair) .and. & + contact_property_search_set(prop)) then + contact_pair_search(pair) = contact_property_search(prop) + end if + if (.not. contact_pair_friction_set(pair) .and. & + contact_property_friction_set(prop)) then + contact_pair_friction(pair) = contact_property_friction(prop) + end if + end do + + ierr = FEM_SUCCESS + end subroutine apply_contact_pair_properties + subroutine validate_contact_data(ierr) integer, intent(out) :: ierr integer :: item @@ -1935,10 +1925,15 @@ contains if (allocated(contact_damping)) deallocate(contact_damping) if (allocated(contact_pair_slave)) deallocate(contact_pair_slave) if (allocated(contact_pair_master)) deallocate(contact_pair_master) + if (allocated(contact_pair_property)) deallocate(contact_pair_property) if (allocated(contact_pair_penalty)) deallocate(contact_pair_penalty) if (allocated(contact_pair_damping)) deallocate(contact_pair_damping) if (allocated(contact_pair_search)) deallocate(contact_pair_search) if (allocated(contact_pair_friction)) deallocate(contact_pair_friction) + if (allocated(contact_pair_penalty_set)) deallocate(contact_pair_penalty_set) + if (allocated(contact_pair_damping_set)) deallocate(contact_pair_damping_set) + if (allocated(contact_pair_search_set)) deallocate(contact_pair_search_set) + if (allocated(contact_pair_friction_set)) deallocate(contact_pair_friction_set) if (allocated(contact_pair_active)) deallocate(contact_pair_active) if (allocated(contact_pair_work)) deallocate(contact_pair_work) if (allocated(contact_pair_max_penetration)) deallocate(contact_pair_max_penetration) @@ -1947,8 +1942,21 @@ contains if (allocated(contact_pair_slip)) deallocate(contact_pair_slip) if (allocated(contact_pair_stick_count)) deallocate(contact_pair_stick_count) if (allocated(contact_pair_slip_count)) deallocate(contact_pair_slip_count) + call db_free_contact_property_arrays() end subroutine db_free_contact_arrays + subroutine db_free_contact_property_arrays() + if (allocated(contact_property_name)) deallocate(contact_property_name) + if (allocated(contact_property_penalty)) deallocate(contact_property_penalty) + if (allocated(contact_property_damping)) deallocate(contact_property_damping) + if (allocated(contact_property_search)) deallocate(contact_property_search) + if (allocated(contact_property_friction)) deallocate(contact_property_friction) + if (allocated(contact_property_penalty_set)) deallocate(contact_property_penalty_set) + if (allocated(contact_property_damping_set)) deallocate(contact_property_damping_set) + if (allocated(contact_property_search_set)) deallocate(contact_property_search_set) + if (allocated(contact_property_friction_set)) deallocate(contact_property_friction_set) + end subroutine db_free_contact_property_arrays + subroutine db_reset_counts() nnode = 0 nelem = 0 @@ -1971,6 +1979,7 @@ contains nmpc_term = 0 ncontact_plane = 0 ncontact_pair = 0 + n_contact_property = 0 contact_active_count = 0 contact_work_step = ZERO contact_work_total = ZERO diff --git a/src/mesh/fem_database_state.f90 b/src/mesh/fem_database_state.f90 new file mode 100644 index 0000000..63ebba3 --- /dev/null +++ b/src/mesh/fem_database_state.f90 @@ -0,0 +1,189 @@ +module fem_database_state + use fem_precision, only: rk_state => rk, ZERO_STATE => ZERO, & + NAME_LEN_STATE => NAME_LEN, & + ELEM_TYPE_LEN_STATE => ELEM_TYPE_LEN, & + MAT_MODEL_LEN_STATE => MAT_MODEL_LEN + implicit none + + integer :: nnode = 0 + integer :: nelem = 0 + integer :: ndof = 0 + integer :: ngauss_total = 0 + integer :: n_nset = 0 + integer :: n_elset = 0 + integer :: n_surface = 0 + integer :: n_surface_item = 0 + integer :: n_material = 0 + integer :: n_section = 0 + integer :: n_plastic_item = 0 + integer :: n_amp = 0 + integer :: n_amp_item = 0 + integer :: nbc = 0 + integer :: ncload = 0 + integer :: ndload = 0 + integer :: nrobin = 0 + integer :: nmpc = 0 + integer :: nmpc_term = 0 + integer :: ncontact_plane = 0 + integer :: ncontact_pair = 0 + integer :: n_contact_property = 0 + + real(rk_state), allocatable :: coord0(:,:) + real(rk_state), allocatable :: coord(:,:) + integer, allocatable :: node_id_ext(:) + integer, allocatable :: elem_conn(:,:) + integer, allocatable :: elem_id_ext(:) + integer, allocatable :: elem_nnode(:) + character(len=ELEM_TYPE_LEN_STATE), allocatable :: elem_type(:) + integer, allocatable :: elem_mat(:) + integer, allocatable :: elem_sec(:) + integer, allocatable :: elem_status(:) + integer, allocatable :: dof_id(:,:) + + real(rk_state), allocatable :: u(:) + real(rk_state), allocatable :: v(:) + real(rk_state), allocatable :: a(:) + real(rk_state), allocatable :: vhalf(:) + real(rk_state), allocatable :: mass_diag(:) + real(rk_state), allocatable :: fint(:) + real(rk_state), allocatable :: fext(:) + real(rk_state), allocatable :: fsph(:) + real(rk_state), allocatable :: fcontact(:) + real(rk_state), allocatable :: freaction(:) + + integer, allocatable :: elem_gp_start(:) + integer, allocatable :: elem_ngp(:) + real(rk_state), allocatable :: stress(:,:) + real(rk_state), allocatable :: strain(:,:) + real(rk_state), allocatable :: statev(:,:) + + character(len=NAME_LEN_STATE), allocatable :: nset_name(:) + integer, allocatable :: nset_start(:) + integer, allocatable :: nset_count(:) + integer, allocatable :: nset_items(:) + + character(len=NAME_LEN_STATE), allocatable :: elset_name(:) + integer, allocatable :: elset_start(:) + integer, allocatable :: elset_count(:) + integer, allocatable :: elset_items(:) + + character(len=NAME_LEN_STATE), allocatable :: surface_name(:) + integer, allocatable :: surface_start(:) + integer, allocatable :: surface_count(:) + integer, allocatable :: surface_owner(:) + character(len=16), allocatable :: surface_type(:) + character(len=NAME_LEN_STATE), allocatable :: surface_target(:) + character(len=16), allocatable :: surface_face(:) + + character(len=NAME_LEN_STATE), allocatable :: mat_name(:) + character(len=MAT_MODEL_LEN_STATE), allocatable :: mat_plastic_model(:) + character(len=MAT_MODEL_LEN_STATE), allocatable :: mat_rate_model(:) + character(len=MAT_MODEL_LEN_STATE), allocatable :: mat_temp_model(:) + character(len=MAT_MODEL_LEN_STATE), allocatable :: mat_failure_model(:) + real(rk_state), allocatable :: mat_density(:) + real(rk_state), allocatable :: mat_e(:) + real(rk_state), allocatable :: mat_nu(:) + real(rk_state), allocatable :: mat_yield0(:) + real(rk_state), allocatable :: mat_hardening_modulus(:) + real(rk_state), allocatable :: mat_eqps_fail(:) + real(rk_state), allocatable :: mat_jc_a(:) + real(rk_state), allocatable :: mat_jc_b(:) + real(rk_state), allocatable :: mat_jc_n(:) + real(rk_state), allocatable :: mat_jc_c(:) + real(rk_state), allocatable :: mat_jc_m(:) + real(rk_state), allocatable :: mat_jc_epsdot0(:) + real(rk_state), allocatable :: mat_jc_troom(:) + real(rk_state), allocatable :: mat_jc_tmelt(:) + real(rk_state), allocatable :: mat_jc_chi(:) + real(rk_state), allocatable :: mat_jc_cp(:) + real(rk_state), allocatable :: mat_jc_d1(:) + real(rk_state), allocatable :: mat_jc_d2(:) + real(rk_state), allocatable :: mat_jc_d3(:) + real(rk_state), allocatable :: mat_jc_d4(:) + real(rk_state), allocatable :: mat_jc_d5(:) + integer, allocatable :: mat_plastic_start(:) + integer, allocatable :: mat_plastic_count(:) + real(rk_state), allocatable :: mat_plastic_stress(:) + real(rk_state), allocatable :: mat_plastic_strain(:) + + character(len=NAME_LEN_STATE), allocatable :: amp_name(:) + integer, allocatable :: amp_start(:) + integer, allocatable :: amp_count(:) + real(rk_state), allocatable :: amp_time(:) + real(rk_state), allocatable :: amp_value(:) + + character(len=16), allocatable :: section_type(:) + character(len=NAME_LEN_STATE), allocatable :: section_elset_name(:) + character(len=NAME_LEN_STATE), allocatable :: section_material_name(:) + real(rk_state), allocatable :: section_thickness(:) + + character(len=NAME_LEN_STATE), allocatable :: bc_target(:) + integer, allocatable :: bc_dof_start(:) + integer, allocatable :: bc_dof_end(:) + real(rk_state), allocatable :: bc_value(:) + integer, allocatable :: bc_amp(:) + + character(len=NAME_LEN_STATE), allocatable :: cload_target(:) + integer, allocatable :: cload_dof(:) + real(rk_state), allocatable :: cload_value(:) + integer, allocatable :: cload_amp(:) + + character(len=NAME_LEN_STATE), allocatable :: dload_target(:) + character(len=16), allocatable :: dload_label(:) + real(rk_state), allocatable :: dload_value(:) + integer, allocatable :: dload_amp(:) + + character(len=NAME_LEN_STATE), allocatable :: robin_target(:) + integer, allocatable :: robin_dof(:) + real(rk_state), allocatable :: robin_stiffness(:) + real(rk_state), allocatable :: robin_damping(:) + real(rk_state), allocatable :: robin_reference(:) + integer, allocatable :: robin_amp(:) + + integer, allocatable :: mpc_start(:) + integer, allocatable :: mpc_count(:) + real(rk_state), allocatable :: mpc_rhs(:) + real(rk_state), allocatable :: mpc_penalty(:) + integer, allocatable :: mpc_node(:) + integer, allocatable :: mpc_dof(:) + real(rk_state), allocatable :: mpc_coeff(:) + + character(len=NAME_LEN_STATE), allocatable :: contact_target(:) + real(rk_state), allocatable :: contact_normal(:,:) + real(rk_state), allocatable :: contact_offset(:) + real(rk_state), allocatable :: contact_penalty(:) + real(rk_state), allocatable :: contact_damping(:) + character(len=NAME_LEN_STATE), allocatable :: contact_pair_slave(:) + character(len=NAME_LEN_STATE), allocatable :: contact_pair_master(:) + character(len=NAME_LEN_STATE), allocatable :: contact_pair_property(:) + real(rk_state), allocatable :: contact_pair_penalty(:) + real(rk_state), allocatable :: contact_pair_damping(:) + real(rk_state), allocatable :: contact_pair_search(:) + real(rk_state), allocatable :: contact_pair_friction(:) + logical, allocatable :: contact_pair_penalty_set(:) + logical, allocatable :: contact_pair_damping_set(:) + logical, allocatable :: contact_pair_search_set(:) + logical, allocatable :: contact_pair_friction_set(:) + character(len=NAME_LEN_STATE), allocatable :: contact_property_name(:) + real(rk_state), allocatable :: contact_property_penalty(:) + real(rk_state), allocatable :: contact_property_damping(:) + real(rk_state), allocatable :: contact_property_search(:) + real(rk_state), allocatable :: contact_property_friction(:) + logical, allocatable :: contact_property_penalty_set(:) + logical, allocatable :: contact_property_damping_set(:) + logical, allocatable :: contact_property_search_set(:) + logical, allocatable :: contact_property_friction_set(:) + integer :: contact_active_count = 0 + real(rk_state) :: contact_work_step = ZERO_STATE + real(rk_state) :: contact_work_total = ZERO_STATE + real(rk_state) :: contact_max_penetration = ZERO_STATE + real(rk_state) :: contact_force_norm = ZERO_STATE + integer, allocatable :: contact_pair_active(:) + real(rk_state), allocatable :: contact_pair_work(:) + real(rk_state), allocatable :: contact_pair_max_penetration(:) + real(rk_state), allocatable :: contact_pair_force_norm(:) + real(rk_state), allocatable :: contact_pair_tangent_force(:,:) + real(rk_state), allocatable :: contact_pair_slip(:) + integer, allocatable :: contact_pair_stick_count(:) + integer, allocatable :: contact_pair_slip_count(:) +end module fem_database_state diff --git a/tests/data/s4_contact_pair_unknown_property.inp b/tests/data/s4_contact_pair_unknown_property.inp new file mode 100644 index 0000000..74da964 --- /dev/null +++ b/tests/data/s4_contact_pair_unknown_property.inp @@ -0,0 +1,34 @@ +*HEADING +FemLite S4 contact pair unknown interaction parser test +*NODE +1, 0.0, 0.0, 0.0 +2, 1.0, 0.0, 0.0 +3, 1.0, 1.0, 0.0 +4, 0.0, 1.0, 0.0 +5, 0.0, 0.0, -0.01 +6, 1.0, 0.0, -0.01 +7, 1.0, 1.0, -0.01 +8, 0.0, 1.0, -0.01 +*ELEMENT, TYPE=S4, ELSET=MASTER +1, 1, 2, 3, 4 +*ELEMENT, TYPE=S4, ELSET=SLAVE +2, 5, 6, 7, 8 +*MATERIAL, NAME=MAT +*DENSITY +1.0 +*ELASTIC +30.0, 0.25 +*SHELL SECTION, ELSET=MASTER, MATERIAL=MAT +0.1 +*SHELL SECTION, ELSET=SLAVE, MATERIAL=MAT +0.1 +*SURFACE, NAME=MASTER_SURF, TYPE=ELEMENT +MASTER, SPOS +*SURFACE, NAME=SLAVE_SURF, TYPE=ELEMENT +SLAVE, SNEG +*CONTACT PAIR, INTERACTION=DOES_NOT_EXIST +SLAVE_SURF, MASTER_SURF +*STEP +*DYNAMIC +0.1, 0.1 +*END STEP diff --git a/tests/data/s4_contact_property.inp b/tests/data/s4_contact_property.inp new file mode 100644 index 0000000..c7e0b19 --- /dev/null +++ b/tests/data/s4_contact_property.inp @@ -0,0 +1,37 @@ +*HEADING +FemLite S4 contact property parser test +*NODE +1, 0.0, 0.0, 0.0 +2, 1.0, 0.0, 0.0 +3, 1.0, 1.0, 0.0 +4, 0.0, 1.0, 0.0 +5, 0.0, 0.0, -0.01 +6, 1.0, 0.0, -0.01 +7, 1.0, 1.0, -0.01 +8, 0.0, 1.0, -0.01 +*ELEMENT, TYPE=S4, ELSET=MASTER +1, 1, 2, 3, 4 +*ELEMENT, TYPE=S4, ELSET=SLAVE +2, 5, 6, 7, 8 +*MATERIAL, NAME=MAT +*DENSITY +1.0 +*ELASTIC +30.0, 0.25 +*SHELL SECTION, ELSET=MASTER, MATERIAL=MAT +0.1 +*SHELL SECTION, ELSET=SLAVE, MATERIAL=MAT +0.1 +*SURFACE, NAME=MASTER_SURF, TYPE=ELEMENT +MASTER, SPOS +*SURFACE, NAME=SLAVE_SURF, TYPE=ELEMENT +SLAVE, SNEG +*SURFACE INTERACTION, NAME=PROP1, PENALTY=1.0E3, DAMPING=2.0, SEARCH=0.1 +*FRICTION +0.2 +*CONTACT PAIR, INTERACTION=PROP1 +SLAVE_SURF, MASTER_SURF +*STEP +*DYNAMIC +0.1, 0.1 +*END STEP diff --git a/tests/module/test_implicit_inp.f90 b/tests/module/test_implicit_inp.f90 index 10e4d82..4c3221a 100644 --- a/tests/module/test_implicit_inp.f90 +++ b/tests/module/test_implicit_inp.f90 @@ -7,7 +7,11 @@ program test_implicit_inp contact_pair_damping, contact_pair_search, & contact_pair_friction, n_surface, surface_name, & surface_start, surface_count, surface_target, & - surface_face, surface_owner, surface_type + surface_face, surface_owner, surface_type, & + n_contact_property, contact_property_name, & + contact_property_penalty, contact_property_damping, & + contact_property_search, contact_property_friction, & + contact_pair_property use fem_database_surface, only: db_contact_facet_match, & db_contact_facet_normal_sign, & db_contact_facet_has_side @@ -457,15 +461,44 @@ contains if (ierr .ne. 0) call fail(478) call check_node_surface_inp() + call check_contact_property_inp() call check_contact_pair_input_errors() end subroutine check_contact_pair_inp + subroutine check_contact_property_inp() + integer :: ierr + + call fem_initialize(ierr) + if (ierr .ne. 0) call fail(530) + + call fem_read_inp('tests/data/s4_contact_property.inp', ierr) + if (ierr .ne. 0) call fail(531) + if (n_contact_property .ne. 1) call fail(532) + if (trim(contact_property_name(1)) .ne. 'PROP1') call fail(533) + call check_close(contact_property_penalty(1), 1000.0_rk, 534) + call check_close(contact_property_damping(1), 2.0_rk, 535) + call check_close(contact_property_search(1), 0.1_rk, 536) + call check_close(contact_property_friction(1), 0.2_rk, 537) + if (trim(contact_pair_property(1)) .ne. 'PROP1') call fail(538) + + call fem_build_model(ierr) + if (ierr .ne. 0) call fail(539) + call check_close(contact_pair_penalty(1), 1000.0_rk, 540) + call check_close(contact_pair_damping(1), 2.0_rk, 541) + call check_close(contact_pair_search(1), 0.1_rk, 542) + call check_close(contact_pair_friction(1), 0.2_rk, 543) + + call fem_finalize(ierr) + if (ierr .ne. 0) call fail(544) + end subroutine check_contact_property_inp + subroutine check_contact_pair_input_errors() call check_contact_pair_inp_error('tests/data/s4_contact_pair_missing_slave.inp', 401) call check_contact_pair_inp_error('tests/data/s4_contact_pair_missing_master.inp', 404) call check_contact_pair_inp_error('tests/data/s4_contact_pair_missing_penalty.inp', 407) call check_contact_pair_build_error('tests/data/s4_contact_pair_surface_bad_face.inp', 415) call check_contact_pair_inp_error('tests/data/s4_contact_pair_surface_bad_type.inp', 445) + call check_contact_pair_build_error('tests/data/s4_contact_pair_unknown_property.inp', 548) end subroutine check_contact_pair_input_errors subroutine check_node_surface_inp()