Skip to content

Commit

Permalink
Added a startup dt setting
Browse files Browse the repository at this point in the history
  • Loading branch information
smillerc committed Apr 9, 2021
1 parent 0b4475e commit b79d598
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
11 changes: 11 additions & 0 deletions src/lib/io/mod_input.f90
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ module mod_input

! timing
real(rk) :: max_time = 1.0_rk
logical :: enable_startup_time = .false.
real(rk) :: startup_delta_t = 0.0_rk
real(rk) :: startup_period = 0.0_rk
real(rk) :: cfl = 0.1_rk ! Courant–Friedrichs–Lewy condition
real(rk) :: initial_delta_t = 0.0_rk
logical :: use_constant_delta_t = .false.
Expand Down Expand Up @@ -237,6 +240,14 @@ subroutine read_from_ini(self, filename)
call cfg%get("time", "max_time", self%max_time)
call cfg%get("time", "initial_delta_t", self%initial_delta_t, 0.0_rk)
call cfg%get("time", "use_constant_delta_t", self%use_constant_delta_t, .false.)

call cfg%get("time", "enable_startup_time", self%enable_startup_time, .false.)

if (self%enable_startup_time) then
call cfg%get("time", "startup_period", self%startup_period)
call cfg%get("time", "startup_delta_t", self%startup_delta_t)
endif

call cfg%get("time", "cfl", self%cfl, 0.1_rk)
call cfg%get("time", "integration_strategy", char_buffer)
call cfg%get("time", "max_iterations", self%max_iterations, huge(1))
Expand Down
26 changes: 23 additions & 3 deletions src/main.f90
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ program cato
integer(ik) :: iteration = 0
integer(ik) :: last_io_iteration = 0
logical :: file_exists = .false.
logical :: constant_dt = .false.
real(rk) :: contour_interval_dt, max_time

open(std_error, file='std.err')
Expand Down Expand Up @@ -116,6 +117,8 @@ program cato
call timer%start()
if(input%use_constant_delta_t) then
delta_t = input%initial_delta_t * t_to_nondim
else if (input%enable_startup_time) then
delta_t = input%startup_delta_t * t_to_nondim
else
if(input%initial_delta_t > 0.0_rk) then
delta_t = input%initial_delta_t * t_to_nondim
Expand All @@ -134,16 +137,33 @@ program cato

do while(time < max_time .and. iteration < input%max_iterations)

constant_dt = .false.
if (input%enable_startup_time) then
if (time <= input%startup_period * t_to_nondim) then
constant_dt = .true.
delta_t = input%startup_delta_t * t_to_nondim
endif
else if (input%use_constant_delta_t .or. (iteration == 0 .and. input%initial_delta_t > 0.0_rk)) then
constant_dt = .true.
delta_t = input%initial_delta_t * t_to_nondim
endif

if(this_image() == 1) write(std_out, '(2(a, es10.3), a, i0)') 'Time =', time * io_time_units * t_to_dim, &
' '//trim(io_time_label)//', Delta t =', delta_t * t_to_dim, ' s, Iteration: ', iteration

! Integrate in time
if(input%use_constant_delta_t .or. (iteration == 0 .and. input%initial_delta_t > 0.0_rk)) then
call master%integrate(error_code=error_code, dt=input%initial_delta_t * t_to_nondim)
if (constant_dt) then
call master%integrate(error_code=error_code, dt=delta_t)
else
call master%integrate(error_code=error_code)
endif

! ! Integrate in time
! if(input%use_constant_delta_t .or. (iteration == 0 .and. input%initial_delta_t > 0.0_rk)) then
! call master%integrate(error_code=error_code, dt=input%initial_delta_t * t_to_nondim)
! else
! call master%integrate(error_code=error_code)
! endif

delta_t = master%dt
new_time = master%time

Expand Down

0 comments on commit b79d598

Please sign in to comment.