Add Shell small strain kinematics

This commit is contained in:
Codex
2026-07-03 21:29:59 +08:00
parent 4619fdf4ac
commit 2f9edf0a25
6 changed files with 590 additions and 33 deletions
@@ -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
+113
View File
@@ -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
+107
View File
@@ -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