Validate SPHLite time control and particle state

This commit is contained in:
Codex
2026-07-02 22:57:23 +08:00
parent 8321ed1b36
commit 576a5c09c7
8 changed files with 277 additions and 63 deletions
+20 -42
View File
@@ -1,7 +1,8 @@
module sph_input_reader
use sph_precision, only: rk, SPH_NDIM
use sph_error, only: SPH_SUCCESS, SPH_ERROR_IO, SPH_ERROR_INPUT, sph_error_set
use sph_control, only: sph_control_set_time
use sph_error, only: SPH_SUCCESS, SPH_ERROR_IO, SPH_ERROR_INPUT, sph_error_set, &
sph_error_get
use sph_input_time, only: sph_input_parse_time_control
use sph_output_csv, only: sph_output_set_directory, sph_output_set_interval
use sph_database, only: npart, SPH_MAX_ELEMENT_NODES, &
SPH_REGION_COUPLING_CONTACT, SPH_REGION_COUPLING_CONTINUUM, &
@@ -263,7 +264,8 @@ contains
else if (key_id == SPH_KEY_SPHLITE) then
if (index(upper_line, 'TIME CONTROL') > 0) then
input_has_time_control = .true.
call sph_input_parse_time_control(line)
call sph_input_parse_time_control(line, input_current_file, &
input_current_line, ierr)
else if (index(upper_line, 'OUTPUT') > 0) then
call sph_input_parse_output_control(line, ierr)
else if (index(upper_line, 'COUPLING REGION') > 0) then
@@ -291,6 +293,7 @@ contains
else if (key_id == SPH_KEY_UNKNOWN) then
input_warning_count = input_warning_count + 1
end if
if (ierr /= SPH_SUCCESS) call sph_input_prefix_current_error(ierr)
end subroutine sph_input_record_keyword
subroutine sph_input_parse_water_eos(line, ierr)
@@ -450,45 +453,6 @@ contains
call sph_db_add_coupling_region(name, set_name, region_type, ierr)
end subroutine sph_input_parse_coupling_region
subroutine sph_input_parse_time_control(line)
character(len=*), intent(in) :: line
character(len=SPH_INPUT_FIELD_LEN) :: fields(SPH_INPUT_MAX_FIELDS)
character(len=SPH_INPUT_FIELD_LEN) :: item
character(len=SPH_INPUT_FIELD_LEN) :: key
character(len=SPH_INPUT_FIELD_LEN) :: value
integer :: nfields
integer :: i
integer :: eq_pos
integer :: ios
real(rk) :: dt
real(rk) :: total_time
integer :: steps
real(rk) :: safety
dt = -1.0_rk
total_time = -1.0_rk
steps = -1
safety = -1.0_rk
call sph_inp_split_csv(line, fields, nfields)
do i = 1, nfields
item = adjustl(fields(i))
eq_pos = index(item, '=')
if (eq_pos <= 0) cycle
key = sph_inp_upper(adjustl(item(1:eq_pos-1)))
value = adjustl(item(eq_pos+1:len_trim(item)))
if (index(key, 'DT') == 1) then
read(value, *, iostat=ios) dt
else if (index(key, 'TIME') == 1 .or. index(key, 'END TIME') == 1) then
read(value, *, iostat=ios) total_time
else if (index(key, 'STEPS') == 1 .or. index(key, 'MAX STEPS') == 1) then
read(value, *, iostat=ios) steps
else if (index(key, 'SAFETY') == 1) then
read(value, *, iostat=ios) safety
end if
end do
call sph_control_set_time(dt, total_time, steps, safety)
end subroutine sph_input_parse_time_control
subroutine sph_input_parse_node(line, node_index, ierr)
character(len=*), intent(in) :: line
integer, intent(in) :: node_index
@@ -678,4 +642,18 @@ contains
call sph_error_set(SPH_ERROR_INPUT, trim(full_message))
end subroutine sph_input_set_error
subroutine sph_input_prefix_current_error(ierr)
integer, intent(in) :: ierr
integer :: code
character(len=SPH_INPUT_LINE_LEN) :: message
character(len=SPH_INPUT_LINE_LEN) :: full_message
if (ierr == SPH_SUCCESS) return
call sph_error_get(code, message)
if (index(trim(message), trim(input_current_file)//':') == 1) return
write(full_message, '(A,":",I0,": ",A)') trim(input_current_file), &
input_current_line, trim(message)
call sph_error_set(code, trim(full_message))
end subroutine sph_input_prefix_current_error
end module sph_input_reader