Enhance contact clipping search and output

This commit is contained in:
shenw
2026-06-23 20:11:55 +08:00
parent 8710688540
commit dd13b44890
15 changed files with 1243 additions and 128 deletions
+1 -1
View File
@@ -392,7 +392,7 @@ coupling 层职责:
- 接触状态、接触力和接触功输出
- 隐式增量残差和迭代次数输出
第三版当前接触模块保留刚性平面接触,并新增基于边界 facet 的面-面 contact pair force/tangent 路径。0.3.1 已补充多 master facet 权重分摊、Coulomb 摩擦和 facet 空间 broad-phase 过滤;完整接触状态、接触功、严格 mortar 和空间网格/BVH 仍属于后续输出与算法增强项。
第三版当前接触模块保留刚性平面接触,并新增基于边界 facet 的面-面 contact pair force/tangent 路径。0.3.1 已补充投影裁剪面积积分、多 master 面积上限修正、Coulomb 摩擦、均匀空间网格候选搜索、facet 空间 broad-phase 精筛,以及接触状态/接触功 CSV 与 API 输出。完整 mortar 形函数积分、摩擦历史和并行 BVH 仍属于后续算法增强项。
输出控制:
+1
View File
@@ -897,6 +897,7 @@ elements_step_xxxxx.csv 至少包含:
- `convergence.csv`:静力和隐式动力增量迭代历史。
- `reactions_step_xxxxx.csv`:节点反力。
- `contact_step_xxxxx.csv`:接触状态、接触力和接触功。
当前字段为 `kind,pair_id,active_count,max_penetration,force_norm,work_estimate,cumulative_work`,包含 summary 行和逐 contact pair 行。
- 静力求解结束后必须写出与显式结果一致的 VTK 场文件。
## 19. 主程序模块
+4 -3
View File
@@ -796,10 +796,11 @@ K_eff Delta_u = R
- 刚性平面接触仍采用节点到平面的 penalty/damping 法向接触。
- 面-面 contact pair 使用边界 facet 的当前构形坐标、速度、法向、面积、中心和等效半径。
- slave facet 质心投影到 master facet 平面,投影点落在 master facet 等效半径和搜索距离内且法向间隙为负时激活;多个 master facet 同时激活时按投影权重分摊。
- 接触力为 `penalty * penetration * area` 加可选法向阻尼项,并可叠加基于相对切向速度的 Coulomb 摩擦力。
- slave facet 沿 master 法向投影到 master facet 平面,在局部二维坐标中执行多边形裁剪;裁剪面积大于零且法向间隙为负时激活。多个 master facet 同时激活时按裁剪面积贡献,且总面积不超过 slave facet 面积。
- 接触力为 `penalty * penetration * clipped_area` 加可选法向阻尼项,并可叠加基于相对切向速度的 Coulomb 摩擦力。
- 接触切线采用法向 penalty/damping 块加切向摩擦近似块,装配 slave-slave、slave-master、master-slave 和 master-master 四类自由度耦合。
- 当前实现包含 facet 中心/等效半径空间 broad-phase 过滤;严格 mortar 积分、精确面内投影裁剪、空间网格/BVH 和完整接触功统计仍为后续增强项。
- 当前实现包含 master facet 均匀空间网格候选搜索和 facet 中心/等效半径 broad-phase 精筛。接触状态记录激活贡献数、最大穿透量、接触力范数和 `0.5 * |F_contact| * penetration` 形式的接触功估计。
- 当前投影裁剪属于面积型 mortar 近似,尚未实现完整 mortar 形函数积分、摩擦粘滑历史变量和并行 BVH。
第一版不实现接触,只保留 fcontact 向量和接口位置。
+17 -4
View File
@@ -544,10 +544,13 @@ end subroutine
第三版提供接触结果查询接口:
```fortran
subroutine fem_get_contact_summary(nactive_contact, contact_work, max_penetration, ierr)
integer, intent(out) :: nactive_contact
real(rk), intent(out) :: contact_work
subroutine fem_get_contact_summary(active_count, work_step, work_total, &
max_penetration, force_norm, ierr)
integer, intent(out) :: active_count
real(rk), intent(out) :: work_step
real(rk), intent(out) :: work_total
real(rk), intent(out) :: max_penetration
real(rk), intent(out) :: force_norm
integer, intent(out) :: ierr
end subroutine
```
@@ -570,7 +573,17 @@ end subroutine
- `contact_pair_search(pair)`:搜索距离,0 表示只按 facet 等效半径过滤。
- `contact_pair_friction(pair)`:Coulomb 摩擦系数,必须非负;0 表示无摩擦。
当前 contact pair 支持多 master facet 权重分摊、Coulomb 摩擦和 facet 空间 broad-phase 过滤。查询统计仍以 `fem_get_contact_summary` 为目标接口,完整激活数量、最大穿透量和接触功统计将在接触输出阶段补齐。
当前 contact pair 支持投影裁剪面积积分、多 master facet 面积上限修正、Coulomb 摩擦、均匀空间网格候选搜索和 facet 空间 broad-phase 精筛。
接触统计包括:
- `contact_active_count`:最近一次接触力评估中的激活贡献数。
- `contact_work_step`:最近一次接触力评估的接触功估计。
- `contact_work_total`:累计接触功估计。
- `contact_max_penetration`:最近一次接触力评估的最大穿透量。
- `contact_force_norm`:最近一次接触力评估的接触力范数累加。
逐 contact pair 统计保存在 `contact_pair_active/work/max_penetration/force_norm` 数组中,并写入 `contact_step_xxxxx.csv`。
## 13. 输出控制接口
+3 -1
View File
@@ -264,13 +264,15 @@ SPH总力映射测试 relative tolerance 1.0e-10 to 1.0e-8
- 面压力等效节点力。
- amplitude 常值和表格插值。
- 刚性平面 contact penalty/damping 力和切线。
- 面-面 contact pair 法向力、阻尼项、Coulomb 摩擦、多 master 分摊、空间 broad-phase、CSR 图案和切线块。
- 面-面 contact pair 法向力、阻尼项、Coulomb 摩擦、多 master 分摊、投影裁剪面积、空间网格候选、空间 broad-phase、CSR 图案和切线块。
输出测试:
- `history.csv` 字段存在。
- `nodes_step_xxxxx.csv` 字段存在。
- `elements_step_xxxxx.csv` 字段存在。
- `contact_step_xxxxx.csv` 字段存在,并包含 summary 与逐 contact pair 行。
- `fem_get_contact_summary` 返回激活数、单步/累计接触功、最大穿透量和接触力范数。
- 删除单元状态可输出。
## 11. 输入解析测试
+14 -12
View File
@@ -273,7 +273,7 @@ K_eff = K_t + a0 M + a1 C
1. `*SURFACE` 输入子集。
2. `*CONTACT PAIR` 输入子集。
3. 接触面数据结构。
4. 朴素接触搜索,后续再优化为空间网格或 BVH。
4. 接触搜索,先采用均匀空间网格,后续可升级 BVH 或并行搜索。
5. 节点-面接触。
6. 面-面接触框架。
7. penalty 法默认接触力。
@@ -285,12 +285,13 @@ K_eff = K_t + a0 M + a1 C
- 保留第二版刚性平面 penalty 接触路径。
- 新增 `contact_pair_slave/master/penalty/damping/search/friction` 集中式数据库数组,可通过 elset、element id 或 `ALL` 指定接触对目标。
- 面-面接触采用边界 facet 的质心投影、法向间隙和 penalty/damping 法向力映射,并在 0.3.1 扩展为多 master facet 权重分摊。
- 面-面接触采用边界 facet 的当前构形、法向间隙和 penalty/damping 法向力映射;0.3.1 已从质心权重推进到 master 平面局部二维投影裁剪面积积分,并对重复 master 面做从面面积上限修正。
- 0.3.1 支持基于相对切向速度的 Coulomb 摩擦力和切向近似切线。
- 0.3.1 增加 facet 中心/等效半径空间 broad-phase 过滤,减少明显不可能接触的 facet 对。
- 0.3.1 增加基于 master facet 桶的均匀空间网格候选搜索,并保留 facet 中心/等效半径 broad-phase 精筛。
- 0.3.1 新增全局和逐 contact pair 的激活数、最大穿透量、接触力范数和接触功估计统计,并输出到 `history.csv` 与 `contact_step_xxxxx.csv`。
- CSR 稀疏图案会为 contact pair 预留 slave-slave、slave-master、master-slave 和 master-master 切线块。
- 已补充 contact pair 法向力、摩擦力、多 master 分摊和切线装配测试。
- 当前尚未实现严格 mortar 积分、精确面内投影裁剪、空间网格/BVH 加速、完整接触状态输出和工程级接触收敛控制。
- 已补充 contact pair 法向力、摩擦力、多 master 分摊、投影裁剪面积、空间网格分支、接触统计和切线装配测试。
- 当前仍未实现完整 mortar 形函数积分、摩擦粘滑历史变量、并行 BVH 和工程级接触收敛控制。
验收条件:
@@ -324,12 +325,13 @@ K_eff = K_t + a0 M + a1 C
- my
- mz
3. `contact_step_xxxxx.csv`:
- contact_id
- node_id 或 facet_id
- penetration
- normal_force
- tangential_force
- contact_status
- kind
- pair_id
- active_count
- max_penetration
- force_norm
- work_estimate
- cumulative_work
4. 静力 VTK 输出:
- displacement
- rotation
@@ -444,7 +446,7 @@ P2 测试:
- 先实体,再壳;先 S4/S3,再 S6/S8。
- Scordelis-Lo 作为壳静力主基准,分网格逐步验证。
- 非线性静力先完成实体 J2 算法切线,再推进壳膜内塑性切线,0.3.1 补齐壳弯曲/剪切 section tangent 映射。
- 接触先保留刚性平面和面-面框架,0.3.1 补充多 master 权重分摊、Coulomb 摩擦和空间 broad-phase,再继续推进节点-面、严格 mortar 和搜索加速。
- 接触先保留刚性平面和面-面框架,0.3.1 补充投影裁剪面积、多 master 面积上限、Coulomb 摩擦、均匀空间网格和接触输出,再继续推进节点-面、完整 mortar 形函数积分、摩擦历史和并行 BVH。
- 输出字段先冻结格式,再增加内容。
- 每个阶段均保持 CTest 可通过。
+5
View File
@@ -17,6 +17,11 @@ int femlite_estimate_stable_dt(double *dtcrit);
int femlite_advance_explicit(double dt);
int femlite_get_current_time(double *time, int *step);
int femlite_get_model_size(int *num_nodes, int *num_elems, int *num_dof);
int femlite_get_contact_summary(int *active_count,
double *work_step,
double *work_total,
double *max_penetration,
double *force_norm);
int femlite_clear_sph_forces(void);
int femlite_apply_sph_nodal_forces(int num_force_nodes,
+22
View File
@@ -288,6 +288,28 @@ contains
ierr = FEM_SUCCESS
end subroutine fem_get_sph_force_summary
subroutine fem_get_contact_summary(active_count, work_step, work_total, &
max_penetration, force_norm, ierr)
integer, intent(out) :: active_count
real(rk), intent(out) :: work_step
real(rk), intent(out) :: work_total
real(rk), intent(out) :: max_penetration
real(rk), intent(out) :: force_norm
integer, intent(out) :: ierr
if (.not. api_initialized) then
call error_set(FEM_ERR_INTERNAL, 'fem_get_contact_summary called before fem_initialize', ierr)
return
end if
active_count = contact_active_count
work_step = contact_work_step
work_total = contact_work_total
max_penetration = contact_max_penetration
force_norm = contact_force_norm
ierr = FEM_SUCCESS
end subroutine fem_get_contact_summary
subroutine fem_get_boundary_facet_count(num_facets, max_face_nodes, ierr)
integer, intent(out) :: num_facets
integer, intent(out) :: max_face_nodes
File diff suppressed because it is too large Load Diff
+23
View File
@@ -20,6 +20,7 @@
#define F_ADVANCE_EXPLICIT FC_GLOBAL(femlite_f_advance_explicit, FEMLITE_F_ADVANCE_EXPLICIT)
#define F_GET_TIME FC_GLOBAL(femlite_f_get_time, FEMLITE_F_GET_TIME)
#define F_GET_SIZE FC_GLOBAL(femlite_f_get_size, FEMLITE_F_GET_SIZE)
#define F_GET_CONTACT_SUMMARY FC_GLOBAL(femlite_f_get_contact_summary, FEMLITE_F_GET_CONTACT_SUMMARY)
#define F_CLEAR_SPH FC_GLOBAL(femlite_f_clear_sph, FEMLITE_F_CLEAR_SPH)
#define F_APPLY_SPH_NODES FC_GLOBAL(femlite_f_apply_sph_nodes, FEMLITE_F_APPLY_SPH_NODES)
#define F_GET_FACET_COUNT FC_GLOBAL(femlite_f_get_facet_count, FEMLITE_F_GET_FACET_COUNT)
@@ -41,6 +42,12 @@ extern void F_ESTIMATE_DT(double *dtcrit, int *ierr);
extern void F_ADVANCE_EXPLICIT(double *dt, int *ierr);
extern void F_GET_TIME(double *time, int *step, int *ierr);
extern void F_GET_SIZE(int *num_nodes, int *num_elems, int *num_dof, int *ierr);
extern void F_GET_CONTACT_SUMMARY(int *active_count,
double *work_step,
double *work_total,
double *max_penetration,
double *force_norm,
int *ierr);
extern void F_CLEAR_SPH(int *ierr);
extern void F_APPLY_SPH_NODES(int *num_force_nodes,
const int *node_ids,
@@ -198,6 +205,22 @@ int femlite_get_model_size(int *num_nodes, int *num_elems, int *num_dof)
return ierr;
}
int femlite_get_contact_summary(int *active_count,
double *work_step,
double *work_total,
double *max_penetration,
double *force_norm)
{
int ierr = 0;
if (active_count == NULL || work_step == NULL || work_total == NULL ||
max_penetration == NULL || force_norm == NULL) {
return -1;
}
F_GET_CONTACT_SUMMARY(active_count, work_step, work_total,
max_penetration, force_norm, &ierr);
return ierr;
}
int femlite_clear_sph_forces(void)
{
int ierr = 0;
+16
View File
@@ -188,6 +188,22 @@ subroutine femlite_f_get_facet_count(num_facets, max_fnodes, ierr)
call fem_get_boundary_facet_count(num_facets, max_fnodes, ierr)
end subroutine femlite_f_get_facet_count
subroutine femlite_f_get_contact_summary(active_count, work_step, work_total, &
max_penetration, force_norm, ierr)
use fem_api
use fem_precision
implicit none
integer, intent(out) :: active_count
real(rk), intent(out) :: work_step
real(rk), intent(out) :: work_total
real(rk), intent(out) :: max_penetration
real(rk), intent(out) :: force_norm
integer, intent(out) :: ierr
call fem_get_contact_summary(active_count, work_step, work_total, &
max_penetration, force_norm, ierr)
end subroutine femlite_f_get_contact_summary
subroutine femlite_f_get_facets(nfacet, max_fnodes, facet_id, elem_id, &
face_id, facet_nnode, facet_conn, x, vnod, &
normal, area, ierr)
+43
View File
@@ -147,6 +147,15 @@ module fem_database
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(:)
contains
@@ -614,13 +623,25 @@ contains
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_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)
if (allocated(contact_pair_force_norm)) deallocate(contact_pair_force_norm)
ncontact_pair = num_pairs
contact_active_count = 0
contact_work_step = ZERO
contact_work_total = ZERO
contact_max_penetration = ZERO
contact_force_norm = ZERO
if (num_pairs .gt. 0) then
allocate(contact_pair_slave(num_pairs), contact_pair_master(num_pairs), &
contact_pair_penalty(num_pairs), contact_pair_damping(num_pairs), &
contact_pair_search(num_pairs), contact_pair_friction(num_pairs), &
contact_pair_active(num_pairs), contact_pair_work(num_pairs), &
contact_pair_max_penetration(num_pairs), &
contact_pair_force_norm(num_pairs), &
stat=stat)
if (stat .ne. 0) then
ncontact_pair = 0
@@ -633,6 +654,10 @@ contains
contact_pair_damping = ZERO
contact_pair_search = ZERO
contact_pair_friction = ZERO
contact_pair_active = 0
contact_pair_work = ZERO
contact_pair_max_penetration = ZERO
contact_pair_force_norm = ZERO
end if
ierr = FEM_SUCCESS
@@ -828,6 +853,15 @@ contains
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
contact_active_count = 0
contact_work_step = ZERO
contact_work_total = ZERO
contact_max_penetration = ZERO
contact_force_norm = ZERO
if (allocated(contact_pair_active)) contact_pair_active = 0
if (allocated(contact_pair_work)) contact_pair_work = ZERO
if (allocated(contact_pair_max_penetration)) contact_pair_max_penetration = ZERO
if (allocated(contact_pair_force_norm)) contact_pair_force_norm = ZERO
ierr = FEM_SUCCESS
end subroutine database_initialize
@@ -1620,6 +1654,10 @@ contains
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_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)
if (allocated(contact_pair_force_norm)) deallocate(contact_pair_force_norm)
nnode = 0
nelem = 0
@@ -1640,6 +1678,11 @@ contains
nmpc_term = 0
ncontact_plane = 0
ncontact_pair = 0
contact_active_count = 0
contact_work_step = ZERO
contact_work_total = ZERO
contact_max_penetration = ZERO
contact_force_norm = ZERO
ierr = FEM_SUCCESS
end subroutine database_finalize
+81 -3
View File
@@ -69,7 +69,9 @@ contains
if (.not. exists .and. .not. history_header_written) then
write(unit_id,'(A)',iostat=ios) &
'step,time,total_mass,kinetic_energy,max_displacement,max_velocity,max_acceleration'
'step,time,total_mass,kinetic_energy,max_displacement,max_velocity,'// &
'max_acceleration,contact_active_count,contact_work_step,'// &
'contact_work_total,contact_max_penetration,contact_force_norm'
if (ios .ne. 0) then
close(unit_id)
call error_set(FEM_ERR_OUTPUT, 'failed to write history CSV header', ierr)
@@ -77,9 +79,12 @@ contains
end if
end if
write(unit_id,'(I12,A,5(ES24.16,A),ES24.16)',iostat=ios) step, ',', time, ',', &
write(unit_id,'(I12,A,5(ES24.16,A),ES24.16,A,I12,4(A,ES24.16))',iostat=ios) &
step, ',', time, ',', &
total_mass, ',', kinetic_energy, ',', max_displacement, ',', &
max_velocity, ',', max_acceleration
max_velocity, ',', max_acceleration, ',', contact_active_count, &
',', contact_work_step, ',', contact_work_total, ',', &
contact_max_penetration, ',', contact_force_norm
if (ios .ne. 0) then
close(unit_id)
call error_set(FEM_ERR_OUTPUT, 'failed to write history CSV row', ierr)
@@ -98,6 +103,9 @@ contains
call output_csv_write_elements(step, ierr)
if (ierr .ne. FEM_SUCCESS) return
call output_csv_write_contact(step, ierr)
if (ierr .ne. FEM_SUCCESS) return
ierr = FEM_SUCCESS
end subroutine output_csv_write
@@ -298,6 +306,76 @@ contains
ierr = FEM_SUCCESS
end subroutine output_csv_write_elements
subroutine output_csv_write_contact(step, ierr)
integer, intent(in) :: step
integer, intent(out) :: ierr
character(len=512) :: filename
integer :: unit_id
integer :: ios
integer :: pair
integer :: active
real(rk) :: max_pen
real(rk) :: force_sum
real(rk) :: work_sum
if (ncontact_plane .le. 0 .and. ncontact_pair .le. 0) then
ierr = FEM_SUCCESS
return
end if
call output_csv_step_filename('contact', step, filename)
unit_id = 66
open(unit=unit_id, file=trim(filename), status='replace', &
action='write', iostat=ios)
if (ios .ne. 0) then
call error_set(FEM_ERR_OUTPUT, 'failed to open contact CSV output', ierr)
return
end if
write(unit_id,'(A)',iostat=ios) &
'kind,pair_id,active_count,max_penetration,force_norm,work_estimate,cumulative_work'
if (ios .ne. 0) then
close(unit_id)
call error_set(FEM_ERR_OUTPUT, 'failed to write contact CSV header', ierr)
return
end if
write(unit_id,'(A,A,I12,A,I12,4(A,ES24.16))',iostat=ios) &
'SUMMARY', ',', 0, ',', contact_active_count, &
',', contact_max_penetration, ',', contact_force_norm, &
',', contact_work_step, ',', contact_work_total
if (ios .ne. 0) then
close(unit_id)
call error_set(FEM_ERR_OUTPUT, 'failed to write contact CSV summary row', ierr)
return
end if
do pair = 1, ncontact_pair
active = 0
max_pen = ZERO
force_sum = ZERO
work_sum = ZERO
if (allocated(contact_pair_active)) active = contact_pair_active(pair)
if (allocated(contact_pair_max_penetration)) then
max_pen = contact_pair_max_penetration(pair)
end if
if (allocated(contact_pair_force_norm)) force_sum = contact_pair_force_norm(pair)
if (allocated(contact_pair_work)) work_sum = contact_pair_work(pair)
write(unit_id,'(A,A,I12,A,I12,4(A,ES24.16))',iostat=ios) &
'PAIR', ',', pair, ',', active, ',', max_pen, ',', force_sum, &
',', work_sum, ',', ZERO
if (ios .ne. 0) then
close(unit_id)
call error_set(FEM_ERR_OUTPUT, 'failed to write contact CSV pair row', ierr)
return
end if
end do
close(unit_id)
ierr = FEM_SUCCESS
end subroutine output_csv_write_contact
subroutine output_csv_average_element(elem, sig, eps, peps, eqps, damage)
integer, intent(in) :: elem
real(rk), intent(out) :: sig(NSTRESS)
+14
View File
@@ -29,6 +29,7 @@ int main(void)
int nfacet = 0;
int max_face_nodes = 0;
int step = 0;
int active_contact = -1;
int node_ids[1] = {2};
int facet_id[8];
int elem_id[8];
@@ -45,6 +46,10 @@ int main(void)
double acc[3] = {0.0, 0.0, 0.0};
double dtcrit = 0.0;
double time = 0.0;
double contact_work_step = -1.0;
double contact_work_total = -1.0;
double contact_max_penetration = -1.0;
double contact_force_norm = -1.0;
ierr = femlite_initialize();
if (ierr != 0) return check_ierr(ierr, 1);
@@ -62,6 +67,15 @@ int main(void)
if (ierr != 0) return check_ierr(ierr, 6);
if (nnode != 4 || nelem != 1 || ndof != 12) return 7;
ierr = femlite_get_contact_summary(&active_contact, &contact_work_step,
&contact_work_total,
&contact_max_penetration,
&contact_force_norm);
if (ierr != 0) return check_ierr(ierr, 24);
if (active_contact != 0 || contact_work_step != 0.0 ||
contact_work_total != 0.0 || contact_max_penetration != 0.0 ||
contact_force_norm != 0.0) return 25;
ierr = femlite_compute_lumped_mass();
if (ierr != 0) return check_ierr(ierr, 8);
ierr = femlite_estimate_stable_dt(&dtcrit);
+161 -1
View File
@@ -17,6 +17,8 @@ program test_contact
call check_surface_pair_tangent()
call check_surface_pair_friction()
call check_surface_pair_multimaster()
call check_pair_clipped()
call check_pair_grid()
contains
@@ -84,6 +86,11 @@ contains
subroutine check_explicit_contact_step()
integer :: ierr
integer :: dof
integer :: active_count
real(rk) :: work_step
real(rk) :: work_total
real(rk) :: max_penetration
real(rk) :: force_norm
call fem_initialize(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(20)
@@ -108,9 +115,16 @@ contains
call check_close(a(dof), ONE, 24)
call check_close(v(dof), 0.10_rk, 25)
call check_close(u(dof), -0.095_rk, 26)
call fem_get_contact_summary(active_count, work_step, work_total, &
max_penetration, force_norm, ierr)
if (ierr .ne. FEM_SUCCESS) call fail(27)
if (active_count .ne. 1) call fail(28)
call check_close(max_penetration, 0.10_rk, 29)
call check_close(force_norm, ONE, 30)
call check_close(work_step, 0.05_rk, 31)
call fem_finalize(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(27)
if (ierr .ne. FEM_SUCCESS) call fail(32)
end subroutine check_explicit_contact_step
subroutine check_surface_pair_force()
@@ -245,6 +259,74 @@ contains
if (ierr .ne. FEM_SUCCESS) call fail(65)
end subroutine check_surface_pair_multimaster
subroutine check_pair_clipped()
integer :: ierr
integer :: node
integer :: dof
call setup_contact_shell_pair(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(70)
do node = 5, 8
coord0(1,node) = coord0(1,node) + 0.5_rk
end do
coord = coord0
call contact_apply_plane_forces(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(71)
do node = 5, 8
dof = dof_id(3,node)
call check_close(fcontact(dof), 1.25_rk, 72)
end do
do node = 1, 4
dof = dof_id(3,node)
call check_close(fcontact(dof), -1.25_rk, 73)
end do
if (contact_active_count .ne. 1) call fail(74)
if (contact_pair_active(1) .ne. 1) call fail(75)
call check_close(contact_max_penetration, 0.01_rk, 76)
call check_close(contact_pair_max_penetration(1), 0.01_rk, 77)
call check_close(contact_force_norm, 5.0_rk, 78)
call check_close(contact_pair_force_norm(1), 5.0_rk, 79)
call check_close(contact_work_step, 0.025_rk, 80)
call check_close(contact_pair_work(1), 0.025_rk, 81)
call database_finalize(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(82)
end subroutine check_pair_clipped
subroutine check_pair_grid()
integer :: ierr
integer :: node
integer :: dof
call setup_contact_grid_pair(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(90)
call contact_apply_plane_forces(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(91)
do node = 73, 76
dof = dof_id(3,node)
call check_close(fcontact(dof), 2.5_rk, 92)
end do
do node = 1, 4
dof = dof_id(3,node)
call check_close(fcontact(dof), -2.5_rk, 93)
end do
do node = 5, 72
dof = dof_id(3,node)
call check_close(fcontact(dof), ZERO, 94)
end do
if (contact_active_count .ne. 1) call fail(95)
call check_close(contact_force_norm, 10.0_rk, 96)
call database_finalize(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(97)
end subroutine check_pair_grid
subroutine setup_basic_nodes(num_nodes, ierr)
integer, intent(in) :: num_nodes
integer, intent(out) :: ierr
@@ -399,6 +481,84 @@ contains
ierr = FEM_SUCCESS
end subroutine setup_contact_shell_multimaster
subroutine setup_contact_grid_pair(ierr)
integer, intent(out) :: ierr
integer :: master
integer :: node_base
integer :: xshift
call database_allocate_model(76, 19, 0, 2, 0, 19, 1, 0, 1, &
0, 0, 0, 0, 0, ierr)
if (ierr .ne. FEM_SUCCESS) return
do master = 1, 18
node_base = 4 * (master - 1)
xshift = 10 * (master - 1)
node_id_ext(node_base+1:node_base+4) = &
(/ node_base + 1, node_base + 2, node_base + 3, node_base + 4 /)
coord0(:,node_base+1) = (/ real(xshift, rk), ZERO, ZERO /)
coord0(:,node_base+2) = (/ real(xshift, rk) + ONE, ZERO, ZERO /)
coord0(:,node_base+3) = (/ real(xshift, rk) + ONE, ONE, ZERO /)
coord0(:,node_base+4) = (/ real(xshift, rk), ONE, ZERO /)
elem_id_ext(master) = master
elem_type(master) = 'S4'
elem_nnode(master) = 4
elem_conn(:,master) = 0
elem_conn(1:4,master) = &
(/ node_base + 1, node_base + 2, node_base + 3, node_base + 4 /)
elem_mat(master) = 1
elem_sec(master) = 1
end do
node_id_ext(73:76) = (/ 73, 74, 75, 76 /)
coord0(:,73) = (/ ZERO, ZERO, -0.01_rk /)
coord0(:,74) = (/ ONE, ZERO, -0.01_rk /)
coord0(:,75) = (/ ONE, ONE, -0.01_rk /)
coord0(:,76) = (/ ZERO, ONE, -0.01_rk /)
coord = coord0
elem_id_ext(19) = 19
elem_type(19) = 'S4'
elem_nnode(19) = 4
elem_conn(:,19) = 0
elem_conn(1:4,19) = (/ 73, 74, 75, 76 /)
elem_mat(19) = 1
elem_sec(19) = 1
elset_name(1) = 'MASTER'
elset_start(1) = 1
elset_count(1) = 18
do master = 1, 18
elset_items(master) = master
end do
elset_name(2) = 'SLAVE'
elset_start(2) = 19
elset_count(2) = 1
elset_items(19) = 19
mat_name(1) = 'MAT'
mat_density(1) = ONE
mat_e(1) = 30.0_rk
mat_nu(1) = 0.25_rk
section_type(1) = 'SHELL'
section_elset_name(1) = 'ALL'
section_material_name(1) = 'MAT'
section_thickness(1) = 0.1_rk
call database_assign_dofs(ierr)
if (ierr .ne. FEM_SUCCESS) return
call database_allocate_contact_pair(1, ierr)
if (ierr .ne. FEM_SUCCESS) return
contact_pair_slave(1) = 'SLAVE'
contact_pair_master(1) = 'MASTER'
contact_pair_penalty(1) = 1000.0_rk
contact_pair_damping(1) = ZERO
contact_pair_search(1) = 0.1_rk
contact_pair_friction(1) = ZERO
ierr = FEM_SUCCESS
end subroutine setup_contact_grid_pair
subroutine check_close(actual, expected, code)
real(rk), intent(in) :: actual
real(rk), intent(in) :: expected