Add blast source snapshots and target filtering
This commit is contained in:
1 parent
58d15da1ae
commit
b2a9caa54a
7 files changed
+597
-33
No files matched your search
+316
-2
@@ -2,8 +2,14 @@ module sph_blast
|
||||
use sph_precision, only: rk, SPH_NDIM
|
||||
use sph_error, only: SPH_SUCCESS, SPH_ERROR_INPUT, SPH_ERROR_DATABASE, &
|
||||
sph_error_set
|
||||
use sph_database, only: SPH_NAME_LEN, SPH_MAX_REGIONS, sph_db_find_elset, &
|
||||
sph_db_find_nset
|
||||
use sph_database, only: SPH_NAME_LEN, SPH_MAX_REGIONS, npart, &
|
||||
particle_id_ext, particle_phase, particle_status, x, mass, volume, &
|
||||
pressure, internal_energy, nset_member_count, nset_members, &
|
||||
elset_member_count, elset_members, element_conn_count, element_conn, &
|
||||
SPH_PHASE_WATER, SPH_PHASE_GAS, SPH_PHASE_EXPLOSIVE, &
|
||||
SPH_PHASE_SOLID, SPH_PHASE_SHELL, SPH_STATUS_ACTIVE, &
|
||||
sph_db_find_elset, sph_db_find_nset, sph_db_find_element
|
||||
use sph_explosive_state, only: explosive_reaction_progress
|
||||
implicit none
|
||||
|
||||
integer, parameter :: SPH_BLAST_PHASE_NONE = 0
|
||||
@@ -30,6 +36,21 @@ module sph_blast
|
||||
real(rk) :: blast_radius(SPH_MAX_REGIONS) = 0.0_rk
|
||||
real(rk) :: blast_load_scale(SPH_MAX_REGIONS) = 0.0_rk
|
||||
real(rk) :: blast_time_window(SPH_MAX_REGIONS) = 0.0_rk
|
||||
integer :: blast_source_count(SPH_MAX_REGIONS) = 0
|
||||
integer :: blast_target_count(SPH_MAX_REGIONS) = 0
|
||||
integer :: blast_candidate_pair_count(SPH_MAX_REGIONS) = 0
|
||||
integer :: blast_skipped_source_count(SPH_MAX_REGIONS) = 0
|
||||
integer :: blast_skipped_target_count(SPH_MAX_REGIONS) = 0
|
||||
integer :: blast_gas_count(SPH_MAX_REGIONS) = 0
|
||||
integer :: blast_water_count(SPH_MAX_REGIONS) = 0
|
||||
integer :: blast_explosive_count(SPH_MAX_REGIONS) = 0
|
||||
real(rk) :: blast_source_mass(SPH_MAX_REGIONS) = 0.0_rk
|
||||
real(rk) :: blast_source_energy(SPH_MAX_REGIONS) = 0.0_rk
|
||||
real(rk) :: blast_source_pressure_mean(SPH_MAX_REGIONS) = 0.0_rk
|
||||
real(rk) :: blast_gas_volume(SPH_MAX_REGIONS) = 0.0_rk
|
||||
real(rk) :: blast_explosive_progress_mean(SPH_MAX_REGIONS) = 0.0_rk
|
||||
real(rk) :: blast_water_pressure_min(SPH_MAX_REGIONS) = 0.0_rk
|
||||
real(rk) :: blast_water_pressure_max(SPH_MAX_REGIONS) = 0.0_rk
|
||||
|
||||
contains
|
||||
|
||||
@@ -49,8 +70,27 @@ contains
|
||||
blast_radius = 0.0_rk
|
||||
blast_load_scale = 0.0_rk
|
||||
blast_time_window = 0.0_rk
|
||||
call sph_blast_clear_snapshot()
|
||||
end subroutine sph_blast_reset
|
||||
|
||||
subroutine sph_blast_clear_snapshot()
|
||||
blast_source_count = 0
|
||||
blast_target_count = 0
|
||||
blast_candidate_pair_count = 0
|
||||
blast_skipped_source_count = 0
|
||||
blast_skipped_target_count = 0
|
||||
blast_gas_count = 0
|
||||
blast_water_count = 0
|
||||
blast_explosive_count = 0
|
||||
blast_source_mass = 0.0_rk
|
||||
blast_source_energy = 0.0_rk
|
||||
blast_source_pressure_mean = 0.0_rk
|
||||
blast_gas_volume = 0.0_rk
|
||||
blast_explosive_progress_mean = 0.0_rk
|
||||
blast_water_pressure_min = 0.0_rk
|
||||
blast_water_pressure_max = 0.0_rk
|
||||
end subroutine sph_blast_clear_snapshot
|
||||
|
||||
subroutine sph_blast_add_region(name, center, radius, source_phase_name, &
|
||||
target_phase_name, target_set_name, scale, time_window, mode_name, ierr)
|
||||
character(len=*), intent(in) :: name
|
||||
@@ -154,6 +194,280 @@ contains
|
||||
end do
|
||||
end subroutine sph_blast_count_unused_regions
|
||||
|
||||
subroutine sph_blast_refresh_snapshot(ierr)
|
||||
integer, intent(out) :: ierr
|
||||
integer :: region
|
||||
|
||||
ierr = SPH_SUCCESS
|
||||
call sph_blast_clear_snapshot()
|
||||
if (npart <= 0) return
|
||||
do region = 1, blast_region_count
|
||||
if (.not. blast_region_enabled(region)) cycle
|
||||
call sph_blast_accumulate_region(region)
|
||||
end do
|
||||
end subroutine sph_blast_refresh_snapshot
|
||||
|
||||
subroutine sph_blast_accumulate_region(region)
|
||||
integer, intent(in) :: region
|
||||
integer :: i
|
||||
|
||||
do i = 1, npart
|
||||
if (sph_blast_phase_matches(blast_source_phase(region), &
|
||||
particle_phase(i))) then
|
||||
if (sph_blast_source_accepts(region, i)) then
|
||||
call sph_blast_accumulate_source(region, i)
|
||||
else
|
||||
blast_skipped_source_count(region) = &
|
||||
blast_skipped_source_count(region) + 1
|
||||
end if
|
||||
end if
|
||||
if (sph_blast_phase_matches(blast_target_phase(region), &
|
||||
particle_phase(i))) then
|
||||
if (sph_blast_target_accepts(region, i)) then
|
||||
call sph_blast_accumulate_target(region, i)
|
||||
else
|
||||
blast_skipped_target_count(region) = &
|
||||
blast_skipped_target_count(region) + 1
|
||||
end if
|
||||
end if
|
||||
call sph_blast_accumulate_environment(region, i)
|
||||
end do
|
||||
if (blast_source_count(region) > 0) then
|
||||
blast_source_pressure_mean(region) = &
|
||||
blast_source_pressure_mean(region) / &
|
||||
real(blast_source_count(region), rk)
|
||||
end if
|
||||
if (blast_explosive_count(region) > 0) then
|
||||
blast_explosive_progress_mean(region) = &
|
||||
blast_explosive_progress_mean(region) / &
|
||||
real(blast_explosive_count(region), rk)
|
||||
end if
|
||||
call sph_blast_count_candidate_pairs(region)
|
||||
end subroutine sph_blast_accumulate_region
|
||||
|
||||
subroutine sph_blast_accumulate_source(region, index)
|
||||
integer, intent(in) :: region
|
||||
integer, intent(in) :: index
|
||||
|
||||
blast_source_count(region) = blast_source_count(region) + 1
|
||||
blast_source_mass(region) = blast_source_mass(region) + mass(index)
|
||||
blast_source_energy(region) = blast_source_energy(region) + &
|
||||
mass(index) * internal_energy(index)
|
||||
blast_source_pressure_mean(region) = blast_source_pressure_mean(region) + &
|
||||
pressure(index)
|
||||
end subroutine sph_blast_accumulate_source
|
||||
|
||||
subroutine sph_blast_accumulate_target(region, index)
|
||||
integer, intent(in) :: region
|
||||
integer, intent(in) :: index
|
||||
|
||||
blast_target_count(region) = blast_target_count(region) + 1
|
||||
end subroutine sph_blast_accumulate_target
|
||||
|
||||
subroutine sph_blast_accumulate_environment(region, index)
|
||||
integer, intent(in) :: region
|
||||
integer, intent(in) :: index
|
||||
|
||||
if (.not. sph_blast_is_active(index)) return
|
||||
if (.not. sph_blast_in_region(region, index)) return
|
||||
if (particle_phase(index) == SPH_PHASE_GAS) then
|
||||
blast_gas_count(region) = blast_gas_count(region) + 1
|
||||
blast_gas_volume(region) = blast_gas_volume(region) + volume(index)
|
||||
else if (particle_phase(index) == SPH_PHASE_WATER) then
|
||||
call sph_blast_accumulate_water(region, index)
|
||||
else if (particle_phase(index) == SPH_PHASE_EXPLOSIVE) then
|
||||
call sph_blast_accumulate_explosive(region, index)
|
||||
end if
|
||||
end subroutine sph_blast_accumulate_environment
|
||||
|
||||
subroutine sph_blast_accumulate_water(region, index)
|
||||
integer, intent(in) :: region
|
||||
integer, intent(in) :: index
|
||||
|
||||
if (blast_water_count(region) == 0) then
|
||||
blast_water_pressure_min(region) = pressure(index)
|
||||
blast_water_pressure_max(region) = pressure(index)
|
||||
else
|
||||
if (pressure(index) < blast_water_pressure_min(region)) then
|
||||
blast_water_pressure_min(region) = pressure(index)
|
||||
end if
|
||||
if (pressure(index) > blast_water_pressure_max(region)) then
|
||||
blast_water_pressure_max(region) = pressure(index)
|
||||
end if
|
||||
end if
|
||||
blast_water_count(region) = blast_water_count(region) + 1
|
||||
end subroutine sph_blast_accumulate_water
|
||||
|
||||
subroutine sph_blast_accumulate_explosive(region, index)
|
||||
integer, intent(in) :: region
|
||||
integer, intent(in) :: index
|
||||
|
||||
if (.not. allocated(explosive_reaction_progress)) return
|
||||
blast_explosive_count(region) = blast_explosive_count(region) + 1
|
||||
blast_explosive_progress_mean(region) = &
|
||||
blast_explosive_progress_mean(region) + &
|
||||
explosive_reaction_progress(index)
|
||||
end subroutine sph_blast_accumulate_explosive
|
||||
|
||||
subroutine sph_blast_count_candidate_pairs(region)
|
||||
integer, intent(in) :: region
|
||||
integer :: source
|
||||
integer :: target
|
||||
|
||||
do source = 1, npart
|
||||
if (.not. sph_blast_source_accepts(region, source)) cycle
|
||||
do target = 1, npart
|
||||
if (.not. sph_blast_target_accepts(region, target)) cycle
|
||||
if (sph_blast_pair_within(region, source, target)) then
|
||||
blast_candidate_pair_count(region) = &
|
||||
blast_candidate_pair_count(region) + 1
|
||||
end if
|
||||
end do
|
||||
end do
|
||||
end subroutine sph_blast_count_candidate_pairs
|
||||
|
||||
logical function sph_blast_source_accepts(region, index)
|
||||
integer, intent(in) :: region
|
||||
integer, intent(in) :: index
|
||||
|
||||
sph_blast_source_accepts = .false.
|
||||
if (.not. sph_blast_phase_matches(blast_source_phase(region), &
|
||||
particle_phase(index))) return
|
||||
if (.not. sph_blast_is_active(index)) return
|
||||
if (.not. sph_blast_in_region(region, index)) return
|
||||
sph_blast_source_accepts = .true.
|
||||
end function sph_blast_source_accepts
|
||||
|
||||
logical function sph_blast_target_accepts(region, index)
|
||||
integer, intent(in) :: region
|
||||
integer, intent(in) :: index
|
||||
|
||||
sph_blast_target_accepts = .false.
|
||||
if (.not. sph_blast_phase_matches(blast_target_phase(region), &
|
||||
particle_phase(index))) return
|
||||
if (.not. sph_blast_is_active(index)) return
|
||||
if (.not. sph_blast_particle_in_target_set(region, index)) return
|
||||
if (.not. sph_blast_in_region(region, index)) return
|
||||
sph_blast_target_accepts = .true.
|
||||
end function sph_blast_target_accepts
|
||||
|
||||
logical function sph_blast_phase_matches(filter_phase, db_phase)
|
||||
integer, intent(in) :: filter_phase
|
||||
integer, intent(in) :: db_phase
|
||||
|
||||
sph_blast_phase_matches = .false.
|
||||
if (filter_phase == SPH_BLAST_PHASE_ALL) then
|
||||
sph_blast_phase_matches = .true.
|
||||
else if (filter_phase == SPH_BLAST_PHASE_WATER) then
|
||||
sph_blast_phase_matches = db_phase == SPH_PHASE_WATER
|
||||
else if (filter_phase == SPH_BLAST_PHASE_GAS) then
|
||||
sph_blast_phase_matches = db_phase == SPH_PHASE_GAS
|
||||
else if (filter_phase == SPH_BLAST_PHASE_EXPLOSIVE) then
|
||||
sph_blast_phase_matches = db_phase == SPH_PHASE_EXPLOSIVE
|
||||
else if (filter_phase == SPH_BLAST_PHASE_SOLID) then
|
||||
sph_blast_phase_matches = db_phase == SPH_PHASE_SOLID
|
||||
else if (filter_phase == SPH_BLAST_PHASE_SHELL) then
|
||||
sph_blast_phase_matches = db_phase == SPH_PHASE_SHELL
|
||||
else if (filter_phase == SPH_BLAST_PHASE_STRUCTURE) then
|
||||
sph_blast_phase_matches = db_phase == SPH_PHASE_SOLID .or. &
|
||||
db_phase == SPH_PHASE_SHELL
|
||||
end if
|
||||
end function sph_blast_phase_matches
|
||||
|
||||
logical function sph_blast_is_active(index)
|
||||
integer, intent(in) :: index
|
||||
|
||||
sph_blast_is_active = .false.
|
||||
if (index < 1 .or. index > npart) return
|
||||
if (particle_status(index) /= SPH_STATUS_ACTIVE) return
|
||||
sph_blast_is_active = .true.
|
||||
end function sph_blast_is_active
|
||||
|
||||
logical function sph_blast_in_region(region, index)
|
||||
integer, intent(in) :: region
|
||||
integer, intent(in) :: index
|
||||
real(rk) :: offset(SPH_NDIM)
|
||||
real(rk) :: distance2
|
||||
real(rk) :: radius2
|
||||
|
||||
sph_blast_in_region = .false.
|
||||
if (region < 1 .or. region > blast_region_count) return
|
||||
if (index < 1 .or. index > npart) return
|
||||
offset = x(:,index) - blast_center(:,region)
|
||||
distance2 = sum(offset * offset)
|
||||
radius2 = blast_radius(region) * blast_radius(region)
|
||||
if (distance2 <= radius2) sph_blast_in_region = .true.
|
||||
end function sph_blast_in_region
|
||||
|
||||
logical function sph_blast_pair_within(region, source, target)
|
||||
integer, intent(in) :: region
|
||||
integer, intent(in) :: source
|
||||
integer, intent(in) :: target
|
||||
real(rk) :: offset(SPH_NDIM)
|
||||
real(rk) :: distance2
|
||||
real(rk) :: radius2
|
||||
|
||||
sph_blast_pair_within = .false.
|
||||
offset = x(:,target) - x(:,source)
|
||||
distance2 = sum(offset * offset)
|
||||
radius2 = blast_radius(region) * blast_radius(region)
|
||||
if (distance2 <= radius2) sph_blast_pair_within = .true.
|
||||
end function sph_blast_pair_within
|
||||
|
||||
logical function sph_blast_particle_in_target_set(region, index)
|
||||
integer, intent(in) :: region
|
||||
integer, intent(in) :: index
|
||||
integer :: set_index
|
||||
|
||||
sph_blast_particle_in_target_set = .false.
|
||||
if (trim(sph_blast_upper(blast_target_set_name(region))) == 'NONE') return
|
||||
set_index = sph_db_find_nset(blast_target_set_name(region))
|
||||
if (set_index > 0) then
|
||||
sph_blast_particle_in_target_set = &
|
||||
sph_blast_nset_contains_particle(set_index, index)
|
||||
return
|
||||
end if
|
||||
set_index = sph_db_find_elset(blast_target_set_name(region))
|
||||
if (set_index > 0) then
|
||||
sph_blast_particle_in_target_set = &
|
||||
sph_blast_elset_contains_particle(set_index, index)
|
||||
end if
|
||||
end function sph_blast_particle_in_target_set
|
||||
|
||||
logical function sph_blast_nset_contains_particle(set_index, index)
|
||||
integer, intent(in) :: set_index
|
||||
integer, intent(in) :: index
|
||||
integer :: member
|
||||
|
||||
sph_blast_nset_contains_particle = .false.
|
||||
do member = 1, nset_member_count(set_index)
|
||||
if (nset_members(member,set_index) == particle_id_ext(index)) then
|
||||
sph_blast_nset_contains_particle = .true.
|
||||
return
|
||||
end if
|
||||
end do
|
||||
end function sph_blast_nset_contains_particle
|
||||
|
||||
logical function sph_blast_elset_contains_particle(set_index, index)
|
||||
integer, intent(in) :: set_index
|
||||
integer, intent(in) :: index
|
||||
integer :: member
|
||||
integer :: elem_index
|
||||
integer :: conn
|
||||
|
||||
sph_blast_elset_contains_particle = .false.
|
||||
do member = 1, elset_member_count(set_index)
|
||||
elem_index = sph_db_find_element(elset_members(member,set_index))
|
||||
if (elem_index <= 0) cycle
|
||||
do conn = 1, element_conn_count(elem_index)
|
||||
if (element_conn(conn,elem_index) == particle_id_ext(index)) then
|
||||
sph_blast_elset_contains_particle = .true.
|
||||
return
|
||||
end if
|
||||
end do
|
||||
end do
|
||||
end function sph_blast_elset_contains_particle
|
||||
|
||||
integer function sph_blast_phase_id(phase_name)
|
||||
character(len=*), intent(in) :: phase_name
|
||||
character(len=SPH_NAME_LEN) :: upper_name
|
||||
|
||||
@@ -21,7 +21,7 @@ module sph_input_reader
|
||||
sph_explosive_set_control, sph_explosive_set_ignition, &
|
||||
sph_explosive_build, sph_explosive_count_unbound_materials
|
||||
use sph_blast, only: sph_blast_reset, sph_blast_add_region, &
|
||||
sph_blast_count_unused_regions
|
||||
sph_blast_count_unused_regions, sph_blast_refresh_snapshot
|
||||
use sph_solid, only: sph_solid_note_material, sph_solid_set_elastic, &
|
||||
sph_solid_set_johnson_cook, sph_solid_set_failure, &
|
||||
sph_solid_set_control, sph_solid_build_state, &
|
||||
@@ -136,6 +136,8 @@ contains
|
||||
if (ierr /= SPH_SUCCESS) return
|
||||
call sph_explosive_build(ierr)
|
||||
if (ierr /= SPH_SUCCESS) return
|
||||
call sph_blast_refresh_snapshot(ierr)
|
||||
if (ierr /= SPH_SUCCESS) return
|
||||
call sph_gas_count_unbound_materials(gas_unbound_count)
|
||||
input_warning_count = input_warning_count + gas_unbound_count
|
||||
call sph_explosive_count_unbound_materials(explosive_unbound_count)
|
||||
|
||||
@@ -12,6 +12,7 @@ module sph_solver_explicit
|
||||
sph_gas_compute_acceleration, sph_gas_update_diagnostics, &
|
||||
sph_gas_estimate_dt_limits, sph_gas_apply_sources_explicit
|
||||
use sph_explosive, only: sph_explosive_advance, sph_explosive_estimate_dt_limit
|
||||
use sph_blast, only: sph_blast_refresh_snapshot
|
||||
use sph_solid_dynamics, only: sph_solid_compute_acceleration, &
|
||||
sph_solid_advance_material, sph_solid_update_diagnostics, &
|
||||
sph_solid_estimate_dt_limits
|
||||
@@ -52,6 +53,8 @@ contains
|
||||
if (ierr /= SPH_SUCCESS) return
|
||||
call sph_gas_update_pressure(ierr)
|
||||
if (ierr /= SPH_SUCCESS) return
|
||||
call sph_blast_refresh_snapshot(ierr)
|
||||
if (ierr /= SPH_SUCCESS) return
|
||||
call sph_water_compute_density_rate(ierr)
|
||||
if (ierr /= SPH_SUCCESS) return
|
||||
call sph_gas_compute_density_rate(ierr)
|
||||
@@ -70,6 +73,8 @@ contains
|
||||
end do
|
||||
call sph_explosive_advance(dt, current_time + dt, ierr)
|
||||
if (ierr /= SPH_SUCCESS) return
|
||||
call sph_blast_refresh_snapshot(ierr)
|
||||
if (ierr /= SPH_SUCCESS) return
|
||||
call sph_gas_apply_sources_explicit(dt, ierr)
|
||||
if (ierr /= SPH_SUCCESS) return
|
||||
call sph_solid_advance_material(dt, ierr)
|
||||
|
||||