Skip to content

Commit

Permalink
Fix FPE when CFLs are zero (Exawind#558)
Browse files Browse the repository at this point in the history
* Fix FPE when CFLs are zero

* Abort if using adaptive time stepping and the CFL is small
  • Loading branch information
marchdf authored Jan 31, 2022
1 parent d006144 commit fbc58ec
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion amr-wind/core/SimTime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,15 @@ void SimTime::set_current_cfl(
const amrex::Real cd_cfl = conv_cfl + diff_cfl;
const amrex::Real cfl_unit_time =
cd_cfl + std::sqrt(cd_cfl * cd_cfl + 4.0 * src_cfl);
amrex::Real dt_new = 2.0 * m_max_cfl / cfl_unit_time;
if ((m_adaptive) &&
(cfl_unit_time < std::numeric_limits<amrex::Real>::epsilon())) {
amrex::Abort(
"CFL is below machine epsilon and the time step is adaptive. "
"Please use a fixed time step or fix the case setup");
}
amrex::Real dt_new =
2.0 * m_max_cfl /
amrex::max(cfl_unit_time, std::numeric_limits<amrex::Real>::epsilon());

// Restrict timestep during initialization phase
if (m_is_init) {
Expand Down

0 comments on commit fbc58ec

Please sign in to comment.