Harden coupling diagnostics and pressure wave smoke
This commit is contained in:
@@ -366,6 +366,8 @@ CLI 内部必须继续调用公共生命周期 API,不得绕过 Fortran API
|
||||
|
||||
如果 0.2.1 需要扩展 C ABI coupling 接口,应只采用中立命名,且不依赖外部 CouplingModule。
|
||||
|
||||
0.2.1 实施决策:本版本不暴露 CouplingInterface 的 C ABI。原因是外部耦合模块名称、区域匹配方式、facet/粒子载荷交换契约尚未冻结;过早公开 C ABI 会把临时占位语义固化为长期接口。0.2.1 仅保留 Fortran 模块级 gate,用于验证中立导出、外部粒子力导入和诊断占位。
|
||||
|
||||
## 16. 测试计划
|
||||
|
||||
0.2.1 默认 gate 建议包含:
|
||||
@@ -476,6 +478,7 @@ git diff --check
|
||||
- 确认外部粒子力影响显式步。
|
||||
- 确认 coupling 诊断继续记录。
|
||||
- 确认默认 gate 不运行真实 FEM-SPH 联合测试。
|
||||
- 记录 0.2.1 暂不暴露 CouplingInterface C ABI 的原因。
|
||||
|
||||
### 阶段 H:Pressure Wave Smoke 和 Gate
|
||||
|
||||
|
||||
@@ -110,9 +110,12 @@ contains
|
||||
if (.not. is_finite_vector(position)) call fail('water coupling position after force is not finite')
|
||||
if (.not. is_finite_vector(velocity)) call fail('water coupling velocity after force is not finite')
|
||||
if (.not. is_finite(particle_pressure)) call fail('water coupling pressure is not finite')
|
||||
call sph_coupling_import_facet_load(1, force, ierr)
|
||||
call assert_ok(ierr, 'water coupling facet load import failed')
|
||||
|
||||
call sph_coupling_get_diagnostics(work, energy, momentum)
|
||||
if (work <= 0.0_rk) call fail('coupling work placeholder not updated')
|
||||
if (energy <= 0.0_rk) call fail('coupling energy placeholder not updated')
|
||||
if (momentum(3) <= 0.0_rk) call fail('coupling momentum placeholder not updated')
|
||||
if (coupling_type /= 0) call fail('water coupling type should remain neutral')
|
||||
|
||||
|
||||
@@ -6,7 +6,8 @@ program test_input
|
||||
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, particle_phase, &
|
||||
SPH_PHASE_WATER
|
||||
coupling_region_type, SPH_PHASE_WATER, SPH_REGION_COUPLING_CONTACT, &
|
||||
SPH_REGION_COUPLING_CONTINUUM
|
||||
implicit none
|
||||
|
||||
integer :: ierr
|
||||
@@ -20,13 +21,17 @@ program test_input
|
||||
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')
|
||||
if (coupling_region_type(1) /= SPH_REGION_COUPLING_CONTACT) then
|
||||
call fail('contact coupling region type mismatch')
|
||||
end if
|
||||
|
||||
call sph_finalize(ierr)
|
||||
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 check_coupling_region_type('tests/data/coupling_region_011.inp', &
|
||||
SPH_REGION_COUPLING_CONTINUUM)
|
||||
call check_good_input('tests/data/water_material_case_021.inp', 4, .false.)
|
||||
call check_good_input('tests/data/water_eos_no_p0_021.inp', 1, .false.)
|
||||
call check_good_input('tests/data/water_eos_with_b_021.inp', 1, .false.)
|
||||
@@ -107,6 +112,22 @@ contains
|
||||
end if
|
||||
end subroutine check_good_input
|
||||
|
||||
subroutine check_coupling_region_type(filename, expected_type)
|
||||
character(len=*), intent(in) :: filename
|
||||
integer, intent(in) :: expected_type
|
||||
|
||||
call sph_initialize(ierr)
|
||||
call assert_ok(ierr, 'initialize failed for coupling type input')
|
||||
call sph_read_inp(filename, ierr)
|
||||
call assert_ok(ierr, 'coupling type input read failed')
|
||||
call sph_build_model(ierr)
|
||||
call assert_ok(ierr, 'coupling type model build failed')
|
||||
if (coupling_region_count <= 0) call fail('coupling type region missing')
|
||||
if (coupling_region_type(1) /= expected_type) call fail('coupling type mismatch')
|
||||
call sph_finalize(ierr)
|
||||
call assert_ok(ierr, 'finalize failed after coupling type input')
|
||||
end subroutine check_coupling_region_type
|
||||
|
||||
subroutine check_repeat_read_replaces_model()
|
||||
call sph_initialize(ierr)
|
||||
call assert_ok(ierr, 'initialize failed for repeat read')
|
||||
|
||||
@@ -4,7 +4,7 @@ program test_pressure_wave_smoke
|
||||
use sph_api, only: sph_initialize, sph_finalize, sph_read_inp, sph_build_model, &
|
||||
sph_run_explicit, sph_get_current_time, sph_get_water_summary, &
|
||||
sph_set_output_directory, sph_write_output
|
||||
use sph_database, only: rho, v
|
||||
use sph_database, only: rho, v, x
|
||||
implicit none
|
||||
|
||||
integer :: ierr
|
||||
@@ -17,52 +17,77 @@ program test_pressure_wave_smoke
|
||||
real(rk) :: min_density
|
||||
real(rk) :: max_density
|
||||
|
||||
call sph_initialize(ierr)
|
||||
call assert_ok(ierr, 'initialize failed')
|
||||
call sph_read_inp('tests/data/water_pressure_wave_020.inp', ierr)
|
||||
call assert_ok(ierr, 'read pressure wave input failed')
|
||||
call sph_build_model(ierr)
|
||||
call assert_ok(ierr, 'build pressure wave model failed')
|
||||
|
||||
rho(1) = 1020.0_rk
|
||||
call sph_get_water_summary(initial_mass, momentum, max_pressure, &
|
||||
min_density, max_density, ierr)
|
||||
call assert_ok(ierr, 'initial pressure wave summary failed')
|
||||
|
||||
call sph_run_explicit(ierr)
|
||||
call assert_ok(ierr, 'run pressure wave failed')
|
||||
call sph_get_current_time(time, step, ierr)
|
||||
call assert_ok(ierr, 'pressure wave time query failed')
|
||||
if (step /= 3) call fail('pressure wave step count mismatch')
|
||||
if (time <= 0.0_rk) call fail('pressure wave time did not advance')
|
||||
|
||||
call sph_get_water_summary(final_mass, momentum, max_pressure, &
|
||||
min_density, max_density, ierr)
|
||||
call assert_ok(ierr, 'final pressure wave summary failed')
|
||||
if (.not. is_finite(max_pressure)) call fail('pressure wave pressure is not finite')
|
||||
if (max_pressure <= 0.0_rk) call fail('pressure wave pressure perturbation missing')
|
||||
if (v(1,2) <= 0.0_rk) call fail('pressure wave did not propagate along +x')
|
||||
if (abs(final_mass - initial_mass) > 1.0e-12_rk) call fail('pressure wave mass drifted')
|
||||
if (.not. vector_is_finite(momentum)) call fail('pressure wave momentum is not finite')
|
||||
if (sqrt(sum(momentum * momentum)) > 1.0e-3_rk) call fail('pressure wave momentum drift too large')
|
||||
|
||||
call sph_set_output_directory('build-codex-unix', ierr)
|
||||
call assert_ok(ierr, 'set pressure wave output directory failed')
|
||||
call sph_write_output(step, time, ierr)
|
||||
call assert_ok(ierr, 'write pressure wave output failed')
|
||||
call check_output_fields(step)
|
||||
|
||||
call sph_finalize(ierr)
|
||||
call assert_ok(ierr, 'finalize failed')
|
||||
call run_pressure_wave_case('tests/data/water_pressure_wave_020.inp', .true.)
|
||||
call run_pressure_wave_case('tests/data/water_pressure_wave_3d_021.inp', .false.)
|
||||
|
||||
contains
|
||||
|
||||
subroutine run_pressure_wave_case(filename, linear_case)
|
||||
character(len=*), intent(in) :: filename
|
||||
logical, intent(in) :: linear_case
|
||||
|
||||
call sph_initialize(ierr)
|
||||
call assert_ok(ierr, 'initialize failed')
|
||||
call sph_read_inp(filename, ierr)
|
||||
call assert_ok(ierr, 'read pressure wave input failed')
|
||||
call sph_build_model(ierr)
|
||||
call assert_ok(ierr, 'build pressure wave model failed')
|
||||
|
||||
if (.not. linear_case) then
|
||||
if (abs(x(2,3)) <= 0.0_rk .or. abs(x(3,4)) <= 0.0_rk) then
|
||||
call fail('3D pressure wave layout is not non-collinear')
|
||||
end if
|
||||
end if
|
||||
|
||||
rho(1) = 1020.0_rk
|
||||
call sph_get_water_summary(initial_mass, momentum, max_pressure, &
|
||||
min_density, max_density, ierr)
|
||||
call assert_ok(ierr, 'initial pressure wave summary failed')
|
||||
|
||||
call sph_run_explicit(ierr)
|
||||
call assert_ok(ierr, 'run pressure wave failed')
|
||||
call sph_get_current_time(time, step, ierr)
|
||||
call assert_ok(ierr, 'pressure wave time query failed')
|
||||
if (step /= 3) call fail('pressure wave step count mismatch')
|
||||
if (time <= 0.0_rk) call fail('pressure wave time did not advance')
|
||||
|
||||
call sph_get_water_summary(final_mass, momentum, max_pressure, &
|
||||
min_density, max_density, ierr)
|
||||
call assert_ok(ierr, 'final pressure wave summary failed')
|
||||
if (.not. is_finite(max_pressure)) call fail('pressure wave pressure is not finite')
|
||||
if (.not. is_finite(min_density)) call fail('pressure wave min density is not finite')
|
||||
if (.not. is_finite(max_density)) call fail('pressure wave max density is not finite')
|
||||
if (max_pressure <= 0.0_rk) call fail('pressure wave pressure perturbation missing')
|
||||
if (linear_case) then
|
||||
if (v(1,2) <= 0.0_rk) call fail('pressure wave did not propagate along +x')
|
||||
else
|
||||
if (v(1,2) <= 0.0_rk .or. v(2,3) <= 0.0_rk .or. v(3,4) <= 0.0_rk) then
|
||||
call fail('3D pressure wave did not propagate outward')
|
||||
end if
|
||||
end if
|
||||
if (abs(final_mass - initial_mass) > 1.0e-12_rk) call fail('pressure wave mass drifted')
|
||||
if (.not. vector_is_finite(momentum)) call fail('pressure wave momentum is not finite')
|
||||
! Smoke threshold only: this is not an engineering accuracy benchmark.
|
||||
if (sqrt(sum(momentum * momentum)) > 1.0e-3_rk) call fail('pressure wave momentum drift too large')
|
||||
|
||||
call sph_set_output_directory('build-codex-unix', ierr)
|
||||
call assert_ok(ierr, 'set pressure wave output directory failed')
|
||||
call sph_write_output(step, time, ierr)
|
||||
call assert_ok(ierr, 'write pressure wave output failed')
|
||||
call check_output_fields(step)
|
||||
|
||||
call sph_finalize(ierr)
|
||||
call assert_ok(ierr, 'finalize failed')
|
||||
end subroutine run_pressure_wave_case
|
||||
|
||||
subroutine check_output_fields(step_value)
|
||||
integer, intent(in) :: step_value
|
||||
character(len=256) :: particle_file
|
||||
character(len=256) :: summary_file
|
||||
character(len=512) :: line
|
||||
logical :: exists
|
||||
logical :: found_step
|
||||
logical :: found_time
|
||||
logical :: found_mass
|
||||
logical :: found_pressure
|
||||
logical :: found_dtcrit
|
||||
@@ -76,12 +101,19 @@ contains
|
||||
read(71, '(A)', iostat=ios) line
|
||||
close(unit=71)
|
||||
if (ios /= 0) call fail('pressure wave particle output header missing')
|
||||
if (index(line, 'id') <= 0) call fail('pressure wave id field missing')
|
||||
if (index(line, 'phase') <= 0) call fail('pressure wave phase field missing')
|
||||
if (index(line, 'x') <= 0) call fail('pressure wave coordinate field missing')
|
||||
if (index(line, 'vx') <= 0) call fail('pressure wave velocity field missing')
|
||||
if (index(line, 'rho') <= 0) call fail('pressure wave rho field missing')
|
||||
if (index(line, 'pressure') <= 0) call fail('pressure wave pressure field missing')
|
||||
if (index(line, 'h') <= 0) call fail('pressure wave h field missing')
|
||||
|
||||
write(summary_file, '("build-codex-unix/sphlite_", I8.8, "_summary.csv")') step_value
|
||||
inquire(file=trim(summary_file), exist=exists)
|
||||
if (.not. exists) call fail('pressure wave summary output missing')
|
||||
found_step = .false.
|
||||
found_time = .false.
|
||||
found_mass = .false.
|
||||
found_pressure = .false.
|
||||
found_dtcrit = .false.
|
||||
@@ -90,11 +122,15 @@ contains
|
||||
do
|
||||
read(72, '(A)', iostat=ios) line
|
||||
if (ios /= 0) exit
|
||||
if (index(line, 'step') > 0) found_step = .true.
|
||||
if (index(line, 'time') > 0) found_time = .true.
|
||||
if (index(line, 'water_mass') > 0) found_mass = .true.
|
||||
if (index(line, 'max_pressure') > 0) found_pressure = .true.
|
||||
if (index(line, 'dtcrit') > 0) found_dtcrit = .true.
|
||||
end do
|
||||
close(unit=72)
|
||||
if (.not. found_step) call fail('pressure wave step field missing')
|
||||
if (.not. found_time) call fail('pressure wave time field missing')
|
||||
if (.not. found_mass) call fail('pressure wave water_mass field missing')
|
||||
if (.not. found_pressure) call fail('pressure wave max_pressure field missing')
|
||||
if (.not. found_dtcrit) call fail('pressure wave dtcrit field missing')
|
||||
|
||||
@@ -374,29 +374,29 @@
|
||||
- [x] 确认外部粒子力导入接口可用。
|
||||
- [x] 确认外部粒子力影响显式步。
|
||||
- [x] 确认 coupling work 诊断继续记录。
|
||||
- [ ] 确认 coupling momentum 诊断继续记录。
|
||||
- [ ] 确认 coupling energy 诊断继续记录。
|
||||
- [ ] 保持接触耦合类型字段。
|
||||
- [ ] 保持连续体耦合类型字段。
|
||||
- [ ] 确认接口命名不出现 FEMLite 内部结构。
|
||||
- [ ] 确认默认 gate 不运行真实 FEM-SPH 联合测试。
|
||||
- [ ] 评估 0.2.1 是否暴露 C ABI coupling 接口。
|
||||
- [ ] 若不暴露 C ABI coupling 接口,在文档中记录原因。
|
||||
- [x] 确认 coupling momentum 诊断继续记录。
|
||||
- [x] 确认 coupling energy 诊断继续记录。
|
||||
- [x] 保持接触耦合类型字段。
|
||||
- [x] 保持连续体耦合类型字段。
|
||||
- [x] 确认接口命名不出现 FEMLite 内部结构。
|
||||
- [x] 确认默认 gate 不运行真实 FEM-SPH 联合测试。
|
||||
- [x] 评估 0.2.1 是否暴露 C ABI coupling 接口。
|
||||
- [x] 若不暴露 C ABI coupling 接口,在文档中记录原因。
|
||||
|
||||
## 阶段 R:Pressure Wave Smoke 加固
|
||||
|
||||
- [ ] 保持已有 5 粒子 pressure wave smoke 可用。
|
||||
- [ ] 评估是否增加非共线 3D 粒子布置。
|
||||
- [ ] 若增加非共线布置,创建对应输入文件。
|
||||
- [ ] 加固初始压力扰动设置。
|
||||
- [ ] 加固运行步数检查。
|
||||
- [ ] 加固 checker 阈值说明。
|
||||
- [ ] 检查压力扰动传播方向。
|
||||
- [ ] 检查输出有限性。
|
||||
- [ ] 检查质量趋势。
|
||||
- [ ] 检查动量趋势。
|
||||
- [ ] 检查粒子 CSV 输出字段。
|
||||
- [ ] 检查 summary CSV 输出字段。
|
||||
- [x] 保持已有 5 粒子 pressure wave smoke 可用。
|
||||
- [x] 评估是否增加非共线 3D 粒子布置。
|
||||
- [x] 若增加非共线布置,创建对应输入文件。
|
||||
- [x] 加固初始压力扰动设置。
|
||||
- [x] 加固运行步数检查。
|
||||
- [x] 加固 checker 阈值说明。
|
||||
- [x] 检查压力扰动传播方向。
|
||||
- [x] 检查输出有限性。
|
||||
- [x] 检查质量趋势。
|
||||
- [x] 检查动量趋势。
|
||||
- [x] 检查粒子 CSV 输出字段。
|
||||
- [x] 检查 summary CSV 输出字段。
|
||||
- [ ] 确认 pressure wave smoke 不作为工程精度 benchmark。
|
||||
- [ ] 确认 pressure wave smoke 保持小规模。
|
||||
- [ ] 确认 pressure wave smoke 进入默认 gate。
|
||||
|
||||
Reference in New Issue
Block a user