Add 0.8.1 contact diagnostics
This commit is contained in:
@@ -0,0 +1,160 @@
|
||||
program test_coupling_contact_diagnostics_081
|
||||
use sph_precision, only: rk, SPH_NDIM
|
||||
use sph_error, only: SPH_SUCCESS
|
||||
use sph_api, only: sph_initialize, sph_finalize, sph_read_inp, sph_build_model
|
||||
use sph_database, only: particle_status, SPH_STATUS_INACTIVE
|
||||
use sph_coupling_interface, only: coupling_contact_flag, &
|
||||
coupling_contact_normal, coupling_contact_gap, &
|
||||
coupling_contact_penetration, coupling_contact_pressure, &
|
||||
sph_coupling_apply_contact_state, sph_coupling_get_contact_diagnostics
|
||||
implicit none
|
||||
|
||||
integer :: ierr
|
||||
|
||||
call check_contact_state_values()
|
||||
call check_contact_state_errors()
|
||||
|
||||
contains
|
||||
|
||||
subroutine check_contact_state_values()
|
||||
integer :: ids(2)
|
||||
integer :: one_id(1)
|
||||
integer :: empty_ids(0)
|
||||
real(rk) :: normals(SPH_NDIM,2)
|
||||
real(rk) :: one_normal(SPH_NDIM,1)
|
||||
real(rk) :: empty_normals(SPH_NDIM,0)
|
||||
real(rk) :: gaps(2)
|
||||
real(rk) :: penetrations(2)
|
||||
real(rk) :: contact_pressures(2)
|
||||
real(rk) :: one_gap(1)
|
||||
real(rk) :: one_penetration(1)
|
||||
real(rk) :: one_pressure(1)
|
||||
real(rk) :: empty_scalars(0)
|
||||
integer :: active_count
|
||||
integer :: skipped_count
|
||||
integer :: stale_count
|
||||
integer :: repeated_count
|
||||
integer :: nonfinite_count
|
||||
integer :: bad_area_count
|
||||
integer :: invalid_weight_count
|
||||
real(rk) :: max_penetration
|
||||
|
||||
call build_case()
|
||||
ids = (/ 1, 2 /)
|
||||
normals(:,1) = (/ 0.0_rk, 0.0_rk, 2.0_rk /)
|
||||
normals(:,2) = (/ 0.0_rk, 0.0_rk, 1.0_rk /)
|
||||
gaps = (/ 1.0e-4_rk, 2.0e-4_rk /)
|
||||
penetrations = (/ 2.0e-3_rk, 4.0e-3_rk /)
|
||||
contact_pressures = (/ 8.0_rk, 6.0_rk /)
|
||||
call sph_coupling_apply_contact_state(1, 2, ids, normals, gaps, &
|
||||
penetrations, contact_pressures, 101, ierr)
|
||||
call assert_ok(ierr, 'contact state import failed')
|
||||
if (coupling_contact_flag(1) /= 1) call fail('contact flag missing')
|
||||
call assert_close(coupling_contact_normal(3,1), 1.0_rk, &
|
||||
'contact normal was not normalized')
|
||||
call assert_close(coupling_contact_gap(2), gaps(2), 'contact gap mismatch')
|
||||
call assert_close(coupling_contact_penetration(2), penetrations(2), &
|
||||
'contact penetration mismatch')
|
||||
call assert_close(coupling_contact_pressure(1), contact_pressures(1), &
|
||||
'contact pressure mismatch')
|
||||
|
||||
one_id(1) = 3
|
||||
one_normal(:,1) = (/ 0.0_rk, 0.0_rk, 1.0_rk /)
|
||||
one_gap(1) = 0.0_rk
|
||||
one_penetration(1) = 1.0e-3_rk
|
||||
one_pressure(1) = 1.0_rk
|
||||
particle_status(3) = SPH_STATUS_INACTIVE
|
||||
call sph_coupling_apply_contact_state(1, 1, one_id, one_normal, one_gap, &
|
||||
one_penetration, one_pressure, 101, ierr)
|
||||
call assert_ok(ierr, 'skipped contact import failed')
|
||||
|
||||
call sph_coupling_get_contact_diagnostics(active_count, skipped_count, &
|
||||
max_penetration, stale_count, repeated_count, nonfinite_count, &
|
||||
bad_area_count, invalid_weight_count, ierr)
|
||||
call assert_ok(ierr, 'contact diagnostics failed')
|
||||
if (active_count /= 2) call fail('active contact count mismatch')
|
||||
if (skipped_count /= 1) call fail('skipped contact count mismatch')
|
||||
if (repeated_count <= 0) call fail('repeated contact diagnostic missing')
|
||||
call assert_close(max_penetration, 4.0e-3_rk, &
|
||||
'max penetration mismatch')
|
||||
if (nonfinite_count /= 0) call fail('unexpected nonfinite contact count')
|
||||
|
||||
call sph_coupling_apply_contact_state(1, 0, empty_ids, empty_normals, &
|
||||
empty_scalars, empty_scalars, empty_scalars, 102, ierr)
|
||||
call assert_ok(ierr, 'empty contact import failed')
|
||||
call sph_coupling_get_contact_diagnostics(active_count, skipped_count, &
|
||||
max_penetration, stale_count, repeated_count, nonfinite_count, &
|
||||
bad_area_count, invalid_weight_count, ierr)
|
||||
call assert_ok(ierr, 'empty contact diagnostics failed')
|
||||
if (active_count /= 0) call fail('empty contact import left active state')
|
||||
call sph_finalize(ierr)
|
||||
call assert_ok(ierr, 'finalize failed after contact values')
|
||||
end subroutine check_contact_state_values
|
||||
|
||||
subroutine check_contact_state_errors()
|
||||
integer :: ids(1)
|
||||
real(rk) :: normals(SPH_NDIM,1)
|
||||
real(rk) :: gaps(1)
|
||||
real(rk) :: penetrations(1)
|
||||
real(rk) :: contact_pressures(1)
|
||||
integer :: active_count
|
||||
integer :: skipped_count
|
||||
integer :: stale_count
|
||||
integer :: repeated_count
|
||||
integer :: nonfinite_count
|
||||
integer :: bad_area_count
|
||||
integer :: invalid_weight_count
|
||||
real(rk) :: max_penetration
|
||||
|
||||
call build_case()
|
||||
ids(1) = 1
|
||||
normals(:,1) = (/ 0.0_rk, 0.0_rk, 1.0_rk /)
|
||||
gaps(1) = 0.0_rk
|
||||
penetrations(1) = 0.0_rk
|
||||
contact_pressures(1) = huge(contact_pressures(1))
|
||||
call sph_coupling_apply_contact_state(1, 1, ids, normals, gaps, &
|
||||
penetrations, contact_pressures, 111, ierr)
|
||||
if (ierr == SPH_SUCCESS) call fail('nonfinite contact state did not fail')
|
||||
call sph_coupling_get_contact_diagnostics(active_count, skipped_count, &
|
||||
max_penetration, stale_count, repeated_count, nonfinite_count, &
|
||||
bad_area_count, invalid_weight_count, ierr)
|
||||
call assert_ok(ierr, 'contact error diagnostics failed')
|
||||
if (nonfinite_count <= 0) call fail('nonfinite contact diagnostic missing')
|
||||
call sph_finalize(ierr)
|
||||
call assert_ok(ierr, 'finalize failed after contact errors')
|
||||
end subroutine check_contact_state_errors
|
||||
|
||||
subroutine build_case()
|
||||
call sph_initialize(ierr)
|
||||
call assert_ok(ierr, 'initialize failed for contact diagnostics')
|
||||
call sph_read_inp('tests/data/coupling_load_mode_081.inp', ierr)
|
||||
call assert_ok(ierr, 'read failed for contact diagnostics')
|
||||
call sph_build_model(ierr)
|
||||
call assert_ok(ierr, 'build failed for contact diagnostics')
|
||||
end subroutine build_case
|
||||
|
||||
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 assert_close(actual, expected, message)
|
||||
real(rk), intent(in) :: actual
|
||||
real(rk), intent(in) :: expected
|
||||
character(len=*), intent(in) :: message
|
||||
|
||||
if (abs(actual - expected) > max(1.0e-10_rk, abs(expected) * 1.0e-8_rk)) then
|
||||
call fail(message)
|
||||
end if
|
||||
end subroutine assert_close
|
||||
|
||||
subroutine fail(message)
|
||||
character(len=*), intent(in) :: message
|
||||
|
||||
write(*, '(A)') trim(message)
|
||||
stop 1
|
||||
end subroutine fail
|
||||
|
||||
end program test_coupling_contact_diagnostics_081
|
||||
@@ -0,0 +1,80 @@
|
||||
program test_coupling_mixed_pressure_motion_081
|
||||
use sph_precision, only: rk, SPH_NDIM
|
||||
use sph_error, only: SPH_SUCCESS
|
||||
use sph_api, only: sph_initialize, sph_finalize, sph_read_inp, &
|
||||
sph_build_model, sph_advance_explicit
|
||||
use sph_database, only: v, SPH_COUPLING_DISTRIBUTION_AREA
|
||||
use sph_coupling_interface, only: SPH_COUPLING_MOTION_DIRECT, &
|
||||
SPH_COUPLING_MOTION_VELOCITY, sph_coupling_apply_facet_pressures, &
|
||||
sph_coupling_apply_motion_boundary
|
||||
implicit none
|
||||
|
||||
integer :: ierr
|
||||
integer :: ids(2)
|
||||
real(rk) :: pressures(2)
|
||||
real(rk) :: target_velocity(SPH_NDIM)
|
||||
|
||||
call sph_initialize(ierr)
|
||||
call assert_ok(ierr, 'initialize failed for mixed pressure motion')
|
||||
call sph_read_inp('tests/data/coupling_load_mode_081.inp', ierr)
|
||||
call assert_ok(ierr, 'read failed for mixed pressure motion')
|
||||
call sph_build_model(ierr)
|
||||
call assert_ok(ierr, 'build failed for mixed pressure motion')
|
||||
|
||||
ids = (/ 1, 2 /)
|
||||
pressures = (/ 40.0_rk, 40.0_rk /)
|
||||
call sph_coupling_apply_facet_pressures(1, 2, ids, pressures, &
|
||||
SPH_COUPLING_DISTRIBUTION_AREA, 501, ierr)
|
||||
call assert_ok(ierr, 'mixed pressure import failed')
|
||||
target_velocity = (/ 0.0_rk, 2.0_rk, 0.0_rk /)
|
||||
call sph_coupling_apply_motion_boundary(2, 1, &
|
||||
SPH_COUPLING_MOTION_VELOCITY, SPH_COUPLING_MOTION_DIRECT, &
|
||||
target_velocity, ierr)
|
||||
call assert_ok(ierr, 'mixed motion import failed')
|
||||
call sph_advance_explicit(1.0e-7_rk, ierr)
|
||||
call assert_ok(ierr, 'mixed pressure motion advance failed')
|
||||
call assert_vector_close(v(:,1), target_velocity, &
|
||||
'motion boundary did not override pressure particle')
|
||||
if (v(3,2) <= 0.0_rk) call fail('free pressure particle did not respond')
|
||||
|
||||
call sph_finalize(ierr)
|
||||
call assert_ok(ierr, 'finalize failed for mixed pressure motion')
|
||||
|
||||
contains
|
||||
|
||||
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 assert_close(actual, expected, message)
|
||||
real(rk), intent(in) :: actual
|
||||
real(rk), intent(in) :: expected
|
||||
character(len=*), intent(in) :: message
|
||||
|
||||
if (abs(actual - expected) > max(1.0e-10_rk, abs(expected) * 1.0e-8_rk)) then
|
||||
call fail(message)
|
||||
end if
|
||||
end subroutine assert_close
|
||||
|
||||
subroutine assert_vector_close(actual, expected, message)
|
||||
real(rk), intent(in) :: actual(SPH_NDIM)
|
||||
real(rk), intent(in) :: expected(SPH_NDIM)
|
||||
character(len=*), intent(in) :: message
|
||||
integer :: i
|
||||
|
||||
do i = 1, SPH_NDIM
|
||||
call assert_close(actual(i), expected(i), message)
|
||||
end do
|
||||
end subroutine assert_vector_close
|
||||
|
||||
subroutine fail(message)
|
||||
character(len=*), intent(in) :: message
|
||||
|
||||
write(*, '(A)') trim(message)
|
||||
stop 1
|
||||
end subroutine fail
|
||||
|
||||
end program test_coupling_mixed_pressure_motion_081
|
||||
@@ -0,0 +1,50 @@
|
||||
program test_coupling_shell_pressure_081
|
||||
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_advance_explicit
|
||||
use sph_database, only: v, SPH_COUPLING_DISTRIBUTION_AREA
|
||||
use sph_coupling_interface, only: sph_coupling_apply_facet_pressures
|
||||
implicit none
|
||||
|
||||
integer :: ierr
|
||||
integer :: ids(3)
|
||||
real(rk) :: pressures(3)
|
||||
|
||||
call sph_initialize(ierr)
|
||||
call assert_ok(ierr, 'initialize failed for shell pressure')
|
||||
call sph_read_inp('tests/data/coupling_load_mode_081.inp', ierr)
|
||||
call assert_ok(ierr, 'read failed for shell pressure')
|
||||
call sph_build_model(ierr)
|
||||
call assert_ok(ierr, 'build failed for shell pressure')
|
||||
|
||||
ids = (/ 1, 2, 3 /)
|
||||
pressures = (/ 50.0_rk, 30.0_rk, 10.0_rk /)
|
||||
call sph_coupling_apply_facet_pressures(1, 3, ids, pressures, &
|
||||
SPH_COUPLING_DISTRIBUTION_AREA, 401, ierr)
|
||||
call assert_ok(ierr, 'shell pressure import failed')
|
||||
call sph_advance_explicit(1.0e-7_rk, ierr)
|
||||
call assert_ok(ierr, 'shell pressure advance failed')
|
||||
if (v(3,1) <= 0.0_rk) call fail('shell pressure response missing')
|
||||
if (v(3,2) <= 0.0_rk) call fail('shell pressure response missing on facet 2')
|
||||
|
||||
call sph_finalize(ierr)
|
||||
call assert_ok(ierr, 'finalize failed for shell pressure')
|
||||
|
||||
contains
|
||||
|
||||
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_coupling_shell_pressure_081
|
||||
@@ -0,0 +1,55 @@
|
||||
program test_coupling_solid_surface_pressure_081
|
||||
use sph_precision, only: rk, SPH_NDIM
|
||||
use sph_error, only: SPH_SUCCESS
|
||||
use sph_api, only: sph_initialize, sph_finalize, sph_read_inp, &
|
||||
sph_build_model, sph_advance_explicit
|
||||
use sph_database, only: v, mass
|
||||
use sph_coupling_interface, only: sph_coupling_apply_particle_forces
|
||||
implicit none
|
||||
|
||||
integer :: ierr
|
||||
integer :: export_indices(1)
|
||||
real(rk) :: pressure_value
|
||||
real(rk) :: proxy_area
|
||||
real(rk) :: forces(SPH_NDIM,1)
|
||||
|
||||
call sph_initialize(ierr)
|
||||
call assert_ok(ierr, 'initialize failed for solid surface pressure')
|
||||
call sph_read_inp('tests/data/coupling_region_080.inp', ierr)
|
||||
call assert_ok(ierr, 'read failed for solid surface pressure')
|
||||
call sph_build_model(ierr)
|
||||
call assert_ok(ierr, 'build failed for solid surface pressure')
|
||||
|
||||
export_indices(1) = 1
|
||||
pressure_value = 2.0e5_rk
|
||||
proxy_area = 1.0e-3_rk
|
||||
forces(:,1) = (/ 0.0_rk, 0.0_rk, pressure_value * proxy_area /)
|
||||
call sph_coupling_apply_particle_forces(1, 1, export_indices, forces, ierr)
|
||||
call assert_ok(ierr, 'solid equivalent pressure import failed')
|
||||
call sph_advance_explicit(1.0e-7_rk, ierr)
|
||||
call assert_ok(ierr, 'solid equivalent pressure advance failed')
|
||||
if (v(3,1) <= 0.0_rk) call fail('solid equivalent pressure response missing')
|
||||
if (v(3,1) <= forces(3,1) / mass(1) * 0.25e-7_rk) then
|
||||
call fail('solid equivalent pressure response too small')
|
||||
end if
|
||||
|
||||
call sph_finalize(ierr)
|
||||
call assert_ok(ierr, 'finalize failed for solid surface pressure')
|
||||
|
||||
contains
|
||||
|
||||
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_coupling_solid_surface_pressure_081
|
||||
@@ -0,0 +1,141 @@
|
||||
program test_coupling_solver_order_081
|
||||
use sph_precision, only: rk, SPH_NDIM
|
||||
use sph_error, only: SPH_SUCCESS
|
||||
use sph_api, only: sph_initialize, sph_finalize, sph_read_inp, &
|
||||
sph_build_model, sph_advance_explicit
|
||||
use sph_database, only: v, mass, SPH_COUPLING_DISTRIBUTION_AREA, &
|
||||
SPH_COUPLING_DISTRIBUTION_MASS
|
||||
use sph_coupling_interface, only: coupling_external_force, &
|
||||
SPH_COUPLING_MOTION_DIRECT, SPH_COUPLING_MOTION_VELOCITY, &
|
||||
sph_coupling_import_force_by_external_id, &
|
||||
sph_coupling_import_region_facet_load, &
|
||||
sph_coupling_apply_facet_pressures, &
|
||||
sph_coupling_apply_facet_tractions, sph_coupling_apply_motion_boundary
|
||||
implicit none
|
||||
|
||||
integer :: ierr
|
||||
|
||||
call check_loads_before_motion()
|
||||
call check_disabled_region_noop()
|
||||
call check_empty_pressure_traction_noop()
|
||||
|
||||
contains
|
||||
|
||||
subroutine check_loads_before_motion()
|
||||
integer :: ids(1)
|
||||
real(rk) :: pressures(1)
|
||||
real(rk) :: tractions(SPH_NDIM,1)
|
||||
real(rk) :: particle_force(SPH_NDIM)
|
||||
real(rk) :: facet_load(SPH_NDIM)
|
||||
real(rk) :: target_velocity(SPH_NDIM)
|
||||
|
||||
call build_case()
|
||||
ids(1) = 1
|
||||
pressures(1) = 20.0_rk
|
||||
call sph_coupling_apply_facet_pressures(1, 1, ids, pressures, &
|
||||
SPH_COUPLING_DISTRIBUTION_AREA, 201, ierr)
|
||||
call assert_ok(ierr, 'pressure import failed for solver order')
|
||||
ids(1) = 2
|
||||
tractions(:,1) = (/ 0.0_rk, 0.0_rk, 30.0_rk /)
|
||||
call sph_coupling_apply_facet_tractions(2, 1, ids, tractions, &
|
||||
SPH_COUPLING_DISTRIBUTION_MASS, 201, ierr)
|
||||
call assert_ok(ierr, 'traction import failed for solver order')
|
||||
particle_force = (/ 0.0_rk, 0.0_rk, mass(3) * 1.0e8_rk /)
|
||||
call sph_coupling_import_force_by_external_id(3, particle_force, ierr)
|
||||
call assert_ok(ierr, 'particle force import failed for solver order')
|
||||
facet_load = (/ 0.0_rk, 0.0_rk, mass(2) * 1.0e8_rk /)
|
||||
call sph_coupling_import_region_facet_load('TRACTION_CONTACT', 2, &
|
||||
facet_load, ierr)
|
||||
call assert_ok(ierr, 'facet load import failed for solver order')
|
||||
target_velocity = (/ 0.0_rk, -1.0_rk, 0.0_rk /)
|
||||
call sph_coupling_apply_motion_boundary(2, 1, &
|
||||
SPH_COUPLING_MOTION_VELOCITY, SPH_COUPLING_MOTION_DIRECT, &
|
||||
target_velocity, ierr)
|
||||
call assert_ok(ierr, 'motion import failed for solver order')
|
||||
call sph_advance_explicit(1.0e-7_rk, ierr)
|
||||
call assert_ok(ierr, 'advance failed for solver order')
|
||||
call assert_vector_close(v(:,1), target_velocity, &
|
||||
'motion boundary was not applied after loads')
|
||||
if (v(3,2) <= 0.0_rk) call fail('facet load did not affect free particle')
|
||||
if (v(3,3) <= 0.0_rk) call fail('particle force did not affect particle')
|
||||
if (maxval(abs(coupling_external_force)) > 0.0_rk) then
|
||||
call fail('coupling force cache was not consumed')
|
||||
end if
|
||||
call sph_finalize(ierr)
|
||||
call assert_ok(ierr, 'finalize failed after solver order')
|
||||
end subroutine check_loads_before_motion
|
||||
|
||||
subroutine check_disabled_region_noop()
|
||||
call build_case()
|
||||
call sph_advance_explicit(1.0e-7_rk, ierr)
|
||||
call assert_ok(ierr, 'disabled region affected empty advance')
|
||||
call sph_finalize(ierr)
|
||||
call assert_ok(ierr, 'finalize failed after disabled noop')
|
||||
end subroutine check_disabled_region_noop
|
||||
|
||||
subroutine check_empty_pressure_traction_noop()
|
||||
integer :: empty_ids(0)
|
||||
real(rk) :: empty_pressures(0)
|
||||
real(rk) :: empty_tractions(SPH_NDIM,0)
|
||||
|
||||
call build_case()
|
||||
call sph_coupling_apply_facet_pressures(1, 0, empty_ids, empty_pressures, &
|
||||
SPH_COUPLING_DISTRIBUTION_AREA, 211, ierr)
|
||||
call assert_ok(ierr, 'empty pressure import failed')
|
||||
call sph_coupling_apply_facet_tractions(2, 0, empty_ids, empty_tractions, &
|
||||
SPH_COUPLING_DISTRIBUTION_MASS, 211, ierr)
|
||||
call assert_ok(ierr, 'empty traction import failed')
|
||||
call sph_advance_explicit(1.0e-7_rk, ierr)
|
||||
call assert_ok(ierr, 'empty load advance failed')
|
||||
if (maxval(abs(v)) > 1.0e-12_rk) then
|
||||
call fail('empty pressure or traction produced velocity')
|
||||
end if
|
||||
call sph_finalize(ierr)
|
||||
call assert_ok(ierr, 'finalize failed after empty pressure traction')
|
||||
end subroutine check_empty_pressure_traction_noop
|
||||
|
||||
subroutine build_case()
|
||||
call sph_initialize(ierr)
|
||||
call assert_ok(ierr, 'initialize failed for solver order')
|
||||
call sph_read_inp('tests/data/coupling_load_mode_081.inp', ierr)
|
||||
call assert_ok(ierr, 'read failed for solver order')
|
||||
call sph_build_model(ierr)
|
||||
call assert_ok(ierr, 'build failed for solver order')
|
||||
end subroutine build_case
|
||||
|
||||
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 assert_close(actual, expected, message)
|
||||
real(rk), intent(in) :: actual
|
||||
real(rk), intent(in) :: expected
|
||||
character(len=*), intent(in) :: message
|
||||
|
||||
if (abs(actual - expected) > max(1.0e-10_rk, abs(expected) * 1.0e-8_rk)) then
|
||||
call fail(message)
|
||||
end if
|
||||
end subroutine assert_close
|
||||
|
||||
subroutine assert_vector_close(actual, expected, message)
|
||||
real(rk), intent(in) :: actual(SPH_NDIM)
|
||||
real(rk), intent(in) :: expected(SPH_NDIM)
|
||||
character(len=*), intent(in) :: message
|
||||
integer :: i
|
||||
|
||||
do i = 1, SPH_NDIM
|
||||
call assert_close(actual(i), expected(i), message)
|
||||
end do
|
||||
end subroutine assert_vector_close
|
||||
|
||||
subroutine fail(message)
|
||||
character(len=*), intent(in) :: message
|
||||
|
||||
write(*, '(A)') trim(message)
|
||||
stop 1
|
||||
end subroutine fail
|
||||
|
||||
end program test_coupling_solver_order_081
|
||||
@@ -0,0 +1,107 @@
|
||||
program test_coupling_stale_epoch_081
|
||||
use sph_precision, only: rk, SPH_NDIM
|
||||
use sph_error, only: SPH_SUCCESS
|
||||
use sph_api, only: sph_initialize, sph_finalize, sph_read_inp, sph_build_model
|
||||
use sph_database, only: SPH_COUPLING_DISTRIBUTION_AREA
|
||||
use sph_coupling_interface, only: coupling_contact_flag, coupling_external_force, &
|
||||
sph_coupling_apply_contact_state, sph_coupling_apply_facet_pressures, &
|
||||
sph_coupling_clear_imports, sph_coupling_get_contact_diagnostics
|
||||
implicit none
|
||||
|
||||
integer :: ierr
|
||||
|
||||
call sph_initialize(ierr)
|
||||
call assert_ok(ierr, 'initialize failed for stale epoch')
|
||||
call sph_read_inp('tests/data/coupling_load_mode_081.inp', ierr)
|
||||
call assert_ok(ierr, 'read failed for stale epoch')
|
||||
call sph_build_model(ierr)
|
||||
call assert_ok(ierr, 'build failed for stale epoch')
|
||||
|
||||
call check_contact_stale_clear()
|
||||
call check_pressure_stale_clear()
|
||||
|
||||
call sph_finalize(ierr)
|
||||
call assert_ok(ierr, 'finalize failed for stale epoch')
|
||||
|
||||
contains
|
||||
|
||||
subroutine check_contact_stale_clear()
|
||||
integer :: ids(1)
|
||||
real(rk) :: normals(SPH_NDIM,1)
|
||||
real(rk) :: gaps(1)
|
||||
real(rk) :: penetrations(1)
|
||||
real(rk) :: contact_pressures(1)
|
||||
integer :: active_count
|
||||
integer :: skipped_count
|
||||
integer :: stale_count
|
||||
integer :: repeated_count
|
||||
integer :: nonfinite_count
|
||||
integer :: bad_area_count
|
||||
integer :: invalid_weight_count
|
||||
real(rk) :: max_penetration
|
||||
|
||||
ids(1) = 1
|
||||
normals(:,1) = (/ 0.0_rk, 0.0_rk, 1.0_rk /)
|
||||
gaps(1) = 0.0_rk
|
||||
penetrations(1) = 1.0e-3_rk
|
||||
contact_pressures(1) = 5.0_rk
|
||||
call sph_coupling_apply_contact_state(1, 1, ids, normals, gaps, &
|
||||
penetrations, contact_pressures, 301, ierr)
|
||||
call assert_ok(ierr, 'contact import failed for stale epoch')
|
||||
call sph_coupling_clear_imports(ierr)
|
||||
call assert_ok(ierr, 'clear imports failed after contact state')
|
||||
if (maxval(coupling_contact_flag) /= 0) then
|
||||
call fail('contact cache was not cleared')
|
||||
end if
|
||||
call sph_coupling_get_contact_diagnostics(active_count, skipped_count, &
|
||||
max_penetration, stale_count, repeated_count, nonfinite_count, &
|
||||
bad_area_count, invalid_weight_count, ierr)
|
||||
call assert_ok(ierr, 'contact stale diagnostics failed')
|
||||
if (active_count /= 0) call fail('active contact count was not cleared')
|
||||
if (stale_count <= 0) call fail('contact stale count missing')
|
||||
end subroutine check_contact_stale_clear
|
||||
|
||||
subroutine check_pressure_stale_clear()
|
||||
integer :: ids(1)
|
||||
real(rk) :: pressures(1)
|
||||
integer :: active_count
|
||||
integer :: skipped_count
|
||||
integer :: stale_count
|
||||
integer :: repeated_count
|
||||
integer :: nonfinite_count
|
||||
integer :: bad_area_count
|
||||
integer :: invalid_weight_count
|
||||
real(rk) :: max_penetration
|
||||
|
||||
ids(1) = 1
|
||||
pressures(1) = 10.0_rk
|
||||
call sph_coupling_apply_facet_pressures(1, 1, ids, pressures, &
|
||||
SPH_COUPLING_DISTRIBUTION_AREA, 302, ierr)
|
||||
call assert_ok(ierr, 'pressure import failed for stale epoch')
|
||||
call sph_coupling_clear_imports(ierr)
|
||||
call assert_ok(ierr, 'clear imports failed after pressure')
|
||||
if (maxval(abs(coupling_external_force)) > 0.0_rk) then
|
||||
call fail('pressure force cache was not cleared')
|
||||
end if
|
||||
call sph_coupling_get_contact_diagnostics(active_count, skipped_count, &
|
||||
max_penetration, stale_count, repeated_count, nonfinite_count, &
|
||||
bad_area_count, invalid_weight_count, ierr)
|
||||
call assert_ok(ierr, 'pressure stale diagnostics failed')
|
||||
if (stale_count < 2) call fail('pressure stale count missing')
|
||||
end subroutine check_pressure_stale_clear
|
||||
|
||||
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_coupling_stale_epoch_081
|
||||
Reference in New Issue
Block a user