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
+71
View File
@@ -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