Add Solid output and restart

This commit is contained in:
Codex
2026-07-03 15:55:37 +08:00
parent c4a6f2191d
commit d14ea370e5
13 changed files with 951 additions and 55 deletions
+1 -1
View File
@@ -67,7 +67,7 @@ contains
close(91)
if (ios /= 0) call fail('restart header read failed')
if (trim(tag) /= 'SPHLITE_RESTART') call fail('restart tag mismatch')
if (trim(state) /= 'STATE_0_4_1') call fail('restart state version mismatch')
if (trim(state) /= 'STATE_0_5') call fail('restart state version mismatch')
end subroutine assert_restart_header
subroutine assert_ok(ierr_value, message)
+16 -2
View File
@@ -106,7 +106,7 @@ contains
subroutine check_particle_header(filename)
character(len=*), intent(in) :: filename
character(len=256) :: header
character(len=512) :: header
integer :: ios
open(unit=71, file=trim(filename), status='old', action='read', iostat=ios)
@@ -117,7 +117,10 @@ contains
if (trim(header) /= 'id,phase,status,material,section,x,y,z,' // &
'vx,vy,vz,rho,pressure,temperature,h,explosive_detonation_time,' // &
'explosive_lambda,explosive_initial_mass,explosive_remaining_mass,' // &
'explosive_released_mass,explosive_released_energy') then
'explosive_released_mass,explosive_released_energy,' // &
'solid_stress_xx,solid_stress_yy,solid_stress_zz,solid_stress_xy,' // &
'solid_stress_yz,solid_stress_zx,solid_plastic_strain,solid_damage,' // &
'solid_softening,solid_failure_status') then
call fail('particle CSV header mismatch')
end if
end subroutine check_particle_header
@@ -156,6 +159,17 @@ contains
call assert_summary_metric(filename, 'explosive_converted_particles')
call assert_summary_metric(filename, 'explosive_source_particles')
call assert_summary_metric(filename, 'explosive_source_mass_total')
call assert_summary_metric(filename, 'solid_particles')
call assert_summary_metric(filename, 'solid_failed_particles')
call assert_summary_metric(filename, 'solid_mass')
call assert_summary_metric(filename, 'solid_momentum_x')
call assert_summary_metric(filename, 'solid_kinetic_energy')
call assert_summary_metric(filename, 'solid_internal_energy')
call assert_summary_metric(filename, 'solid_max_von_mises')
call assert_summary_metric(filename, 'solid_plastic_strain_min')
call assert_summary_metric(filename, 'solid_damage_max')
call assert_summary_metric(filename, 'solid_softening_min')
call assert_summary_metric(filename, 'solid_dtcrit')
end subroutine check_summary_metrics
subroutine assert_summary_metric(filename, metric)
+1 -1
View File
@@ -168,7 +168,7 @@ contains
call fail('restart version mismatch')
end if
if (patch /= SPH_VERSION_PATCH) call fail('restart patch mismatch')
if (trim(state_version) /= 'STATE_0_4_1') call fail('restart state version mismatch')
if (trim(state_version) /= 'STATE_0_5') call fail('restart state version mismatch')
read(74, *, iostat=ios) file_time, file_step, count
if (ios /= 0) call fail('restart time state read failed')
if (abs(file_time - expected_time) > 1.0e-12_rk) call fail('restart time write mismatch')
+271
View File
@@ -0,0 +1,271 @@
program test_solid_output
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, &
sph_estimate_stable_dt, sph_set_output_directory, sph_write_output
use sph_database, only: v, solid_particle_count, solid_failed_count, &
solid_dtcrit, SPH_STATUS_FAILED
use sph_solid, only: sph_solid_mark_particle_failed
use sph_solid_state, only: solid_stress, solid_plastic_strain, solid_damage, &
solid_softening, solid_internal_energy, solid_failure_status
use sph_solid_dynamics, only: sph_solid_update_diagnostics
implicit none
integer :: ierr
call check_solid_output_fields()
contains
subroutine check_solid_output_fields()
real(rk) :: dtcrit
call delete_output_pair(50)
call sph_initialize(ierr)
call assert_ok(ierr, 'initialize failed for Solid output')
call sph_read_inp('tests/data/solid_body_force_050.inp', ierr)
call assert_ok(ierr, 'read failed for Solid output')
call sph_build_model(ierr)
call assert_ok(ierr, 'build failed for Solid output')
call seed_solid_state()
call sph_solid_mark_particle_failed(2, ierr)
call assert_ok(ierr, 'mark Solid failed particle failed')
call sph_estimate_stable_dt(dtcrit, ierr)
call assert_ok(ierr, 'Solid output dt estimate failed')
call sph_solid_update_diagnostics(ierr)
call assert_ok(ierr, 'Solid output diagnostics failed')
call sph_set_output_directory('build-codex-unix', ierr)
call assert_ok(ierr, 'Solid output directory failed')
call sph_write_output(50, 0.0_rk, ierr)
call assert_ok(ierr, 'Solid output write failed')
call check_particle_csv('build-codex-unix/sphlite_00000050.csv')
call check_summary_csv('build-codex-unix/sphlite_00000050_summary.csv')
call sph_finalize(ierr)
call assert_ok(ierr, 'finalize failed for Solid output')
end subroutine check_solid_output_fields
subroutine seed_solid_state()
v(:,1) = (/2.0_rk, 3.0_rk, 4.0_rk/)
solid_stress(:,1) = (/1.0_rk, 2.0_rk, 3.0_rk, &
4.0_rk, 5.0_rk, 6.0_rk/)
solid_plastic_strain(1) = 0.25_rk
solid_damage(1) = 0.40_rk
solid_softening(1) = 0.60_rk
solid_internal_energy(1) = 2.0_rk
solid_failure_status(1) = 0
end subroutine seed_solid_state
subroutine check_particle_csv(filename)
character(len=*), intent(in) :: filename
character(len=512) :: header
integer :: unit
integer :: ios
integer :: id
integer :: phase
integer :: status
integer :: mat
integer :: sec
integer :: failure
real(rk) :: pos(3)
real(rk) :: vel(3)
real(rk) :: scalar_values(4)
real(rk) :: explosive_values(6)
real(rk) :: stress_values(6)
real(rk) :: plastic
real(rk) :: damage
real(rk) :: softening
unit = 84
open(unit=unit, file=trim(filename), status='old', action='read', iostat=ios)
if (ios /= 0) call fail('Solid particle CSV open failed')
read(unit, '(A)', iostat=ios) header
if (ios /= 0) call fail('Solid particle CSV header read failed')
if (trim(header) /= 'id,phase,status,material,section,x,y,z,' // &
'vx,vy,vz,rho,pressure,temperature,h,explosive_detonation_time,' // &
'explosive_lambda,explosive_initial_mass,explosive_remaining_mass,' // &
'explosive_released_mass,explosive_released_energy,' // &
'solid_stress_xx,solid_stress_yy,solid_stress_zz,solid_stress_xy,' // &
'solid_stress_yz,solid_stress_zx,solid_plastic_strain,solid_damage,' // &
'solid_softening,solid_failure_status') then
call fail('Solid particle CSV header mismatch')
end if
read(unit, *, iostat=ios) id, phase, status, mat, sec, pos, vel, &
scalar_values, explosive_values, stress_values, plastic, damage, &
softening, failure
close(unit=unit)
if (ios /= 0) call fail('Solid particle CSV row read failed')
if (id /= 1) call fail('Solid particle CSV id mismatch')
if (maxval(abs(vel - (/2.0_rk, 3.0_rk, 4.0_rk/))) > 1.0e-12_rk) then
call fail('Solid particle CSV velocity mismatch')
end if
if (maxval(abs(stress_values - solid_stress(:,1))) > 1.0e-12_rk) then
call fail('Solid particle CSV stress mismatch')
end if
if (abs(plastic - solid_plastic_strain(1)) > 1.0e-12_rk) then
call fail('Solid particle CSV plastic strain mismatch')
end if
if (abs(damage - solid_damage(1)) > 1.0e-12_rk) then
call fail('Solid particle CSV damage mismatch')
end if
if (abs(softening - solid_softening(1)) > 1.0e-12_rk) then
call fail('Solid particle CSV softening mismatch')
end if
if (failure /= solid_failure_status(1)) call fail('Solid particle CSV failure mismatch')
end subroutine check_particle_csv
subroutine check_summary_csv(filename)
character(len=*), intent(in) :: filename
call assert_summary_int(filename, 'solid_particles', solid_particle_count)
call assert_summary_int(filename, 'solid_failed_particles', solid_failed_count)
if (solid_particle_count /= 1) call fail('Solid summary active count mismatch')
if (solid_failed_count /= 1) call fail('Solid summary failed count mismatch')
call assert_summary_present(filename, 'solid_mass')
call assert_summary_present(filename, 'solid_momentum_x')
call assert_summary_present(filename, 'solid_momentum_y')
call assert_summary_present(filename, 'solid_momentum_z')
call assert_summary_positive(filename, 'solid_kinetic_energy')
call assert_summary_positive(filename, 'solid_internal_energy')
call assert_summary_positive(filename, 'solid_max_von_mises')
call assert_summary_present(filename, 'solid_plastic_strain_min')
call assert_summary_present(filename, 'solid_plastic_strain_max')
call assert_summary_present(filename, 'solid_damage_min')
call assert_summary_present(filename, 'solid_damage_max')
call assert_summary_present(filename, 'solid_softening_min')
call assert_summary_present(filename, 'solid_softening_max')
call assert_summary_positive(filename, 'solid_dt_cfl')
call assert_summary_positive(filename, 'solid_dt_accel')
call assert_summary_positive(filename, 'solid_dtcrit')
if (solid_dtcrit <= 0.0_rk) call fail('Solid dtcrit diagnostic missing')
end subroutine check_summary_csv
subroutine assert_summary_present(filename, metric)
character(len=*), intent(in) :: filename
character(len=*), intent(in) :: metric
character(len=256) :: line
integer :: unit
integer :: ios
logical :: found
found = .false.
unit = 85
open(unit=unit, file=trim(filename), status='old', action='read', iostat=ios)
if (ios /= 0) call fail('Solid summary CSV open failed')
do
read(unit, '(A)', iostat=ios) line
if (ios /= 0) exit
if (index(line, trim(metric) // ',') == 1) found = .true.
end do
close(unit=unit)
if (.not. found) call fail('Solid summary metric missing')
end subroutine assert_summary_present
subroutine assert_summary_int(filename, metric, expected)
character(len=*), intent(in) :: filename
character(len=*), intent(in) :: metric
integer, intent(in) :: expected
integer :: actual
call read_summary_int(filename, metric, actual)
if (actual /= expected) call fail('Solid summary integer mismatch')
end subroutine assert_summary_int
subroutine assert_summary_positive(filename, metric)
character(len=*), intent(in) :: filename
character(len=*), intent(in) :: metric
real(rk) :: value
call read_summary_real(filename, metric, value)
if (value <= 0.0_rk) call fail('Solid summary positive metric missing')
end subroutine assert_summary_positive
subroutine read_summary_int(filename, metric, value)
character(len=*), intent(in) :: filename
character(len=*), intent(in) :: metric
integer, intent(out) :: value
character(len=256) :: line
integer :: unit
integer :: ios
integer :: start
unit = 86
open(unit=unit, file=trim(filename), status='old', action='read', iostat=ios)
if (ios /= 0) call fail('Solid summary integer open failed')
do
read(unit, '(A)', iostat=ios) line
if (ios /= 0) exit
if (index(line, trim(metric) // ',') == 1) then
start = len_trim(metric) + 2
read(line(start:), *, iostat=ios) value
close(unit=unit)
if (ios /= 0) call fail('Solid summary integer parse failed')
return
end if
end do
close(unit=unit)
call fail('Solid summary integer missing')
end subroutine read_summary_int
subroutine read_summary_real(filename, metric, value)
character(len=*), intent(in) :: filename
character(len=*), intent(in) :: metric
real(rk), intent(out) :: value
character(len=256) :: line
integer :: unit
integer :: ios
integer :: start
unit = 87
open(unit=unit, file=trim(filename), status='old', action='read', iostat=ios)
if (ios /= 0) call fail('Solid summary real open failed')
do
read(unit, '(A)', iostat=ios) line
if (ios /= 0) exit
if (index(line, trim(metric) // ',') == 1) then
start = len_trim(metric) + 2
read(line(start:), *, iostat=ios) value
close(unit=unit)
if (ios /= 0) call fail('Solid summary real parse failed')
return
end if
end do
close(unit=unit)
call fail('Solid summary real missing')
end subroutine read_summary_real
subroutine delete_output_pair(step_value)
integer, intent(in) :: step_value
character(len=256) :: filename
write(filename, '("build-codex-unix/sphlite_",I8.8,".csv")') step_value
call delete_file_if_exists(filename)
write(filename, '("build-codex-unix/sphlite_",I8.8,"_summary.csv")') step_value
call delete_file_if_exists(filename)
end subroutine delete_output_pair
subroutine delete_file_if_exists(filename)
character(len=*), intent(in) :: filename
logical :: exists
integer :: ios
inquire(file=trim(filename), exist=exists)
if (.not. exists) return
open(unit=88, file=trim(filename), status='old', iostat=ios)
if (ios == 0) close(unit=88, status='delete')
end subroutine delete_file_if_exists
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_solid_output
@@ -0,0 +1,100 @@
program test_solid_restart_041_compat
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, &
sph_write_restart, sph_read_restart, sph_advance_explicit
use sph_database, only: solid_particle_count, solid_failed_count
use sph_solid, only: solid_material_count
use sph_solid_state, only: solid_stress
implicit none
integer :: ierr
call check_041_restart_clears_solid_state()
contains
subroutine check_041_restart_clears_solid_state()
call write_current_water_restart('build-codex-unix/restart_water_for_041.tmp')
call write_041_compat_restart('build-codex-unix/restart_water_for_041.tmp', &
'build-codex-unix/restart_solid_041_compat.tmp')
call sph_initialize(ierr)
call assert_ok(ierr, 'initialize failed for Solid 0.4.1 compat')
call sph_read_inp('tests/data/solid_elastic_minimal_050.inp', ierr)
call assert_ok(ierr, 'read Solid seed failed for 0.4.1 compat')
call sph_build_model(ierr)
call assert_ok(ierr, 'build Solid seed failed for 0.4.1 compat')
if (.not. allocated(solid_stress)) call fail('Solid seed state was not allocated')
call sph_read_restart('build-codex-unix/restart_solid_041_compat.tmp', ierr)
call assert_ok(ierr, 'read 0.4.1 restart failed for Solid compat')
if (solid_material_count /= 0) call fail('0.4.1 restart left Solid material table')
if (allocated(solid_stress)) call fail('0.4.1 restart left Solid particle state')
if (solid_particle_count /= 0) call fail('0.4.1 restart left Solid active count')
if (solid_failed_count /= 0) call fail('0.4.1 restart left Solid failed count')
call sph_advance_explicit(1.0e-7_rk, ierr)
call assert_ok(ierr, 'continue 0.4.1 restart failed for Solid compat')
call sph_finalize(ierr)
call assert_ok(ierr, 'finalize failed for Solid 0.4.1 compat')
end subroutine check_041_restart_clears_solid_state
subroutine write_current_water_restart(filename)
character(len=*), intent(in) :: filename
call sph_initialize(ierr)
call assert_ok(ierr, 'initialize water fixture failed')
call sph_read_inp('tests/data/water_minimal_020.inp', ierr)
call assert_ok(ierr, 'read water fixture failed')
call sph_build_model(ierr)
call assert_ok(ierr, 'build water fixture failed')
call sph_write_restart(filename, ierr)
call assert_ok(ierr, 'write water fixture failed')
call sph_finalize(ierr)
call assert_ok(ierr, 'finalize water fixture failed')
end subroutine write_current_water_restart
subroutine write_041_compat_restart(source_filename, target_filename)
character(len=*), intent(in) :: source_filename
character(len=*), intent(in) :: target_filename
character(len=512) :: lines(256)
character(len=512) :: line
integer :: line_count
integer :: i
integer :: ios
line_count = 0
open(unit=94, file=trim(source_filename), status='old', action='read', iostat=ios)
if (ios /= 0) call fail('open source restart for 0.4.1 compat failed')
do
read(94, '(A)', iostat=ios) line
if (ios /= 0) exit
line_count = line_count + 1
if (line_count > size(lines)) call fail('0.4.1 compat fixture is too large')
lines(line_count) = line
end do
close(unit=94)
if (line_count <= 7) call fail('0.4.1 compat fixture is too short')
lines(1) = 'SPHLITE_RESTART 0 4 1 STATE_0_4_1'
open(unit=95, file=trim(target_filename), status='unknown', action='write', &
iostat=ios)
if (ios /= 0) call fail('open target restart for 0.4.1 compat failed')
do i = 1, line_count - 7
write(95, '(A)') trim(lines(i))
end do
close(unit=95)
end subroutine write_041_compat_restart
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_solid_restart_041_compat
+211
View File
@@ -0,0 +1,211 @@
program test_solid_restart_050
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, &
sph_estimate_stable_dt, sph_advance_explicit, sph_write_restart, &
sph_read_restart
use sph_database, only: particle_phase, particle_status, solid_particle_count, &
solid_failed_count, solid_dtcrit, SPH_PHASE_SOLID_FAILED, SPH_STATUS_FAILED
use sph_solid, only: solid_material_count, solid_material_names, &
solid_elastic_e, solid_elastic_nu, solid_johnson_cook_defined, &
solid_jc_a, solid_failure_defined, solid_failure_d, solid_softening_width, &
sph_solid_mark_particle_failed
use sph_solid_state, only: solid_body_force, solid_stress, solid_strain, &
solid_plastic_strain, solid_plastic_strain_rate, solid_temperature, &
solid_damage, solid_softening, solid_internal_energy, &
solid_reference_volume, solid_deformation_gradient, &
solid_correction_matrix, solid_acc_internal, solid_failure_status
use sph_solid_dynamics, only: sph_solid_update_diagnostics
implicit none
integer :: ierr
call check_solid_restart_round_trip()
contains
subroutine check_solid_restart_round_trip()
real(rk) :: expected_stress(6)
real(rk) :: expected_strain(6)
real(rk) :: expected_deformation(3,3)
real(rk) :: expected_correction(3,3)
real(rk) :: expected_acc_internal(3)
real(rk) :: expected_dtcrit
call sph_initialize(ierr)
call assert_ok(ierr, 'initialize failed for Solid restart')
call sph_read_inp('tests/data/solid_restart_050.inp', ierr)
call assert_ok(ierr, 'read failed for Solid restart')
call sph_build_model(ierr)
call assert_ok(ierr, 'build failed for Solid restart')
call seed_solid_restart_state(expected_stress, expected_strain, &
expected_deformation, expected_correction, expected_acc_internal)
call sph_estimate_stable_dt(expected_dtcrit, ierr)
call assert_ok(ierr, 'Solid restart dt estimate failed')
expected_dtcrit = solid_dtcrit
call sph_solid_update_diagnostics(ierr)
call assert_ok(ierr, 'Solid restart diagnostics failed')
call sph_write_restart('build-codex-unix/restart_solid_050.tmp', ierr)
call assert_ok(ierr, 'Solid restart write failed')
call scramble_solid_state()
call sph_read_restart('build-codex-unix/restart_solid_050.tmp', ierr)
call assert_ok(ierr, 'Solid restart read failed')
call assert_material_table_restored()
call assert_particle_state_restored(expected_stress, expected_strain, &
expected_deformation, expected_correction, expected_acc_internal)
if (solid_particle_count /= 3) call fail('Solid restart active count mismatch')
if (solid_failed_count /= 1) call fail('Solid restart failed count mismatch')
if (abs(solid_dtcrit - expected_dtcrit) > 1.0e-12_rk) then
call fail('Solid restart dtcrit mismatch')
end if
call sph_advance_explicit(1.0e-8_rk, ierr)
call assert_ok(ierr, 'Solid restart continuation failed')
call sph_finalize(ierr)
call assert_ok(ierr, 'finalize failed for Solid restart')
end subroutine check_solid_restart_round_trip
subroutine seed_solid_restart_state(expected_stress, expected_strain, &
expected_deformation, expected_correction, expected_acc_internal)
real(rk), intent(out) :: expected_stress(6)
real(rk), intent(out) :: expected_strain(6)
real(rk), intent(out) :: expected_deformation(3,3)
real(rk), intent(out) :: expected_correction(3,3)
real(rk), intent(out) :: expected_acc_internal(3)
expected_stress = (/11.0_rk, 22.0_rk, 33.0_rk, &
4.0_rk, 5.0_rk, 6.0_rk/)
expected_strain = (/0.01_rk, 0.02_rk, 0.03_rk, &
0.004_rk, 0.005_rk, 0.006_rk/)
expected_deformation = reshape((/1.10_rk, 0.01_rk, 0.02_rk, &
0.03_rk, 1.20_rk, 0.04_rk, 0.05_rk, 0.06_rk, 1.30_rk/), (/3,3/))
expected_correction = reshape((/0.90_rk, 0.07_rk, 0.08_rk, &
0.09_rk, 0.80_rk, 0.10_rk, 0.11_rk, 0.12_rk, 0.70_rk/), (/3,3/))
expected_acc_internal = (/1.1_rk, 2.2_rk, 3.3_rk/)
solid_body_force = (/0.10_rk, 0.20_rk, 0.30_rk/)
solid_stress(:,1) = expected_stress
solid_strain(:,1) = expected_strain
solid_plastic_strain(1) = 0.125_rk
solid_plastic_strain_rate(1) = 2.5_rk
solid_temperature(1) = 310.0_rk
solid_damage(1) = 0.35_rk
solid_softening(1) = 0.65_rk
solid_internal_energy(1) = 9.5_rk
solid_reference_volume(1) = 0.00123_rk
solid_deformation_gradient(:,:,1) = expected_deformation
solid_correction_matrix(:,:,1) = expected_correction
solid_acc_internal(:,1) = expected_acc_internal
solid_failure_status(1) = 0
call sph_solid_mark_particle_failed(4, ierr)
call assert_ok(ierr, 'mark Solid failed particle for restart failed')
end subroutine seed_solid_restart_state
subroutine scramble_solid_state()
solid_body_force = -999.0_rk
solid_stress = -999.0_rk
solid_strain = -999.0_rk
solid_plastic_strain = -999.0_rk
solid_plastic_strain_rate = -999.0_rk
solid_temperature = -999.0_rk
solid_damage = -999.0_rk
solid_softening = -999.0_rk
solid_internal_energy = -999.0_rk
solid_reference_volume = -999.0_rk
solid_deformation_gradient = -999.0_rk
solid_correction_matrix = -999.0_rk
solid_acc_internal = -999.0_rk
solid_failure_status = -999
end subroutine scramble_solid_state
subroutine assert_material_table_restored()
if (solid_material_count /= 1) call fail('Solid restart material count mismatch')
if (trim(solid_material_names(1)) /= 'STEEL_RESTART') then
call fail('Solid restart material name mismatch')
end if
if (abs(solid_elastic_e(1) - 210.0e9_rk) > 1.0e-3_rk) then
call fail('Solid restart elastic modulus mismatch')
end if
if (abs(solid_elastic_nu(1) - 0.30_rk) > 1.0e-12_rk) then
call fail('Solid restart Poisson ratio mismatch')
end if
if (.not. solid_johnson_cook_defined(1)) then
call fail('Solid restart Johnson-Cook flag missing')
end if
if (abs(solid_jc_a(1) - 792.0e6_rk) > 1.0e-3_rk) then
call fail('Solid restart Johnson-Cook A mismatch')
end if
if (.not. solid_failure_defined(1)) call fail('Solid restart failure flag missing')
if (abs(solid_failure_d(1,1) - 0.05_rk) > 1.0e-12_rk) then
call fail('Solid restart failure parameter mismatch')
end if
if (abs(solid_softening_width(1) - 0.25_rk) > 1.0e-12_rk) then
call fail('Solid restart softening width mismatch')
end if
end subroutine assert_material_table_restored
subroutine assert_particle_state_restored(expected_stress, expected_strain, &
expected_deformation, expected_correction, expected_acc_internal)
real(rk), intent(in) :: expected_stress(6)
real(rk), intent(in) :: expected_strain(6)
real(rk), intent(in) :: expected_deformation(3,3)
real(rk), intent(in) :: expected_correction(3,3)
real(rk), intent(in) :: expected_acc_internal(3)
if (maxval(abs(solid_body_force - (/0.10_rk, 0.20_rk, 0.30_rk/))) > &
1.0e-12_rk) call fail('Solid restart body force mismatch')
if (maxval(abs(solid_stress(:,1) - expected_stress)) > 1.0e-12_rk) then
call fail('Solid restart stress mismatch')
end if
if (maxval(abs(solid_strain(:,1) - expected_strain)) > 1.0e-12_rk) then
call fail('Solid restart strain mismatch')
end if
if (abs(solid_plastic_strain(1) - 0.125_rk) > 1.0e-12_rk) then
call fail('Solid restart plastic strain mismatch')
end if
if (abs(solid_plastic_strain_rate(1) - 2.5_rk) > 1.0e-12_rk) then
call fail('Solid restart plastic rate mismatch')
end if
if (abs(solid_temperature(1) - 310.0_rk) > 1.0e-12_rk) then
call fail('Solid restart temperature mismatch')
end if
if (abs(solid_damage(1) - 0.35_rk) > 1.0e-12_rk) then
call fail('Solid restart damage mismatch')
end if
if (abs(solid_softening(1) - 0.65_rk) > 1.0e-12_rk) then
call fail('Solid restart softening mismatch')
end if
if (abs(solid_internal_energy(1) - 9.5_rk) > 1.0e-12_rk) then
call fail('Solid restart internal energy mismatch')
end if
if (abs(solid_reference_volume(1) - 0.00123_rk) > 1.0e-12_rk) then
call fail('Solid restart reference volume mismatch')
end if
if (maxval(abs(solid_deformation_gradient(:,:,1) - expected_deformation)) > &
1.0e-12_rk) call fail('Solid restart deformation mismatch')
if (maxval(abs(solid_correction_matrix(:,:,1) - expected_correction)) > &
1.0e-12_rk) call fail('Solid restart correction mismatch')
if (maxval(abs(solid_acc_internal(:,1) - expected_acc_internal)) > &
1.0e-12_rk) call fail('Solid restart internal acceleration mismatch')
if (solid_failure_status(4) /= SPH_STATUS_FAILED) then
call fail('Solid restart failure status mismatch')
end if
if (particle_status(4) /= SPH_STATUS_FAILED) call fail('Solid restart status mismatch')
if (particle_phase(4) /= SPH_PHASE_SOLID_FAILED) then
call fail('Solid restart failed phase mismatch')
end if
end subroutine assert_particle_state_restored
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_solid_restart_050