Add water input cases and runtime state scaffolding
This commit is contained in:
@@ -47,6 +47,27 @@ module sph_database
|
||||
real(rk), allocatable :: internal_energy(:)
|
||||
real(rk), allocatable :: temperature(:)
|
||||
real(rk), allocatable :: h(:)
|
||||
real(rk), allocatable :: drho_dt(:)
|
||||
real(rk), allocatable :: acc_pressure(:,:)
|
||||
real(rk), allocatable :: acc_viscosity(:,:)
|
||||
real(rk), allocatable :: acc_body(:,:)
|
||||
integer, allocatable :: particle_cell_id(:)
|
||||
integer, allocatable :: cell_head(:)
|
||||
integer, allocatable :: cell_next(:)
|
||||
integer, allocatable :: neighbor_count(:)
|
||||
integer, allocatable :: neighbor_offset(:)
|
||||
integer, allocatable :: neighbor_list(:)
|
||||
|
||||
integer :: water_particle_count = 0
|
||||
real(rk) :: water_mass = 0.0_rk
|
||||
real(rk) :: water_momentum(SPH_NDIM) = 0.0_rk
|
||||
real(rk) :: water_max_pressure = 0.0_rk
|
||||
real(rk) :: water_min_density = 0.0_rk
|
||||
real(rk) :: water_max_density = 0.0_rk
|
||||
real(rk) :: water_pressure_impulse = 0.0_rk
|
||||
real(rk) :: water_dt_cfl = 0.0_rk
|
||||
real(rk) :: water_dt_accel = 0.0_rk
|
||||
real(rk) :: water_dt_viscous = 0.0_rk
|
||||
|
||||
integer :: material_count = 0
|
||||
character(len=SPH_NAME_LEN) :: material_name(SPH_MAX_MATERIALS)
|
||||
@@ -106,7 +127,10 @@ contains
|
||||
x(SPH_NDIM,count), v(SPH_NDIM,count), a(SPH_NDIM,count), &
|
||||
vhalf(SPH_NDIM,count), mass(count), rho(count), volume(count), &
|
||||
pressure(count), internal_energy(count), temperature(count), &
|
||||
h(count), stat=stat)
|
||||
h(count), drho_dt(count), acc_pressure(SPH_NDIM,count), &
|
||||
acc_viscosity(SPH_NDIM,count), acc_body(SPH_NDIM,count), &
|
||||
particle_cell_id(count), cell_next(count), neighbor_count(count), &
|
||||
neighbor_offset(count), stat=stat)
|
||||
if (stat /= 0) then
|
||||
call sph_db_free()
|
||||
call sph_error_set(SPH_ERROR_DATABASE, 'failed to allocate particle database')
|
||||
@@ -139,7 +163,16 @@ contains
|
||||
internal_energy(i) = 0.0_rk
|
||||
temperature(i) = 293.15_rk
|
||||
h(i) = 1.0_rk
|
||||
drho_dt(i) = 0.0_rk
|
||||
acc_pressure(:,i) = 0.0_rk
|
||||
acc_viscosity(:,i) = 0.0_rk
|
||||
acc_body(:,i) = 0.0_rk
|
||||
particle_cell_id(i) = 0
|
||||
cell_next(i) = 0
|
||||
neighbor_count(i) = 0
|
||||
neighbor_offset(i) = 0
|
||||
end do
|
||||
call sph_db_clear_water_diagnostics()
|
||||
end subroutine sph_db_initialize_defaults
|
||||
|
||||
subroutine sph_db_free()
|
||||
@@ -160,8 +193,19 @@ contains
|
||||
if (allocated(internal_energy)) deallocate(internal_energy)
|
||||
if (allocated(temperature)) deallocate(temperature)
|
||||
if (allocated(h)) deallocate(h)
|
||||
if (allocated(drho_dt)) deallocate(drho_dt)
|
||||
if (allocated(acc_pressure)) deallocate(acc_pressure)
|
||||
if (allocated(acc_viscosity)) deallocate(acc_viscosity)
|
||||
if (allocated(acc_body)) deallocate(acc_body)
|
||||
if (allocated(particle_cell_id)) deallocate(particle_cell_id)
|
||||
if (allocated(cell_head)) deallocate(cell_head)
|
||||
if (allocated(cell_next)) deallocate(cell_next)
|
||||
if (allocated(neighbor_count)) deallocate(neighbor_count)
|
||||
if (allocated(neighbor_offset)) deallocate(neighbor_offset)
|
||||
if (allocated(neighbor_list)) deallocate(neighbor_list)
|
||||
npart = 0
|
||||
call sph_db_clear_metadata()
|
||||
call sph_db_clear_water_diagnostics()
|
||||
end subroutine sph_db_free
|
||||
|
||||
subroutine sph_db_clear_metadata()
|
||||
@@ -196,6 +240,43 @@ contains
|
||||
coupling_region_internal_id = 0
|
||||
end subroutine sph_db_clear_metadata
|
||||
|
||||
subroutine sph_db_clear_water_diagnostics()
|
||||
water_particle_count = 0
|
||||
water_mass = 0.0_rk
|
||||
water_momentum = 0.0_rk
|
||||
water_max_pressure = 0.0_rk
|
||||
water_min_density = 0.0_rk
|
||||
water_max_density = 0.0_rk
|
||||
water_pressure_impulse = 0.0_rk
|
||||
water_dt_cfl = 0.0_rk
|
||||
water_dt_accel = 0.0_rk
|
||||
water_dt_viscous = 0.0_rk
|
||||
end subroutine sph_db_clear_water_diagnostics
|
||||
|
||||
subroutine sph_db_allocate_neighbor_storage(max_links, num_cells, ierr)
|
||||
integer, intent(in) :: max_links
|
||||
integer, intent(in) :: num_cells
|
||||
integer, intent(out) :: ierr
|
||||
integer :: stat
|
||||
|
||||
ierr = SPH_SUCCESS
|
||||
if (max_links < 0 .or. num_cells < 0) then
|
||||
call sph_error_set(SPH_ERROR_ARGUMENT, 'neighbor storage sizes must be non-negative')
|
||||
ierr = SPH_ERROR_ARGUMENT
|
||||
return
|
||||
end if
|
||||
if (allocated(neighbor_list)) deallocate(neighbor_list)
|
||||
if (allocated(cell_head)) deallocate(cell_head)
|
||||
allocate(neighbor_list(max_links), cell_head(num_cells), stat=stat)
|
||||
if (stat /= 0) then
|
||||
call sph_error_set(SPH_ERROR_DATABASE, 'failed to allocate neighbor storage')
|
||||
ierr = SPH_ERROR_DATABASE
|
||||
return
|
||||
end if
|
||||
if (max_links > 0) neighbor_list = 0
|
||||
if (num_cells > 0) cell_head = 0
|
||||
end subroutine sph_db_allocate_neighbor_storage
|
||||
|
||||
subroutine sph_db_get_particle_count(count, ierr)
|
||||
integer, intent(out) :: count
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
Reference in New Issue
Block a user