diff --git a/CMakeLists.txt b/CMakeLists.txt index 6fb829d..d2aa524 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.20) project(FemLite - VERSION 0.3.0 + VERSION 0.3.1 LANGUAGES C Fortran ) diff --git a/docs/02_software_architecture_design.md b/docs/02_software_architecture_design.md index 0e72d33..795f8af 100644 --- a/docs/02_software_architecture_design.md +++ b/docs/02_software_architecture_design.md @@ -392,7 +392,7 @@ coupling 层职责: - 接触状态、接触力和接触功输出 - 隐式增量残差和迭代次数输出 -第三版当前接触模块保留刚性平面接触,并新增基于边界 facet 的面-面 contact pair force/tangent 路径。完整接触状态、接触功和搜索加速仍属于后续输出与算法增强项。 +第三版当前接触模块保留刚性平面接触,并新增基于边界 facet 的面-面 contact pair force/tangent 路径。0.3.1 已补充多 master facet 权重分摊、Coulomb 摩擦和 facet 空间 broad-phase 过滤;完整接触状态、接触功、严格 mortar 和空间网格/BVH 仍属于后续输出与算法增强项。 输出控制: diff --git a/docs/03_detailed_design.md b/docs/03_detailed_design.md index 39c0350..9b95dd2 100644 --- a/docs/03_detailed_design.md +++ b/docs/03_detailed_design.md @@ -820,7 +820,7 @@ end subroutine 当前非线性 Newmark-Newton 实现约定: - 实体单元切线从当前积分点材料状态取得弹性/J2 算法切线。 -- 壳单元膜内项对 J2/J2_JC 使用当前积分点算法切线,弯曲和横向剪切项暂用弹性近似切线。 +- 壳单元膜内、弯曲和横向剪切 section tangent 对 J2/J2_JC 使用当前积分点算法切线映射。 - 每个非线性增量保存材料状态和单元状态备份,迭代试算前恢复,收敛后提交,失败后回滚。 - Robin、MPC、刚性平面 penalty contact 和面-面 contact pair 的切线进入 Newton 有效刚度。 - 静力和非线性 Newmark 均支持线搜索;可选步长缩减在失败时恢复增量起点状态后重试。 diff --git a/docs/04_mathematical_model_and_algorithms.md b/docs/04_mathematical_model_and_algorithms.md index f5ffeda..298b844 100644 --- a/docs/04_mathematical_model_and_algorithms.md +++ b/docs/04_mathematical_model_and_algorithms.md @@ -700,7 +700,7 @@ for each load increment: 当前 V3.4/V3.5 阶段实现采用 Newton 形式: - 残差使用当前位移下的非线性内力 `F_int(u,state)`。 -- 实体单元切线使用当前积分点弹性/J2 算法切线;壳单元膜内项对 J2/J2_JC 使用当前积分点算法切线,壳弯曲和横向剪切项暂保留弹性近似。 +- 实体单元切线使用当前积分点弹性/J2 算法切线;壳单元膜内、弯曲和横向剪切 section tangent 对 J2/J2_JC 使用当前积分点算法切线映射。 - Dirichlet、CLOAD、DLOAD、Robin、MPC、SPH/contact 外力向量进入静力残差。 - Robin、MPC、刚性平面 penalty contact 和面-面 contact pair 切线进入 Newton 切线矩阵。 - 材料状态和单元删除标志采用增量级 trial/restore/commit;非收敛时恢复到增量起点。 @@ -756,12 +756,12 @@ R = F_ext(t_{n+1}) - F_int(u_trial,state) - M a_trial - C v_trial K_eff Delta_u = R ``` -当前实现中 `K_eff` 使用当前实体材料算法切线、壳膜内塑性算法切线或壳弹性近似切线、集中质量矩阵、Rayleigh 阻尼和外部约束/接触切线形成。收敛判据使用绝对力残差和相对力残差,Dirichlet 约束自由度的位移增量残差置零。非线性 Newmark 支持线搜索;可选步长缩减在单步失败时恢复运动学量和材料 trial 状态后重试。 +当前实现中 `K_eff` 使用当前实体材料算法切线、壳 section 塑性算法切线、集中质量矩阵、Rayleigh 阻尼和外部约束/接触切线形成。收敛判据使用绝对力残差和相对力残差,Dirichlet 约束自由度的位移增量残差置零。非线性 Newmark 支持线搜索;可选步长缩减在单步失败时恢复运动学量和材料 trial 状态后重试。 当前限制: - Rayleigh 阻尼已在线性 Newmark 和非线性 Newmark-Newton 骨架中接入。 -- 实体 J2 非线性 Newmark 使用当前积分点算法切线,壳膜内 J2/J2_JC 使用当前积分点算法切线,壳弯曲/剪切塑性切线仍为后续增强项。 +- 实体 J2 非线性 Newmark 使用当前积分点算法切线,壳膜内、弯曲和横向剪切 section tangent 对 J2/J2_JC 使用当前积分点算法切线映射。 - 材料状态和单元删除标志已具备 trial/restore/commit 机制。 - Robin 和 MPC 的非线性动力切线已接入 `K_eff`。 - 刚性平面 contact 和面-面 contact pair 的 penalty/damping 切线已接入 `K_eff`。 @@ -788,18 +788,18 @@ K_eff Delta_u = R - 面-面接触框架。 - 接触法向与穿透量。 - 接触阻尼。 -- 摩擦接口预留。 +- Coulomb 摩擦力和切向近似切线。 - 静力接触和动力接触统一残差接口。 - 接触功输出。 当前第三版阶段实现: - 刚性平面接触仍采用节点到平面的 penalty/damping 法向接触。 -- 面-面 contact pair 使用边界 facet 的当前构形坐标、速度、法向和面积。 -- slave facet 质心投影到 master facet 平面,投影点落在 master facet 等效半径和搜索距离内且法向间隙为负时激活。 -- 接触力为 `penalty * penetration * area` 加可选法向阻尼项,均分到 slave 和 master facet 节点。 -- 接触切线采用法向 penalty/damping 块,装配 slave-slave、slave-master、master-slave 和 master-master 四类自由度耦合。 -- 当前尚未实现摩擦、mortar 积分、精确面内投影裁剪、空间加速搜索和完整接触功统计。 +- 面-面 contact pair 使用边界 facet 的当前构形坐标、速度、法向、面积、中心和等效半径。 +- slave facet 质心投影到 master facet 平面,投影点落在 master facet 等效半径和搜索距离内且法向间隙为负时激活;多个 master facet 同时激活时按投影权重分摊。 +- 接触力为 `penalty * penetration * area` 加可选法向阻尼项,并可叠加基于相对切向速度的 Coulomb 摩擦力。 +- 接触切线采用法向 penalty/damping 块加切向摩擦近似块,装配 slave-slave、slave-master、master-slave 和 master-master 四类自由度耦合。 +- 当前实现包含 facet 中心/等效半径空间 broad-phase 过滤;严格 mortar 积分、精确面内投影裁剪、空间网格/BVH 和完整接触功统计仍为后续增强项。 第一版不实现接触,只保留 fcontact 向量和接口位置。 diff --git a/docs/05_interface_control_document.md b/docs/05_interface_control_document.md index 3f3a3b2..6654ab0 100644 --- a/docs/05_interface_control_document.md +++ b/docs/05_interface_control_document.md @@ -300,7 +300,7 @@ end subroutine - `fem_run_implicit_newmark` 使用输入文件中的时间控制运行到 `time_end`。 - `fem_run_newmark_nonlinear` 使用输入文件中的时间控制运行到 `time_end`,对应命令行 `--implicit-newmark-nonlinear`。 - `fem_set_rayleigh_damping` 设置 `C = alpha_mass M + beta_stiffness K`。 -- 非线性 Newmark Fortran95 接口当前接入实体 J2 算法切线、壳膜内 J2/J2_JC 切线、trial/restore/commit、线搜索、可选步长缩减、Robin/MPC 切线、刚性平面 penalty contact 切线和面-面 contact pair 切线;C ABI 和 Python 调试接口跟随扩展。 +- 非线性 Newmark Fortran95 接口当前接入实体 J2 算法切线、壳膜内/弯曲/剪切 J2/J2_JC section tangent、trial/restore/commit、线搜索、可选步长缩减、Robin/MPC 切线、刚性平面 penalty contact 切线和面-面 contact pair 切线;C ABI 和 Python 调试接口跟随扩展。 ## 10. 载荷接口 @@ -568,8 +568,9 @@ end subroutine - `contact_pair_penalty(pair)`:法向 penalty 刚度,必须大于 0。 - `contact_pair_damping(pair)`:法向阻尼,必须非负。 - `contact_pair_search(pair)`:搜索距离,0 表示只按 facet 等效半径过滤。 +- `contact_pair_friction(pair)`:Coulomb 摩擦系数,必须非负;0 表示无摩擦。 -当前 contact pair 查询统计仍以 `fem_get_contact_summary` 为目标接口,完整激活数量、最大穿透量和接触功统计将在接触输出阶段补齐。 +当前 contact pair 支持多 master facet 权重分摊、Coulomb 摩擦和 facet 空间 broad-phase 过滤。查询统计仍以 `fem_get_contact_summary` 为目标接口,完整激活数量、最大穿透量和接触功统计将在接触输出阶段补齐。 ## 13. 输出控制接口 diff --git a/docs/06_test_and_verification_plan.md b/docs/06_test_and_verification_plan.md index 7f45cc1..4420f98 100644 --- a/docs/06_test_and_verification_plan.md +++ b/docs/06_test_and_verification_plan.md @@ -232,7 +232,7 @@ SPH总力映射测试 relative tolerance 1.0e-10 to 1.0e-8 - S4 选择性减缩积分路径。 - S4 patch test。 - S3/S4/S6/S8 线性静力刚度测试。 -- S4 J2/J2_JC 膜内塑性状态更新和膜内算法切线对称性测试。 +- S4 J2/J2_JC 膜内塑性状态更新和膜内/弯曲/剪切 section tangent 对称性测试。 - Scordelis-Lo 壳静力位移基准测试。 - 板壳弯曲静力基准测试。 @@ -264,7 +264,7 @@ SPH总力映射测试 relative tolerance 1.0e-10 to 1.0e-8 - 面压力等效节点力。 - amplitude 常值和表格插值。 - 刚性平面 contact penalty/damping 力和切线。 -- 面-面 contact pair 法向力、阻尼项、CSR 图案和切线块。 +- 面-面 contact pair 法向力、阻尼项、Coulomb 摩擦、多 master 分摊、空间 broad-phase、CSR 图案和切线块。 输出测试: diff --git a/docs/v3_development_plan.md b/docs/v3_development_plan.md index e6292d0..3d3f899 100644 --- a/docs/v3_development_plan.md +++ b/docs/v3_development_plan.md @@ -189,7 +189,7 @@ FemLite 0.3.0 定位为: 5. 失败回退和步长缩减。 6. 小应变 J2 弹塑性静力路径。 7. 大变形 Updated Lagrangian 静力路径。 -8. 实体 J2 算法切线,壳膜内 J2 算法切线,壳弯曲/剪切塑性切线后续完善。 +8. 实体 J2 算法切线,壳膜内/弯曲/剪切 section J2 算法切线。 9. 材料状态 trial/commit 机制。 当前实现状态: @@ -198,12 +198,12 @@ FemLite 0.3.0 定位为: - 已实现命令行 `--static-nonlinear` 入口。 - 已实现按 `*STATIC` 时间控制分增量加载。 - 当前残差由 CLOAD、DLOAD、Robin、MPC、SPH、contact 外力和内力共同构成。 -- 实体单元切线按积分点材料状态使用弹性/J2 算法切线;壳单元膜内项对 J2/J2_JC 使用当前积分点算法切线,弯曲和横向剪切项暂保留弹性近似。 +- 实体单元切线按积分点材料状态使用弹性/J2 算法切线;壳单元膜内、弯曲和横向剪切 section tangent 对 J2/J2_JC 使用当前积分点算法切线映射。 - 已实现材料状态和单元删除标志的 trial/restore/commit 机制,非收敛时恢复到增量起点。 - 已接入 Robin、MPC、刚性平面 penalty contact 和面-面 contact pair 的非线性切线。 - 已覆盖弹性非线性退化、位移控制 J2 塑性状态更新和 trial rollback 测试。 - 已实现 Newton 线搜索;可选步长缩减支持在非收敛时回退到增量起点并缩小当前增量。 -- 壳弯曲/剪切塑性一致切线、节点-面接触、摩擦接触和接触输出统计仍需继续完善。 +- 节点-面接触、接触输出统计和更高阶接触积分仍需继续完善。 验收条件: @@ -252,7 +252,7 @@ K_eff = K_t + a0 M + a1 C - 已提供 `fem_set_rayleigh_damping(alpha_mass, beta_stiffness, ierr)`。 - 已覆盖 C3D4 单步隐式 Newmark 拉伸、Rayleigh 阻尼、非线性 Newmark 线弹性退化和 CLI 回归测试。 - 已覆盖非线性 Newmark 中 Robin、MPC、刚性平面接触切线、面-面 contact pair 切线和失败后 trial rollback 的解析小算例。 -- 非线性 Newmark 对实体 J2 使用当前积分点算法切线;壳膜内 J2/J2_JC 使用当前积分点算法切线,壳弯曲/剪切塑性切线和更完整隐式动力基准尚未完成。 +- 非线性 Newmark 对实体 J2 使用当前积分点算法切线;壳膜内、弯曲和横向剪切 section tangent 对 J2/J2_JC 使用当前积分点算法切线映射,更完整隐式动力基准仍需继续补充。 - 已实现非线性 Newmark 线搜索;可选动态步长缩减在单步失败时恢复运动学量和材料 trial 状态后重试。 验收条件: @@ -284,11 +284,13 @@ K_eff = K_t + a0 M + a1 C 当前实现状态: - 保留第二版刚性平面 penalty 接触路径。 -- 新增 `contact_pair_slave/master/penalty/damping/search` 集中式数据库数组,可通过 elset、element id 或 `ALL` 指定接触对目标。 -- 面-面接触采用边界 facet 的质心投影、法向间隙和 penalty/damping 法向力映射,当前用于小规模接触对验证。 +- 新增 `contact_pair_slave/master/penalty/damping/search/friction` 集中式数据库数组,可通过 elset、element id 或 `ALL` 指定接触对目标。 +- 面-面接触采用边界 facet 的质心投影、法向间隙和 penalty/damping 法向力映射,并在 0.3.1 扩展为多 master facet 权重分摊。 +- 0.3.1 支持基于相对切向速度的 Coulomb 摩擦力和切向近似切线。 +- 0.3.1 增加 facet 中心/等效半径空间 broad-phase 过滤,减少明显不可能接触的 facet 对。 - CSR 稀疏图案会为 contact pair 预留 slave-slave、slave-master、master-slave 和 master-master 切线块。 -- 已补充 contact pair 法向力和切线装配测试。 -- 当前尚未实现摩擦、mortar 接触、空间加速搜索、完整接触状态输出和工程级接触收敛控制。 +- 已补充 contact pair 法向力、摩擦力、多 master 分摊和切线装配测试。 +- 当前尚未实现严格 mortar 积分、精确面内投影裁剪、空间网格/BVH 加速、完整接触状态输出和工程级接触收敛控制。 验收条件: @@ -441,8 +443,8 @@ P2 测试: - 先实现线性静力,再实现非线性静力。 - 先实体,再壳;先 S4/S3,再 S6/S8。 - Scordelis-Lo 作为壳静力主基准,分网格逐步验证。 -- 非线性静力先完成实体 J2 算法切线,再推进壳膜内塑性切线,最后补齐壳弯曲/剪切塑性一致切线。 -- 接触先保留刚性平面和朴素面-面框架,再补节点-面、摩擦和搜索加速。 +- 非线性静力先完成实体 J2 算法切线,再推进壳膜内塑性切线,0.3.1 补齐壳弯曲/剪切 section tangent 映射。 +- 接触先保留刚性平面和面-面框架,0.3.1 补充多 master 权重分摊、Coulomb 摩擦和空间 broad-phase,再继续推进节点-面、严格 mortar 和搜索加速。 - 输出字段先冻结格式,再增加内容。 - 每个阶段均保持 CTest 可通过。 diff --git a/src/base/fem_precision.f90 b/src/base/fem_precision.f90 index a813380..0c20c29 100644 --- a/src/base/fem_precision.f90 +++ b/src/base/fem_precision.f90 @@ -16,7 +16,7 @@ module fem_precision integer, parameter :: FEMLITE_VERSION_MAJOR = 0 integer, parameter :: FEMLITE_VERSION_MINOR = 3 - integer, parameter :: FEMLITE_VERSION_PATCH = 0 + integer, parameter :: FEMLITE_VERSION_PATCH = 1 real(rk), parameter :: ZERO = 0.0_rk real(rk), parameter :: ONE = 1.0_rk diff --git a/src/boundary/fem_contact.f90 b/src/boundary/fem_contact.f90 index d2be207..77d822b 100644 --- a/src/boundary/fem_contact.f90 +++ b/src/boundary/fem_contact.f90 @@ -312,7 +312,6 @@ contains integer :: stat integer :: sf integer :: mf - integer :: best integer, allocatable :: facet_id(:) integer, allocatable :: elem_id(:) integer, allocatable :: face_id(:) @@ -321,13 +320,23 @@ contains real(rk), allocatable :: x(:,:,:) real(rk), allocatable :: vnod(:,:,:) real(rk), allocatable :: normal(:,:) + real(rk), allocatable :: center(:,:) + real(rk), allocatable :: velc(:,:) real(rk), allocatable :: area(:) + real(rk), allocatable :: radius(:) real(rk) :: gap real(rk) :: vn - real(rk) :: best_gap - real(rk) :: best_vn real(rk) :: force_mag + real(rk) :: normal_mag + real(rk) :: total_weight + real(rk) :: pair_weight + real(rk) :: share + real(rk) :: mu + real(rk) :: vt_norm real(rk) :: nrm(NDIM) + real(rk) :: tdir(NDIM) + real(rk) :: force_vec(NDIM) + integer :: q call cpl_build_facets(ierr) if (ierr .ne. FEM_SUCCESS) return @@ -340,7 +349,8 @@ contains allocate(facet_id(nf), elem_id(nf), face_id(nf), fnnode(nf), & fconn(max_nodes,nf), x(NDIM,max_nodes,nf), & - vnod(NDIM,max_nodes,nf), normal(NDIM,nf), area(nf), stat=stat) + vnod(NDIM,max_nodes,nf), normal(NDIM,nf), & + center(NDIM,nf), velc(NDIM,nf), area(nf), radius(nf), stat=stat) if (stat .ne. 0) then call error_set(FEM_ERR_INTERNAL, 'failed to allocate contact pair facets', ierr) return @@ -350,41 +360,60 @@ contains fconn, x, vnod, normal, area, ierr) if (ierr .ne. FEM_SUCCESS) go to 900 + do q = 1, nf + call facet_center_velocity(q, nf, max_nodes, fnnode, x, vnod, & + center(:,q), velc(:,q)) + radius(q) = facet_radius_value(q, nf, max_nodes, fnnode, x, center(:,q)) + end do + mu = contact_pair_friction_value(pair) + do sf = 1, nf if (.not. facet_target_matches(elem_id(sf), contact_pair_slave(pair))) cycle - best = 0 - best_gap = ZERO - best_vn = ZERO - nrm = ZERO + total_weight = ZERO do mf = 1, nf if (sf .eq. mf) cycle if (.not. facet_target_matches(elem_id(mf), contact_pair_master(pair))) cycle + if (.not. contact_spatial_candidate(pair, sf, mf, nf, center, radius)) cycle if (facet_nodes_share(max_nodes, fnnode(sf), fconn(:,sf), & fnnode(mf), fconn(:,mf))) cycle call pair_contact_gap(pair, sf, mf, nf, max_nodes, fnnode, & - x, vnod, normal, gap, vn, ierr) + x, vnod, normal, gap, vn, pair_weight, ierr) if (ierr .ne. FEM_SUCCESS) go to 900 - if (gap .lt. ZERO) then - if (best .eq. 0 .or. gap .lt. best_gap) then - best = mf - best_gap = gap - best_vn = vn - nrm = normal(:,mf) - end if - end if + if (gap .lt. ZERO) total_weight = total_weight + pair_weight end do - if (best .gt. 0) then - force_mag = contact_pair_penalty(pair) * (-best_gap) * area(sf) - if (best_vn .lt. ZERO) then - force_mag = force_mag + contact_pair_damping(pair) * & - (-best_vn) * area(sf) - end if - call add_contact_pair_force(max_nodes, fnnode(sf), fconn(:,sf), & - fnnode(best), fconn(:,best), & - force_mag, nrm, ierr) + if (total_weight .le. tiny(ONE)) cycle + + do mf = 1, nf + if (sf .eq. mf) cycle + if (.not. facet_target_matches(elem_id(mf), contact_pair_master(pair))) cycle + if (.not. contact_spatial_candidate(pair, sf, mf, nf, center, radius)) cycle + if (facet_nodes_share(max_nodes, fnnode(sf), fconn(:,sf), & + fnnode(mf), fconn(:,mf))) cycle + call pair_contact_gap(pair, sf, mf, nf, max_nodes, fnnode, & + x, vnod, normal, gap, vn, pair_weight, ierr) if (ierr .ne. FEM_SUCCESS) go to 900 - end if + if (gap .ge. ZERO) cycle + + share = pair_weight / total_weight + nrm = normalized_contact_normal(normal(:,mf), ierr) + if (ierr .ne. FEM_SUCCESS) go to 900 + normal_mag = contact_pair_penalty(pair) * (-gap) * area(sf) * share + if (vn .lt. ZERO) then + normal_mag = normal_mag + contact_pair_damping(pair) * & + (-vn) * area(sf) * share + end if + call contact_tangent_direction(sf, mf, nf, max_nodes, fnnode, & + vnod, nrm, tdir, vt_norm) + force_vec = normal_mag * nrm + if (mu .gt. ZERO .and. vt_norm .gt. tiny(ONE) .and. normal_mag .gt. ZERO) then + force_mag = mu * normal_mag + force_vec = force_vec - force_mag * tdir + end if + call add_contact_pair_force_vec(max_nodes, fnnode(sf), fconn(:,sf), & + fnnode(mf), fconn(:,mf), force_vec, ierr) + if (ierr .ne. FEM_SUCCESS) go to 900 + end do end do ierr = FEM_SUCCESS @@ -398,7 +427,10 @@ contains if (allocated(x)) deallocate(x) if (allocated(vnod)) deallocate(vnod) if (allocated(normal)) deallocate(normal) + if (allocated(center)) deallocate(center) + if (allocated(velc)) deallocate(velc) if (allocated(area)) deallocate(area) + if (allocated(radius)) deallocate(radius) end subroutine apply_contact_pair_force_one subroutine apply_contact_pair_tan_one(pair, kmat, velocity_scale, ierr) @@ -411,7 +443,6 @@ contains integer :: stat integer :: sf integer :: mf - integer :: best integer, allocatable :: facet_id(:) integer, allocatable :: elem_id(:) integer, allocatable :: face_id(:) @@ -420,13 +451,22 @@ contains real(rk), allocatable :: x(:,:,:) real(rk), allocatable :: vnod(:,:,:) real(rk), allocatable :: normal(:,:) + real(rk), allocatable :: center(:,:) + real(rk), allocatable :: velc(:,:) real(rk), allocatable :: area(:) + real(rk), allocatable :: radius(:) real(rk) :: gap real(rk) :: vn - real(rk) :: best_gap - real(rk) :: best_vn real(rk) :: coeff + real(rk) :: total_weight + real(rk) :: pair_weight + real(rk) :: share + real(rk) :: mu real(rk) :: nrm(NDIM) + real(rk) :: ktan(NDIM,NDIM) + integer :: idir + integer :: jdir + integer :: q call cpl_build_facets(ierr) if (ierr .ne. FEM_SUCCESS) return @@ -439,7 +479,8 @@ contains allocate(facet_id(nf), elem_id(nf), face_id(nf), fnnode(nf), & fconn(max_nodes,nf), x(NDIM,max_nodes,nf), & - vnod(NDIM,max_nodes,nf), normal(NDIM,nf), area(nf), stat=stat) + vnod(NDIM,max_nodes,nf), normal(NDIM,nf), & + center(NDIM,nf), velc(NDIM,nf), area(nf), radius(nf), stat=stat) if (stat .ne. 0) then call error_set(FEM_ERR_INTERNAL, 'failed to allocate contact tangent facets', ierr) return @@ -449,39 +490,62 @@ contains fconn, x, vnod, normal, area, ierr) if (ierr .ne. FEM_SUCCESS) go to 900 + do q = 1, nf + call facet_center_velocity(q, nf, max_nodes, fnnode, x, vnod, & + center(:,q), velc(:,q)) + radius(q) = facet_radius_value(q, nf, max_nodes, fnnode, x, center(:,q)) + end do + mu = contact_pair_friction_value(pair) + do sf = 1, nf if (.not. facet_target_matches(elem_id(sf), contact_pair_slave(pair))) cycle - best = 0 - best_gap = ZERO - best_vn = ZERO - nrm = ZERO + total_weight = ZERO do mf = 1, nf if (sf .eq. mf) cycle if (.not. facet_target_matches(elem_id(mf), contact_pair_master(pair))) cycle + if (.not. contact_spatial_candidate(pair, sf, mf, nf, center, radius)) cycle if (facet_nodes_share(max_nodes, fnnode(sf), fconn(:,sf), & fnnode(mf), fconn(:,mf))) cycle call pair_contact_gap(pair, sf, mf, nf, max_nodes, fnnode, & - x, vnod, normal, gap, vn, ierr) + x, vnod, normal, gap, vn, pair_weight, ierr) if (ierr .ne. FEM_SUCCESS) go to 900 - if (gap .lt. ZERO) then - if (best .eq. 0 .or. gap .lt. best_gap) then - best = mf - best_gap = gap - best_vn = vn - nrm = normal(:,mf) - end if - end if + if (gap .lt. ZERO) total_weight = total_weight + pair_weight end do - if (best .gt. 0) then - coeff = contact_pair_penalty(pair) * area(sf) - if (best_vn .lt. ZERO) then - coeff = coeff + velocity_scale * contact_pair_damping(pair) * area(sf) - end if - call add_contact_pair_tan(kmat, max_nodes, fnnode(sf), fconn(:,sf), & - fnnode(best), fconn(:,best), coeff, nrm, ierr) + if (total_weight .le. tiny(ONE)) cycle + + do mf = 1, nf + if (sf .eq. mf) cycle + if (.not. facet_target_matches(elem_id(mf), contact_pair_master(pair))) cycle + if (.not. contact_spatial_candidate(pair, sf, mf, nf, center, radius)) cycle + if (facet_nodes_share(max_nodes, fnnode(sf), fconn(:,sf), & + fnnode(mf), fconn(:,mf))) cycle + call pair_contact_gap(pair, sf, mf, nf, max_nodes, fnnode, & + x, vnod, normal, gap, vn, pair_weight, ierr) if (ierr .ne. FEM_SUCCESS) go to 900 - end if + if (gap .ge. ZERO) cycle + + share = pair_weight / total_weight + nrm = normalized_contact_normal(normal(:,mf), ierr) + if (ierr .ne. FEM_SUCCESS) go to 900 + coeff = contact_pair_penalty(pair) * area(sf) * share + if (vn .lt. ZERO) then + coeff = coeff + velocity_scale * contact_pair_damping(pair) * area(sf) * share + end if + ktan = ZERO + do idir = 1, NDIM + do jdir = 1, NDIM + ktan(idir,jdir) = coeff * nrm(idir) * nrm(jdir) + if (mu .gt. ZERO) then + if (idir .eq. jdir) ktan(idir,jdir) = ktan(idir,jdir) + mu * coeff + ktan(idir,jdir) = ktan(idir,jdir) - mu * coeff * nrm(idir) * nrm(jdir) + end if + end do + end do + call add_contact_pair_tan_matrix(kmat, max_nodes, fnnode(sf), fconn(:,sf), & + fnnode(mf), fconn(:,mf), ktan, ierr) + if (ierr .ne. FEM_SUCCESS) go to 900 + end do end do ierr = FEM_SUCCESS @@ -495,7 +559,10 @@ contains if (allocated(x)) deallocate(x) if (allocated(vnod)) deallocate(vnod) if (allocated(normal)) deallocate(normal) + if (allocated(center)) deallocate(center) + if (allocated(velc)) deallocate(velc) if (allocated(area)) deallocate(area) + if (allocated(radius)) deallocate(radius) end subroutine apply_contact_pair_tan_one logical function facet_target_matches(elem_ext, target) @@ -552,8 +619,89 @@ contains end do end function facet_nodes_share + logical function contact_spatial_candidate(pair, sf, mf, nf, center, radius) + integer, intent(in) :: pair + integer, intent(in) :: sf + integer, intent(in) :: mf + integer, intent(in) :: nf + real(rk), intent(in) :: center(NDIM,nf) + real(rk), intent(in) :: radius(nf) + real(rk) :: delta(NDIM) + real(rk) :: limit + + delta = center(:,sf) - center(:,mf) + limit = radius(sf) + radius(mf) + if (allocated(contact_pair_search)) then + if (pair .ge. 1 .and. pair .le. size(contact_pair_search)) then + limit = limit + contact_pair_search(pair) + end if + end if + limit = max(limit, tiny(ONE)) + contact_spatial_candidate = sum(delta * delta) .le. limit * limit + tiny(ONE) + end function contact_spatial_candidate + + real(rk) function contact_pair_friction_value(pair) + integer, intent(in) :: pair + + contact_pair_friction_value = ZERO + if (.not. allocated(contact_pair_friction)) return + if (pair .lt. 1 .or. pair .gt. size(contact_pair_friction)) return + contact_pair_friction_value = max(ZERO, contact_pair_friction(pair)) + end function contact_pair_friction_value + + function normalized_contact_normal(raw_normal, ierr) result(nrm) + real(rk), intent(in) :: raw_normal(NDIM) + integer, intent(out) :: ierr + real(rk) :: nrm(NDIM) + real(rk) :: nlen + + nrm = raw_normal + nlen = sqrt(sum(nrm * nrm)) + if (nlen .le. tiny(ONE)) then + call error_set(FEM_ERR_COUPLING, 'contact pair master facet normal is zero', ierr) + return + end if + nrm = nrm / nlen + ierr = FEM_SUCCESS + end function normalized_contact_normal + + subroutine contact_tangent_direction(sf, mf, nf, max_nodes, fnnode, & + vnod, normal, tdir, vt_norm) + integer, intent(in) :: sf + integer, intent(in) :: mf + integer, intent(in) :: nf + integer, intent(in) :: max_nodes + integer, intent(in) :: fnnode(nf) + real(rk), intent(in) :: vnod(NDIM,max_nodes,nf) + real(rk), intent(in) :: normal(NDIM) + real(rk), intent(out) :: tdir(NDIM) + real(rk), intent(out) :: vt_norm + real(rk) :: sv(NDIM) + real(rk) :: mv(NDIM) + integer :: local_node + + sv = ZERO + mv = ZERO + do local_node = 1, fnnode(sf) + sv = sv + vnod(:,local_node,sf) + end do + do local_node = 1, fnnode(mf) + mv = mv + vnod(:,local_node,mf) + end do + sv = sv / real(fnnode(sf), rk) + mv = mv / real(fnnode(mf), rk) + tdir = (sv - mv) - dot_product(sv - mv, normal) * normal + vt_norm = sqrt(sum(tdir * tdir)) + if (vt_norm .gt. tiny(ONE)) then + tdir = tdir / vt_norm + else + tdir = ZERO + vt_norm = ZERO + end if + end subroutine contact_tangent_direction + subroutine pair_contact_gap(pair, sf, mf, nf, max_nodes, fnnode, x, vnod, & - normal, gap, vn, ierr) + normal, gap, vn, pair_weight, ierr) integer, intent(in) :: pair integer, intent(in) :: sf integer, intent(in) :: mf @@ -565,6 +713,7 @@ contains real(rk), intent(in) :: normal(NDIM,nf) real(rk), intent(out) :: gap real(rk), intent(out) :: vn + real(rk), intent(out) :: pair_weight integer, intent(out) :: ierr real(rk) :: sc(NDIM) real(rk) :: mc(NDIM) @@ -576,7 +725,9 @@ contains real(rk) :: radius real(rk) :: search real(rk) :: dist + real(rk) :: support + pair_weight = ZERO call facet_center_velocity(sf, nf, max_nodes, fnnode, x, vnod, sc, sv) call facet_center_velocity(mf, nf, max_nodes, fnnode, x, vnod, mc, mv) @@ -605,7 +756,12 @@ contains projection = sc - gap * nrm dist = sqrt(sum((projection - mc) * (projection - mc))) - if (dist .gt. radius + max(search, tiny(ONE))) gap = ZERO + support = radius + max(search, tiny(ONE)) + if (dist .gt. support) then + gap = ZERO + else + pair_weight = max(tiny(ONE), ONE - dist / max(support, tiny(ONE))) + end if ierr = FEM_SUCCESS end subroutine pair_contact_gap @@ -651,15 +807,14 @@ contains end do end function facet_radius_value - subroutine add_contact_pair_force(max_nodes, nslave, slave_conn, nmaster, & - master_conn, force_mag, normal, ierr) + subroutine add_contact_pair_force_vec(max_nodes, nslave, slave_conn, nmaster, & + master_conn, force_vec, ierr) integer, intent(in) :: max_nodes integer, intent(in) :: nslave integer, intent(in) :: nmaster integer, intent(in) :: slave_conn(max_nodes) integer, intent(in) :: master_conn(max_nodes) - real(rk), intent(in) :: force_mag - real(rk), intent(in) :: normal(NDIM) + real(rk), intent(in) :: force_vec(NDIM) integer, intent(out) :: ierr integer :: local_node integer :: node @@ -667,7 +822,7 @@ contains integer :: dof real(rk) :: weight - weight = force_mag / real(nslave, rk) + weight = ONE / real(nslave, rk) do local_node = 1, nslave node = database_find_node(slave_conn(local_node)) if (node .eq. 0) then @@ -676,11 +831,11 @@ contains end if do idir = 1, NDIM dof = dof_id(idir,node) - if (dof .gt. 0) fcontact(dof) = fcontact(dof) + weight * normal(idir) + if (dof .gt. 0) fcontact(dof) = fcontact(dof) + weight * force_vec(idir) end do end do - weight = force_mag / real(nmaster, rk) + weight = ONE / real(nmaster, rk) do local_node = 1, nmaster node = database_find_node(master_conn(local_node)) if (node .eq. 0) then @@ -689,30 +844,29 @@ contains end if do idir = 1, NDIM dof = dof_id(idir,node) - if (dof .gt. 0) fcontact(dof) = fcontact(dof) - weight * normal(idir) + if (dof .gt. 0) fcontact(dof) = fcontact(dof) - weight * force_vec(idir) end do end do ierr = FEM_SUCCESS - end subroutine add_contact_pair_force + end subroutine add_contact_pair_force_vec - subroutine add_contact_pair_tan(kmat, max_nodes, nslave, slave_conn, & - nmaster, master_conn, coeff, normal, ierr) + subroutine add_contact_pair_tan_matrix(kmat, max_nodes, nslave, slave_conn, & + nmaster, master_conn, kmat3, ierr) type(csr_matrix), intent(inout) :: kmat integer, intent(in) :: max_nodes integer, intent(in) :: nslave integer, intent(in) :: nmaster integer, intent(in) :: slave_conn(max_nodes) integer, intent(in) :: master_conn(max_nodes) - real(rk), intent(in) :: coeff - real(rk), intent(in) :: normal(NDIM) + real(rk), intent(in) :: kmat3(NDIM,NDIM) integer, intent(out) :: ierr integer :: i integer :: j real(rk) :: ws real(rk) :: wm - if (abs(coeff) .le. tiny(ONE)) then + if (maxval(abs(kmat3)) .le. tiny(ONE)) then ierr = FEM_SUCCESS return end if @@ -721,40 +875,40 @@ contains wm = ONE / real(nmaster, rk) do i = 1, nslave do j = 1, nslave - call add_contact_pair_block(kmat, slave_conn(i), slave_conn(j), & - coeff * ws * ws, normal, ierr) + call add_contact_pair_mat_block(kmat, slave_conn(i), slave_conn(j), & + ws * ws, kmat3, ierr) if (ierr .ne. FEM_SUCCESS) return end do do j = 1, nmaster - call add_contact_pair_block(kmat, slave_conn(i), master_conn(j), & - -coeff * ws * wm, normal, ierr) + call add_contact_pair_mat_block(kmat, slave_conn(i), master_conn(j), & + -ws * wm, kmat3, ierr) if (ierr .ne. FEM_SUCCESS) return end do end do do i = 1, nmaster do j = 1, nslave - call add_contact_pair_block(kmat, master_conn(i), slave_conn(j), & - -coeff * wm * ws, normal, ierr) + call add_contact_pair_mat_block(kmat, master_conn(i), slave_conn(j), & + -wm * ws, kmat3, ierr) if (ierr .ne. FEM_SUCCESS) return end do do j = 1, nmaster - call add_contact_pair_block(kmat, master_conn(i), master_conn(j), & - coeff * wm * wm, normal, ierr) + call add_contact_pair_mat_block(kmat, master_conn(i), master_conn(j), & + wm * wm, kmat3, ierr) if (ierr .ne. FEM_SUCCESS) return end do end do ierr = FEM_SUCCESS - end subroutine add_contact_pair_tan + end subroutine add_contact_pair_tan_matrix - subroutine add_contact_pair_block(kmat, node_a_ext, node_b_ext, scale, & - normal, ierr) + subroutine add_contact_pair_mat_block(kmat, node_a_ext, node_b_ext, scale, & + kmat3, ierr) type(csr_matrix), intent(inout) :: kmat integer, intent(in) :: node_a_ext integer, intent(in) :: node_b_ext real(rk), intent(in) :: scale - real(rk), intent(in) :: normal(NDIM) + real(rk), intent(in) :: kmat3(NDIM,NDIM) integer, intent(out) :: ierr integer :: node_a integer :: node_b @@ -776,14 +930,13 @@ contains do jdir = 1, NDIM col = dof_id(jdir,node_b) if (col .gt. 0) then - call csr_add_value(kmat, row, col, & - scale * normal(idir) * normal(jdir), ierr) + call csr_add_value(kmat, row, col, scale * kmat3(idir,jdir), ierr) if (ierr .ne. FEM_SUCCESS) return end if end do end do ierr = FEM_SUCCESS - end subroutine add_contact_pair_block + end subroutine add_contact_pair_mat_block end module fem_contact diff --git a/src/element/fem_element_stiffness.f90 b/src/element/fem_element_stiffness.f90 index 49ae280..dfd44d0 100644 --- a/src/element/fem_element_stiffness.f90 +++ b/src/element/fem_element_stiffness.f90 @@ -217,7 +217,7 @@ contains if (allocated(elem_gp_start)) then if (elem .le. size(elem_gp_start)) gp = elem_gp_start(elem) end if - call shell_apply_mem_tangent(mat, thickness, gp, dmem, ierr) + call shell_apply_section_tangent(mat, thickness, gp, dmem, dben, dshr, ierr) if (ierr .ne. FEM_SUCCESS) return call shell_b_matrices(NLOCAL, nshape, dndx, dndy, bmem, bben, bshr) @@ -257,7 +257,9 @@ contains real(rk) :: dmem(3,3) real(rk) :: dmem_gp(3,3) real(rk) :: dben(3,3) + real(rk) :: dben_gp(3,3) real(rk) :: dshr(2,2) + real(rk) :: dshr_gp(2,2) real(rk) :: klocal(NQDOF,NQDOF) real(rk) :: transform(NQDOF,NGDOF) real(rk) :: tmp(NQDOF,NGDOF) @@ -345,16 +347,19 @@ contains area = area + weight call shell_b_matrices(NLOCAL, nshape, dndx, dndy, bmem, bben, bshr) dmem_gp = dmem + dben_gp = dben + dshr_gp = dshr gp = 0 if (allocated(elem_gp_start)) then if (elem .le. size(elem_gp_start)) gp = elem_gp_start(elem) + q - 1 end if - call shell_apply_mem_tangent(mat, thickness, gp, dmem_gp, ierr) + call shell_apply_section_tangent(mat, thickness, gp, dmem_gp, dben_gp, & + dshr_gp, ierr) if (ierr .ne. FEM_SUCCESS) return klocal = klocal + weight * matmul(transpose(bmem), matmul(dmem_gp, bmem)) + & - weight * matmul(transpose(bben), matmul(dben, bben)) + & - weight * matmul(transpose(bshr), matmul(dshr, bshr)) + weight * matmul(transpose(bben), matmul(dben_gp, bben)) + & + weight * matmul(transpose(bshr), matmul(dshr_gp, bshr)) end do call shell_transform_matrix(NLOCAL, basis, transform) @@ -388,7 +393,9 @@ contains real(rk) :: dmem(3,3) real(rk) :: dmem_gp(3,3) real(rk) :: dben(3,3) + real(rk) :: dben_gp(3,3) real(rk) :: dshr(2,2) + real(rk) :: dshr_gp(2,2) real(rk) :: klocal(5*nlocal,5*nlocal) real(rk) :: transform(5*nlocal,6*nlocal) real(rk) :: tmp(5*nlocal,6*nlocal) @@ -477,16 +484,19 @@ contains area = area + weight call shell_b_matrices(nlocal, nshape, dndx, dndy, bmem, bben, bshr) dmem_gp = dmem + dben_gp = dben + dshr_gp = dshr gp = 0 if (allocated(elem_gp_start)) then if (elem .le. size(elem_gp_start)) gp = elem_gp_start(elem) + q - 1 end if - call shell_apply_mem_tangent(mat, thickness, gp, dmem_gp, ierr) + call shell_apply_section_tangent(mat, thickness, gp, dmem_gp, dben_gp, & + dshr_gp, ierr) if (ierr .ne. FEM_SUCCESS) return klocal = klocal + weight * matmul(transpose(bmem), matmul(dmem_gp, bmem)) + & - weight * matmul(transpose(bben), matmul(dben, bben)) + & - weight * matmul(transpose(bshr), matmul(dshr, bshr)) + weight * matmul(transpose(bben), matmul(dben_gp, bben)) + & + weight * matmul(transpose(bshr), matmul(dshr_gp, bshr)) end do call shell_transform_matrix(nlocal, basis, transform) @@ -939,13 +949,17 @@ contains dshr(2,2) = coeff_shr end subroutine shell_constitutive - subroutine shell_apply_mem_tangent(mat, thickness, gp, dmem, ierr) + subroutine shell_apply_section_tangent(mat, thickness, gp, dmem, dben, dshr, ierr) integer, intent(in) :: mat real(rk), intent(in) :: thickness integer, intent(in) :: gp real(rk), intent(inout) :: dmem(3,3) + real(rk), intent(inout) :: dben(3,3) + real(rk), intent(inout) :: dshr(2,2) integer, intent(out) :: ierr real(rk) :: d3d(NSTRESS,NSTRESS) + real(rk) :: h3 + real(rk) :: hshear if (gp .le. 0) then ierr = FEM_SUCCESS @@ -982,8 +996,25 @@ contains dmem(3,2) = thickness * d3d(4,2) dmem(3,3) = thickness * d3d(4,4) + h3 = thickness**3 / 12.0_rk + dben(1,1) = h3 * d3d(1,1) + dben(1,2) = h3 * d3d(1,2) + dben(1,3) = h3 * d3d(1,4) + dben(2,1) = h3 * d3d(2,1) + dben(2,2) = h3 * d3d(2,2) + dben(2,3) = h3 * d3d(2,4) + dben(3,1) = h3 * d3d(4,1) + dben(3,2) = h3 * d3d(4,2) + dben(3,3) = h3 * d3d(4,4) + + hshear = (5.0_rk / 6.0_rk) * thickness + dshr(1,1) = hshear * d3d(5,5) + dshr(1,2) = hshear * d3d(5,6) + dshr(2,1) = hshear * d3d(6,5) + dshr(2,2) = hshear * d3d(6,6) + ierr = FEM_SUCCESS - end subroutine shell_apply_mem_tangent + end subroutine shell_apply_section_tangent subroutine shell_b_matrices(nlocal, nshape, dndx, dndy, bmem, bben, bshr) integer, intent(in) :: nlocal diff --git a/src/mesh/fem_database.f90 b/src/mesh/fem_database.f90 index 13ef926..1185d76 100644 --- a/src/mesh/fem_database.f90 +++ b/src/mesh/fem_database.f90 @@ -146,6 +146,7 @@ module fem_database real(rk), allocatable :: contact_pair_penalty(:) real(rk), allocatable :: contact_pair_damping(:) real(rk), allocatable :: contact_pair_search(:) + real(rk), allocatable :: contact_pair_friction(:) contains @@ -612,13 +613,15 @@ contains 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) ncontact_pair = num_pairs 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), stat=stat) + contact_pair_search(num_pairs), contact_pair_friction(num_pairs), & + stat=stat) if (stat .ne. 0) then ncontact_pair = 0 call error_set(FEM_ERR_INTERNAL, 'failed to allocate contact pair arrays', ierr) @@ -629,6 +632,7 @@ contains contact_pair_penalty = ZERO contact_pair_damping = ZERO contact_pair_search = ZERO + contact_pair_friction = ZERO end if ierr = FEM_SUCCESS @@ -823,6 +827,7 @@ contains 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 ierr = FEM_SUCCESS end subroutine database_initialize @@ -1435,6 +1440,12 @@ contains call error_set(FEM_ERR_INPUT, 'contact pair search distance must be non-negative', ierr) return end if + if (allocated(contact_pair_friction)) then + if (contact_pair_friction(item) .lt. ZERO) then + call error_set(FEM_ERR_INPUT, 'contact pair friction must be non-negative', ierr) + return + end if + end if end do ierr = FEM_SUCCESS @@ -1608,6 +1619,7 @@ contains 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) nnode = 0 nelem = 0 diff --git a/tests/interface/test_c_api.c b/tests/interface/test_c_api.c index cab986b..08f0602 100644 --- a/tests/interface/test_c_api.c +++ b/tests/interface/test_c_api.c @@ -51,7 +51,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 != 0) return 3; + if (major != 0 || minor != 3 || patch != 1) return 3; ierr = femlite_read_inp("examples/c3d4_one_element.inp"); if (ierr != 0) return check_ierr(ierr, 4); diff --git a/tests/module/test_contact.f90 b/tests/module/test_contact.f90 index cf6b795..7aaaea0 100644 --- a/tests/module/test_contact.f90 +++ b/tests/module/test_contact.f90 @@ -15,6 +15,8 @@ program test_contact call check_explicit_contact_step() call check_surface_pair_force() call check_surface_pair_tangent() + call check_surface_pair_friction() + call check_surface_pair_multimaster() contains @@ -168,6 +170,81 @@ contains if (ierr .ne. FEM_SUCCESS) call fail(47) end subroutine check_surface_pair_tangent + subroutine check_surface_pair_friction() + type(csr_matrix) :: kmat + integer :: ierr + integer :: stat + integer :: node + integer :: dof + integer :: row + integer :: col + real(rk) :: value + + call setup_contact_shell_pair(ierr) + if (ierr .ne. FEM_SUCCESS) call fail(50) + contact_pair_friction(1) = 0.2_rk + do node = 5, 8 + dof = dof_id(1,node) + v(dof) = ONE + end do + + call contact_apply_plane_forces(ierr) + if (ierr .ne. FEM_SUCCESS) call fail(51) + + do node = 1, 4 + dof = dof_id(1,node) + call check_close(fcontact(dof), 0.5_rk, 52) + end do + do node = 5, 8 + dof = dof_id(1,node) + call check_close(fcontact(dof), -0.5_rk, 53) + end do + + call csr_init(kmat) + call assembly_build_csr_pattern(kmat, ierr) + if (ierr .ne. FEM_SUCCESS) call fail(54) + call contact_apply_plane_tangent(kmat, ZERO, ierr) + if (ierr .ne. FEM_SUCCESS) call fail(55) + + row = dof_id(1,5) + col = dof_id(1,5) + call csr_get_value(kmat, row, col, value, ierr) + if (ierr .ne. FEM_SUCCESS) call fail(56) + call check_close(value, 12.5_rk, 57) + + call csr_free(kmat, stat) + call database_finalize(ierr) + if (ierr .ne. FEM_SUCCESS) call fail(58) + end subroutine check_surface_pair_friction + + subroutine check_surface_pair_multimaster() + integer :: ierr + integer :: node + integer :: dof + + call setup_contact_shell_multimaster(ierr) + if (ierr .ne. FEM_SUCCESS) call fail(60) + + call contact_apply_plane_forces(ierr) + if (ierr .ne. FEM_SUCCESS) call fail(61) + + do node = 5, 8 + dof = dof_id(3,node) + call check_close(fcontact(dof), 2.5_rk, 62) + end do + do node = 1, 4 + dof = dof_id(3,node) + call check_close(fcontact(dof), -1.25_rk, 63) + end do + do node = 9, 12 + dof = dof_id(3,node) + call check_close(fcontact(dof), -1.25_rk, 64) + end do + + call database_finalize(ierr) + if (ierr .ne. FEM_SUCCESS) call fail(65) + end subroutine check_surface_pair_multimaster + subroutine setup_basic_nodes(num_nodes, ierr) integer, intent(in) :: num_nodes integer, intent(out) :: ierr @@ -254,9 +331,74 @@ contains 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_shell_pair + subroutine setup_contact_shell_multimaster(ierr) + integer, intent(out) :: ierr + + call database_allocate_model(12, 3, 0, 2, 0, 3, 1, 0, 1, & + 0, 0, 0, 0, 0, ierr) + if (ierr .ne. FEM_SUCCESS) return + + node_id_ext(1:12) = (/ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 /) + coord0(:,1) = (/ ZERO, ZERO, ZERO /) + coord0(:,2) = (/ ONE, ZERO, ZERO /) + coord0(:,3) = (/ ONE, ONE, ZERO /) + coord0(:,4) = (/ ZERO, ONE, ZERO /) + coord0(:,5) = (/ ZERO, ZERO, -0.01_rk /) + coord0(:,6) = (/ ONE, ZERO, -0.01_rk /) + coord0(:,7) = (/ ONE, ONE, -0.01_rk /) + coord0(:,8) = (/ ZERO, ONE, -0.01_rk /) + coord0(:,9) = coord0(:,1) + coord0(:,10) = coord0(:,2) + coord0(:,11) = coord0(:,3) + coord0(:,12) = coord0(:,4) + coord = coord0 + + elem_id_ext(1:3) = (/ 1, 2, 3 /) + elem_type(1:3) = 'S4' + elem_nnode(1:3) = 4 + elem_conn(:,1:3) = 0 + elem_conn(1:4,1) = (/ 1, 2, 3, 4 /) + elem_conn(1:4,2) = (/ 5, 6, 7, 8 /) + elem_conn(1:4,3) = (/ 9, 10, 11, 12 /) + elem_mat(1:3) = 1 + elem_sec(1:3) = 1 + + elset_name(1) = 'MASTER' + elset_start(1) = 1 + elset_count(1) = 2 + elset_items(1:2) = (/ 1, 3 /) + elset_name(2) = 'SLAVE' + elset_start(2) = 3 + elset_count(2) = 1 + elset_items(3) = 2 + + 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_shell_multimaster + subroutine check_close(actual, expected, code) real(rk), intent(in) :: actual real(rk), intent(in) :: expected diff --git a/tests/module/test_shell_internal.f90 b/tests/module/test_shell_internal.f90 index 65bb89d..3e78ac2 100644 --- a/tests/module/test_shell_internal.f90 +++ b/tests/module/test_shell_internal.f90 @@ -76,9 +76,12 @@ contains integer :: elem_dofs(MAX_SHELL_TEST_DOF) integer :: n_elem_dof real(rk) :: ke(MAX_SHELL_TEST_DOF,MAX_SHELL_TEST_DOF) + real(rk) :: ke_elastic(MAX_SHELL_TEST_DOF,MAX_SHELL_TEST_DOF) call setup_s4_j2(ierr) if (ierr .ne. FEM_SUCCESS) call fail(451) + call element_linear_stiffness(1, elem_dofs, n_elem_dof, ke_elastic, ierr) + if (ierr .ne. FEM_SUCCESS) call fail(450) call apply_x_extension(EXX) call element_compute_internal_force(ierr, 0.1_rk) @@ -92,6 +95,9 @@ contains if (ierr .ne. FEM_SUCCESS) call fail(457) if (n_elem_dof .ne. 24) call fail(458) call check_matrix_symmetric(ke, n_elem_dof, 459) + if (ke(1,1) .ge. ke_elastic(1,1)) call fail(461) + if (ke(5,5) .ge. ke_elastic(5,5)) call fail(462) + if (ke(3,3) .le. ZERO) call fail(463) call database_finalize(ierr) if (ierr .ne. FEM_SUCCESS) call fail(460) diff --git a/tests/performance/perf_p1.f90 b/tests/performance/perf_p1.f90 index 527c580..01a254f 100644 --- a/tests/performance/perf_p1.f90 +++ b/tests/performance/perf_p1.f90 @@ -40,7 +40,7 @@ program perf_p1 call fem_get_version(major, minor, patch, ierr) call exit_if_error(ierr) - if (major .ne. 0 .or. minor .ne. 3 .or. patch .ne. 0) then + if (major .ne. 0 .or. minor .ne. 3 .or. patch .ne. 1) then write(*,'(A,I1,A,I1,A,I1)') 'unexpected FemLite version ', major, '.', minor, '.', patch call exit(3) end if diff --git a/tests/unit/test_smoke.f90 b/tests/unit/test_smoke.f90 index 5a778e9..3a4bad9 100644 --- a/tests/unit/test_smoke.f90 +++ b/tests/unit/test_smoke.f90 @@ -94,7 +94,7 @@ program test_smoke if (ierr .ne. 0) stop 2 if (major .ne. 0) stop 3 if (minor .ne. 3) stop 4 - if (patch .ne. 0) stop 5 + if (patch .ne. 1) stop 5 call fem_read_inp('examples/c3d4_one_element.inp', ierr) if (ierr .ne. 0) stop 11