Add node-based surface parsing
This commit is contained in:
@@ -604,3 +604,28 @@ FemLite 0.4.x 定位为:
|
||||
- `DEFERRED`:经评审确认推迟到 0.5.0 或后续,必须说明原因和风险。
|
||||
|
||||
任何 `DEFERRED` 项不得影响 0.1.0、0.2.0、0.3.3 已验收能力。
|
||||
|
||||
## 22. 0.4.0 开发记录
|
||||
|
||||
### V4.1 Surface/Contact 输入增强
|
||||
|
||||
已启动:
|
||||
|
||||
- 新增 surface 类型字段,当前支持 `ELEMENT` 和 `NODE` 两类 surface。
|
||||
- `*SURFACE` 的 `TYPE` 缺省仍为 `ELEMENT`,保持 0.3.3 输入兼容。
|
||||
- `TYPE=NODE` 可读取节点号、节点集或 `ALL` 目标,并在数据库校验阶段检查节点/节点集是否存在。
|
||||
- `TYPE=NODE` 数据行暂不允许 face label。
|
||||
- contact pair 仍基于 facet 接触路径;若 contact pair 直接引用 node-based surface,数据库校验阶段报错,避免静默无效接触。
|
||||
- facet 匹配函数仅对 `ELEMENT` surface 生效,避免把 node surface 的节点号误匹配为单元号。
|
||||
|
||||
已补充测试:
|
||||
|
||||
- `tests/data/s4_node_surface.inp`:node-based surface 解析和数据库校验。
|
||||
- `implicit_inp`:检查 `surface_type`、node target、facet 匹配隔离和 `fem_build_model`。
|
||||
- `contact`:确认旧 element surface/contact pair 路径不回退。
|
||||
|
||||
后续:
|
||||
|
||||
- 增加 node-based surface 查询接口。
|
||||
- 增加 contact property 数据结构和解析。
|
||||
- 在节点-面接触或后续 contact pair 扩展中接入 node-based slave surface。
|
||||
|
||||
@@ -28,23 +28,29 @@ subroutine start_nset(set_index, item_pos, set_name_value)
|
||||
elset_count(set_index) = 0
|
||||
end subroutine start_elset
|
||||
|
||||
subroutine start_surface(surface_index, item_pos, surface_name_value)
|
||||
subroutine start_surface(surface_index, item_pos, surface_name_value, &
|
||||
surface_type_value)
|
||||
integer, intent(in) :: surface_index
|
||||
integer, intent(in) :: item_pos
|
||||
character(len=*), intent(in) :: surface_name_value
|
||||
character(len=*), intent(in) :: surface_type_value
|
||||
|
||||
surface_name(surface_index) = surface_name_value
|
||||
if (allocated(surface_type)) surface_type(surface_index) = surface_type_value
|
||||
surface_start(surface_index) = item_pos + 1
|
||||
surface_count(surface_index) = 0
|
||||
end subroutine start_surface
|
||||
|
||||
subroutine reset_surface(surface_index, item_pos, surface_name_value)
|
||||
subroutine reset_surface(surface_index, item_pos, surface_name_value, &
|
||||
surface_type_value)
|
||||
integer, intent(in) :: surface_index
|
||||
integer, intent(in) :: item_pos
|
||||
character(len=*), intent(in) :: surface_name_value
|
||||
character(len=*), intent(in) :: surface_type_value
|
||||
integer :: pos
|
||||
|
||||
call start_surface(surface_index, item_pos, surface_name_value)
|
||||
call start_surface(surface_index, item_pos, surface_name_value, &
|
||||
surface_type_value)
|
||||
if (.not. allocated(surface_owner)) return
|
||||
do pos = 1, n_surface_item
|
||||
if (surface_owner(pos) .eq. surface_index) surface_owner(pos) = 0
|
||||
|
||||
@@ -874,8 +874,9 @@ contains
|
||||
return
|
||||
end if
|
||||
call get_keyword_value(line, 'TYPE', type_value)
|
||||
if (len_trim(type_value) .gt. 0 .and. trim(type_value) .ne. 'ELEMENT') then
|
||||
call error_set(FEM_ERR_INPUT, 'only *SURFACE TYPE=ELEMENT is supported', ierr)
|
||||
if (len_trim(type_value) .eq. 0) type_value = 'ELEMENT'
|
||||
if (trim(type_value) .ne. 'ELEMENT' .and. trim(type_value) .ne. 'NODE') then
|
||||
call error_set(FEM_ERR_INPUT, 'only *SURFACE TYPE=ELEMENT/NODE is supported', ierr)
|
||||
return
|
||||
end if
|
||||
call get_keyword_value(line, 'OP', op_value)
|
||||
@@ -887,11 +888,19 @@ contains
|
||||
existing_surface = database_find_surface(name_value)
|
||||
if (existing_surface .ne. 0) then
|
||||
current_surface = existing_surface
|
||||
if (trim(op_value) .eq. 'NEW') call reset_surface(current_surface, surface_pos, name_value)
|
||||
if (trim(op_value) .eq. 'NEW') then
|
||||
call reset_surface(current_surface, surface_pos, name_value, type_value)
|
||||
else if (allocated(surface_type)) then
|
||||
if (trim(surface_type(current_surface)) .ne. trim(type_value)) then
|
||||
call error_set(FEM_ERR_INPUT, &
|
||||
'*SURFACE OP=ADD cannot change surface TYPE', ierr)
|
||||
return
|
||||
end if
|
||||
end if
|
||||
else
|
||||
used_surface_count = used_surface_count + 1
|
||||
current_surface = used_surface_count
|
||||
call start_surface(current_surface, surface_pos, name_value)
|
||||
call start_surface(current_surface, surface_pos, name_value, type_value)
|
||||
end if
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine fill_surface_keyword
|
||||
|
||||
@@ -69,6 +69,7 @@ module fem_database
|
||||
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(:)
|
||||
|
||||
@@ -703,6 +704,7 @@ contains
|
||||
if (allocated(surface_start)) deallocate(surface_start)
|
||||
if (allocated(surface_count)) deallocate(surface_count)
|
||||
if (allocated(surface_owner)) deallocate(surface_owner)
|
||||
if (allocated(surface_type)) deallocate(surface_type)
|
||||
if (allocated(surface_target)) deallocate(surface_target)
|
||||
if (allocated(surface_face)) deallocate(surface_face)
|
||||
|
||||
@@ -711,7 +713,8 @@ contains
|
||||
|
||||
if (num_surfaces .gt. 0) then
|
||||
allocate(surface_name(num_surfaces), surface_start(num_surfaces), &
|
||||
surface_count(num_surfaces), stat=stat)
|
||||
surface_count(num_surfaces), surface_type(num_surfaces), &
|
||||
stat=stat)
|
||||
if (stat .ne. 0) then
|
||||
n_surface = 0
|
||||
n_surface_item = 0
|
||||
@@ -721,6 +724,7 @@ contains
|
||||
surface_name = ' '
|
||||
surface_start = 0
|
||||
surface_count = 0
|
||||
surface_type = 'ELEMENT'
|
||||
end if
|
||||
|
||||
if (num_items .gt. 0) then
|
||||
@@ -858,6 +862,7 @@ contains
|
||||
if (allocated(surface_start)) surface_start = 0
|
||||
if (allocated(surface_count)) surface_count = 0
|
||||
if (allocated(surface_owner)) surface_owner = 0
|
||||
if (allocated(surface_type)) surface_type = 'ELEMENT'
|
||||
if (allocated(surface_target)) surface_target = ' '
|
||||
if (allocated(surface_face)) surface_face = ' '
|
||||
if (allocated(mat_name)) mat_name = ' '
|
||||
@@ -1577,12 +1582,22 @@ contains
|
||||
ierr)
|
||||
return
|
||||
end if
|
||||
if (contact_target_is_node_surface(contact_pair_slave(item))) then
|
||||
call error_set(FEM_ERR_INPUT, &
|
||||
'contact pair slave node-based surface is not yet supported', ierr)
|
||||
return
|
||||
end if
|
||||
if (.not. contact_surface_target_exists(contact_pair_master(item))) then
|
||||
call error_set(FEM_ERR_INPUT, &
|
||||
'contact pair master is not ALL, a surface, an element, or an element set', &
|
||||
ierr)
|
||||
return
|
||||
end if
|
||||
if (contact_target_is_node_surface(contact_pair_master(item))) then
|
||||
call error_set(FEM_ERR_INPUT, &
|
||||
'contact pair master node-based surface is not yet supported', ierr)
|
||||
return
|
||||
end if
|
||||
if (contact_pair_penalty(item) .le. ZERO) then
|
||||
call error_set(FEM_ERR_INPUT, 'contact pair penalty must be positive', ierr)
|
||||
return
|
||||
@@ -1623,13 +1638,24 @@ contains
|
||||
do pos = 1, n_surface_item
|
||||
if (.not. allocated(surface_owner)) exit
|
||||
if (surface_owner(pos) .ne. item) cycle
|
||||
if (.not. elem_or_elset_exists(surface_target(pos))) then
|
||||
call error_set(FEM_ERR_INPUT, 'surface references unknown element or elset', ierr)
|
||||
return
|
||||
end if
|
||||
if (.not. surface_face_label_valid(surface_face(pos))) then
|
||||
call error_set(FEM_ERR_INPUT, 'surface has invalid face label', ierr)
|
||||
return
|
||||
if (trim(surface_type(item)) .eq. 'NODE') then
|
||||
if (.not. node_or_nset_or_all_exists(surface_target(pos))) then
|
||||
call error_set(FEM_ERR_INPUT, 'node surface references unknown node or nset', ierr)
|
||||
return
|
||||
end if
|
||||
if (len_trim(surface_face(pos)) .ne. 0) then
|
||||
call error_set(FEM_ERR_INPUT, 'node surface data line must not have a face label', ierr)
|
||||
return
|
||||
end if
|
||||
else
|
||||
if (.not. elem_or_elset_exists(surface_target(pos))) then
|
||||
call error_set(FEM_ERR_INPUT, 'surface references unknown element or elset', ierr)
|
||||
return
|
||||
end if
|
||||
if (.not. surface_face_label_valid(surface_face(pos))) then
|
||||
call error_set(FEM_ERR_INPUT, 'surface has invalid face label', ierr)
|
||||
return
|
||||
end if
|
||||
end if
|
||||
end do
|
||||
end do
|
||||
@@ -1637,6 +1663,17 @@ contains
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine validate_surface_data
|
||||
|
||||
logical function contact_target_is_node_surface(target)
|
||||
character(len=*), intent(in) :: target
|
||||
integer :: surface_id
|
||||
|
||||
contact_target_is_node_surface = .false.
|
||||
surface_id = database_find_surface(adjustl(target))
|
||||
if (surface_id .le. 0) return
|
||||
if (.not. allocated(surface_type)) return
|
||||
contact_target_is_node_surface = trim(surface_type(surface_id)) .eq. 'NODE'
|
||||
end function contact_target_is_node_surface
|
||||
|
||||
logical function contact_surface_target_exists(target)
|
||||
character(len=*), intent(in) :: target
|
||||
character(len=NAME_LEN) :: local_target
|
||||
@@ -1654,6 +1691,20 @@ contains
|
||||
end if
|
||||
end function contact_surface_target_exists
|
||||
|
||||
logical function node_or_nset_or_all_exists(target)
|
||||
character(len=*), intent(in) :: target
|
||||
character(len=NAME_LEN) :: local_target
|
||||
|
||||
local_target = adjustl(target)
|
||||
if (len_trim(local_target) .eq. 0) then
|
||||
node_or_nset_or_all_exists = .false.
|
||||
else if (trim(local_target) .eq. 'ALL' .or. trim(local_target) .eq. 'all') then
|
||||
node_or_nset_or_all_exists = .true.
|
||||
else
|
||||
node_or_nset_or_all_exists = node_or_nset_exists(local_target)
|
||||
end if
|
||||
end function node_or_nset_or_all_exists
|
||||
|
||||
logical function surface_face_label_valid(label)
|
||||
character(len=*), intent(in) :: label
|
||||
character(len=16) :: local_label
|
||||
@@ -1803,6 +1854,7 @@ contains
|
||||
if (allocated(surface_start)) deallocate(surface_start)
|
||||
if (allocated(surface_count)) deallocate(surface_count)
|
||||
if (allocated(surface_owner)) deallocate(surface_owner)
|
||||
if (allocated(surface_type)) deallocate(surface_type)
|
||||
if (allocated(surface_target)) deallocate(surface_target)
|
||||
if (allocated(surface_face)) deallocate(surface_face)
|
||||
if (allocated(mat_name)) deallocate(mat_name)
|
||||
|
||||
@@ -2,9 +2,10 @@ module fem_database_surface
|
||||
use fem_precision, only: NAME_LEN
|
||||
use fem_element_topology
|
||||
use fem_database, only: n_surface, n_surface_item, surface_owner, &
|
||||
surface_target, surface_face, database_find_surface, &
|
||||
database_find_elset, database_find_elem, elset_start, &
|
||||
elset_count, elset_items, elem_type, db_upper, &
|
||||
surface_target, surface_face, surface_type, &
|
||||
database_find_surface, database_find_elset, &
|
||||
database_find_elem, elset_start, elset_count, &
|
||||
elset_items, elem_type, db_upper, &
|
||||
surface_face_normal_sign, &
|
||||
surface_face_has_explicit_side
|
||||
implicit none
|
||||
@@ -113,6 +114,7 @@ contains
|
||||
|
||||
database_surface_contains_elem = .false.
|
||||
if (surface_id .le. 0 .or. surface_id .gt. n_surface) return
|
||||
if (.not. surface_is_element_type(surface_id)) return
|
||||
if (.not. allocated(surface_owner)) return
|
||||
if (.not. allocated(surface_target)) return
|
||||
|
||||
@@ -133,6 +135,7 @@ contains
|
||||
|
||||
db_surface_has_facet = .false.
|
||||
if (surface_id .le. 0 .or. surface_id .gt. n_surface) return
|
||||
if (.not. surface_is_element_type(surface_id)) return
|
||||
if (.not. allocated(surface_owner)) return
|
||||
if (.not. allocated(surface_target)) return
|
||||
|
||||
@@ -155,6 +158,7 @@ contains
|
||||
|
||||
surface_facet_normal_sign = 1
|
||||
if (surface_id .le. 0 .or. surface_id .gt. n_surface) return
|
||||
if (.not. surface_is_element_type(surface_id)) return
|
||||
if (.not. allocated(surface_owner)) return
|
||||
if (.not. allocated(surface_target)) return
|
||||
|
||||
@@ -177,6 +181,7 @@ contains
|
||||
|
||||
surface_facet_has_explicit_side = .false.
|
||||
if (surface_id .le. 0 .or. surface_id .gt. n_surface) return
|
||||
if (.not. surface_is_element_type(surface_id)) return
|
||||
if (.not. allocated(surface_owner)) return
|
||||
if (.not. allocated(surface_target)) return
|
||||
|
||||
@@ -192,6 +197,15 @@ contains
|
||||
end do
|
||||
end function surface_facet_has_explicit_side
|
||||
|
||||
logical function surface_is_element_type(surface_id)
|
||||
integer, intent(in) :: surface_id
|
||||
|
||||
surface_is_element_type = .true.
|
||||
if (.not. allocated(surface_type)) return
|
||||
if (surface_id .lt. 1 .or. surface_id .gt. size(surface_type)) return
|
||||
surface_is_element_type = trim(surface_type(surface_id)) .eq. 'ELEMENT'
|
||||
end function surface_is_element_type
|
||||
|
||||
logical function surface_item_matches_elem(elem_ext, target)
|
||||
integer, intent(in) :: elem_ext
|
||||
character(len=*), intent(in) :: target
|
||||
|
||||
@@ -22,7 +22,7 @@ FemLite S4 unsupported surface type parser test
|
||||
0.1
|
||||
*SHELL SECTION, ELSET=SLAVE, MATERIAL=MAT
|
||||
0.1
|
||||
*SURFACE, NAME=MASTER_SURF, TYPE=NODE
|
||||
*SURFACE, NAME=MASTER_SURF, TYPE=ANALYTICAL
|
||||
MASTER, SPOS
|
||||
*SURFACE, NAME=SLAVE_SURF, TYPE=ELEMENT
|
||||
SLAVE, SNEG
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
*HEADING
|
||||
FemLite S4 node-based surface 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
|
||||
*ELEMENT, TYPE=S4, ELSET=PLATE
|
||||
1, 1, 2, 3, 4
|
||||
*NSET, NSET=TOP_NODES
|
||||
3, 4
|
||||
*MATERIAL, NAME=MAT
|
||||
*DENSITY
|
||||
1.0
|
||||
*ELASTIC
|
||||
30.0, 0.25
|
||||
*SHELL SECTION, ELSET=PLATE, MATERIAL=MAT
|
||||
0.1
|
||||
*SURFACE, NAME=NODE_SURF, TYPE=NODE
|
||||
TOP_NODES
|
||||
1
|
||||
*STEP
|
||||
*DYNAMIC
|
||||
0.1, 0.1
|
||||
*END STEP
|
||||
@@ -56,7 +56,7 @@ int main(void)
|
||||
|
||||
ierr = femlite_get_version(&major, &minor, &patch);
|
||||
if (ierr != 0) return check_ierr(ierr, 2);
|
||||
if (major != 0 || minor != 3 || patch != 3) return 3;
|
||||
if (major != 0 || minor != 4 || patch != 0) return 3;
|
||||
|
||||
ierr = femlite_read_inp("examples/c3d4_one_element.inp");
|
||||
if (ierr != 0) return check_ierr(ierr, 4);
|
||||
|
||||
@@ -7,7 +7,7 @@ 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_face, surface_owner, surface_type
|
||||
use fem_database_surface, only: db_contact_facet_match, &
|
||||
db_contact_facet_normal_sign, &
|
||||
db_contact_facet_has_side
|
||||
@@ -456,12 +456,41 @@ contains
|
||||
call fem_finalize(ierr)
|
||||
if (ierr .ne. 0) call fail(478)
|
||||
|
||||
call check_node_surface_inp()
|
||||
call check_contact_pair_input_errors()
|
||||
end subroutine check_contact_pair_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)
|
||||
end subroutine check_contact_pair_inp
|
||||
end subroutine check_contact_pair_input_errors
|
||||
|
||||
subroutine check_node_surface_inp()
|
||||
integer :: ierr
|
||||
|
||||
call fem_initialize(ierr)
|
||||
if (ierr .ne. 0) call fail(480)
|
||||
|
||||
call fem_read_inp('tests/data/s4_node_surface.inp', ierr)
|
||||
if (ierr .ne. 0) call fail(481)
|
||||
if (n_surface .ne. 1) call fail(482)
|
||||
if (trim(surface_name(1)) .ne. 'NODE_SURF') call fail(483)
|
||||
if (trim(surface_type(1)) .ne. 'NODE') call fail(484)
|
||||
if (surface_start(1) .ne. 1) call fail(485)
|
||||
if (surface_count(1) .ne. 2) call fail(486)
|
||||
if (trim(surface_target(1)) .ne. 'TOP_NODES') call fail(487)
|
||||
if (trim(surface_target(2)) .ne. '1') call fail(488)
|
||||
if (db_contact_facet_match(1, 1, 'NODE_SURF')) call fail(489)
|
||||
|
||||
call fem_build_model(ierr)
|
||||
if (ierr .ne. 0) call fail(490)
|
||||
|
||||
call fem_finalize(ierr)
|
||||
if (ierr .ne. 0) call fail(491)
|
||||
end subroutine check_node_surface_inp
|
||||
|
||||
subroutine check_contact_pair_inp_error(path, code_base)
|
||||
character(len=*), intent(in) :: path
|
||||
|
||||
Reference in New Issue
Block a user