Integrate water explicit stepping and dt limits

This commit is contained in:
Codex
2026-07-02 20:52:05 +08:00
parent 662129d2bb
commit 4809701068
10 changed files with 226 additions and 33 deletions
+31 -4
View File
@@ -1,11 +1,14 @@
module sph_solver_explicit
use sph_precision, only: rk
use sph_error, only: SPH_SUCCESS, SPH_ERROR_ARGUMENT, sph_error_set
use sph_control, only: current_time, current_step, dt_default, end_time, max_steps
use sph_database, only: npart, x, v, a, vhalf
use sph_control, only: current_time, current_step, dt_default, end_time, max_steps, &
safety_factor, output_interval, output_enabled
use sph_database, only: npart, x, v, a, vhalf, rho, drho_dt
use sph_neighbor, only: sph_neighbor_rebuild
use sph_water, only: sph_water_update_pressure, sph_water_compute_density_rate, &
sph_water_compute_acceleration, sph_water_update_diagnostics
sph_water_compute_acceleration, sph_water_update_diagnostics, &
sph_water_estimate_dt_limits
use sph_output_csv, only: sph_output_write_step
implicit none
contains
@@ -14,8 +17,13 @@ contains
real(rk), intent(out) :: dtcrit
integer, intent(out) :: ierr
dtcrit = dt_default
ierr = SPH_SUCCESS
dtcrit = dt_default
if (npart > 0) then
call sph_solver_water_dt(dtcrit, ierr)
if (ierr /= SPH_SUCCESS) return
if (dtcrit <= 0.0_rk .or. dtcrit > dt_default) dtcrit = dt_default
end if
end subroutine sph_solver_estimate_stable_dt
subroutine sph_solver_advance_explicit(dt, ierr)
@@ -42,6 +50,7 @@ contains
do i = 1, npart
vhalf(:,i) = v(:,i) + 0.5_rk * dt * a(:,i)
x(:,i) = x(:,i) + dt * vhalf(:,i)
rho(i) = rho(i) + dt * drho_dt(i)
v(:,i) = vhalf(:,i) + 0.5_rk * dt * a(:,i)
end do
call sph_water_update_diagnostics(ierr)
@@ -50,6 +59,12 @@ contains
current_time = current_time + dt
current_step = current_step + 1
if (output_enabled .and. output_interval > 0) then
if (mod(current_step, output_interval) == 0) then
call sph_output_write_step(current_step, current_time, ierr)
if (ierr /= SPH_SUCCESS) return
end if
end if
end subroutine sph_solver_advance_explicit
subroutine sph_solver_run_explicit(ierr)
@@ -70,4 +85,16 @@ contains
end do
end subroutine sph_solver_run_explicit
subroutine sph_solver_water_dt(dtcrit, ierr)
real(rk), intent(out) :: dtcrit
integer, intent(out) :: ierr
real(rk) :: dt_cfl
real(rk) :: dt_accel
real(rk) :: dt_viscous
call sph_water_estimate_dt_limits(dt_cfl, dt_accel, dt_viscous, ierr)
if (ierr /= SPH_SUCCESS) return
dtcrit = min(dt_cfl, min(dt_accel, dt_viscous)) * safety_factor
end subroutine sph_solver_water_dt
end module sph_solver_explicit