Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/convection/incflo_compute_MAC_projected_velocities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ incflo::compute_MAC_projected_velocities (
Real /*time*/)
{
BL_PROFILE("incflo::compute_MAC_projected_velocities()");
Real l_dt = m_dt;
Real l_dt = dt_real();

auto mac_phi = get_mac_phi();

Expand Down Expand Up @@ -60,7 +60,7 @@ incflo::compute_MAC_projected_velocities (
} // end m_godunov_include_diff_in_forcing

if (nghost_force() > 0) {
fillpatch_force(m_cur_time, vel_forces, nghost_force());
fillpatch_force(cur_time_real(), vel_forces, nghost_force());
}

} // end m_advection_type
Expand Down Expand Up @@ -198,7 +198,7 @@ incflo::compute_MAC_projected_velocities (
{
MultiFab time_dep_inflow_vel(vel[lev]->boxArray(),vel[lev]->DistributionMap(),AMREX_SPACEDIM,1);
time_dep_inflow_vel.setVal(0.);
fillphysbc_velocity(lev, m_cur_time+Real(0.5)*l_dt, time_dep_inflow_vel, 1);
fillphysbc_velocity(lev, real_time(m_cur_time + 0.5*m_dt), time_dep_inflow_vel, 1);

Box domain(geom[lev].Domain());
const auto dlo = lbound(domain);
Expand Down
18 changes: 9 additions & 9 deletions src/convection/incflo_compute_advection_term.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ incflo::compute_convective_term (Vector<MultiFab*> const& conv_u,
} // end m_godunov_include_diff_in_forcing

if (nghost_force() > 0)
fillpatch_force(m_cur_time, vel_forces, nghost_force());
fillpatch_force(cur_time_real(), vel_forces, nghost_force());

// Note that for conservative tracers, this is forcing for (rho s)
// and for non-conservative, this is forcing for s
Expand All @@ -198,12 +198,12 @@ incflo::compute_convective_term (Vector<MultiFab*> const& conv_u,
for (int lev = 0; lev <= finest_level; ++lev)
MultiFab::Add(*tra_forces[lev], m_leveldata[lev]->laps_o, 0, 0, m_ntrac, 0);
if (nghost_force() > 0)
fillpatch_force(m_cur_time, tra_forces, nghost_force());
fillpatch_force(cur_time_real(), tra_forces, nghost_force());
}

if (m_use_temperature)
{
compute_tem_forces(m_cur_time, tem_forces);
compute_tem_forces(cur_time_real(), tem_forces);
for (int lev = 0; lev <= finest_level; ++lev) {
auto& ld = *m_leveldata[lev];
#ifdef _OPENMP
Expand Down Expand Up @@ -233,14 +233,14 @@ incflo::compute_convective_term (Vector<MultiFab*> const& conv_u,
}
}
if (nghost_force() > 0) {
fillpatch_force(m_cur_time, tem_forces, nghost_force()); }
fillpatch_force(cur_time_real(), tem_forces, nghost_force()); }
}

} // end m_advection_type

for (int lev = 0; lev <= finest_level; ++lev)
{
Real time_nph = m_cur_time + Real(0.5)*m_dt;
Real time_nph = real_time(m_cur_time + 0.5*m_dt);
if (nghost_mac() > 0)
{
// FillPatch umac.
Expand Down Expand Up @@ -672,7 +672,7 @@ incflo::compute_convective_term (Vector<MultiFab*> const& conv_u,
: m_advect_momentum
? rhovel_f.const_array()
: vel_forces[lev]->const_array(mfi),
geom[lev], m_dt,
geom[lev], dt_real(),
get_velocity_bcrec(),
get_velocity_bcrec_device_ptr(),
get_velocity_iconserv_device_ptr(),
Expand Down Expand Up @@ -710,7 +710,7 @@ incflo::compute_convective_term (Vector<MultiFab*> const& conv_u,
v_mac[lev]->const_array(mfi),
w_mac[lev]->const_array(mfi)),
divu_arr, Array4<Real const>{},
geom[lev], m_dt,
geom[lev], dt_real(),
get_density_bcrec(),
get_density_bcrec_device_ptr(),
get_density_iconserv_device_ptr(),
Expand Down Expand Up @@ -778,7 +778,7 @@ incflo::compute_convective_term (Vector<MultiFab*> const& conv_u,
w_mac[lev]->const_array(mfi)),
divu_arr,
(!tra_forces.empty()) ? tra_forces[lev]->const_array(mfi) : Array4<Real const>{},
geom[lev], m_dt,
geom[lev], dt_real(),
get_tracer_bcrec(),
get_tracer_bcrec_device_ptr(),
get_tracer_iconserv_device_ptr(),
Expand Down Expand Up @@ -820,7 +820,7 @@ incflo::compute_convective_term (Vector<MultiFab*> const& conv_u,
w_mac[lev]->const_array(mfi)),
divu_arr,
(!tem_forces.empty()) ? tem_forces[lev]->const_array(mfi) : Array4<Real const>{},
geom[lev], m_dt,
geom[lev], dt_real(),
get_temperature_bcrec(),
get_temperature_bcrec_device_ptr(),
m_iconserv_temperature_d.data(),
Expand Down
39 changes: 23 additions & 16 deletions src/incflo.H
Original file line number Diff line number Diff line change
Expand Up @@ -405,27 +405,34 @@ private:
amrex::Vector<amrex::Real> m_t_old;
amrex::Vector<amrex::Real> m_t_new;

// Times
amrex::Real m_cur_time = amrex::Real( 0.0);
amrex::Real m_dt = amrex::Real(-1.0);
amrex::Real m_prev_dt = amrex::Real(-1.0);
amrex::Real m_prev_prev_dt = amrex::Real(-1.0);
// Keep time-step bookkeeping in double precision even in single-precision builds.
double m_cur_time = 0.0;
double m_dt = -1.0;
double m_prev_dt = -1.0;
double m_prev_prev_dt = -1.0;

[[nodiscard]] static amrex::Real real_time (double a_time) noexcept {
return static_cast<amrex::Real>(a_time);
}
[[nodiscard]] amrex::Real cur_time_real () const noexcept { return real_time(m_cur_time); }
[[nodiscard]] amrex::Real dt_real () const noexcept { return real_time(m_dt); }
[[nodiscard]] amrex::Real new_time_real () const noexcept { return real_time(m_cur_time + m_dt); }

// Time step counter
int m_nstep = -1;

// Stop simulation if cur_time reaches stop_time OR nstep reaches max_step
// OR steady_state = true AND steady_state_tol is reached
amrex::Real m_stop_time = amrex::Real(-1.0);
double m_stop_time = -1.0;
int m_max_step = -1;
bool m_steady_state = false;
amrex::Real m_steady_state_tol = amrex::Real(1.0e-5);

// Options to control time stepping
amrex::Real m_cfl = amrex::Real(0.5);
amrex::Real m_fixed_dt = amrex::Real(-1.);
amrex::Real m_init_shrink = amrex::Real(0.1);
amrex::Real m_dt_change_max = amrex::Real(1.1);
double m_cfl = 0.5;
double m_fixed_dt = -1.0;
double m_init_shrink = 0.1;
double m_dt_change_max = 1.1;

// Initial projection / iterations
bool m_do_initial_proj = true;
Expand Down Expand Up @@ -600,16 +607,16 @@ private:
amrex::Real m_papa_reg = 0.0;
//! Lower bound on the strain rate used by the power-law viscosity, so that
//! eta = mu*sr^(n-1) stays finite (and non-zero) at zero strain rate
amrex::Real m_sr_floor = 1.e-9;
amrex::Real m_sr_floor = amrex::Real(1.e-9);
amrex::Real m_eta_0 = 0.0;

int m_plot_int = -1;

// Dump plotfiles at as close as possible to the designated period *without* changing dt
amrex::Real m_plot_per_approx = -1.0;
double m_plot_per_approx = -1.0;

// Dump plotfiles at exactcly the designated period by changing dt
amrex::Real m_plot_per_exact = -1.0;
double m_plot_per_exact = -1.0;

int m_last_plt = -1;
std::string m_plot_file{"plt"};
Expand Down Expand Up @@ -638,7 +645,7 @@ private:
// smallplotfile allows users to output certain variables at a different frequency.
// Off by default.
int m_smallplot_int = -1;
amrex::Real m_smallplot_per_approx = -1.0;
double m_smallplot_per_approx = -1.0;
// No smallplot_per_exact because it requires changing the timestep
int m_last_smallplt = -1;
bool m_smallplotfile_on_restart = false;
Expand Down Expand Up @@ -983,8 +990,8 @@ private:
void Advance ();
[[nodiscard]] bool writeNow () {
return writeNow(m_plot_int, m_plot_per_approx, m_plot_per_exact); }
[[nodiscard]] bool writeNow (int a_plot_int, amrex::Real a_plot_per_approx,
amrex::Real a_plot_per_exact) const;
[[nodiscard]] bool writeNow (int a_plot_int, double a_plot_per_approx,
double a_plot_per_exact) const;

///////////////////////////////////////////////////////////////////////////
//
Expand Down
10 changes: 5 additions & 5 deletions src/incflo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void incflo::InitData ()

// This is an AmrCore member function which recursively makes new levels
// with MakeNewLevelFromScratch.
InitFromScratch(m_cur_time);
InitFromScratch(cur_time_real());

#ifdef AMREX_USE_EB
if (!EBFactory(0).isAllRegular()) {
Expand Down Expand Up @@ -147,7 +147,7 @@ void incflo::Evolve()
if (m_regrid_int > 0 && m_nstep > 0 && m_nstep%m_regrid_int == 0)
{
if (m_verbose > 0) amrex::Print() << "Regridding...\n";
regrid(0, m_cur_time);
regrid(0, cur_time_real());
if (m_verbose > 0 && ParallelDescriptor::IOProcessor()) {
printGridSummary(amrex::OutStream(), 0, finest_level);
}
Expand Down Expand Up @@ -289,7 +289,7 @@ void incflo::MakeNewLevelFromScratch (int lev, Real time, const BoxArray& new_gr
}

bool
incflo::writeNow(int a_plot_int, Real a_plot_per_approx, Real a_plot_per_exact) const
incflo::writeNow(int a_plot_int, double a_plot_per_approx, double a_plot_per_exact) const
{
bool write_now = false;

Expand All @@ -312,8 +312,8 @@ incflo::writeNow(int a_plot_int, Real a_plot_per_approx, Real a_plot_per_exact)
// the counter, because we have indeed reached the next a_plot_per_approx interval
// at this point.

const Real eps = std::numeric_limits<Real>::epsilon() * Real(10.0) * std::abs(m_cur_time);
const Real next_plot_time = (num_per_old + 1) * a_plot_per_approx;
const double eps = std::numeric_limits<double>::epsilon() * 10.0 * std::abs(m_cur_time);
const double next_plot_time = (num_per_old + 1) * a_plot_per_approx;

if ((num_per_new == num_per_old) && std::abs(m_cur_time - next_plot_time) <= eps)
{
Expand Down
12 changes: 6 additions & 6 deletions src/incflo_advance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ void incflo::Advance()

int ng = nghost_state();
for (int lev = 0; lev <= finest_level; ++lev) {
fillpatch_velocity(lev, m_cur_time, m_leveldata[lev]->velocity, ng);
fillpatch_density(lev, m_cur_time, m_leveldata[lev]->density, ng);
fillpatch_velocity(lev, cur_time_real(), m_leveldata[lev]->velocity, ng);
fillpatch_density(lev, cur_time_real(), m_leveldata[lev]->density, ng);
if (m_advect_tracer) {
fillpatch_tracer(lev, m_cur_time, m_leveldata[lev]->tracer, ng);
fillpatch_tracer(lev, cur_time_real(), m_leveldata[lev]->tracer, ng);
}
if (m_use_temperature) {
fillpatch_temperature(lev, m_cur_time, m_leveldata[lev]->temperature, ng);
fillpatch_temperature(lev, cur_time_real(), m_leveldata[lev]->temperature, ng);
}
}

Expand All @@ -34,8 +34,8 @@ void incflo::Advance()
// Set new and old time to correctly use in fillpatching
for(int lev = 0; lev <= finest_level; lev++)
{
m_t_old[lev] = m_cur_time;
m_t_new[lev] = m_cur_time + m_dt;
m_t_old[lev] = cur_time_real();
m_t_new[lev] = new_time_real();
}

if (m_verbose > 0)
Expand Down
4 changes: 2 additions & 2 deletions src/incflo_apply_corrector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void incflo::ApplyCorrector()
BL_PROFILE("incflo::ApplyCorrector");

// We use the new time value for things computed on the "*" state
Real new_time = m_cur_time + m_dt;
Real new_time = new_time_real();

// *************************************************************************************
// Allocate space for the MAC velocities
Expand Down Expand Up @@ -163,7 +163,7 @@ void incflo::ApplyCorrector()
bool incremental_projection = false;
ApplyProjection(get_density_nph_const(),
AMREX_D_DECL(GetVecOfPtrs(u_mac), GetVecOfPtrs(v_mac),
GetVecOfPtrs(w_mac)),new_time,m_dt,incremental_projection);
GetVecOfPtrs(w_mac)), new_time, dt_real(), incremental_projection);

#ifdef AMREX_USE_EB
// **********************************************************************************************
Expand Down
12 changes: 6 additions & 6 deletions src/incflo_apply_predictor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void incflo::ApplyPredictor (bool incremental_projection)
BL_PROFILE("incflo::ApplyPredictor");

// We use the new time value for things computed on the "*" state
Real new_time = m_cur_time + m_dt;
Real new_time = new_time_real();

// *************************************************************************************
// Allocate space for the MAC velocities
Expand Down Expand Up @@ -137,7 +137,7 @@ void incflo::ApplyPredictor (bool incremental_projection)
// *************************************************************************************
compute_viscosity(GetVecOfPtrs(vel_eta),
get_density_old(), get_velocity_old(),
m_cur_time, nghost_eta);
cur_time_real(), nghost_eta);

// *************************************************************************************
// Compute explicit viscous term
Expand All @@ -161,7 +161,7 @@ void incflo::ApplyPredictor (bool incremental_projection)
}
if (m_use_temperature)
{
compute_temperature_diff_coeff(m_cur_time, GetVecOfPtrs(tem_eta));
compute_temperature_diff_coeff(cur_time_real(), GetVecOfPtrs(tem_eta));
if (need_divtau()) {
compute_laps_T(get_laps_tem_old(), get_temperature_old_const(), GetVecOfConstPtrs(tem_eta));
}
Expand All @@ -180,7 +180,7 @@ void incflo::ApplyPredictor (bool incremental_projection)
// *************************************************************************************
compute_MAC_projected_velocities(get_velocity_old_const(), get_density_old_const(),
AMREX_D_DECL(GetVecOfPtrs(u_mac), GetVecOfPtrs(v_mac),
GetVecOfPtrs(w_mac)), GetVecOfPtrs(vel_forces), m_cur_time);
GetVecOfPtrs(w_mac)), GetVecOfPtrs(vel_forces), cur_time_real());

// *************************************************************************************
// if (advection_type == "Godunov")
Expand All @@ -196,7 +196,7 @@ void incflo::ApplyPredictor (bool incremental_projection)
AMREX_D_DECL(GetVecOfPtrs(u_mac), GetVecOfPtrs(v_mac),
GetVecOfPtrs(w_mac)),
GetVecOfPtrs(vel_forces), GetVecOfPtrs(tra_forces),
GetVecOfPtrs(tem_forces), m_cur_time);
GetVecOfPtrs(tem_forces), cur_time_real());

// *************************************************************************************
// Update density
Expand All @@ -223,7 +223,7 @@ void incflo::ApplyPredictor (bool incremental_projection)
// **********************************************************************************************
ApplyProjection(get_density_nph_const(),
AMREX_D_DECL(GetVecOfPtrs(u_mac), GetVecOfPtrs(v_mac),
GetVecOfPtrs(w_mac)),new_time,m_dt,incremental_projection);
GetVecOfPtrs(w_mac)), new_time, dt_real(), incremental_projection);

#ifdef INCFLO_USE_PARTICLES
// **************************************************************************************
Expand Down
Loading
Loading