From 521509d45a12b0952673a41565d61300c3dc1986 Mon Sep 17 00:00:00 2001 From: Codex Date: Fri, 3 Jul 2026 21:42:07 +0800 Subject: [PATCH] Map Shell strains to integration points --- CMakeLists.txt | 6 + src/shell/sph_shell.f90 | 74 ++++++- .../module/test_shell_ip_strain_increment.f90 | 186 ++++++++++++++++++ todo.md | 42 ++-- 4 files changed, 286 insertions(+), 22 deletions(-) create mode 100644 tests/module/test_shell_ip_strain_increment.f90 diff --git a/CMakeLists.txt b/CMakeLists.txt index 593c361..a470fc5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -262,6 +262,12 @@ set_target_properties(test_shell_shear_strain PROPERTIES Fortran_MODULE_DIRECTOR add_test(NAME shell_shear_strain COMMAND test_shell_shear_strain) set_tests_properties(shell_shear_strain PROPERTIES WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") +add_executable(test_shell_ip_strain_increment tests/module/test_shell_ip_strain_increment.f90) +target_link_libraries(test_shell_ip_strain_increment PRIVATE sphlite_core) +set_target_properties(test_shell_ip_strain_increment PROPERTIES Fortran_MODULE_DIRECTORY "${SPHLITE_MODULE_DIR}") +add_test(NAME shell_ip_strain_increment COMMAND test_shell_ip_strain_increment) +set_tests_properties(shell_ip_strain_increment PROPERTIES WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") + add_executable(test_solid_051_input_validation tests/module/test_solid_051_input_validation.f90) target_link_libraries(test_solid_051_input_validation PRIVATE sphlite_core) set_target_properties(test_solid_051_input_validation PROPERTIES Fortran_MODULE_DIRECTORY "${SPHLITE_MODULE_DIR}") diff --git a/src/shell/sph_shell.f90 b/src/shell/sph_shell.f90 index 8421096..9020f37 100644 --- a/src/shell/sph_shell.f90 +++ b/src/shell/sph_shell.f90 @@ -21,6 +21,7 @@ module sph_shell integer, parameter :: SPH_SHELL_MEMBRANE_COMPONENTS = 3 integer, parameter :: SPH_SHELL_BENDING_COMPONENTS = 3 integer, parameter :: SPH_SHELL_SHEAR_COMPONENTS = 2 + integer, parameter :: SPH_SHELL_IP_STRAIN_COMPONENTS = 5 integer, parameter :: SPH_SHELL_STRESS_COMPONENTS = 6 integer, parameter :: SPH_SHELL_MAX_INTEGRATION_POINTS = 5 integer, parameter :: SPH_SHELL_MAX_ORIENTATIONS = 32 @@ -79,6 +80,8 @@ module sph_shell real(rk) :: shell_max_membrane_strain = 0.0_rk real(rk) :: shell_max_bending_strain = 0.0_rk real(rk) :: shell_max_shear_strain = 0.0_rk + real(rk) :: shell_max_ip_strain_increment = 0.0_rk + integer :: shell_active_ip_count = 0 real(rk), allocatable :: shell_thickness(:) real(rk), allocatable :: shell_director(:,:) real(rk), allocatable :: shell_reference_area(:) @@ -105,6 +108,7 @@ module sph_shell real(rk), allocatable :: shell_ip_weight(:,:) real(rk), allocatable :: shell_ip_stress(:,:,:) real(rk), allocatable :: shell_ip_strain(:,:,:) + real(rk), allocatable :: shell_ip_strain_increment(:,:,:) real(rk), allocatable :: shell_ip_plastic_strain(:,:) real(rk), allocatable :: shell_ip_temperature(:,:) real(rk), allocatable :: shell_ip_damage(:,:) @@ -173,6 +177,8 @@ contains shell_max_membrane_strain = 0.0_rk shell_max_bending_strain = 0.0_rk shell_max_shear_strain = 0.0_rk + shell_max_ip_strain_increment = 0.0_rk + shell_active_ip_count = 0 end subroutine sph_shell_clear_orientation_table subroutine sph_shell_note_material(name, material_type_in) @@ -546,7 +552,8 @@ contains allocated(shell_alpha) .and. & allocated(shell_membrane_strain_increment) .and. & allocated(shell_bending_strain_increment) .and. & - allocated(shell_shear_strain_increment)) return + allocated(shell_shear_strain_increment) .and. & + allocated(shell_ip_strain_increment)) return call sph_shell_deallocate_state() end if allocate(shell_thickness(npart), shell_director(SPH_NDIM,npart), & @@ -570,6 +577,8 @@ contains SPH_SHELL_MAX_INTEGRATION_POINTS,npart), & shell_ip_strain(SPH_SHELL_STRESS_COMPONENTS, & SPH_SHELL_MAX_INTEGRATION_POINTS,npart), & + shell_ip_strain_increment(SPH_SHELL_IP_STRAIN_COMPONENTS, & + SPH_SHELL_MAX_INTEGRATION_POINTS,npart), & shell_ip_plastic_strain(SPH_SHELL_MAX_INTEGRATION_POINTS,npart), & shell_ip_temperature(SPH_SHELL_MAX_INTEGRATION_POINTS,npart), & shell_ip_damage(SPH_SHELL_MAX_INTEGRATION_POINTS,npart), & @@ -611,6 +620,7 @@ contains if (allocated(shell_ip_weight)) deallocate(shell_ip_weight) if (allocated(shell_ip_stress)) deallocate(shell_ip_stress) if (allocated(shell_ip_strain)) deallocate(shell_ip_strain) + if (allocated(shell_ip_strain_increment)) deallocate(shell_ip_strain_increment) if (allocated(shell_ip_plastic_strain)) deallocate(shell_ip_plastic_strain) if (allocated(shell_ip_temperature)) deallocate(shell_ip_temperature) if (allocated(shell_ip_damage)) deallocate(shell_ip_damage) @@ -644,6 +654,7 @@ contains if (allocated(shell_ip_weight)) shell_ip_weight = 0.0_rk if (allocated(shell_ip_stress)) shell_ip_stress = 0.0_rk if (allocated(shell_ip_strain)) shell_ip_strain = 0.0_rk + if (allocated(shell_ip_strain_increment)) shell_ip_strain_increment = 0.0_rk if (allocated(shell_ip_plastic_strain)) shell_ip_plastic_strain = 0.0_rk if (allocated(shell_ip_temperature)) shell_ip_temperature = 0.0_rk if (allocated(shell_ip_damage)) shell_ip_damage = 0.0_rk @@ -663,6 +674,8 @@ contains shell_max_membrane_strain = 0.0_rk shell_max_bending_strain = 0.0_rk shell_max_shear_strain = 0.0_rk + shell_max_ip_strain_increment = 0.0_rk + shell_active_ip_count = 0 end subroutine sph_shell_reset_build_diagnostics subroutine sph_shell_initialize_particle_state(ierr) @@ -1074,8 +1087,67 @@ contains call sph_shell_store_strain(i, displacement_grad, director_grad, ierr) if (ierr /= SPH_SUCCESS) return end do + call sph_shell_update_ip_strain_increment(ierr) end subroutine sph_shell_compute_small_strain + subroutine sph_shell_update_ip_strain_increment(ierr) + integer, intent(out) :: ierr + integer :: i + integer :: ip + integer :: point_count + real(rk) :: thickness_coordinate + + ierr = SPH_SUCCESS + shell_max_ip_strain_increment = 0.0_rk + shell_active_ip_count = 0 + if (.not. allocated(shell_ip_strain_increment)) return + shell_ip_strain_increment = 0.0_rk + shell_ip_strain = 0.0_rk + do i = 1, npart + if (.not. sph_shell_particle_is_active_section(i, section_id(i))) cycle + if (allocated(shell_failure_status)) then + if (shell_failure_status(i) /= SPH_STATUS_ACTIVE) cycle + end if + point_count = shell_ip_count(i) + do ip = 1, point_count + thickness_coordinate = shell_ip_coord(ip,i) * shell_thickness(i) + shell_ip_strain_increment(1,ip,i) = shell_membrane_strain(1,i) + & + thickness_coordinate * shell_bending_strain(1,i) + shell_ip_strain_increment(2,ip,i) = shell_membrane_strain(2,i) + & + thickness_coordinate * shell_bending_strain(2,i) + shell_ip_strain_increment(3,ip,i) = shell_membrane_strain(3,i) + & + thickness_coordinate * shell_bending_strain(3,i) + shell_ip_strain_increment(4,ip,i) = shell_shear_strain(1,i) + shell_ip_strain_increment(5,ip,i) = shell_shear_strain(2,i) + if (.not. sph_shell_vector_is_finite(shell_ip_strain_increment(:,ip,i))) then + call sph_error_set(SPH_ERROR_INPUT, & + 'Shell integration point strain increment is not finite') + ierr = SPH_ERROR_INPUT + return + end if + shell_ip_strain(1:5,ip,i) = shell_ip_strain_increment(:,ip,i) + shell_max_ip_strain_increment = max(shell_max_ip_strain_increment, & + maxval(abs(shell_ip_strain_increment(:,ip,i)))) + shell_active_ip_count = shell_active_ip_count + 1 + end do + end do + end subroutine sph_shell_update_ip_strain_increment + + subroutine sph_shell_get_kinematic_diagnostics(max_membrane, max_bending, & + max_shear, max_ip_increment, active_ip_count) + real(rk), intent(out) :: max_membrane + real(rk), intent(out) :: max_bending + real(rk), intent(out) :: max_shear + real(rk), intent(out) :: max_ip_increment + integer, intent(out) :: active_ip_count + + max_membrane = shell_max_membrane_strain + max_bending = shell_max_bending_strain + max_shear = shell_max_shear_strain + max_ip_increment = shell_max_ip_strain_increment + active_ip_count = shell_active_ip_count + end subroutine sph_shell_get_kinematic_diagnostics + subroutine sph_shell_compute_local_gradients(index, displacement_grad, & director_grad, ierr) integer, intent(in) :: index diff --git a/tests/module/test_shell_ip_strain_increment.f90 b/tests/module/test_shell_ip_strain_increment.f90 new file mode 100644 index 0000000..b88c1ee --- /dev/null +++ b/tests/module/test_shell_ip_strain_increment.f90 @@ -0,0 +1,186 @@ +program test_shell_ip_strain_increment + use sph_precision, only: rk + use sph_error, only: SPH_SUCCESS + use sph_api, only: sph_initialize, sph_finalize, sph_read_inp, sph_build_model + use sph_database, only: npart, x, x0 + use sph_shell, only: shell_ip_count, shell_ip_coord, shell_thickness, & + shell_ip_strain, shell_ip_strain_increment, shell_active_ip_count, & + shell_max_ip_strain_increment, shell_membrane_strain, & + sph_shell_compute_small_strain, sph_shell_set_particle_director, & + sph_shell_get_kinematic_diagnostics + implicit none + + integer :: ierr + + call check_three_point_mapping() + call check_five_point_mapping() + call check_mixed_isolation() + call check_no_shell_diagnostics() + +contains + + subroutine check_three_point_mapping() + real(rk) :: eps + real(rk) :: shear + real(rk) :: kappa + + eps = 0.01_rk + shear = 0.02_rk + kappa = 0.10_rk + call sph_initialize(ierr) + call assert_ok(ierr, 'initialize failed for Shell 3pt IP strain') + call sph_read_inp('tests/data/shell_ip_strain_3pt_061.inp', ierr) + call assert_ok(ierr, 'read failed for Shell 3pt IP strain') + call sph_build_model(ierr) + call assert_ok(ierr, 'build failed for Shell 3pt IP strain') + call impose_field(eps, shear, kappa) + call sph_shell_compute_small_strain(ierr) + call assert_ok(ierr, 'compute failed for Shell 3pt IP strain') + if (shell_ip_count(1) /= 3) call fail('Shell 3pt IP count mismatch') + call assert_ip_particle(1, eps, shear, kappa) + if (maxval(abs(shell_ip_strain_increment(:,4:5,1))) > 1.0e-12_rk) & + call fail('unused Shell 3pt IP increment not zero') + if (shell_active_ip_count /= npart * 3) call fail('Shell 3pt active IP count mismatch') + call sph_finalize(ierr) + call assert_ok(ierr, 'finalize failed for Shell 3pt IP strain') + end subroutine check_three_point_mapping + + subroutine check_five_point_mapping() + real(rk) :: eps + real(rk) :: shear + real(rk) :: kappa + real(rk) :: diag_membrane + real(rk) :: diag_bending + real(rk) :: diag_shear + real(rk) :: diag_ip + integer :: diag_count + + eps = 0.015_rk + shear = 0.01_rk + kappa = 0.08_rk + call sph_initialize(ierr) + call assert_ok(ierr, 'initialize failed for Shell 5pt IP strain') + call sph_read_inp('tests/data/shell_ip_strain_5pt_061.inp', ierr) + call assert_ok(ierr, 'read failed for Shell 5pt IP strain') + call sph_build_model(ierr) + call assert_ok(ierr, 'build failed for Shell 5pt IP strain') + call impose_field(eps, shear, kappa) + call sph_shell_compute_small_strain(ierr) + call assert_ok(ierr, 'compute failed for Shell 5pt IP strain') + if (shell_ip_count(1) /= 5) call fail('Shell 5pt IP count mismatch') + call assert_ip_particle(1, eps, shear, kappa) + if (shell_active_ip_count /= npart * 5) call fail('Shell 5pt active IP count mismatch') + call sph_shell_get_kinematic_diagnostics(diag_membrane, diag_bending, & + diag_shear, diag_ip, diag_count) + if (diag_count /= shell_active_ip_count) call fail('Shell IP diagnostic count mismatch') + if (abs(diag_ip - shell_max_ip_strain_increment) > 1.0e-12_rk) & + call fail('Shell IP diagnostic max mismatch') + call sph_finalize(ierr) + call assert_ok(ierr, 'finalize failed for Shell 5pt IP strain') + end subroutine check_five_point_mapping + + subroutine check_mixed_isolation() + call sph_initialize(ierr) + call assert_ok(ierr, 'initialize failed for mixed Shell IP strain') + call sph_read_inp('tests/data/shell_solid_kinematics_isolation_061.inp', ierr) + call assert_ok(ierr, 'read failed for mixed Shell IP strain') + call sph_build_model(ierr) + call assert_ok(ierr, 'build failed for mixed Shell IP strain') + x = x0 + x(1,3) = x0(1,3) + 5.0_rk + x(2,4) = x0(2,4) - 5.0_rk + call sph_shell_compute_small_strain(ierr) + call assert_ok(ierr, 'compute failed for mixed Shell IP strain') + if (maxval(abs(shell_ip_strain_increment(:,:,3:4))) > 1.0e-12_rk) & + call fail('Solid particles polluted Shell IP strain increment') + if (shell_active_ip_count /= 6) call fail('mixed Shell IP active count mismatch') + call sph_finalize(ierr) + call assert_ok(ierr, 'finalize failed for mixed Shell IP strain') + end subroutine check_mixed_isolation + + subroutine check_no_shell_diagnostics() + real(rk) :: diag_membrane + real(rk) :: diag_bending + real(rk) :: diag_shear + real(rk) :: diag_ip + integer :: diag_count + real(rk), allocatable :: x_before(:,:) + + call sph_initialize(ierr) + call assert_ok(ierr, 'initialize failed for no-Shell diagnostics') + call sph_read_inp('tests/data/gas_air_products_mixed_031.inp', ierr) + call assert_ok(ierr, 'read failed for no-Shell diagnostics') + call sph_build_model(ierr) + call assert_ok(ierr, 'build failed for no-Shell diagnostics') + allocate(x_before(size(x,1), size(x,2))) + x_before = x + call sph_shell_compute_small_strain(ierr) + call assert_ok(ierr, 'no-Shell kinematics should be a no-op') + if (maxval(abs(x - x_before)) > 1.0e-12_rk) & + call fail('Gas particles modified by Shell kinematics') + call sph_shell_get_kinematic_diagnostics(diag_membrane, diag_bending, & + diag_shear, diag_ip, diag_count) + if (diag_membrane /= 0.0_rk .or. diag_bending /= 0.0_rk .or. & + diag_shear /= 0.0_rk .or. diag_ip /= 0.0_rk .or. diag_count /= 0) & + call fail('no-Shell kinematic diagnostics not zero') + deallocate(x_before) + call sph_finalize(ierr) + call assert_ok(ierr, 'finalize failed for no-Shell diagnostics') + end subroutine check_no_shell_diagnostics + + subroutine impose_field(eps, shear, kappa) + real(rk), intent(in) :: eps + real(rk), intent(in) :: shear + real(rk), intent(in) :: kappa + integer :: i + real(rk) :: director_value(3) + + do i = 1, npart + x(:,i) = x0(:,i) + x(1,i) = (1.0_rk + eps) * x0(1,i) + x(3,i) = x0(3,i) + shear * x0(1,i) + director_value = (/kappa * x0(1,i), 0.0_rk, 1.0_rk/) + call sph_shell_set_particle_director(i, director_value, ierr) + call assert_ok(ierr, 'set Shell IP director failed') + end do + end subroutine impose_field + + subroutine assert_ip_particle(index, eps, shear, kappa) + integer, intent(in) :: index + real(rk), intent(in) :: eps + real(rk), intent(in) :: shear + real(rk), intent(in) :: kappa + integer :: ip + real(rk) :: expected_11 + real(rk) :: z + + do ip = 1, shell_ip_count(index) + z = shell_ip_coord(ip,index) * shell_thickness(index) + expected_11 = eps + z * kappa + if (abs(shell_ip_strain_increment(1,ip,index) - expected_11) > & + 2.5e-4_rk) call fail('Shell IP 11 increment mismatch') + if (abs(shell_ip_strain_increment(4,ip,index) - shear) > 1.0e-12_rk) & + call fail('Shell IP 13 increment mismatch') + if (maxval(abs(shell_ip_strain(1:5,ip,index) - & + shell_ip_strain_increment(:,ip,index))) > 1.0e-12_rk) & + call fail('Shell IP strain mirror mismatch') + end do + if (abs(shell_membrane_strain(1,index) - eps) > 1.0e-12_rk) & + call fail('Shell particle membrane strain missing before IP mapping') + end subroutine assert_ip_particle + + subroutine assert_ok(ierr_value, message) + integer, intent(in) :: ierr_value + character(len=*), intent(in) :: message + + if (ierr_value /= SPH_SUCCESS) call fail(message) + end subroutine assert_ok + + subroutine fail(message) + character(len=*), intent(in) :: message + + write(*, '(A)') trim(message) + stop 1 + end subroutine fail + +end program test_shell_ip_strain_increment diff --git a/todo.md b/todo.md index a6d4409..051b0a1 100644 --- a/todo.md +++ b/todo.md @@ -148,27 +148,27 @@ ## 阶段 E:厚度积分点应变增量、诊断和隔离检查 -- [ ] 设计 Shell 厚度积分点应变增量分量顺序。 -- [ ] 确认厚度积分点应变增量使用 `11,22,12,13,23` 顺序。 -- [ ] 将膜应变贡献映射到 active 积分点应变增量。 -- [ ] 将厚度坐标乘弯曲应变贡献映射到 active 积分点应变增量。 -- [ ] 将横向剪切应变贡献映射到 active 积分点应变增量。 -- [ ] 确认 3 点厚度积分规则参与应变增量映射。 -- [ ] 确认 5 点厚度积分规则参与应变增量映射。 -- [ ] 确认未使用积分点保持安全默认值。 -- [ ] 确认未使用积分点不参与诊断统计。 -- [ ] 将积分点应变增量写入 Shell integration point strain 状态。 -- [ ] 对积分点应变增量执行有限性检查。 -- [ ] 记录 Shell 最大积分点应变增量诊断。 -- [ ] 记录 Shell active 积分点数量诊断。 -- [ ] 汇总 Shell 0.6.1 运动学诊断查询入口。 -- [ ] 确认 Shell 运动学诊断无 active Shell 粒子时返回安全默认值。 -- [ ] 确认 Shell/Solid 混合模型中 Solid 状态不被修改。 -- [ ] 确认 Water/Gas/Explosive 粒子不被 Shell 运动学路径修改。 -- [ ] 确认 0.6.0 Shell state build 测试仍通过。 -- [ ] 确认 0.6.0 Shell section integration 测试仍通过。 -- [ ] 新增 `shell_ip_strain_increment` 测试。 -- [ ] 将 `shell_ip_strain_increment` 接入 CTest。 +- [x] 设计 Shell 厚度积分点应变增量分量顺序。 +- [x] 确认厚度积分点应变增量使用 `11,22,12,13,23` 顺序。 +- [x] 将膜应变贡献映射到 active 积分点应变增量。 +- [x] 将厚度坐标乘弯曲应变贡献映射到 active 积分点应变增量。 +- [x] 将横向剪切应变贡献映射到 active 积分点应变增量。 +- [x] 确认 3 点厚度积分规则参与应变增量映射。 +- [x] 确认 5 点厚度积分规则参与应变增量映射。 +- [x] 确认未使用积分点保持安全默认值。 +- [x] 确认未使用积分点不参与诊断统计。 +- [x] 将积分点应变增量写入 Shell integration point strain 状态。 +- [x] 对积分点应变增量执行有限性检查。 +- [x] 记录 Shell 最大积分点应变增量诊断。 +- [x] 记录 Shell active 积分点数量诊断。 +- [x] 汇总 Shell 0.6.1 运动学诊断查询入口。 +- [x] 确认 Shell 运动学诊断无 active Shell 粒子时返回安全默认值。 +- [x] 确认 Shell/Solid 混合模型中 Solid 状态不被修改。 +- [x] 确认 Water/Gas/Explosive 粒子不被 Shell 运动学路径修改。 +- [x] 确认 0.6.0 Shell state build 测试仍通过。 +- [x] 确认 0.6.0 Shell section integration 测试仍通过。 +- [x] 新增 `shell_ip_strain_increment` 测试。 +- [x] 将 `shell_ip_strain_increment` 接入 CTest。 ## 阶段 F:门禁、source size、文档和发布准备