Add CCLite 0.2.8 verification cases

This commit is contained in:
Codex
2026-07-06 09:12:22 +08:00
parent 85e21cbb95
commit 45cd4273b2
16 changed files with 812 additions and 38 deletions
+28 -2
View File
@@ -20,8 +20,8 @@ module ccl_controller
ccl_data_header_set_count, ccl_data_header_set_state, ccl_data_header_size, &
ccl_data_header_validate, ccl_data_record_size_for_role
use ccl_diagnostics, only: CCL_Diagnostics_Type, ccl_diagnostics_close, &
ccl_diagnostics_open, ccl_diagnostics_write_contact, ccl_diagnostics_write_force_balance, &
ccl_diagnostics_write_ipc, ccl_diagnostics_write_run
ccl_diagnostics_open, ccl_diagnostics_write_candidate, ccl_diagnostics_write_contact, &
ccl_diagnostics_write_force_balance, ccl_diagnostics_write_ipc, ccl_diagnostics_write_run
use ccl_errors, only: CCL_ERROR_INPUT_INVALID_VALUE, CCL_ERROR_IPC_TIMEOUT, &
CCL_ERROR_SYSTEM_INTERNAL, CCL_ERROR_WORKER_START_FAILED, CCL_ERROR_WORKER_STOP_FAILED, &
CCL_SUCCESS
@@ -412,6 +412,8 @@ contains
call run_broad_phase_search(particles, particle_count, facets, facet_count, candidates, &
candidate_count, broad_stats, ierr)
if (ierr /= CCL_SUCCESS) return
call write_candidate_report(diag, step_id, particles, particle_count, facets, facet_count, &
candidates, candidate_count)
call ccl_narrow_phase_stats_reset(total_narrow_stats)
call ccl_contact_force_stats_reset(total_force_stats)
@@ -559,6 +561,30 @@ contains
end do
end subroutine run_broad_phase_search
subroutine write_candidate_report(diag, step_id, particles, particle_count, facets, facet_count, &
candidates, candidate_count)
type(CCL_Diagnostics_Type), intent(inout) :: diag
integer, intent(in) :: step_id
type(CCL_SPH_Particle_View_Type), intent(in) :: particles(:)
integer, intent(in) :: particle_count
type(CCL_FEM_Facet_View_Type), intent(in) :: facets(:)
integer, intent(in) :: facet_count
type(CCL_Candidate_Pair_Type), intent(in) :: candidates(:)
integer, intent(in) :: candidate_count
integer :: i
integer :: particle_index
integer :: facet_index
do i = 1, candidate_count
particle_index = candidates(i)%particle_index
facet_index = candidates(i)%facet_index
if (particle_index < 1 .or. particle_index > particle_count) cycle
if (facet_index < 1 .or. facet_index > facet_count) cycle
call ccl_diagnostics_write_candidate(diag, step_id, particle_index, facet_index, &
particles(particle_index)%external_id, facets(facet_index)%facet_id)
end do
end subroutine write_candidate_report
real(c_double) function choose_contact_cell_size(particles, particle_count) result(cell_size)
type(CCL_SPH_Particle_View_Type), intent(in) :: particles(:)
integer, intent(in) :: particle_count
+25
View File
@@ -12,6 +12,7 @@ module ccl_diagnostics
integer :: ipc_unit = -1
integer :: force_unit = -1
integer :: contact_unit = -1
integer :: candidate_unit = -1
logical :: is_open = .false.
end type CCL_Diagnostics_Type
@@ -58,6 +59,13 @@ contains
return
end if
open(newunit=diag%candidate_unit, file=join_path(diag%output_dir, "candidate_report.csv"), &
status="replace", action="write", encoding="UTF-8", iostat=ios)
if (ios /= 0) then
ierr = CCL_ERROR_SYSTEM_INTERNAL
return
end if
diag%is_open = .true.
write(diag%ipc_unit, '(a)') "step_id,solver_id,command_id,command_seq,ack_seq,worker_state," // &
"heartbeat_seq,elapsed_ms,error_code"
@@ -66,6 +74,7 @@ contains
"nonfinite_contact_count,skipped_separated_count,skipped_degenerate_count,skipped_invalid_count"
write(diag%contact_unit, '(a)') "step_id,pair_id,sph_id,facet_id,gap,penetration,normal_x,normal_y," // &
"normal_z,force_x,force_y,force_z,node_count"
write(diag%candidate_unit, '(a)') "step_id,particle_index,facet_index,sph_id,facet_id"
call ccl_diagnostics_write_run(diag, "INFO", "run", "version=" // CCL_VERSION_LABEL)
call ccl_diagnostics_write_run(diag, "INFO", "run", "case_id=" // trim(case_id))
call ccl_diagnostics_write_run(diag, "INFO", "run", "input=" // trim(input_file))
@@ -176,6 +185,20 @@ contains
flush(diag%contact_unit)
end subroutine ccl_diagnostics_write_contact
subroutine ccl_diagnostics_write_candidate(diag, step_id, particle_index, facet_index, sph_id, facet_id)
type(CCL_Diagnostics_Type), intent(inout) :: diag
integer, intent(in) :: step_id
integer, intent(in) :: particle_index
integer, intent(in) :: facet_index
integer(8), intent(in) :: sph_id
integer(8), intent(in) :: facet_id
if (.not. diag%is_open .or. diag%candidate_unit == -1) return
write(diag%candidate_unit, '(i0,",",i0,",",i0,",",i0,",",i0)') &
step_id, particle_index, facet_index, sph_id, facet_id
flush(diag%candidate_unit)
end subroutine ccl_diagnostics_write_candidate
subroutine ccl_diagnostics_close(diag)
type(CCL_Diagnostics_Type), intent(inout) :: diag
@@ -183,10 +206,12 @@ contains
if (diag%ipc_unit /= -1) close(diag%ipc_unit)
if (diag%force_unit /= -1) close(diag%force_unit)
if (diag%contact_unit /= -1) close(diag%contact_unit)
if (diag%candidate_unit /= -1) close(diag%candidate_unit)
diag%log_unit = -1
diag%ipc_unit = -1
diag%force_unit = -1
diag%contact_unit = -1
diag%candidate_unit = -1
diag%is_open = .false.
end subroutine ccl_diagnostics_close
+40 -13
View File
@@ -389,20 +389,38 @@ contains
ierr = CCL_ERROR_IPC_BAD_HEADER
return
end if
call clear_sph_particle_record(runtime%sph_particles(1))
runtime%sph_particles(1)%external_id = 101_c_int64_t
runtime%sph_particles(1)%internal_index = 1_c_int32_t
runtime%sph_particles(1)%status = 1_c_int32_t
runtime%sph_particles(1)%valid_flags = 1_c_int32_t
runtime%sph_particles(1)%mass = 1.0_c_double
runtime%sph_particles(1)%volume = 1.0_c_double
runtime%sph_particles(1)%density = 1.0_c_double
runtime%sph_particles(1)%contact_radius = 0.2_c_double
runtime%sph_particles(1)%x = [0.25_c_double, 0.25_c_double, 0.10_c_double]
runtime%sph_particles(1)%v = [0.0_c_double, 0.0_c_double, -1.0_c_double]
item_count = 1_c_int32_t
call set_sph_contact_particle(runtime%sph_particles(1), 101_c_int64_t, 1_c_int32_t, &
[0.25_c_double, 0.25_c_double, 0.10_c_double])
if (is_multi_fixture(runtime%input_file)) then
call set_sph_contact_particle(runtime%sph_particles(2), 102_c_int64_t, 2_c_int32_t, &
[0.75_c_double, 0.25_c_double, 0.10_c_double])
call set_sph_contact_particle(runtime%sph_particles(3), 103_c_int64_t, 3_c_int32_t, &
[0.25_c_double, 0.75_c_double, 0.10_c_double])
item_count = 3_c_int32_t
else
item_count = 1_c_int32_t
end if
end subroutine write_sph_contact_fixture
subroutine set_sph_contact_particle(record, external_id, internal_index, x)
type(CCL_SPH_Particle_Record_Type), intent(out) :: record
integer(c_int64_t), intent(in) :: external_id
integer(c_int32_t), intent(in) :: internal_index
real(c_double), intent(in) :: x(3)
call clear_sph_particle_record(record)
record%external_id = external_id
record%internal_index = internal_index
record%status = 1_c_int32_t
record%valid_flags = 1_c_int32_t
record%mass = 1.0_c_double
record%volume = 1.0_c_double
record%density = 1.0_c_double
record%contact_radius = 0.2_c_double
record%x = x
record%v = [0.0_c_double, 0.0_c_double, -1.0_c_double]
end subroutine set_sph_contact_particle
subroutine write_fem_contact_fixture(runtime, item_count, ierr)
type(CCL_Mock_Worker_Runtime), intent(inout) :: runtime
integer(c_int32_t), intent(out) :: item_count
@@ -526,9 +544,18 @@ contains
character(len=len(text)) :: upper
upper = to_upper_text(text)
enabled = index(upper, "CONTACT") > 0 .or. index(upper, "WALL") > 0
enabled = index(upper, "CONTACT") > 0 .or. index(upper, "WALL") > 0 .or. &
index(upper, "PLANE") > 0
end function is_contact_fixture
logical function is_multi_fixture(text) result(enabled)
character(len=*), intent(in) :: text
character(len=len(text)) :: upper
upper = to_upper_text(text)
enabled = index(upper, "MULTI") > 0 .or. index(upper, "PLANE") > 0
end function is_multi_fixture
character(len=len(text)) function to_upper_text(text) result(value)
character(len=*), intent(in) :: text
integer :: i