Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove "use namespace integrator_rp" #1625

Merged
merged 5 commits into from
Jul 26, 2024
Merged
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
14 changes: 6 additions & 8 deletions EOS/helmholtz/actual_eos.H
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
#include <cmath>
#include <vector>

using namespace eos_rp;

// Frank Timmes Helmholtz based Equation of State
// https://cococubed.com/

Expand Down Expand Up @@ -576,8 +574,8 @@ void apply_radiation (T& state)
// on prad, this will result in the radiation term effectively vanishing below the
// cutoff density. For simplicity we ignore the effect this has on the derivatives.

if (prad_limiter_rho_c > 0.0e0_rt && prad_limiter_delta_rho > 0.0e0_rt) {
prad = prad * 0.5e0_rt * (1.0e0_rt + std::tanh((state.rho - prad_limiter_rho_c) / prad_limiter_delta_rho));
if (eos_rp::prad_limiter_rho_c > 0.0e0_rt && eos_rp::prad_limiter_delta_rho > 0.0e0_rt) {
prad = prad * 0.5e0_rt * (1.0e0_rt + std::tanh((state.rho - eos_rp::prad_limiter_rho_c) / eos_rp::prad_limiter_delta_rho));
}

amrex::Real dpraddd = 0.0e0_rt;
Expand Down Expand Up @@ -1310,10 +1308,10 @@ void actual_eos_init ()

// Read in the runtime parameters

input_is_constant = eos_input_is_constant;
do_coulomb = use_eos_coulomb;
ttol = eos_ttol;
dtol = eos_dtol;
input_is_constant = eos_rp::eos_input_is_constant;
do_coulomb = eos_rp::use_eos_coulomb;
ttol = eos_rp::eos_ttol;
dtol = eos_rp::eos_dtol;

// read the helmholtz free energy table

Expand Down
3 changes: 0 additions & 3 deletions integration/BackwardEuler/_parameters
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
@namespace: integrator

# Maximum amount any quantity can change by in a timestep
maximum_timestep_change_factor real 1.01

# Maximum number of iterations for the Newton solve
max_iter int 25

Expand Down
8 changes: 4 additions & 4 deletions integration/BackwardEuler/be_integrator.H
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ int single_step (BurnT& state, BeT& be, const amrex::Real dt)

// Newton loop

for (int iter = 1; iter <= max_iter; iter++) {
for (int iter = 1; iter <= integrator_rp::max_iter; iter++) {

// work with the current guess

Expand Down Expand Up @@ -136,7 +136,7 @@ int single_step (BurnT& state, BeT& be, const amrex::Real dt)
y_norm = std::sqrt(y_norm / int_neqs);
b_norm = std::sqrt(b_norm / int_neqs);

if (b_norm < tol * y_norm) {
if (b_norm < integrator_rp::tol * y_norm) {
converged = true;
break;
}
Expand Down Expand Up @@ -191,7 +191,7 @@ int be_integrator (BurnT& state, BeT& be)
// main timestepping loop

while (be.t < (1.0_rt - timestep_safety_factor) * be.tout &&
be.n_step < ode_max_steps) {
be.n_step < integrator_rp::ode_max_steps) {

// store the current solution -- we'll revert to this if a step fails
amrex::Array1D<amrex::Real, 1, int_neqs> y_old;
Expand Down Expand Up @@ -291,7 +291,7 @@ int be_integrator (BurnT& state, BeT& be)

}

if (be.n_step >= ode_max_steps) {
if (be.n_step >= integrator_rp::ode_max_steps) {
ierr = IERR_TOO_MANY_STEPS;
}

Expand Down
36 changes: 17 additions & 19 deletions integration/ForwardEuler/actual_integrator.H
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
#include <fe_type.H>
#include <integrator_data.H>

using namespace integrator_rp;

template <typename IntT, typename BurnT>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
amrex::Real calculate_dt (IntT& int_state, BurnT& state, amrex::Array1D<amrex::Real, 1, NumSpec>& spec_rhs, amrex::Real& ener_rhs)
Expand All @@ -31,13 +29,13 @@ amrex::Real calculate_dt (IntT& int_state, BurnT& state, amrex::Array1D<amrex::R

for (int n = 1; n <= NumSpec; ++n) {

if (state.xn[n-1] >= atol_spec) {
if (state.xn[n-1] >= integrator_rp::atol_spec) {

amrex::Real target_dX;
if (spec_rhs(n) > 0.0) {
target_dX = (maximum_timestep_change_factor - 1.0_rt) * state.xn[n-1];
target_dX = (integrator_rp::maximum_timestep_change_factor - 1.0_rt) * state.xn[n-1];
} else {
target_dX = (1.0_rt - 1.0_rt / maximum_timestep_change_factor) * state.xn[n-1];
target_dX = (1.0_rt - 1.0_rt / integrator_rp::maximum_timestep_change_factor) * state.xn[n-1];
}

amrex::Real dXdt = amrex::max(std::abs(spec_rhs(n)), 1.0e-30_rt);
Expand All @@ -48,13 +46,13 @@ amrex::Real calculate_dt (IntT& int_state, BurnT& state, amrex::Array1D<amrex::R

}

if (integrate_energy) {
if (integrator_rp::integrate_energy) {

amrex::Real target_de;
if (ener_rhs > 0.0) {
target_de = (maximum_timestep_change_factor - 1.0_rt) * state.e;
target_de = (integrator_rp::maximum_timestep_change_factor - 1.0_rt) * state.e;
} else {
target_de = (1.0_rt - 1.0_rt / maximum_timestep_change_factor) * state.e;
target_de = (1.0_rt - 1.0_rt / integrator_rp::maximum_timestep_change_factor) * state.e;
}

amrex::Real dedt = amrex::max(std::abs(ener_rhs), 1.0e-30_rt);
Expand All @@ -63,7 +61,7 @@ amrex::Real calculate_dt (IntT& int_state, BurnT& state, amrex::Array1D<amrex::R

}

dt = amrex::min(dt, ode_max_dt);
dt = amrex::min(dt, integrator_rp::ode_max_dt);

return dt;
}
Expand All @@ -80,13 +78,13 @@ void clean_state (const amrex::Real time, IntT& int_state, BurnT& state)

// Evaluate the EOS to get T from e.

if (call_eos_in_rhs) {
if (integrator_rp::call_eos_in_rhs) {
eos(eos_input_re, state);
}

// Ensure that the temperature always stays within reasonable limits.

state.T = std::clamp(state.T, EOSData::mintemp, MAX_TEMP);
state.T = std::clamp(state.T, EOSData::mintemp, integrator_rp::MAX_TEMP);

}

Expand Down Expand Up @@ -142,11 +140,11 @@ void initialize_int_state (IntT& int_state)

// Set the tolerances.

int_state.atol_spec = atol_spec; // mass fractions
int_state.atol_enuc = atol_enuc; // energy generated
int_state.atol_spec = integrator_rp::atol_spec; // mass fractions
int_state.atol_enuc = integrator_rp::atol_enuc; // energy generated

int_state.rtol_spec = rtol_spec; // mass fractions
int_state.rtol_enuc = rtol_enuc; // energy generated
int_state.rtol_spec = integrator_rp::rtol_spec; // mass fractions
int_state.rtol_enuc = integrator_rp::rtol_enuc; // energy generated

// Initialize the integration time.

Expand Down Expand Up @@ -179,7 +177,7 @@ void actual_integrator (BurnT& state, amrex::Real dt, bool is_retry=false)
xn_in[n] = state.xn[n];
}

while (fe.t < (1.0_rt - timestep_safety_factor) * dt && fe.n_step < ode_max_steps) {
while (fe.t < (1.0_rt - timestep_safety_factor) * dt && fe.n_step < integrator_rp::ode_max_steps) {
// Evaluate the RHS.

amrex::Array1D<amrex::Real, 1, NumSpec> spec_rhs;
Expand All @@ -204,7 +202,7 @@ void actual_integrator (BurnT& state, amrex::Real dt, bool is_retry=false)
state.xn[n-1] += spec_rhs(n) * dt_sub;
}

if (integrate_energy) {
if (integrator_rp::integrate_energy) {
fe.y(net_ienuc) += ener_rhs * dt_sub;
state.e += ener_rhs * dt_sub;
}
Expand All @@ -215,7 +213,7 @@ void actual_integrator (BurnT& state, amrex::Real dt, bool is_retry=false)
clean_state(fe.t, fe, state);
}

if (fe.n_step >= ode_max_steps) {
if (fe.n_step >= integrator_rp::ode_max_steps) {
state.success = false;
state.error_code = IERR_TOO_MANY_STEPS;
}
Expand All @@ -226,7 +224,7 @@ void actual_integrator (BurnT& state, amrex::Real dt, bool is_retry=false)
state.n_jac = 0;

#ifndef AMREX_USE_GPU
if (burner_verbose) {
if (integrator_rp::burner_verbose) {
// Print out some integration statistics, if desired.
std::cout << "integration summary: " << std::endl;
std::cout << "dens: " << state.rho << " temp: " << state.T << std::endl;
Expand Down
44 changes: 21 additions & 23 deletions integration/QSS/actual_integrator.H
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
#include <extern_parameters.H>
#include <integrator_data.H>

using namespace integrator_rp;

template <typename BurnT>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void clean_state (BurnT& state)
Expand All @@ -26,13 +24,13 @@ void clean_state (BurnT& state)

// Evaluate the EOS to get T from e.

if (call_eos_in_rhs) {
if (integrator_rp::call_eos_in_rhs) {
eos(eos_input_re, state);
}

// Ensure that the temperature always stays within reasonable limits.

state.T = amrex::min(MAX_TEMP, amrex::max(state.T, EOSData::mintemp));
state.T = amrex::min(integrator_rp::MAX_TEMP, amrex::max(state.T, EOSData::mintemp));
}

template <typename BurnT>
Expand Down Expand Up @@ -78,7 +76,7 @@ void evaluate_rhs (BurnT& state, amrex::Array1D<amrex::Real, 1, NumSpec>& f_minu
f_minus(n) = ydot(2 * n) * aion[n-1];
}

if (integrate_energy) {
if (integrator_rp::integrate_energy) {
dedt = ydot(2 * net_ienuc - 1) - ydot(2 * net_ienuc);
}
else {
Expand Down Expand Up @@ -130,7 +128,7 @@ bool predictor (BurnT& state_0, amrex::Array1D<amrex::Real, 1, NumSpec>& f_minus
amrex::Real dXdt = (f_plus_0(n) - k_0 * X_0) / (1.0_rt + alpha_0 * k_0 * dt);
state.xn[n-1] = X_0 + dt * dXdt;

if (X_0 >= atol_spec && (state.xn[n-1] < -species_tolerance || state.xn[n-1] > 1.0_rt + species_tolerance)) {
if (X_0 >= integrator_rp::atol_spec && (state.xn[n-1] < -integrator_rp::species_tolerance || state.xn[n-1] > 1.0_rt + integrator_rp::species_tolerance)) {
return false;
}
}
Expand Down Expand Up @@ -178,7 +176,7 @@ bool corrector (const BurnT& state_0, const amrex::Array1D<amrex::Real, 1, NumSp

state.xn[n-1] = X_c;

if (X_0 >= atol_spec && (state.xn[n-1] < -species_tolerance || state.xn[n-1] > 1.0_rt + species_tolerance)) {
if (X_0 >= integrator_rp::atol_spec && (state.xn[n-1] < -integrator_rp::species_tolerance || state.xn[n-1] > 1.0_rt + integrator_rp::species_tolerance)) {
return false;
}
}
Expand Down Expand Up @@ -223,14 +221,14 @@ void actual_integrator (BurnT& state, amrex::Real dt, const bool is_retry=false)
amrex::Real dt_sub = dt;

for (int n = 1; n <= NumSpec; ++n) {
if (xn_in[n-1] >= atol_spec) {
if (xn_in[n-1] >= integrator_rp::atol_spec) {
dt_sub = amrex::min(dt_sub, xn_in[n - 1] / amrex::max(std::abs(f_plus_init(n) - f_minus_init(n)), 1.e-50_rt));
}
}

dt_sub *= dt_init_fraction;
dt_sub *= integrator_rp::dt_init_fraction;

dt_sub = amrex::min(dt_sub, ode_max_dt);
dt_sub = amrex::min(dt_sub, integrator_rp::ode_max_dt);

// When checking the integration time to see if we're done,
// be careful with roundoff issues.
Expand All @@ -239,13 +237,13 @@ void actual_integrator (BurnT& state, amrex::Real dt, const bool is_retry=false)

int num_timesteps = 0;

while (t < (1.0_rt - timestep_safety_factor) * dt && num_timesteps < ode_max_steps)
while (t < (1.0_rt - timestep_safety_factor) * dt && num_timesteps < integrator_rp::ode_max_steps)
{
// Start the step with a guess that is a small factor above the previous timestep.

dt_sub *= dt_max_change_factor;
dt_sub *= integrator_rp::dt_max_change_factor;

dt_sub = amrex::min(dt_sub, ode_max_dt);
dt_sub = amrex::min(dt_sub, integrator_rp::ode_max_dt);

// Prevent the timestep from overshooting the final time.

Expand Down Expand Up @@ -304,7 +302,7 @@ void actual_integrator (BurnT& state, amrex::Real dt, const bool is_retry=false)

int timestep_iter = 0;

for (timestep_iter = 0; timestep_iter < num_timestep_iters; ++timestep_iter)
for (timestep_iter = 0; timestep_iter < integrator_rp::num_timestep_iters; ++timestep_iter)
{
// Evaluate the predictor. The return value indicates whether we consider it
// a successful prediction; if it was unsuccessful, we'll cut the timestep by
Expand All @@ -320,7 +318,7 @@ void actual_integrator (BurnT& state, amrex::Real dt, const bool is_retry=false)
BurnT predictor_state = state;

if (!success) {
dt_sub *= dt_cut_factor;
dt_sub *= integrator_rp::dt_cut_factor;
continue;
}

Expand All @@ -329,7 +327,7 @@ void actual_integrator (BurnT& state, amrex::Real dt, const bool is_retry=false)
// predictor for the next. The return value is the maximum relative diff between
// the predictor and the corrector.

for (int corrector_iter = 0; corrector_iter < num_corrector_iters; ++corrector_iter)
for (int corrector_iter = 0; corrector_iter < integrator_rp::num_corrector_iters; ++corrector_iter)
{
success = corrector(state_0, f_minus_0, f_plus_0, dedt_0, t, dt_sub, state);

Expand All @@ -339,7 +337,7 @@ void actual_integrator (BurnT& state, amrex::Real dt, const bool is_retry=false)
}

if (!success) {
dt_sub *= dt_cut_factor;
dt_sub *= integrator_rp::dt_cut_factor;
continue;
}

Expand All @@ -350,15 +348,15 @@ void actual_integrator (BurnT& state, amrex::Real dt, const bool is_retry=false)
for (int n = 1; n <= NumSpec; ++n)
{
amrex::Real dX = std::abs(state.xn[n-1] - predictor_state.xn[n-1]);
if (state_0.xn[n-1] >= atol_spec) {
if (state_0.xn[n-1] >= integrator_rp::atol_spec) {
max_diff = amrex::max(max_diff, dX / state.xn[n-1]);
}
}

// If the relative diff was smaller than the requested tolerance factor, we're done.
// Otherwise, cut dt and try again.

if (max_diff <= predictor_corrector_tolerance) {
if (max_diff <= integrator_rp::predictor_corrector_tolerance) {
break;
}
else {
Expand All @@ -369,14 +367,14 @@ void actual_integrator (BurnT& state, amrex::Real dt, const bool is_retry=false)
// method; given the expense of our RHS it seems unlikely that this would make
// a performance difference, but it is a potential optimization.

amrex::Real sigma = max_diff / (predictor_corrector_tolerance / tolerance_safety_factor);
amrex::Real sigma = max_diff / (integrator_rp::predictor_corrector_tolerance / integrator_rp::tolerance_safety_factor);
dt_sub *= (1.0_rt / std::sqrt(sigma) + 0.005);
}
}

// If we didn't get a converged timestep in the fixed number of iterations, the integration failed.

if (timestep_iter >= num_timestep_iters) {
if (timestep_iter >= integrator_rp::num_timestep_iters) {
state.success = false;
state.error_code = IERR_CORRECTOR_CONVERGENCE;
break;
Expand All @@ -389,7 +387,7 @@ void actual_integrator (BurnT& state, amrex::Real dt, const bool is_retry=false)
state.n_step = num_timesteps;
}

if (num_timesteps >= ode_max_steps) {
if (num_timesteps >= integrator_rp::ode_max_steps) {
state.success = false;
state.error_code = IERR_TOO_MANY_STEPS;
}
Expand All @@ -403,7 +401,7 @@ void actual_integrator (BurnT& state, amrex::Real dt, const bool is_retry=false)
state.e -= e_in;

#ifndef AMREX_USE_GPU
if (burner_verbose) {
if (integrator_rp::burner_verbose) {
// Print out some integration statistics, if desired.
std::cout << "integration summary: " << std::endl;
std::cout << "dens: " << state.rho << " temp: " << state.T << std::endl;
Expand Down
2 changes: 0 additions & 2 deletions integration/RKC/actual_integrator_sdc.H
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
#include <rkc_type.H>
#include <rkc.H>

using namespace integrator_rp;

template <typename BurnT>
AMREX_GPU_HOST_DEVICE AMREX_INLINE
void actual_integrator (BurnT& state, amrex::Real dt, bool is_retry=false)
Expand Down
Loading
Loading