From 2f9edf0a2526865eeae5e6ba6484ee94d6129402 Mon Sep 17 00:00:00 2001 From: Codex Date: Fri, 3 Jul 2026 21:29:59 +0800 Subject: [PATCH] Add Shell small strain kinematics --- CMakeLists.txt | 18 ++ src/shell/sph_shell.f90 | 242 +++++++++++++++++++- tests/module/test_shell_bending_strain.f90 | 81 +++++++ tests/module/test_shell_membrane_strain.f90 | 113 +++++++++ tests/module/test_shell_shear_strain.f90 | 107 +++++++++ todo.md | 62 ++--- 6 files changed, 590 insertions(+), 33 deletions(-) create mode 100644 tests/module/test_shell_bending_strain.f90 create mode 100644 tests/module/test_shell_membrane_strain.f90 create mode 100644 tests/module/test_shell_shear_strain.f90 diff --git a/CMakeLists.txt b/CMakeLists.txt index b2dbb61..593c361 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -244,6 +244,24 @@ set_target_properties(test_shell_local_frame PROPERTIES Fortran_MODULE_DIRECTORY add_test(NAME shell_local_frame COMMAND test_shell_local_frame) set_tests_properties(shell_local_frame PROPERTIES WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") +add_executable(test_shell_membrane_strain tests/module/test_shell_membrane_strain.f90) +target_link_libraries(test_shell_membrane_strain PRIVATE sphlite_core) +set_target_properties(test_shell_membrane_strain PROPERTIES Fortran_MODULE_DIRECTORY "${SPHLITE_MODULE_DIR}") +add_test(NAME shell_membrane_strain COMMAND test_shell_membrane_strain) +set_tests_properties(shell_membrane_strain PROPERTIES WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") + +add_executable(test_shell_bending_strain tests/module/test_shell_bending_strain.f90) +target_link_libraries(test_shell_bending_strain PRIVATE sphlite_core) +set_target_properties(test_shell_bending_strain PROPERTIES Fortran_MODULE_DIRECTORY "${SPHLITE_MODULE_DIR}") +add_test(NAME shell_bending_strain COMMAND test_shell_bending_strain) +set_tests_properties(shell_bending_strain PROPERTIES WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") + +add_executable(test_shell_shear_strain tests/module/test_shell_shear_strain.f90) +target_link_libraries(test_shell_shear_strain PRIVATE sphlite_core) +set_target_properties(test_shell_shear_strain PROPERTIES Fortran_MODULE_DIRECTORY "${SPHLITE_MODULE_DIR}") +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_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 36b6a99..8421096 100644 --- a/src/shell/sph_shell.f90 +++ b/src/shell/sph_shell.f90 @@ -5,7 +5,7 @@ module sph_shell use sph_database, only: SPH_MAX_MATERIALS, SPH_MAX_SETS, SPH_MAX_ELEMENTS, & SPH_MAX_ELEMENT_NODES, SPH_NAME_LEN, material_count, material_name, & material_type, material_density, npart, particle_id_ext, & - particle_phase, particle_status, material_id, x0, mass, volume, & + particle_phase, particle_status, material_id, x0, x, mass, volume, & internal_energy, temperature, nset_count, nset_name, & nset_member_count, nset_members, elset_count, elset_name, & elset_member_count, elset_members, element_id_ext, element_conn_count, & @@ -76,6 +76,9 @@ module sph_shell integer :: shell_inertia_degenerate_count = 0 real(rk) :: shell_director_max_length_error = 0.0_rk real(rk) :: shell_max_angular_velocity = 0.0_rk + 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), allocatable :: shell_thickness(:) real(rk), allocatable :: shell_director(:,:) real(rk), allocatable :: shell_reference_area(:) @@ -90,6 +93,9 @@ module sph_shell real(rk), allocatable :: shell_membrane_strain(:,:) real(rk), allocatable :: shell_bending_strain(:,:) real(rk), allocatable :: shell_shear_strain(:,:) + real(rk), allocatable :: shell_membrane_strain_increment(:,:) + real(rk), allocatable :: shell_bending_strain_increment(:,:) + real(rk), allocatable :: shell_shear_strain_increment(:,:) real(rk), allocatable :: shell_damage(:) real(rk), allocatable :: shell_softening(:) real(rk), allocatable :: shell_internal_energy(:) @@ -164,6 +170,9 @@ contains shell_inertia_degenerate_count = 0 shell_director_max_length_error = 0.0_rk shell_max_angular_velocity = 0.0_rk + shell_max_membrane_strain = 0.0_rk + shell_max_bending_strain = 0.0_rk + shell_max_shear_strain = 0.0_rk end subroutine sph_shell_clear_orientation_table subroutine sph_shell_note_material(name, material_type_in) @@ -480,6 +489,25 @@ contains call sph_shell_update_max_angular_velocity() end subroutine sph_shell_set_particle_angular_velocity + subroutine sph_shell_set_particle_director(index, director_value, ierr) + integer, intent(in) :: index + real(rk), intent(in) :: director_value(SPH_NDIM) + integer, intent(out) :: ierr + integer :: status_value + + ierr = SPH_SUCCESS + if (index < 1 .or. index > npart .or. .not. allocated(shell_director)) then + call sph_error_set(SPH_ERROR_ARGUMENT, 'Shell director index is invalid') + ierr = SPH_ERROR_ARGUMENT + return + end if + status_value = shell_director_status(index) + if (status_value == SPH_SHELL_DIRECTOR_NONE) status_value = SPH_SHELL_DIRECTOR_INPUT + call sph_shell_apply_director(index, director_value, status_value, ierr) + if (ierr /= SPH_SUCCESS) return + call sph_shell_initialize_local_frame(index, section_id(index), ierr) + end subroutine sph_shell_set_particle_director + subroutine sph_shell_build_state(ierr) integer, intent(out) :: ierr @@ -515,7 +543,10 @@ contains allocated(shell_local_e2) .and. & allocated(shell_local_e3) .and. & allocated(shell_local_frame_status) .and. & - allocated(shell_alpha)) return + allocated(shell_alpha) .and. & + allocated(shell_membrane_strain_increment) .and. & + allocated(shell_bending_strain_increment) .and. & + allocated(shell_shear_strain_increment)) return call sph_shell_deallocate_state() end if allocate(shell_thickness(npart), shell_director(SPH_NDIM,npart), & @@ -527,6 +558,9 @@ contains shell_membrane_strain(SPH_SHELL_MEMBRANE_COMPONENTS,npart), & shell_bending_strain(SPH_SHELL_BENDING_COMPONENTS,npart), & shell_shear_strain(SPH_SHELL_SHEAR_COMPONENTS,npart), & + shell_membrane_strain_increment(SPH_SHELL_MEMBRANE_COMPONENTS,npart), & + shell_bending_strain_increment(SPH_SHELL_BENDING_COMPONENTS,npart), & + shell_shear_strain_increment(SPH_SHELL_SHEAR_COMPONENTS,npart), & shell_damage(npart), shell_softening(npart), & shell_internal_energy(npart), shell_failure_status(npart), & shell_ip_count(npart), & @@ -565,6 +599,9 @@ contains if (allocated(shell_membrane_strain)) deallocate(shell_membrane_strain) if (allocated(shell_bending_strain)) deallocate(shell_bending_strain) if (allocated(shell_shear_strain)) deallocate(shell_shear_strain) + if (allocated(shell_membrane_strain_increment)) deallocate(shell_membrane_strain_increment) + if (allocated(shell_bending_strain_increment)) deallocate(shell_bending_strain_increment) + if (allocated(shell_shear_strain_increment)) deallocate(shell_shear_strain_increment) if (allocated(shell_damage)) deallocate(shell_damage) if (allocated(shell_softening)) deallocate(shell_softening) if (allocated(shell_internal_energy)) deallocate(shell_internal_energy) @@ -595,6 +632,9 @@ contains if (allocated(shell_membrane_strain)) shell_membrane_strain = 0.0_rk if (allocated(shell_bending_strain)) shell_bending_strain = 0.0_rk if (allocated(shell_shear_strain)) shell_shear_strain = 0.0_rk + if (allocated(shell_membrane_strain_increment)) shell_membrane_strain_increment = 0.0_rk + if (allocated(shell_bending_strain_increment)) shell_bending_strain_increment = 0.0_rk + if (allocated(shell_shear_strain_increment)) shell_shear_strain_increment = 0.0_rk if (allocated(shell_damage)) shell_damage = 0.0_rk if (allocated(shell_softening)) shell_softening = 0.0_rk if (allocated(shell_internal_energy)) shell_internal_energy = 0.0_rk @@ -620,6 +660,9 @@ contains shell_inertia_degenerate_count = 0 shell_director_max_length_error = 0.0_rk shell_max_angular_velocity = 0.0_rk + shell_max_membrane_strain = 0.0_rk + shell_max_bending_strain = 0.0_rk + shell_max_shear_strain = 0.0_rk end subroutine sph_shell_reset_build_diagnostics subroutine sph_shell_initialize_particle_state(ierr) @@ -997,6 +1040,201 @@ contains call sph_shell_update_max_angular_velocity() end subroutine sph_shell_update_directors + subroutine sph_shell_compute_small_strain(ierr) + integer, intent(out) :: ierr + integer :: i + real(rk) :: displacement_grad(3,2) + real(rk) :: director_grad(2,2) + + ierr = SPH_SUCCESS + if (.not. allocated(shell_membrane_strain)) return + shell_membrane_strain = 0.0_rk + shell_bending_strain = 0.0_rk + shell_shear_strain = 0.0_rk + shell_membrane_strain_increment = 0.0_rk + shell_bending_strain_increment = 0.0_rk + shell_shear_strain_increment = 0.0_rk + shell_max_membrane_strain = 0.0_rk + shell_max_bending_strain = 0.0_rk + shell_max_shear_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 + if (shell_local_frame_status(i) /= SPH_SHELL_FRAME_OK) then + call sph_error_set(SPH_ERROR_INPUT, 'Shell strain requires local frame') + ierr = SPH_ERROR_INPUT + return + end if + call sph_shell_compute_local_gradients(i, displacement_grad, & + director_grad, ierr) + if (ierr /= SPH_SUCCESS) return + call sph_shell_store_strain(i, displacement_grad, director_grad, ierr) + if (ierr /= SPH_SUCCESS) return + end do + end subroutine sph_shell_compute_small_strain + + subroutine sph_shell_compute_local_gradients(index, displacement_grad, & + director_grad, ierr) + integer, intent(in) :: index + real(rk), intent(out) :: displacement_grad(3,2) + real(rk), intent(out) :: director_grad(2,2) + integer, intent(out) :: ierr + integer :: j + integer :: row + integer :: neighbor_count + real(rk) :: moment(2,2) + real(rk) :: disp_rhs(3,2) + real(rk) :: dir_rhs(2,2) + real(rk) :: rlocal(2) + real(rk) :: displacement_delta(SPH_NDIM) + real(rk) :: director_delta(SPH_NDIM) + real(rk) :: disp_local(3) + real(rk) :: dir_local(2) + + ierr = SPH_SUCCESS + displacement_grad = 0.0_rk + director_grad = 0.0_rk + moment = 0.0_rk + disp_rhs = 0.0_rk + dir_rhs = 0.0_rk + neighbor_count = 0 + do j = 1, npart + if (j == index) cycle + if (.not. sph_shell_particle_is_active_section(j, section_id(index))) cycle + rlocal(1) = sum((x0(:,j) - x0(:,index)) * shell_local_e1(:,index)) + rlocal(2) = sum((x0(:,j) - x0(:,index)) * shell_local_e2(:,index)) + if (sum(rlocal * rlocal) <= SPH_SHELL_EPS) cycle + displacement_delta = (x(:,j) - x0(:,j)) - (x(:,index) - x0(:,index)) + director_delta = shell_director(:,j) - shell_director(:,index) + disp_local(1) = sum(displacement_delta * shell_local_e1(:,index)) + disp_local(2) = sum(displacement_delta * shell_local_e2(:,index)) + disp_local(3) = sum(displacement_delta * shell_local_e3(:,index)) + dir_local(1) = sum(director_delta * shell_local_e1(:,index)) + dir_local(2) = sum(director_delta * shell_local_e2(:,index)) + moment(1,1) = moment(1,1) + rlocal(1) * rlocal(1) + moment(1,2) = moment(1,2) + rlocal(1) * rlocal(2) + moment(2,2) = moment(2,2) + rlocal(2) * rlocal(2) + do row = 1, 3 + disp_rhs(row,1) = disp_rhs(row,1) + disp_local(row) * rlocal(1) + disp_rhs(row,2) = disp_rhs(row,2) + disp_local(row) * rlocal(2) + end do + do row = 1, 2 + dir_rhs(row,1) = dir_rhs(row,1) + dir_local(row) * rlocal(1) + dir_rhs(row,2) = dir_rhs(row,2) + dir_local(row) * rlocal(2) + end do + neighbor_count = neighbor_count + 1 + end do + moment(2,1) = moment(1,2) + if (neighbor_count <= 0) then + call sph_error_set(SPH_ERROR_INPUT, 'Shell strain gradient has no neighbors') + ierr = SPH_ERROR_INPUT + return + end if + call sph_shell_solve_local_gradient(moment, disp_rhs, displacement_grad, ierr) + if (ierr /= SPH_SUCCESS) return + call sph_shell_solve_local_gradient_2(moment, dir_rhs, director_grad, ierr) + end subroutine sph_shell_compute_local_gradients + + subroutine sph_shell_solve_local_gradient(moment, rhs, gradient, ierr) + real(rk), intent(in) :: moment(2,2) + real(rk), intent(in) :: rhs(3,2) + real(rk), intent(out) :: gradient(3,2) + integer, intent(out) :: ierr + integer :: row + + ierr = SPH_SUCCESS + gradient = 0.0_rk + do row = 1, 3 + call sph_shell_solve_local_gradient_row(moment, rhs(row,:), & + gradient(row,:), ierr) + if (ierr /= SPH_SUCCESS) return + end do + end subroutine sph_shell_solve_local_gradient + + subroutine sph_shell_solve_local_gradient_2(moment, rhs, gradient, ierr) + real(rk), intent(in) :: moment(2,2) + real(rk), intent(in) :: rhs(2,2) + real(rk), intent(out) :: gradient(2,2) + integer, intent(out) :: ierr + integer :: row + + ierr = SPH_SUCCESS + gradient = 0.0_rk + do row = 1, 2 + call sph_shell_solve_local_gradient_row(moment, rhs(row,:), & + gradient(row,:), ierr) + if (ierr /= SPH_SUCCESS) return + end do + end subroutine sph_shell_solve_local_gradient_2 + + subroutine sph_shell_solve_local_gradient_row(moment, rhs, gradient, ierr) + real(rk), intent(in) :: moment(2,2) + real(rk), intent(in) :: rhs(2) + real(rk), intent(out) :: gradient(2) + integer, intent(out) :: ierr + real(rk) :: det + + ierr = SPH_SUCCESS + gradient = 0.0_rk + det = moment(1,1) * moment(2,2) - moment(1,2) * moment(2,1) + if (abs(det) > SPH_SHELL_EPS) then + gradient(1) = (rhs(1) * moment(2,2) - rhs(2) * moment(2,1)) / det + gradient(2) = (-rhs(1) * moment(1,2) + rhs(2) * moment(1,1)) / det + else if (moment(1,1) > SPH_SHELL_EPS .and. & + abs(moment(1,2)) <= SPH_SHELL_EPS) then + gradient(1) = rhs(1) / moment(1,1) + else if (moment(2,2) > SPH_SHELL_EPS .and. & + abs(moment(1,2)) <= SPH_SHELL_EPS) then + gradient(2) = rhs(2) / moment(2,2) + else + call sph_error_set(SPH_ERROR_INPUT, 'Shell strain gradient is degenerate') + ierr = SPH_ERROR_INPUT + end if + end subroutine sph_shell_solve_local_gradient_row + + subroutine sph_shell_store_strain(index, displacement_grad, director_grad, ierr) + integer, intent(in) :: index + real(rk), intent(in) :: displacement_grad(3,2) + real(rk), intent(in) :: director_grad(2,2) + integer, intent(out) :: ierr + + ierr = SPH_SUCCESS + if (.not. sph_shell_vector_is_finite(reshape(displacement_grad, (/6/))) .or. & + .not. sph_shell_vector_is_finite(reshape(director_grad, (/4/)))) then + call sph_error_set(SPH_ERROR_INPUT, 'Shell strain gradient is not finite') + ierr = SPH_ERROR_INPUT + return + end if + shell_membrane_strain(1,index) = displacement_grad(1,1) + shell_membrane_strain(2,index) = displacement_grad(2,2) + shell_membrane_strain(3,index) = 0.5_rk * & + (displacement_grad(1,2) + displacement_grad(2,1)) + shell_bending_strain(1,index) = director_grad(1,1) + shell_bending_strain(2,index) = director_grad(2,2) + shell_bending_strain(3,index) = 0.5_rk * & + (director_grad(1,2) + director_grad(2,1)) + shell_shear_strain(1,index) = displacement_grad(3,1) + shell_shear_strain(2,index) = displacement_grad(3,2) + shell_membrane_strain_increment(:,index) = shell_membrane_strain(:,index) + shell_bending_strain_increment(:,index) = shell_bending_strain(:,index) + shell_shear_strain_increment(:,index) = shell_shear_strain(:,index) + call sph_shell_update_strain_diagnostics(index) + end subroutine sph_shell_store_strain + + subroutine sph_shell_update_strain_diagnostics(index) + integer, intent(in) :: index + + shell_max_membrane_strain = max(shell_max_membrane_strain, & + maxval(abs(shell_membrane_strain(:,index)))) + shell_max_bending_strain = max(shell_max_bending_strain, & + maxval(abs(shell_bending_strain(:,index)))) + shell_max_shear_strain = max(shell_max_shear_strain, & + maxval(abs(shell_shear_strain(:,index)))) + end subroutine sph_shell_update_strain_diagnostics + subroutine sph_shell_find_director_for_particle(index, director_value, found) integer, intent(in) :: index real(rk), intent(out) :: director_value(SPH_NDIM) diff --git a/tests/module/test_shell_bending_strain.f90 b/tests/module/test_shell_bending_strain.f90 new file mode 100644 index 0000000..c8f9fdc --- /dev/null +++ b/tests/module/test_shell_bending_strain.f90 @@ -0,0 +1,81 @@ +program test_shell_bending_strain + 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_bending_strain, shell_max_bending_strain, & + sph_shell_compute_small_strain, sph_shell_set_particle_director + implicit none + + integer :: ierr + + call check_uniform_director_bending_zero() + call check_controlled_curvature() + +contains + + subroutine check_uniform_director_bending_zero() + call sph_initialize(ierr) + call assert_ok(ierr, 'initialize failed for uniform Shell bending') + call sph_read_inp('tests/data/shell_reference_triangle_061.inp', ierr) + call assert_ok(ierr, 'read failed for uniform Shell bending') + call sph_build_model(ierr) + call assert_ok(ierr, 'build failed for uniform Shell bending') + x = x0 + call sph_shell_compute_small_strain(ierr) + call assert_ok(ierr, 'uniform Shell bending compute failed') + if (maxval(abs(shell_bending_strain)) > 1.0e-12_rk) & + call fail('uniform Shell director produced bending strain') + call sph_finalize(ierr) + call assert_ok(ierr, 'finalize failed for uniform Shell bending') + end subroutine check_uniform_director_bending_zero + + subroutine check_controlled_curvature() + integer :: i + real(rk) :: kappa + real(rk) :: director_value(3) + + kappa = 0.10_rk + call sph_initialize(ierr) + call assert_ok(ierr, 'initialize failed for controlled Shell curvature') + call sph_read_inp('tests/data/shell_controlled_curvature_061.inp', ierr) + call assert_ok(ierr, 'read failed for controlled Shell curvature') + call sph_build_model(ierr) + call assert_ok(ierr, 'build failed for controlled Shell curvature') + x = x0 + do i = 1, npart + 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 controlled Shell director failed') + end do + call sph_shell_compute_small_strain(ierr) + call assert_ok(ierr, 'controlled Shell curvature compute failed') + do i = 1, npart + if (abs(shell_bending_strain(1,i) - kappa) > 2.5e-3_rk) & + call fail('controlled Shell curvature strain 11 mismatch') + if (abs(shell_bending_strain(2,i)) > 1.0e-12_rk) & + call fail('controlled Shell curvature strain 22 mismatch') + if (abs(shell_bending_strain(3,i)) > 1.0e-12_rk) & + call fail('controlled Shell curvature strain 12 mismatch') + end do + if (abs(shell_max_bending_strain - kappa) > 2.5e-3_rk) & + call fail('Shell bending strain diagnostic mismatch') + call sph_finalize(ierr) + call assert_ok(ierr, 'finalize failed for controlled Shell curvature') + end subroutine check_controlled_curvature + + 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_bending_strain diff --git a/tests/module/test_shell_membrane_strain.f90 b/tests/module/test_shell_membrane_strain.f90 new file mode 100644 index 0000000..2d0a23f --- /dev/null +++ b/tests/module/test_shell_membrane_strain.f90 @@ -0,0 +1,113 @@ +program test_shell_membrane_strain + 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_membrane_strain, shell_bending_strain, & + shell_shear_strain, shell_max_membrane_strain, & + sph_shell_compute_small_strain + implicit none + + integer :: ierr + + call check_rigid_translation() + call check_uniaxial_membrane() + call check_simple_shear_membrane() + +contains + + subroutine check_rigid_translation() + integer :: i + + call sph_initialize(ierr) + call assert_ok(ierr, 'initialize failed for Shell rigid strain') + call sph_read_inp('tests/data/shell_rigid_translation_strain_061.inp', ierr) + call assert_ok(ierr, 'read failed for Shell rigid strain') + call sph_build_model(ierr) + call assert_ok(ierr, 'build failed for Shell rigid strain') + do i = 1, npart + x(:,i) = x0(:,i) + (/0.2_rk, -0.3_rk, 0.4_rk/) + end do + call sph_shell_compute_small_strain(ierr) + call assert_ok(ierr, 'Shell rigid strain compute failed') + if (maxval(abs(shell_membrane_strain)) > 1.0e-12_rk) & + call fail('rigid translation produced Shell membrane strain') + if (maxval(abs(shell_bending_strain)) > 1.0e-12_rk) & + call fail('rigid translation produced Shell bending strain') + if (maxval(abs(shell_shear_strain)) > 1.0e-12_rk) & + call fail('rigid translation produced Shell shear strain') + call sph_finalize(ierr) + call assert_ok(ierr, 'finalize failed for Shell rigid strain') + end subroutine check_rigid_translation + + subroutine check_uniaxial_membrane() + integer :: i + real(rk) :: eps + + eps = 0.02_rk + call sph_initialize(ierr) + call assert_ok(ierr, 'initialize failed for Shell uniaxial strain') + call sph_read_inp('tests/data/shell_uniaxial_membrane_061.inp', ierr) + call assert_ok(ierr, 'read failed for Shell uniaxial strain') + call sph_build_model(ierr) + call assert_ok(ierr, 'build failed for Shell uniaxial strain') + do i = 1, npart + x(:,i) = x0(:,i) + x(1,i) = (1.0_rk + eps) * x0(1,i) + end do + call sph_shell_compute_small_strain(ierr) + call assert_ok(ierr, 'Shell uniaxial strain compute failed') + do i = 1, npart + if (abs(shell_membrane_strain(1,i) - eps) > 1.0e-12_rk) & + call fail('Shell uniaxial membrane strain 11 mismatch') + if (abs(shell_membrane_strain(2,i)) > 1.0e-12_rk) & + call fail('Shell uniaxial membrane strain 22 mismatch') + if (abs(shell_membrane_strain(3,i)) > 1.0e-12_rk) & + call fail('Shell uniaxial membrane strain 12 mismatch') + end do + if (abs(shell_max_membrane_strain - eps) > 1.0e-12_rk) & + call fail('Shell membrane strain diagnostic mismatch') + call sph_finalize(ierr) + call assert_ok(ierr, 'finalize failed for Shell uniaxial strain') + end subroutine check_uniaxial_membrane + + subroutine check_simple_shear_membrane() + integer :: i + real(rk) :: gamma + + gamma = 0.04_rk + call sph_initialize(ierr) + call assert_ok(ierr, 'initialize failed for Shell shear membrane') + call sph_read_inp('tests/data/shell_simple_shear_membrane_061.inp', ierr) + call assert_ok(ierr, 'read failed for Shell shear membrane') + call sph_build_model(ierr) + call assert_ok(ierr, 'build failed for Shell shear membrane') + do i = 1, npart + x(:,i) = x0(:,i) + x(2,i) = x0(2,i) + gamma * x0(1,i) + end do + call sph_shell_compute_small_strain(ierr) + call assert_ok(ierr, 'Shell shear membrane compute failed') + do i = 1, npart + if (abs(shell_membrane_strain(3,i) - 0.5_rk * gamma) > 1.0e-12_rk) & + call fail('Shell simple shear membrane strain mismatch') + end do + call sph_finalize(ierr) + call assert_ok(ierr, 'finalize failed for Shell shear membrane') + end subroutine check_simple_shear_membrane + + 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_membrane_strain diff --git a/tests/module/test_shell_shear_strain.f90 b/tests/module/test_shell_shear_strain.f90 new file mode 100644 index 0000000..7086a53 --- /dev/null +++ b/tests/module/test_shell_shear_strain.f90 @@ -0,0 +1,107 @@ +program test_shell_shear_strain + 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, SPH_STATUS_FAILED + use sph_shell, only: shell_shear_strain, shell_membrane_strain, & + shell_max_shear_strain, shell_failure_status, sph_shell_compute_small_strain + implicit none + + integer :: ierr + + call check_transverse_shear() + call check_solid_isolation() + call check_failed_shell_skip() + +contains + + subroutine check_transverse_shear() + integer :: i + real(rk) :: gamma + + gamma = 0.05_rk + call sph_initialize(ierr) + call assert_ok(ierr, 'initialize failed for Shell transverse shear') + call sph_read_inp('tests/data/shell_transverse_shear_061.inp', ierr) + call assert_ok(ierr, 'read failed for Shell transverse shear') + call sph_build_model(ierr) + call assert_ok(ierr, 'build failed for Shell transverse shear') + do i = 1, npart + x(:,i) = x0(:,i) + x(3,i) = x0(3,i) + gamma * x0(1,i) + end do + call sph_shell_compute_small_strain(ierr) + call assert_ok(ierr, 'Shell transverse shear compute failed') + do i = 1, npart + if (abs(shell_shear_strain(1,i) - gamma) > 1.0e-12_rk) & + call fail('Shell transverse shear 13 mismatch') + if (abs(shell_shear_strain(2,i)) > 1.0e-12_rk) & + call fail('Shell transverse shear 23 mismatch') + end do + if (abs(shell_max_shear_strain - gamma) > 1.0e-12_rk) & + call fail('Shell shear strain diagnostic mismatch') + call sph_finalize(ierr) + call assert_ok(ierr, 'finalize failed for Shell transverse shear') + end subroutine check_transverse_shear + + subroutine check_solid_isolation() + call sph_initialize(ierr) + call assert_ok(ierr, 'initialize failed for Shell strain isolation') + call sph_read_inp('tests/data/shell_solid_kinematics_isolation_061.inp', ierr) + call assert_ok(ierr, 'read failed for Shell strain isolation') + call sph_build_model(ierr) + call assert_ok(ierr, 'build failed for Shell strain isolation') + x = x0 + x(1,3) = x0(1,3) + 10.0_rk + x(2,4) = x0(2,4) - 10.0_rk + call sph_shell_compute_small_strain(ierr) + call assert_ok(ierr, 'Shell strain isolation compute failed') + if (maxval(abs(shell_membrane_strain(:,3:4))) > 1.0e-12_rk) & + call fail('Solid particles polluted Shell membrane strain') + if (maxval(abs(shell_shear_strain(:,3:4))) > 1.0e-12_rk) & + call fail('Solid particles polluted Shell shear strain') + call sph_finalize(ierr) + call assert_ok(ierr, 'finalize failed for Shell strain isolation') + end subroutine check_solid_isolation + + subroutine check_failed_shell_skip() + integer :: i + real(rk) :: eps + + eps = 0.03_rk + call sph_initialize(ierr) + call assert_ok(ierr, 'initialize failed for failed Shell strain') + call sph_read_inp('tests/data/shell_uniaxial_membrane_061.inp', ierr) + call assert_ok(ierr, 'read failed for failed Shell strain') + call sph_build_model(ierr) + call assert_ok(ierr, 'build failed for failed Shell strain') + do i = 1, npart + x(:,i) = x0(:,i) + x(1,i) = (1.0_rk + eps) * x0(1,i) + end do + shell_failure_status(1) = SPH_STATUS_FAILED + call sph_shell_compute_small_strain(ierr) + call assert_ok(ierr, 'failed Shell strain compute failed') + if (maxval(abs(shell_membrane_strain(:,1))) > 1.0e-12_rk) & + call fail('failed Shell particle was not skipped') + if (abs(shell_membrane_strain(1,2) - eps) > 1.0e-12_rk) & + call fail('active Shell particle strain missing after failed skip') + call sph_finalize(ierr) + call assert_ok(ierr, 'finalize failed for failed Shell strain') + end subroutine check_failed_shell_skip + + 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_shear_strain diff --git a/todo.md b/todo.md index d4c09b2..a6d4409 100644 --- a/todo.md +++ b/todo.md @@ -114,37 +114,37 @@ ## 阶段 D:Mindlin-Reissner 小变形膜、弯曲和剪切应变 -- [ ] 设计 Shell 运动学过程的输入输出约定。 -- [ ] 锁定 Shell 膜应变局部分量顺序 `11,22,12`。 -- [ ] 锁定 Shell 弯曲应变局部分量顺序 `11,22,12`。 -- [ ] 锁定 Shell 剪切应变局部分量顺序 `13,23`。 -- [ ] 新增 Shell strain increment 工作数组布局。 -- [ ] 在 Shell allocate/build 路径分配 strain increment 工作数组。 -- [ ] 在 Shell reset 路径初始化 strain increment 工作数组。 -- [ ] 在 Shell clear/finalize 路径释放 strain increment 工作数组。 -- [ ] 实现 Shell 刚体平动下膜应变为零的路径。 -- [ ] 实现 Shell 单轴拉伸膜应变计算。 -- [ ] 实现 Shell 简单剪切膜应变计算。 -- [ ] 将膜应变写入 `shell_membrane_strain`。 -- [ ] 实现均匀 director 场下弯曲应变为零的路径。 -- [ ] 实现受控曲率场弯曲应变计算。 -- [ ] 将弯曲应变写入 `shell_bending_strain`。 -- [ ] 实现刚体平动下横向剪切应变为零的路径。 -- [ ] 实现受控横向剪切应变计算。 -- [ ] 将横向剪切应变写入 `shell_shear_strain`。 -- [ ] 对 Shell 应变计算执行有限性检查。 -- [ ] 确认非 Shell 粒子不参与应变计算。 -- [ ] 确认 failed Shell 粒子按受控策略跳过或保持状态。 -- [ ] 确认未建立局部基时应变计算报 error。 -- [ ] 记录 Shell 最大膜应变诊断。 -- [ ] 记录 Shell 最大弯曲应变诊断。 -- [ ] 记录 Shell 最大剪切应变诊断。 -- [ ] 新增 `shell_membrane_strain` 测试。 -- [ ] 新增 `shell_bending_strain` 测试。 -- [ ] 新增 `shell_shear_strain` 测试。 -- [ ] 将 `shell_membrane_strain` 接入 CTest。 -- [ ] 将 `shell_bending_strain` 接入 CTest。 -- [ ] 将 `shell_shear_strain` 接入 CTest。 +- [x] 设计 Shell 运动学过程的输入输出约定。 +- [x] 锁定 Shell 膜应变局部分量顺序 `11,22,12`。 +- [x] 锁定 Shell 弯曲应变局部分量顺序 `11,22,12`。 +- [x] 锁定 Shell 剪切应变局部分量顺序 `13,23`。 +- [x] 新增 Shell strain increment 工作数组布局。 +- [x] 在 Shell allocate/build 路径分配 strain increment 工作数组。 +- [x] 在 Shell reset 路径初始化 strain increment 工作数组。 +- [x] 在 Shell clear/finalize 路径释放 strain increment 工作数组。 +- [x] 实现 Shell 刚体平动下膜应变为零的路径。 +- [x] 实现 Shell 单轴拉伸膜应变计算。 +- [x] 实现 Shell 简单剪切膜应变计算。 +- [x] 将膜应变写入 `shell_membrane_strain`。 +- [x] 实现均匀 director 场下弯曲应变为零的路径。 +- [x] 实现受控曲率场弯曲应变计算。 +- [x] 将弯曲应变写入 `shell_bending_strain`。 +- [x] 实现刚体平动下横向剪切应变为零的路径。 +- [x] 实现受控横向剪切应变计算。 +- [x] 将横向剪切应变写入 `shell_shear_strain`。 +- [x] 对 Shell 应变计算执行有限性检查。 +- [x] 确认非 Shell 粒子不参与应变计算。 +- [x] 确认 failed Shell 粒子按受控策略跳过或保持状态。 +- [x] 确认未建立局部基时应变计算报 error。 +- [x] 记录 Shell 最大膜应变诊断。 +- [x] 记录 Shell 最大弯曲应变诊断。 +- [x] 记录 Shell 最大剪切应变诊断。 +- [x] 新增 `shell_membrane_strain` 测试。 +- [x] 新增 `shell_bending_strain` 测试。 +- [x] 新增 `shell_shear_strain` 测试。 +- [x] 将 `shell_membrane_strain` 接入 CTest。 +- [x] 将 `shell_bending_strain` 接入 CTest。 +- [x] 将 `shell_shear_strain` 接入 CTest。 ## 阶段 E:厚度积分点应变增量、诊断和隔离检查