110 lines
4.1 KiB
Fortran
110 lines
4.1 KiB
Fortran
|
|
program test_coupling_facet_errors_080
|
||
|
|
use sph_precision, only: rk, SPH_NDIM
|
||
|
|
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_director, shell_reference_area
|
||
|
|
use sph_coupling_interface, only: sph_coupling_get_region_facet_count, &
|
||
|
|
sph_coupling_export_region_facets, SPH_COUPLING_FACET_VECTOR_COUNT
|
||
|
|
implicit none
|
||
|
|
|
||
|
|
integer :: ierr
|
||
|
|
|
||
|
|
call check_solid_has_no_facet_proxy()
|
||
|
|
call check_disabled_facet_region()
|
||
|
|
call check_zero_area_facet_fails()
|
||
|
|
call check_nonfinite_normal_fails()
|
||
|
|
|
||
|
|
contains
|
||
|
|
|
||
|
|
subroutine check_solid_has_no_facet_proxy()
|
||
|
|
integer :: count
|
||
|
|
|
||
|
|
call sph_initialize(ierr)
|
||
|
|
call assert_ok(ierr, 'initialize failed for solid facet error')
|
||
|
|
call sph_read_inp('tests/data/coupling_region_080.inp', ierr)
|
||
|
|
call assert_ok(ierr, 'read failed for solid facet error')
|
||
|
|
call sph_build_model(ierr)
|
||
|
|
call assert_ok(ierr, 'build failed for solid facet error')
|
||
|
|
call sph_coupling_get_region_facet_count('CONTACT_FACETS', count, ierr)
|
||
|
|
if (ierr == SPH_SUCCESS) call fail('solid facet proxy count did not fail')
|
||
|
|
call sph_finalize(ierr)
|
||
|
|
call assert_ok(ierr, 'finalize failed after solid facet error')
|
||
|
|
end subroutine check_solid_has_no_facet_proxy
|
||
|
|
|
||
|
|
subroutine check_disabled_facet_region()
|
||
|
|
integer :: count
|
||
|
|
|
||
|
|
call sph_initialize(ierr)
|
||
|
|
call assert_ok(ierr, 'initialize failed for disabled facet region')
|
||
|
|
call sph_read_inp('tests/data/coupling_region_080.inp', ierr)
|
||
|
|
call assert_ok(ierr, 'read failed for disabled facet region')
|
||
|
|
call sph_build_model(ierr)
|
||
|
|
call assert_ok(ierr, 'build failed for disabled facet region')
|
||
|
|
call sph_coupling_get_region_facet_count('CONTACT_DISABLED', count, ierr)
|
||
|
|
call assert_ok(ierr, 'disabled facet count failed')
|
||
|
|
if (count /= 0) call fail('disabled facet region returned facets')
|
||
|
|
call sph_finalize(ierr)
|
||
|
|
call assert_ok(ierr, 'finalize failed after disabled facet region')
|
||
|
|
end subroutine check_disabled_facet_region
|
||
|
|
|
||
|
|
subroutine check_zero_area_facet_fails()
|
||
|
|
integer :: count
|
||
|
|
integer :: facet_ids(3)
|
||
|
|
integer :: particle_ids(3)
|
||
|
|
integer :: materials(3)
|
||
|
|
integer :: sections(3)
|
||
|
|
real(rk) :: vectors(SPH_NDIM,SPH_COUPLING_FACET_VECTOR_COUNT,3)
|
||
|
|
real(rk) :: areas(3)
|
||
|
|
|
||
|
|
call build_shell_case()
|
||
|
|
shell_reference_area(1) = 0.0_rk
|
||
|
|
call sph_coupling_export_region_facets('SHELL_FACETS', 3, count, &
|
||
|
|
facet_ids, particle_ids, materials, sections, vectors, areas, ierr)
|
||
|
|
if (ierr == SPH_SUCCESS) call fail('zero area facet did not fail')
|
||
|
|
call sph_finalize(ierr)
|
||
|
|
call assert_ok(ierr, 'finalize failed after zero area facet')
|
||
|
|
end subroutine check_zero_area_facet_fails
|
||
|
|
|
||
|
|
subroutine check_nonfinite_normal_fails()
|
||
|
|
integer :: count
|
||
|
|
integer :: facet_ids(3)
|
||
|
|
integer :: particle_ids(3)
|
||
|
|
integer :: materials(3)
|
||
|
|
integer :: sections(3)
|
||
|
|
real(rk) :: vectors(SPH_NDIM,SPH_COUPLING_FACET_VECTOR_COUNT,3)
|
||
|
|
real(rk) :: areas(3)
|
||
|
|
|
||
|
|
call build_shell_case()
|
||
|
|
shell_director(1,1) = huge(shell_director(1,1))
|
||
|
|
call sph_coupling_export_region_facets('SHELL_FACETS', 3, count, &
|
||
|
|
facet_ids, particle_ids, materials, sections, vectors, areas, ierr)
|
||
|
|
if (ierr == SPH_SUCCESS) call fail('nonfinite facet normal did not fail')
|
||
|
|
call sph_finalize(ierr)
|
||
|
|
call assert_ok(ierr, 'finalize failed after nonfinite facet normal')
|
||
|
|
end subroutine check_nonfinite_normal_fails
|
||
|
|
|
||
|
|
subroutine build_shell_case()
|
||
|
|
call sph_initialize(ierr)
|
||
|
|
call assert_ok(ierr, 'initialize failed for shell facet error')
|
||
|
|
call sph_read_inp('tests/data/coupling_shell_region_080.inp', ierr)
|
||
|
|
call assert_ok(ierr, 'read failed for shell facet error')
|
||
|
|
call sph_build_model(ierr)
|
||
|
|
call assert_ok(ierr, 'build failed for shell facet error')
|
||
|
|
end subroutine build_shell_case
|
||
|
|
|
||
|
|
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_coupling_facet_errors_080
|