Calculates domain-wide CFL and optionally scales the timestep size.
For stability in reacting flows, the timestep growth is capped
to 2% per step when use_dynamic_dt is active.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mesh_t), | intent(in) | :: | mesh | |||
| type(flow_mpi_t), | intent(in) | :: | flow | |||
| type(case_params_t), | intent(inout) | :: | params | |||
| type(flow_fields_t), | intent(in) | :: | fields | |||
| type(solver_stats_t), | intent(inout) | :: | stats |
subroutine compute_and_update_cfl(mesh, flow, params, fields, stats) type(mesh_t), intent(in) :: mesh type(flow_mpi_t), intent(in) :: flow type(case_params_t), intent(inout) :: params type(flow_fields_t), intent(in) :: fields type(solver_stats_t), intent(inout) :: stats integer :: c, lf, f real(rk) :: local_cfl_rate, max_cfl_rate real(rk) :: cell_outward_flux integer :: ierr local_cfl_rate = zero do c = flow%first_cell, flow%last_cell cell_outward_flux = zero do lf = 1, mesh%ncell_faces(c) f = mesh%cell_faces(lf, c) cell_outward_flux = cell_outward_flux + abs(fields%face_flux(f)) end do cell_outward_flux = half * cell_outward_flux / mesh%cells(c)%volume if (cell_outward_flux > local_cfl_rate) then local_cfl_rate = cell_outward_flux end if end do call MPI_Allreduce(local_cfl_rate, max_cfl_rate, 1, MPI_DOUBLE_PRECISION, MPI_MAX, flow%comm, ierr) call check_mpi(ierr, 'cfl max rate') if (params%use_dynamic_dt) then if (max_cfl_rate > tiny_safe) then ! Tighten dt growth cap to 1.02x per step for stability starting from rest params%dt = min(params%max_cfl / max_cfl_rate, params%dt * 1.02_rk) end if end if stats%cfl = max_cfl_rate * params%dt end subroutine compute_and_update_cfl