78 lines
2.6 KiB
Fortran
78 lines
2.6 KiB
Fortran
program test_gas_source_errors
|
|
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_gas, only: sph_gas_add_source_by_particle
|
|
implicit none
|
|
|
|
integer :: ierr
|
|
|
|
call check_invalid_particle()
|
|
call check_invalid_value()
|
|
call check_non_gas_particle()
|
|
|
|
contains
|
|
|
|
subroutine check_invalid_particle()
|
|
real(rk) :: zero_momentum(3)
|
|
|
|
zero_momentum = 0.0_rk
|
|
call build_gas_case()
|
|
call sph_gas_add_source_by_particle(0, 1.0_rk, zero_momentum, 1.0_rk, ierr)
|
|
if (ierr == SPH_SUCCESS) call fail('invalid Gas source particle did not fail')
|
|
call sph_finalize(ierr)
|
|
call assert_ok(ierr, 'finalize failed after invalid particle')
|
|
end subroutine check_invalid_particle
|
|
|
|
subroutine check_invalid_value()
|
|
real(rk) :: zero_momentum(3)
|
|
|
|
zero_momentum = 0.0_rk
|
|
call build_gas_case()
|
|
call sph_gas_add_source_by_particle(1, huge(1.0_rk), zero_momentum, 1.0_rk, ierr)
|
|
if (ierr == SPH_SUCCESS) call fail('invalid Gas source value did not fail')
|
|
call sph_finalize(ierr)
|
|
call assert_ok(ierr, 'finalize failed after invalid value')
|
|
end subroutine check_invalid_value
|
|
|
|
subroutine check_non_gas_particle()
|
|
real(rk) :: zero_momentum(3)
|
|
|
|
zero_momentum = 0.0_rk
|
|
call sph_initialize(ierr)
|
|
call assert_ok(ierr, 'initialize failed for non-Gas source')
|
|
call sph_read_inp('tests/data/water_minimal_021.inp', ierr)
|
|
call assert_ok(ierr, 'read failed for non-Gas source')
|
|
call sph_build_model(ierr)
|
|
call assert_ok(ierr, 'build failed for non-Gas source')
|
|
call sph_gas_add_source_by_particle(1, 1.0_rk, zero_momentum, 1.0_rk, ierr)
|
|
if (ierr == SPH_SUCCESS) call fail('non-Gas source target did not fail')
|
|
call sph_finalize(ierr)
|
|
call assert_ok(ierr, 'finalize failed after non-Gas source')
|
|
end subroutine check_non_gas_particle
|
|
|
|
subroutine build_gas_case()
|
|
call sph_initialize(ierr)
|
|
call assert_ok(ierr, 'initialize failed for Gas source error')
|
|
call sph_read_inp('tests/data/gas_air_ideal_031.inp', ierr)
|
|
call assert_ok(ierr, 'read failed for Gas source error')
|
|
call sph_build_model(ierr)
|
|
call assert_ok(ierr, 'build failed for Gas source error')
|
|
end subroutine build_gas_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_gas_source_errors
|