Skip to content

Commit

Permalink
Cleanup (AMReX-Fluids#103)
Browse files Browse the repository at this point in the history
1. Make first call to compute_vel_forces in ApplyPredictor safer for new
forms of the forcing term. For the forcing terms currently in incflo,
the old way was fine and this code change should not alter results.
However, for restart, only old time data is guaranteed to be FillPatched
at this point. So, since old and new represent the same data at this
point in the code, this is a safer choice for more general forms of the
forcing term that users may wish to introduce.
2. Add time step options to Docs
3. Add a comment, fix typo and outdated info in other comments.
  • Loading branch information
cgilet authored Jun 14, 2024
1 parent 0a40f11 commit 4a94e63
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Docs/sphinx_documentation/source/InputsTimeStepping.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ The inputs below must be preceded by "incflo."
+----------------------+-----------------------------------------------------------------------+-------------+--------------+
| cfl | CFL constraint (dt < cfl * dx / u) if fixed_dt not > 0 | Real | 0.5 |
+----------------------+-----------------------------------------------------------------------+-------------+--------------+
| dt_change_max | maximum percentage dt can increase | Real | 1.1 |
+----------------------+-----------------------------------------------------------------------+-------------+--------------+
| init_shrink | reduce the initial time step by this safety factor | Real | 0.1 |
+----------------------+-----------------------------------------------------------------------+-------------+--------------+

Setting the Time Step
---------------------
Expand Down
5 changes: 3 additions & 2 deletions src/incflo_apply_predictor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ using namespace amrex;
//
// vel = u** - dt * grad p / rho^nph
//
// It is assumed that the ghost cels of the old data have been filled and
// It is assumed that the ghost cells of the old data have been filled and
// the old and new data are the same in valid region.
//
void incflo::ApplyPredictor (bool incremental_projection)
Expand Down Expand Up @@ -139,6 +139,7 @@ void incflo::ApplyPredictor (bool incremental_projection)

// *************************************************************************************
// Compute explicit viscous term
// Note that for !advect_momentum, this actually computes divtau / rho
// *************************************************************************************
if (need_divtau() || use_tensor_correction )
{
Expand All @@ -160,7 +161,7 @@ void incflo::ApplyPredictor (bool incremental_projection)
// *************************************************************************************
bool include_pressure_gradient = !(m_use_mac_phi_in_godunov);
compute_vel_forces(GetVecOfPtrs(vel_forces), get_velocity_old_const(),
get_density_old_const(), get_tracer_old_const(), get_tracer_new_const(),
get_density_old_const(), get_tracer_old_const(), get_tracer_old_const(),
include_pressure_gradient);
compute_MAC_projected_velocities(get_velocity_old_const(), get_density_old_const(),
AMREX_D_DECL(GetVecOfPtrs(u_mac), GetVecOfPtrs(v_mac),
Expand Down
2 changes: 1 addition & 1 deletion src/incflo_compute_dt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ void incflo::ComputeDt (int initialization, bool explicit_diffusion)
dt_new = Real(0.5) * m_dt;
}

// Don't let the timestep grow by more than 10% per step
// Don't let the timestep grow by more than m_dt_change_max per step
// unless the previous time step was unduly shrunk to match m_plot_per_exact
Real allowed_change_factor = m_dt_change_max;
if( (m_dt > Real(0.0)) && !(m_plot_per_exact > 0 && m_last_plt == m_nstep && m_nstep > 0) )
Expand Down

0 comments on commit 4a94e63

Please sign in to comment.