Prepare SPHLite 0.2.0 development baseline
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
program test_coupling_interface
|
||||
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_coupling_interface, only: sph_coupling_get_particle_count, &
|
||||
sph_coupling_export_particle, sph_coupling_get_facet_count, &
|
||||
sph_coupling_export_facet, sph_coupling_import_particle_force, &
|
||||
sph_coupling_import_facet_load, sph_coupling_get_diagnostics, &
|
||||
coupling_type
|
||||
implicit none
|
||||
|
||||
integer :: ierr
|
||||
integer :: count
|
||||
integer :: ext_id
|
||||
integer :: nodes(3)
|
||||
real(rk) :: position(3)
|
||||
real(rk) :: velocity(3)
|
||||
real(rk) :: force(3)
|
||||
real(rk) :: work
|
||||
real(rk) :: energy
|
||||
real(rk) :: momentum(3)
|
||||
|
||||
call sph_initialize(ierr)
|
||||
call assert_ok(ierr, 'initialize failed')
|
||||
call sph_read_inp('tests/data/coupling_region_011.inp', ierr)
|
||||
call assert_ok(ierr, 'read input failed')
|
||||
call sph_build_model(ierr)
|
||||
call assert_ok(ierr, 'build model failed')
|
||||
|
||||
call sph_coupling_get_particle_count(count, ierr)
|
||||
call assert_ok(ierr, 'coupling particle count failed')
|
||||
if (count /= 2) call fail('coupling particle count mismatch')
|
||||
call sph_coupling_export_particle(1, ext_id, position, velocity, ierr)
|
||||
call assert_ok(ierr, 'coupling particle export failed')
|
||||
if (ext_id /= 1) call fail('coupling particle export id mismatch')
|
||||
|
||||
call sph_coupling_get_facet_count(count, ierr)
|
||||
call assert_ok(ierr, 'coupling facet count failed')
|
||||
if (count /= 0) call fail('0.1.1 should not export real facets')
|
||||
call sph_coupling_export_facet(2, nodes, ierr)
|
||||
if (ierr == SPH_SUCCESS) call fail('facet export error path did not fail')
|
||||
|
||||
force = 1.0_rk
|
||||
call sph_coupling_import_particle_force(1, force, ierr)
|
||||
call assert_ok(ierr, 'coupling particle force import failed')
|
||||
call sph_coupling_import_facet_load(1, force, ierr)
|
||||
call assert_ok(ierr, 'coupling facet load import failed')
|
||||
call sph_coupling_get_diagnostics(work, energy, momentum)
|
||||
if (work <= 0.0_rk .or. energy <= 0.0_rk) call fail('coupling diagnostics not updated')
|
||||
if (coupling_type /= 0) call fail('default coupling type should remain neutral')
|
||||
|
||||
call sph_finalize(ierr)
|
||||
call assert_ok(ierr, 'finalize failed')
|
||||
|
||||
contains
|
||||
|
||||
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_interface
|
||||
+55
-19
@@ -1,25 +1,30 @@
|
||||
program test_input
|
||||
use sph_error, only: SPH_SUCCESS
|
||||
use sph_api, only: sph_initialize, sph_finalize, sph_read_inp, &
|
||||
sph_build_model, sph_get_particle_count
|
||||
sph_build_model, sph_get_particle_count, sph_get_input_warning_count
|
||||
use sph_input_reader, only: sph_input_get_warning_count
|
||||
use sph_database, only: material_count, section_count, nset_count, &
|
||||
elset_count, element_count, coupling_region_count
|
||||
implicit none
|
||||
|
||||
integer :: ierr
|
||||
integer :: count
|
||||
integer :: warnings
|
||||
|
||||
call sph_initialize(ierr)
|
||||
call assert_ok(ierr, 'initialize failed for minimal input')
|
||||
call sph_read_inp('tests/data/minimal_particles.inp', ierr)
|
||||
call assert_ok(ierr, 'minimal input read failed')
|
||||
call sph_build_model(ierr)
|
||||
call assert_ok(ierr, 'minimal model build failed')
|
||||
call sph_get_particle_count(count, ierr)
|
||||
call assert_ok(ierr, 'minimal particle count failed')
|
||||
if (count /= 4) call fail('minimal input particle count mismatch')
|
||||
call check_good_input('tests/data/minimal_particles_011.inp', 4, .true.)
|
||||
if (material_count /= 1) call fail('material metadata was not saved')
|
||||
if (section_count /= 1) call fail('section metadata was not saved')
|
||||
if (nset_count <= 0) call fail('node set metadata was not saved')
|
||||
if (elset_count <= 0) call fail('element set metadata was not saved')
|
||||
if (element_count <= 0) call fail('element metadata was not saved')
|
||||
if (coupling_region_count <= 0) call fail('coupling region metadata was not saved')
|
||||
|
||||
call sph_finalize(ierr)
|
||||
call assert_ok(ierr, 'finalize failed after minimal input')
|
||||
call assert_ok(ierr, 'finalize failed after metadata check')
|
||||
|
||||
call check_good_input('tests/data/mixed_case_011.inp', 2, .false.)
|
||||
call check_good_input('tests/data/output_control_011.inp', 2, .false.)
|
||||
call check_good_input('tests/data/coupling_region_011.inp', 2, .false.)
|
||||
|
||||
call sph_initialize(ierr)
|
||||
call assert_ok(ierr, 'initialize failed for unknown keyword input')
|
||||
@@ -27,22 +32,53 @@ program test_input
|
||||
call assert_ok(ierr, 'unknown keyword input read failed')
|
||||
call sph_input_get_warning_count(warnings)
|
||||
if (warnings <= 0) call fail('unknown keyword warning was not recorded')
|
||||
call sph_get_input_warning_count(warnings, ierr)
|
||||
call assert_ok(ierr, 'warning count API failed')
|
||||
if (warnings <= 0) call fail('warning count API did not report warning')
|
||||
call sph_build_model(ierr)
|
||||
call assert_ok(ierr, 'unknown keyword input build failed')
|
||||
call sph_finalize(ierr)
|
||||
call assert_ok(ierr, 'finalize failed after unknown keyword input')
|
||||
|
||||
call sph_initialize(ierr)
|
||||
call assert_ok(ierr, 'initialize failed for missing required input')
|
||||
call sph_read_inp('tests/data/missing_required.inp', ierr)
|
||||
call assert_ok(ierr, 'missing required input read failed')
|
||||
call sph_build_model(ierr)
|
||||
if (ierr == SPH_SUCCESS) call fail('missing required input did not fail')
|
||||
call sph_finalize(ierr)
|
||||
call assert_ok(ierr, 'finalize failed after missing required input')
|
||||
call check_bad_input('tests/data/missing_material_011.inp')
|
||||
call check_bad_input('tests/data/missing_section_011.inp')
|
||||
call check_bad_input('tests/data/missing_time_control_011.inp')
|
||||
|
||||
contains
|
||||
|
||||
subroutine check_good_input(filename, expected_count, leave_open)
|
||||
character(len=*), intent(in) :: filename
|
||||
integer, intent(in) :: expected_count
|
||||
logical, intent(in) :: leave_open
|
||||
|
||||
call sph_initialize(ierr)
|
||||
call assert_ok(ierr, 'initialize failed for good input')
|
||||
call sph_read_inp(filename, ierr)
|
||||
call assert_ok(ierr, 'good input read failed')
|
||||
call sph_build_model(ierr)
|
||||
call assert_ok(ierr, 'good model build failed')
|
||||
call sph_get_particle_count(count, ierr)
|
||||
call assert_ok(ierr, 'good particle count failed')
|
||||
if (count /= expected_count) call fail('good input particle count mismatch')
|
||||
if (.not. leave_open) then
|
||||
call sph_finalize(ierr)
|
||||
call assert_ok(ierr, 'finalize failed after good input')
|
||||
end if
|
||||
end subroutine check_good_input
|
||||
|
||||
subroutine check_bad_input(filename)
|
||||
character(len=*), intent(in) :: filename
|
||||
|
||||
call sph_initialize(ierr)
|
||||
call assert_ok(ierr, 'initialize failed for bad input')
|
||||
call sph_read_inp(filename, ierr)
|
||||
call assert_ok(ierr, 'bad input read should still parse nodes')
|
||||
call sph_build_model(ierr)
|
||||
if (ierr == SPH_SUCCESS) call fail('bad input did not fail model build')
|
||||
call sph_finalize(ierr)
|
||||
call assert_ok(ierr, 'finalize failed after bad input')
|
||||
end subroutine check_bad_input
|
||||
|
||||
subroutine assert_ok(ierr_value, message)
|
||||
integer, intent(in) :: ierr_value
|
||||
character(len=*), intent(in) :: message
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
program test_output
|
||||
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, &
|
||||
sph_set_output_directory, sph_set_output_interval, sph_write_output
|
||||
implicit none
|
||||
|
||||
integer :: ierr
|
||||
|
||||
call sph_initialize(ierr)
|
||||
call assert_ok(ierr, 'initialize failed')
|
||||
call sph_read_inp('tests/data/output_control_011.inp', ierr)
|
||||
call assert_ok(ierr, 'read input failed')
|
||||
call sph_build_model(ierr)
|
||||
call assert_ok(ierr, 'build model failed')
|
||||
call sph_set_output_directory('build-codex-unix', ierr)
|
||||
call assert_ok(ierr, 'set output directory failed')
|
||||
call sph_set_output_interval(1, ierr)
|
||||
call assert_ok(ierr, 'set output interval failed')
|
||||
call sph_write_output(0, 0.0_rk, ierr)
|
||||
call assert_ok(ierr, 'write output failed')
|
||||
call sph_finalize(ierr)
|
||||
call assert_ok(ierr, 'finalize failed')
|
||||
|
||||
contains
|
||||
|
||||
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_output
|
||||
@@ -0,0 +1,49 @@
|
||||
program test_restart
|
||||
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, &
|
||||
sph_run_explicit, sph_get_current_time, sph_write_restart, sph_read_restart, &
|
||||
sph_advance_explicit
|
||||
implicit none
|
||||
|
||||
integer :: ierr
|
||||
integer :: step
|
||||
real(rk) :: time
|
||||
|
||||
call sph_initialize(ierr)
|
||||
call assert_ok(ierr, 'initialize failed')
|
||||
call sph_read_inp('tests/data/minimal_particles_011.inp', ierr)
|
||||
call assert_ok(ierr, 'read input failed')
|
||||
call sph_build_model(ierr)
|
||||
call assert_ok(ierr, 'build model failed')
|
||||
call sph_run_explicit(ierr)
|
||||
call assert_ok(ierr, 'run explicit failed')
|
||||
call sph_write_restart('build-codex-unix/restart_test.tmp', ierr)
|
||||
call assert_ok(ierr, 'write restart failed')
|
||||
call sph_read_restart('build-codex-unix/restart_test.tmp', ierr)
|
||||
call assert_ok(ierr, 'read restart failed')
|
||||
call sph_get_current_time(time, step, ierr)
|
||||
call assert_ok(ierr, 'time after restart failed')
|
||||
if (step /= 1) call fail('restart did not restore step')
|
||||
call sph_advance_explicit(1.0e-6_rk, ierr)
|
||||
call assert_ok(ierr, 'advance after restart failed')
|
||||
call sph_finalize(ierr)
|
||||
call assert_ok(ierr, 'finalize failed')
|
||||
|
||||
contains
|
||||
|
||||
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_restart
|
||||
Reference in New Issue
Block a user