187 lines
7.4 KiB
Fortran
187 lines
7.4 KiB
Fortran
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
|