program test_input_solid_material 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_get_input_warning_count use sph_database, only: material_count, section_count, particle_phase, & material_id, SPH_PHASE_SOLID use sph_solid, only: solid_material_count, solid_material_ids, & solid_elastic_defined, solid_johnson_cook_defined, & solid_failure_defined, solid_control_defined, solid_elastic_e, & solid_elastic_nu, solid_jc_a, solid_jc_epsdot0, & solid_failure_d, solid_softening_width implicit none integer :: ierr integer :: warnings call check_elastic_input() call check_johnson_cook_input() call check_multisection_input() call check_unbound_warning() contains subroutine check_elastic_input() call sph_initialize(ierr) call assert_ok(ierr, 'initialize failed for elastic Solid input') call sph_read_inp('tests/data/solid_elastic_minimal_050.inp', ierr) call assert_ok(ierr, 'read failed for elastic Solid input') call sph_build_model(ierr) call assert_ok(ierr, 'build failed for elastic Solid input') if (solid_material_count /= 1) call fail('elastic Solid material count mismatch') if (section_count /= 1) call fail('elastic Solid section count mismatch') if (.not. solid_elastic_defined(1)) call fail('elastic Solid data missing') if (abs(solid_elastic_e(1) - 210.0e9_rk) > 1.0e3_rk) call fail('elastic modulus mismatch') if (abs(solid_elastic_nu(1) - 0.30_rk) > 1.0e-12_rk) call fail('Poisson ratio mismatch') if (any(particle_phase(1:4) /= SPH_PHASE_SOLID)) call fail('Solid phase mismatch') call sph_finalize(ierr) call assert_ok(ierr, 'finalize failed for elastic Solid input') end subroutine check_elastic_input subroutine check_johnson_cook_input() call sph_initialize(ierr) call assert_ok(ierr, 'initialize failed for Johnson-Cook Solid input') call sph_read_inp('tests/data/solid_johnson_cook_failure_050.inp', ierr) call assert_ok(ierr, 'read failed for Johnson-Cook Solid input') call sph_build_model(ierr) call assert_ok(ierr, 'build failed for Johnson-Cook Solid input') if (solid_material_count /= 1) call fail('Johnson-Cook Solid material count mismatch') if (.not. solid_johnson_cook_defined(1)) call fail('Johnson-Cook flow missing') if (.not. solid_failure_defined(1)) call fail('Johnson-Cook failure missing') if (.not. solid_control_defined(1)) call fail('Solid control missing') if (solid_jc_a(1) <= 0.0_rk) call fail('Johnson-Cook A mismatch') if (solid_jc_epsdot0(1) <= 0.0_rk) call fail('Johnson-Cook epsdot0 mismatch') if (abs(solid_failure_d(1,1) - 0.05_rk) > 1.0e-12_rk) call fail('failure D1 mismatch') if (abs(solid_softening_width(1) - 0.25_rk) > 1.0e-12_rk) call fail('softening mismatch') call sph_finalize(ierr) call assert_ok(ierr, 'finalize failed for Johnson-Cook Solid input') end subroutine check_johnson_cook_input subroutine check_multisection_input() call sph_initialize(ierr) call assert_ok(ierr, 'initialize failed for Solid multisection input') call sph_read_inp('tests/data/solid_section_050.inp', ierr) call assert_ok(ierr, 'read failed for Solid multisection input') call sph_build_model(ierr) call assert_ok(ierr, 'build failed for Solid multisection input') if (material_count /= 2) call fail('Solid material metadata count mismatch') if (section_count /= 2) call fail('Solid section metadata count mismatch') if (solid_material_count /= 2) call fail('Solid table count mismatch') if (material_id(1) /= solid_material_ids(1)) call fail('first Solid material mapping mismatch') if (material_id(4) /= solid_material_ids(2)) call fail('second Solid material mapping mismatch') call sph_finalize(ierr) call assert_ok(ierr, 'finalize failed for Solid multisection input') end subroutine check_multisection_input subroutine check_unbound_warning() call sph_initialize(ierr) call assert_ok(ierr, 'initialize failed for unbound Solid input') call sph_read_inp('tests/data/solid_unbound_material_warning_050.inp', ierr) call assert_ok(ierr, 'read failed for unbound Solid input') call sph_build_model(ierr) call assert_ok(ierr, 'build failed for unbound Solid input') call sph_get_input_warning_count(warnings, ierr) call assert_ok(ierr, 'warning count failed for unbound Solid input') if (warnings <= 0) call fail('unbound Solid material warning missing') call sph_finalize(ierr) call assert_ok(ierr, 'finalize failed for unbound Solid input') end subroutine check_unbound_warning 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_input_solid_material