112 lines
4.8 KiB
Fortran
112 lines
4.8 KiB
Fortran
|
|
program test_shell_local_frame
|
||
|
|
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_local_e1, shell_local_e2, shell_local_e3, &
|
||
|
|
shell_local_frame_status, SPH_SHELL_FRAME_OK, SPH_SHELL_FRAME_NONE
|
||
|
|
implicit none
|
||
|
|
|
||
|
|
integer :: ierr
|
||
|
|
|
||
|
|
call check_orientation_frame()
|
||
|
|
call check_reference_frame()
|
||
|
|
call check_non_shell_frame_defaults()
|
||
|
|
|
||
|
|
contains
|
||
|
|
|
||
|
|
subroutine check_orientation_frame()
|
||
|
|
call sph_initialize(ierr)
|
||
|
|
call assert_ok(ierr, 'initialize failed for Shell orientation frame')
|
||
|
|
call sph_read_inp('tests/data/shell_section_orientation_061.inp', ierr)
|
||
|
|
call assert_ok(ierr, 'read failed for Shell orientation frame')
|
||
|
|
call sph_build_model(ierr)
|
||
|
|
call assert_ok(ierr, 'build failed for Shell orientation frame')
|
||
|
|
call assert_frame(1, 'orientation Shell frame')
|
||
|
|
if (any(abs(shell_local_e1(:,1) - (/1.0_rk, 0.0_rk, 0.0_rk/)) > &
|
||
|
|
1.0e-12_rk)) call fail('orientation Shell e1 mismatch')
|
||
|
|
if (any(abs(shell_local_e2(:,1) - (/0.0_rk, 1.0_rk, 0.0_rk/)) > &
|
||
|
|
1.0e-12_rk)) call fail('orientation Shell e2 mismatch')
|
||
|
|
call sph_finalize(ierr)
|
||
|
|
call assert_ok(ierr, 'finalize failed for Shell orientation frame')
|
||
|
|
end subroutine check_orientation_frame
|
||
|
|
|
||
|
|
subroutine check_reference_frame()
|
||
|
|
call sph_initialize(ierr)
|
||
|
|
call assert_ok(ierr, 'initialize failed for Shell reference frame')
|
||
|
|
call sph_read_inp('tests/data/shell_reference_triangle_061.inp', ierr)
|
||
|
|
call assert_ok(ierr, 'read failed for Shell reference frame')
|
||
|
|
call sph_build_model(ierr)
|
||
|
|
call assert_ok(ierr, 'build failed for Shell reference frame')
|
||
|
|
call assert_frame(1, 'reference Shell frame')
|
||
|
|
if (any(abs(shell_local_e3(:,1) - (/0.0_rk, 0.0_rk, 1.0_rk/)) > &
|
||
|
|
1.0e-12_rk)) call fail('reference Shell e3 mismatch')
|
||
|
|
call sph_finalize(ierr)
|
||
|
|
call assert_ok(ierr, 'finalize failed for Shell reference frame')
|
||
|
|
end subroutine check_reference_frame
|
||
|
|
|
||
|
|
subroutine check_non_shell_frame_defaults()
|
||
|
|
call sph_initialize(ierr)
|
||
|
|
call assert_ok(ierr, 'initialize failed for Shell frame isolation')
|
||
|
|
call sph_read_inp('tests/data/shell_solid_kinematics_isolation_061.inp', ierr)
|
||
|
|
call assert_ok(ierr, 'read failed for Shell frame isolation')
|
||
|
|
call sph_build_model(ierr)
|
||
|
|
call assert_ok(ierr, 'build failed for Shell frame isolation')
|
||
|
|
if (any(abs(shell_local_e1(:,3)) > 1.0e-12_rk)) &
|
||
|
|
call fail('Solid particle Shell e1 default changed')
|
||
|
|
if (any(abs(shell_local_e2(:,3)) > 1.0e-12_rk)) &
|
||
|
|
call fail('Solid particle Shell e2 default changed')
|
||
|
|
if (any(abs(shell_local_e3(:,3)) > 1.0e-12_rk)) &
|
||
|
|
call fail('Solid particle Shell e3 default changed')
|
||
|
|
if (shell_local_frame_status(3) /= SPH_SHELL_FRAME_NONE) &
|
||
|
|
call fail('Solid particle Shell frame status default changed')
|
||
|
|
call sph_finalize(ierr)
|
||
|
|
call assert_ok(ierr, 'finalize failed for Shell frame isolation')
|
||
|
|
end subroutine check_non_shell_frame_defaults
|
||
|
|
|
||
|
|
subroutine assert_frame(index, label)
|
||
|
|
integer, intent(in) :: index
|
||
|
|
character(len=*), intent(in) :: label
|
||
|
|
real(rk) :: handedness
|
||
|
|
|
||
|
|
if (shell_local_frame_status(index) /= SPH_SHELL_FRAME_OK) &
|
||
|
|
call fail(trim(label) // ' status mismatch')
|
||
|
|
if (abs(sqrt(sum(shell_local_e1(:,index) * shell_local_e1(:,index))) - &
|
||
|
|
1.0_rk) > 1.0e-12_rk) call fail(trim(label) // ' e1 norm mismatch')
|
||
|
|
if (abs(sqrt(sum(shell_local_e2(:,index) * shell_local_e2(:,index))) - &
|
||
|
|
1.0_rk) > 1.0e-12_rk) call fail(trim(label) // ' e2 norm mismatch')
|
||
|
|
if (abs(sqrt(sum(shell_local_e3(:,index) * shell_local_e3(:,index))) - &
|
||
|
|
1.0_rk) > 1.0e-12_rk) call fail(trim(label) // ' e3 norm mismatch')
|
||
|
|
if (abs(sum(shell_local_e1(:,index) * shell_local_e2(:,index))) > &
|
||
|
|
1.0e-12_rk) call fail(trim(label) // ' e1/e2 not orthogonal')
|
||
|
|
handedness = sum(cross(shell_local_e1(:,index), shell_local_e2(:,index)) * &
|
||
|
|
shell_local_e3(:,index))
|
||
|
|
if (abs(handedness - 1.0_rk) > 1.0e-12_rk) &
|
||
|
|
call fail(trim(label) // ' handedness mismatch')
|
||
|
|
end subroutine assert_frame
|
||
|
|
|
||
|
|
function cross(left, right) result(out)
|
||
|
|
real(rk), intent(in) :: left(3)
|
||
|
|
real(rk), intent(in) :: right(3)
|
||
|
|
real(rk) :: out(3)
|
||
|
|
|
||
|
|
out(1) = left(2) * right(3) - left(3) * right(2)
|
||
|
|
out(2) = left(3) * right(1) - left(1) * right(3)
|
||
|
|
out(3) = left(1) * right(2) - left(2) * right(1)
|
||
|
|
end function cross
|
||
|
|
|
||
|
|
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_local_frame
|