From 774c5f7d0c0e891128494736c1b9bdfdc94c37c3 Mon Sep 17 00:00:00 2001 From: Codex Date: Fri, 3 Jul 2026 19:45:36 +0800 Subject: [PATCH] Add Shell state allocation stage --- CMakeLists.txt | 12 ++ src/shell/sph_shell.f90 | 199 +++++++++++++++++- tests/data/shell_solid_mixed_060.inp | 28 +++ .../module/test_shell_section_integration.f90 | 80 +++++++ tests/module/test_shell_state_build.f90 | 90 ++++++++ todo.md | 72 +++---- 6 files changed, 441 insertions(+), 40 deletions(-) create mode 100644 tests/data/shell_solid_mixed_060.inp create mode 100644 tests/module/test_shell_section_integration.f90 create mode 100644 tests/module/test_shell_state_build.f90 diff --git a/CMakeLists.txt b/CMakeLists.txt index 19db9c6..eef1070 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -202,6 +202,18 @@ set_target_properties(test_input_shell_errors PROPERTIES Fortran_MODULE_DIRECTOR add_test(NAME input_shell_errors COMMAND test_input_shell_errors) set_tests_properties(input_shell_errors PROPERTIES WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") +add_executable(test_shell_state_build tests/module/test_shell_state_build.f90) +target_link_libraries(test_shell_state_build PRIVATE sphlite_core) +set_target_properties(test_shell_state_build PROPERTIES Fortran_MODULE_DIRECTORY "${SPHLITE_MODULE_DIR}") +add_test(NAME shell_state_build COMMAND test_shell_state_build) +set_tests_properties(shell_state_build PROPERTIES WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") + +add_executable(test_shell_section_integration tests/module/test_shell_section_integration.f90) +target_link_libraries(test_shell_section_integration PRIVATE sphlite_core) +set_target_properties(test_shell_section_integration PROPERTIES Fortran_MODULE_DIRECTORY "${SPHLITE_MODULE_DIR}") +add_test(NAME shell_section_integration COMMAND test_shell_section_integration) +set_tests_properties(shell_section_integration 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 3810660..45225dc 100644 --- a/src/shell/sph_shell.f90 +++ b/src/shell/sph_shell.f90 @@ -1,15 +1,21 @@ module sph_shell - use sph_precision, only: rk + use sph_precision, only: rk, SPH_NDIM use sph_error, only: SPH_SUCCESS, SPH_ERROR_ARGUMENT, SPH_ERROR_INPUT, & sph_error_set use sph_database, only: SPH_MAX_MATERIALS, SPH_NAME_LEN, material_count, & material_name, material_type, material_density, npart, particle_phase, & - particle_status, material_id, section_count, section_id, section_type, & - section_material_id, section_thickness, section_integration_points, & + particle_status, material_id, internal_energy, temperature, & + section_count, section_id, section_type, section_material_id, & + section_thickness, section_integration_points, & section_shear_correction, SPH_PHASE_SHELL, SPH_STATUS_ACTIVE implicit none logical :: shell_module_initialized = .false. + 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_STRESS_COMPONENTS = 6 + integer, parameter :: SPH_SHELL_MAX_INTEGRATION_POINTS = 5 logical :: shell_material_seen = .false. integer :: shell_material_count = 0 integer :: shell_material_ids(SPH_MAX_MATERIALS) = 0 @@ -31,6 +37,25 @@ module sph_shell real(rk) :: shell_failure_d(5,SPH_MAX_MATERIALS) = 0.0_rk character(len=SPH_NAME_LEN) :: shell_softening_type(SPH_MAX_MATERIALS) = ' ' real(rk) :: shell_softening_width(SPH_MAX_MATERIALS) = 0.0_rk + real(rk), allocatable :: shell_thickness(:) + real(rk), allocatable :: shell_director(:,:) + real(rk), allocatable :: shell_omega(:,:) + real(rk), allocatable :: shell_membrane_strain(:,:) + real(rk), allocatable :: shell_bending_strain(:,:) + real(rk), allocatable :: shell_shear_strain(:,:) + real(rk), allocatable :: shell_damage(:) + real(rk), allocatable :: shell_softening(:) + real(rk), allocatable :: shell_internal_energy(:) + integer, allocatable :: shell_failure_status(:) + integer, allocatable :: shell_ip_count(:) + real(rk), allocatable :: shell_ip_coord(:,:) + real(rk), allocatable :: shell_ip_weight(:,:) + real(rk), allocatable :: shell_ip_stress(:,:,:) + real(rk), allocatable :: shell_ip_strain(:,:,:) + real(rk), allocatable :: shell_ip_plastic_strain(:,:) + real(rk), allocatable :: shell_ip_temperature(:,:) + real(rk), allocatable :: shell_ip_damage(:,:) + real(rk), allocatable :: shell_ip_softening(:,:) contains @@ -42,6 +67,7 @@ contains subroutine sph_shell_reset() shell_module_initialized = .false. call sph_shell_clear_material_table() + call sph_shell_deallocate_state() end subroutine sph_shell_reset subroutine sph_shell_clear_material_table() @@ -222,10 +248,175 @@ contains integer, intent(out) :: ierr ierr = SPH_SUCCESS - if (.not. shell_material_seen) return + if (.not. shell_material_seen) then + call sph_shell_deallocate_state() + return + end if call sph_shell_validate_input(ierr) + if (ierr /= SPH_SUCCESS) return + call sph_shell_allocate_state(ierr) + if (ierr /= SPH_SUCCESS) return + call sph_shell_clear_particle_state() + call sph_shell_initialize_particle_state(ierr) end subroutine sph_shell_build_state + subroutine sph_shell_allocate_state(ierr) + integer, intent(out) :: ierr + integer :: stat + + ierr = SPH_SUCCESS + if (npart <= 0) then + call sph_shell_deallocate_state() + return + end if + if (allocated(shell_thickness)) then + if (size(shell_thickness) == npart) return + call sph_shell_deallocate_state() + end if + allocate(shell_thickness(npart), shell_director(SPH_NDIM,npart), & + shell_omega(SPH_NDIM,npart), & + 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_damage(npart), shell_softening(npart), & + shell_internal_energy(npart), shell_failure_status(npart), & + shell_ip_count(npart), & + shell_ip_coord(SPH_SHELL_MAX_INTEGRATION_POINTS,npart), & + shell_ip_weight(SPH_SHELL_MAX_INTEGRATION_POINTS,npart), & + shell_ip_stress(SPH_SHELL_STRESS_COMPONENTS, & + SPH_SHELL_MAX_INTEGRATION_POINTS,npart), & + shell_ip_strain(SPH_SHELL_STRESS_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), & + shell_ip_softening(SPH_SHELL_MAX_INTEGRATION_POINTS,npart), & + stat=stat) + if (stat /= 0) then + call sph_shell_deallocate_state() + call sph_error_set(SPH_ERROR_INPUT, 'failed to allocate Shell state') + ierr = SPH_ERROR_INPUT + return + end if + call sph_shell_clear_particle_state() + end subroutine sph_shell_allocate_state + + subroutine sph_shell_deallocate_state() + if (allocated(shell_thickness)) deallocate(shell_thickness) + if (allocated(shell_director)) deallocate(shell_director) + if (allocated(shell_omega)) deallocate(shell_omega) + 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_damage)) deallocate(shell_damage) + if (allocated(shell_softening)) deallocate(shell_softening) + if (allocated(shell_internal_energy)) deallocate(shell_internal_energy) + if (allocated(shell_failure_status)) deallocate(shell_failure_status) + if (allocated(shell_ip_count)) deallocate(shell_ip_count) + if (allocated(shell_ip_coord)) deallocate(shell_ip_coord) + 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_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) + if (allocated(shell_ip_softening)) deallocate(shell_ip_softening) + end subroutine sph_shell_deallocate_state + + subroutine sph_shell_clear_particle_state() + if (allocated(shell_thickness)) shell_thickness = 0.0_rk + if (allocated(shell_director)) shell_director = 0.0_rk + if (allocated(shell_omega)) shell_omega = 0.0_rk + 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_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 + if (allocated(shell_failure_status)) shell_failure_status = SPH_STATUS_ACTIVE + if (allocated(shell_ip_count)) shell_ip_count = 0 + if (allocated(shell_ip_coord)) shell_ip_coord = 0.0_rk + 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_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 + if (allocated(shell_ip_softening)) shell_ip_softening = 0.0_rk + end subroutine sph_shell_clear_particle_state + + subroutine sph_shell_initialize_particle_state(ierr) + integer, intent(out) :: ierr + integer :: i + integer :: sec + + ierr = SPH_SUCCESS + do i = 1, npart + if (particle_status(i) /= SPH_STATUS_ACTIVE) cycle + if (particle_phase(i) /= SPH_PHASE_SHELL) cycle + sec = section_id(i) + call sph_shell_initialize_active_particle(i, sec, ierr) + if (ierr /= SPH_SUCCESS) return + end do + end subroutine sph_shell_initialize_particle_state + + subroutine sph_shell_initialize_active_particle(index, sec, ierr) + integer, intent(in) :: index + integer, intent(in) :: sec + integer, intent(out) :: ierr + integer :: ip + integer :: point_count + + ierr = SPH_SUCCESS + point_count = section_integration_points(sec) + shell_thickness(index) = section_thickness(sec) + shell_director(:,index) = (/0.0_rk, 0.0_rk, 1.0_rk/) + shell_internal_energy(index) = internal_energy(index) + shell_softening(index) = 1.0_rk + shell_failure_status(index) = SPH_STATUS_ACTIVE + shell_ip_count(index) = point_count + call sph_shell_set_integration_rule(point_count, & + shell_ip_coord(:,index), shell_ip_weight(:,index), ierr) + if (ierr /= SPH_SUCCESS) return + do ip = 1, point_count + shell_ip_temperature(ip,index) = temperature(index) + shell_ip_softening(ip,index) = 1.0_rk + end do + end subroutine sph_shell_initialize_active_particle + + subroutine sph_shell_set_integration_rule(point_count, coords, weights, ierr) + integer, intent(in) :: point_count + real(rk), intent(out) :: coords(SPH_SHELL_MAX_INTEGRATION_POINTS) + real(rk), intent(out) :: weights(SPH_SHELL_MAX_INTEGRATION_POINTS) + integer, intent(out) :: ierr + real(rk) :: a + real(rk) :: b + real(rk) :: root70 + + ierr = SPH_SUCCESS + coords = 0.0_rk + weights = 0.0_rk + if (point_count == 3) then + a = 0.5_rk * sqrt(3.0_rk / 5.0_rk) + coords(1:3) = (/-a, 0.0_rk, a/) + weights(1:3) = (/5.0_rk / 18.0_rk, 4.0_rk / 9.0_rk, & + 5.0_rk / 18.0_rk/) + else if (point_count == 5) then + root70 = sqrt(70.0_rk) + a = sqrt(5.0_rk + 2.0_rk * sqrt(10.0_rk / 7.0_rk)) / 6.0_rk + b = sqrt(5.0_rk - 2.0_rk * sqrt(10.0_rk / 7.0_rk)) / 6.0_rk + coords(1:5) = (/-a, -b, 0.0_rk, b, a/) + weights(1:5) = (/(322.0_rk - 13.0_rk * root70) / 1800.0_rk, & + (322.0_rk + 13.0_rk * root70) / 1800.0_rk, & + 64.0_rk / 225.0_rk, & + (322.0_rk + 13.0_rk * root70) / 1800.0_rk, & + (322.0_rk - 13.0_rk * root70) / 1800.0_rk/) + else + call sph_error_set(SPH_ERROR_INPUT, 'Shell integration point count must be 3 or 5') + ierr = SPH_ERROR_INPUT + end if + end subroutine sph_shell_set_integration_rule + subroutine sph_shell_validate_input(ierr) integer, intent(out) :: ierr integer :: shell_index diff --git a/tests/data/shell_solid_mixed_060.inp b/tests/data/shell_solid_mixed_060.inp new file mode 100644 index 0000000..9844b81 --- /dev/null +++ b/tests/data/shell_solid_mixed_060.inp @@ -0,0 +1,28 @@ +*NODE +1, 0.0, 0.0, 0.0 +2, 0.1, 0.0, 0.0 +3, 0.0, 0.1, 0.0 +4, 0.1, 0.1, 0.0 +*ELEMENT, TYPE=SPH3D +1, 1 +2, 2 +3, 3 +4, 4 +*ELSET, ELSET=SHELL_PARTICLES +1, 2 +*ELSET, ELSET=SOLID_PARTICLES +3, 4 +*MATERIAL, NAME=SHELL_MIXED_STEEL, TYPE=SHELL +*DENSITY +7850.0 +*ELASTIC +210.0E9, 0.30 +*MATERIAL, NAME=SOLID_MIXED_STEEL, TYPE=SOLID +*DENSITY +7850.0 +*ELASTIC +210.0E9, 0.30 +*SHELL SECTION, ELSET=SHELL_PARTICLES, MATERIAL=SHELL_MIXED_STEEL, THICKNESS=0.010, POINTS=3, SHEAR_CORRECTION=0.8333333333 +*SOLID SECTION, ELSET=SOLID_PARTICLES, MATERIAL=SOLID_MIXED_STEEL +*SPHLITE PARTICLE CONTROL, H=0.12, MASS=7.85, VOLUME=0.001 +*SPHLITE TIME CONTROL, DT=1.0E-7, TIME=1.0E-7, STEPS=1, SAFETY=0.5 diff --git a/tests/module/test_shell_section_integration.f90 b/tests/module/test_shell_section_integration.f90 new file mode 100644 index 0000000..4ba6bdd --- /dev/null +++ b/tests/module/test_shell_section_integration.f90 @@ -0,0 +1,80 @@ +program test_shell_section_integration + 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_shell, only: shell_ip_count, shell_ip_coord, shell_ip_weight, & + shell_ip_stress, shell_ip_strain, shell_ip_plastic_strain, & + shell_ip_temperature, shell_ip_damage, shell_ip_softening + implicit none + + integer :: ierr + + call check_three_point_rule() + call check_five_point_rule() + +contains + + subroutine check_three_point_rule() + call sph_initialize(ierr) + call assert_ok(ierr, 'initialize failed for Shell 3 point rule') + call sph_read_inp('tests/data/shell_section_3pt_060.inp', ierr) + call assert_ok(ierr, 'read failed for Shell 3 point rule') + call sph_build_model(ierr) + call assert_ok(ierr, 'build failed for Shell 3 point rule') + if (shell_ip_count(1) /= 3) call fail('Shell 3 point count mismatch') + if (abs(sum(shell_ip_weight(1:3,1)) - 1.0_rk) > 1.0e-12_rk) & + call fail('Shell 3 point weight sum mismatch') + if (abs(shell_ip_coord(1,1) + shell_ip_coord(3,1)) > 1.0e-12_rk) & + call fail('Shell 3 point coordinate symmetry mismatch') + if (shell_ip_coord(2,1) /= 0.0_rk) call fail('Shell 3 point center coordinate mismatch') + if (any(abs(shell_ip_weight(4:5,1)) > 1.0e-12_rk)) call fail('Shell unused 3 point weights not zero') + if (any(abs(shell_ip_temperature(1:3,1) - 293.15_rk) > 1.0e-12_rk)) & + call fail('Shell 3 point temperature mismatch') + if (any(abs(shell_ip_softening(1:3,1) - 1.0_rk) > 1.0e-12_rk)) & + call fail('Shell 3 point softening mismatch') + call sph_finalize(ierr) + call assert_ok(ierr, 'finalize failed for Shell 3 point rule') + end subroutine check_three_point_rule + + subroutine check_five_point_rule() + call sph_initialize(ierr) + call assert_ok(ierr, 'initialize failed for Shell 5 point rule') + call sph_read_inp('tests/data/shell_section_5pt_060.inp', ierr) + call assert_ok(ierr, 'read failed for Shell 5 point rule') + call sph_build_model(ierr) + call assert_ok(ierr, 'build failed for Shell 5 point rule') + if (shell_ip_count(1) /= 5) call fail('Shell 5 point count mismatch') + if (abs(sum(shell_ip_weight(1:5,1)) - 1.0_rk) > 1.0e-12_rk) & + call fail('Shell 5 point weight sum mismatch') + if (abs(shell_ip_coord(1,1) + shell_ip_coord(5,1)) > 1.0e-12_rk) & + call fail('Shell 5 point outer coordinate symmetry mismatch') + if (abs(shell_ip_coord(2,1) + shell_ip_coord(4,1)) > 1.0e-12_rk) & + call fail('Shell 5 point inner coordinate symmetry mismatch') + if (shell_ip_coord(3,1) /= 0.0_rk) call fail('Shell 5 point center coordinate mismatch') + if (abs(shell_ip_weight(1,1) - shell_ip_weight(5,1)) > 1.0e-12_rk) & + call fail('Shell 5 point outer weight symmetry mismatch') + if (abs(shell_ip_weight(2,1) - shell_ip_weight(4,1)) > 1.0e-12_rk) & + call fail('Shell 5 point inner weight symmetry mismatch') + if (any(abs(shell_ip_stress(:,:,1)) > 1.0e-12_rk)) call fail('Shell integration stress default mismatch') + if (any(abs(shell_ip_strain(:,:,1)) > 1.0e-12_rk)) call fail('Shell integration strain default mismatch') + if (any(abs(shell_ip_plastic_strain(:,1)) > 1.0e-12_rk)) call fail('Shell integration plastic default mismatch') + if (any(abs(shell_ip_damage(:,1)) > 1.0e-12_rk)) call fail('Shell integration damage default mismatch') + call sph_finalize(ierr) + call assert_ok(ierr, 'finalize failed for Shell 5 point rule') + end subroutine check_five_point_rule + + 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_section_integration diff --git a/tests/module/test_shell_state_build.f90 b/tests/module/test_shell_state_build.f90 new file mode 100644 index 0000000..b80a3e9 --- /dev/null +++ b/tests/module/test_shell_state_build.f90 @@ -0,0 +1,90 @@ +program test_shell_state_build + 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: particle_phase, SPH_PHASE_SHELL, SPH_PHASE_SOLID, & + SPH_STATUS_ACTIVE + use sph_shell, only: shell_thickness, shell_director, shell_omega, & + shell_membrane_strain, shell_bending_strain, shell_shear_strain, & + shell_damage, shell_softening, shell_internal_energy, & + shell_failure_status, shell_ip_count + implicit none + + integer :: ierr + + call check_shell_state_defaults() + call check_mixed_particle_defaults() + call check_finalize_releases_state() + +contains + + subroutine check_shell_state_defaults() + call sph_initialize(ierr) + call assert_ok(ierr, 'initialize failed for Shell state') + call sph_read_inp('tests/data/shell_minimal_060.inp', ierr) + call assert_ok(ierr, 'read failed for Shell state') + call sph_build_model(ierr) + call assert_ok(ierr, 'build failed for Shell state') + if (.not. allocated(shell_thickness)) call fail('Shell thickness not allocated') + if (size(shell_thickness) /= 4) call fail('Shell state size mismatch') + if (abs(shell_thickness(1) - 0.010_rk) > 1.0e-12_rk) call fail('Shell thickness mismatch') + if (any(abs(shell_director(:,1) - (/0.0_rk, 0.0_rk, 1.0_rk/)) > 1.0e-12_rk)) & + call fail('Shell director default mismatch') + if (any(abs(shell_omega(:,1)) > 1.0e-12_rk)) call fail('Shell omega default mismatch') + if (any(abs(shell_membrane_strain(:,1)) > 1.0e-12_rk)) call fail('Shell membrane strain default mismatch') + if (any(abs(shell_bending_strain(:,1)) > 1.0e-12_rk)) call fail('Shell bending strain default mismatch') + if (any(abs(shell_shear_strain(:,1)) > 1.0e-12_rk)) call fail('Shell shear strain default mismatch') + if (shell_damage(1) /= 0.0_rk) call fail('Shell damage default mismatch') + if (shell_softening(1) /= 1.0_rk) call fail('Shell softening default mismatch') + if (shell_internal_energy(1) /= 0.0_rk) call fail('Shell internal energy default mismatch') + if (shell_failure_status(1) /= SPH_STATUS_ACTIVE) call fail('Shell failure status default mismatch') + if (shell_ip_count(1) /= 3) call fail('Shell integration count default mismatch') + call sph_finalize(ierr) + call assert_ok(ierr, 'finalize failed for Shell state') + end subroutine check_shell_state_defaults + + subroutine check_mixed_particle_defaults() + call sph_initialize(ierr) + call assert_ok(ierr, 'initialize failed for mixed Shell state') + call sph_read_inp('tests/data/shell_solid_mixed_060.inp', ierr) + call assert_ok(ierr, 'read failed for mixed Shell state') + call sph_build_model(ierr) + call assert_ok(ierr, 'build failed for mixed Shell state') + if (any(particle_phase(1:2) /= SPH_PHASE_SHELL)) call fail('mixed Shell phase mismatch') + if (any(particle_phase(3:4) /= SPH_PHASE_SOLID)) call fail('mixed Solid phase mismatch') + if (any(abs(shell_thickness(1:2) - 0.010_rk) > 1.0e-12_rk)) call fail('mixed Shell thickness mismatch') + if (any(abs(shell_thickness(3:4)) > 1.0e-12_rk)) call fail('non-Shell thickness not zero') + if (any(abs(shell_director(:,3)) > 1.0e-12_rk)) call fail('non-Shell director not zero') + if (shell_ip_count(3) /= 0 .or. shell_ip_count(4) /= 0) call fail('non-Shell integration count not zero') + if (shell_softening(3) /= 0.0_rk) call fail('non-Shell softening not safe default') + call sph_finalize(ierr) + call assert_ok(ierr, 'finalize failed for mixed Shell state') + end subroutine check_mixed_particle_defaults + + subroutine check_finalize_releases_state() + call sph_initialize(ierr) + call assert_ok(ierr, 'initialize failed for Shell finalize state') + call sph_read_inp('tests/data/shell_minimal_060.inp', ierr) + call assert_ok(ierr, 'read failed for Shell finalize state') + call sph_build_model(ierr) + call assert_ok(ierr, 'build failed for Shell finalize state') + call sph_finalize(ierr) + call assert_ok(ierr, 'finalize failed for Shell finalize state') + if (allocated(shell_thickness)) call fail('Shell state not released on finalize') + end subroutine check_finalize_releases_state + + 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_state_build diff --git a/todo.md b/todo.md index d4d0f85..37344ea 100644 --- a/todo.md +++ b/todo.md @@ -82,42 +82,42 @@ ## 阶段 C:Shell 状态数组、厚度积分点和默认值 -- [ ] 设计 Shell 粒子级状态常量和数组布局。 -- [ ] 新增或补齐 Shell thickness 状态数组。 -- [ ] 新增或补齐 Shell director 状态数组。 -- [ ] 新增或补齐 Shell omega 状态数组。 -- [ ] 新增或补齐 Shell membrane strain 状态数组。 -- [ ] 新增或补齐 Shell bending strain 状态数组。 -- [ ] 新增或补齐 Shell shear strain 状态数组。 -- [ ] 新增或补齐 Shell damage 状态数组。 -- [ ] 新增或补齐 Shell softening 状态数组。 -- [ ] 新增或补齐 Shell internal energy 状态数组。 -- [ ] 新增或补齐 Shell failure status 状态数组。 -- [ ] 设计 Shell 厚度积分点状态常量和数组布局。 -- [ ] 新增或补齐 Shell integration point count 状态数组。 -- [ ] 新增或补齐 Shell integration point coordinate 状态数组。 -- [ ] 新增或补齐 Shell integration point weight 状态数组。 -- [ ] 新增或补齐 Shell integration point stress 状态数组。 -- [ ] 新增或补齐 Shell integration point strain 状态数组。 -- [ ] 新增或补齐 Shell integration point plastic strain 状态数组。 -- [ ] 新增或补齐 Shell integration point temperature 状态数组。 -- [ ] 新增或补齐 Shell integration point damage 状态数组。 -- [ ] 新增或补齐 Shell integration point softening 状态数组。 -- [ ] 在 Shell reset 路径初始化粒子级状态。 -- [ ] 在 Shell reset 路径初始化积分点状态。 -- [ ] 在 Shell allocate/build 路径分配粒子级状态。 -- [ ] 在 Shell allocate/build 路径分配积分点状态。 -- [ ] 在 Shell clear/finalize 路径释放粒子级状态。 -- [ ] 在 Shell clear/finalize 路径释放积分点状态。 -- [ ] 初始化 active Shell 粒子的 thickness。 -- [ ] 初始化 active Shell 粒子的 integration point count。 -- [ ] 初始化 active Shell 粒子的 integration point 坐标和权重。 -- [ ] 初始化 active Shell 粒子的 damage、softening 和 failure status。 -- [ ] 对非 Shell 粒子设置安全默认 Shell 状态。 -- [ ] 新增 `shell_state_build` 测试。 -- [ ] 新增 `shell_section_integration` 测试。 -- [ ] 将 `shell_state_build` 接入 CTest。 -- [ ] 将 `shell_section_integration` 接入 CTest。 +- [x] 设计 Shell 粒子级状态常量和数组布局。 +- [x] 新增或补齐 Shell thickness 状态数组。 +- [x] 新增或补齐 Shell director 状态数组。 +- [x] 新增或补齐 Shell omega 状态数组。 +- [x] 新增或补齐 Shell membrane strain 状态数组。 +- [x] 新增或补齐 Shell bending strain 状态数组。 +- [x] 新增或补齐 Shell shear strain 状态数组。 +- [x] 新增或补齐 Shell damage 状态数组。 +- [x] 新增或补齐 Shell softening 状态数组。 +- [x] 新增或补齐 Shell internal energy 状态数组。 +- [x] 新增或补齐 Shell failure status 状态数组。 +- [x] 设计 Shell 厚度积分点状态常量和数组布局。 +- [x] 新增或补齐 Shell integration point count 状态数组。 +- [x] 新增或补齐 Shell integration point coordinate 状态数组。 +- [x] 新增或补齐 Shell integration point weight 状态数组。 +- [x] 新增或补齐 Shell integration point stress 状态数组。 +- [x] 新增或补齐 Shell integration point strain 状态数组。 +- [x] 新增或补齐 Shell integration point plastic strain 状态数组。 +- [x] 新增或补齐 Shell integration point temperature 状态数组。 +- [x] 新增或补齐 Shell integration point damage 状态数组。 +- [x] 新增或补齐 Shell integration point softening 状态数组。 +- [x] 在 Shell reset 路径初始化粒子级状态。 +- [x] 在 Shell reset 路径初始化积分点状态。 +- [x] 在 Shell allocate/build 路径分配粒子级状态。 +- [x] 在 Shell allocate/build 路径分配积分点状态。 +- [x] 在 Shell clear/finalize 路径释放粒子级状态。 +- [x] 在 Shell clear/finalize 路径释放积分点状态。 +- [x] 初始化 active Shell 粒子的 thickness。 +- [x] 初始化 active Shell 粒子的 integration point count。 +- [x] 初始化 active Shell 粒子的 integration point 坐标和权重。 +- [x] 初始化 active Shell 粒子的 damage、softening 和 failure status。 +- [x] 对非 Shell 粒子设置安全默认 Shell 状态。 +- [x] 新增 `shell_state_build` 测试。 +- [x] 新增 `shell_section_integration` 测试。 +- [x] 将 `shell_state_build` 接入 CTest。 +- [x] 将 `shell_section_integration` 接入 CTest。 ## 阶段 D:Director、转动状态和参考面积/惯量