Prepare SPHLite 0.2.0 development baseline

This commit is contained in:
Codex
2026-07-02 19:50:44 +08:00
parent ad31c2d5cc
commit ed1f5a5ab2
36 changed files with 3122 additions and 267 deletions
+55 -19
View File
@@ -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