@@ -31,7 +31,7 @@ module adaptive_timestepping
3131 ! !< Contains new style adaptive timestepping routines
3232
3333 use fldebug
34- use global_parameters, only : OPTION_PATH_LEN, FIELD_NAME_LEN
34+ use global_parameters, only : OPTION_PATH_LEN, FIELD_NAME_LEN, PYTHON_FUNC_LEN
3535 use spud
3636 use unittest_tools
3737 use fields
@@ -70,6 +70,8 @@ subroutine calc_cflnumber_field_based_dt(state, dt, force_calculation)
7070 type (scalar_field), pointer :: cflnumber_field
7171 type (vector_field), pointer :: velocity_field
7272 type (mesh_type), pointer :: mesh
73+ character (len= PYTHON_FUNC_LEN) :: pyfunc
74+ real :: current_time
7375
7476 ewrite(1 , * ) " In calc_cflnumber_field_based_dt"
7577
@@ -79,9 +81,19 @@ subroutine calc_cflnumber_field_based_dt(state, dt, force_calculation)
7981 lforce_calculation = .false.
8082 end if
8183
84+ call get_option(" /timestepping/current_time" , current_time)
85+
8286 call get_option(base_path // " /requested_cfl" , max_cfl)
83- call get_option(base_path // " /minimum_timestep" , min_dt, default = tiny (0.0 ))
84- call get_option(base_path // " /maximum_timestep" , max_dt, default = huge (0.0 ))
87+ call get_option(base_path // " /minimum_timestep/constant" , min_dt, default = tiny (0.0 ))
88+ if (have_option(base_path // ' /minimum_timestep/python' )) then
89+ call get_option(base_path // ' /minimum_timestep/python' , pyfunc)
90+ call real_from_python(pyfunc, current_time, min_dt)
91+ end if
92+ call get_option(base_path // " /maximum_timestep/constant" , max_dt, default = huge (0.0 ))
93+ if (have_option(base_path // ' /maximum_timestep/python' )) then
94+ call get_option(base_path // ' /maximum_timestep/python' , pyfunc)
95+ call real_from_python(pyfunc, current_time, max_dt)
96+ end if
8597 call get_option(base_path // " /increase_tolerance" , increase_tolerance, default = huge (0.0 ) * epsilon (0.0 ))
8698 ! what type of cfl number are we using?
8799 call get_option(base_path// " /courant_number[0]/name" , cfl_type)
@@ -187,6 +199,8 @@ subroutine adaptive_timestepping_check_options
187199 character (len = OPTION_PATH_LEN) :: base_path
188200 integer :: stat
189201 real :: max_cfl, max_dt, min_dt, increase_tolerance
202+ character (len= PYTHON_FUNC_LEN) :: pyfunc
203+ real :: current_time
190204
191205 base_path = " /timestepping/adaptive_timestep"
192206
@@ -205,7 +219,15 @@ subroutine adaptive_timestepping_check_options
205219 FLExit(" Maximum adaptive timestepping CFL number must be positive" )
206220 end if
207221
208- call get_option(trim (base_path) // " /minimum_timestep" , min_dt, stat)
222+ call get_option(" /timestepping/current_time" , current_time)
223+
224+ if (have_option(trim (base_path) // ' /minimum_timestep/constant' )) then
225+ call get_option(trim (base_path) // " /minimum_timestep/constant" , min_dt, stat)
226+ else if (have_option(trim (base_path) // ' /minimum_timestep/python' )) then
227+ call get_option(trim (base_path) // ' /minimum_timestep/python' , pyfunc)
228+ call real_from_python(pyfunc, current_time, min_dt)
229+ end if
230+
209231 if (stat == SPUD_NO_ERROR) then
210232 if (min_dt < 0.0 ) then
211233 FLExit(" Minimum timestep size cannot be negative" )
0 commit comments