Skip to content

Commit

Permalink
Merge pull request #1584 from zingale/amrex_namespace
Browse files Browse the repository at this point in the history
remove using namespace amrex from aprox nets
  • Loading branch information
zingale authored Jun 21, 2024
2 parents 30469dd + 2d23cce commit f9e2e1d
Show file tree
Hide file tree
Showing 59 changed files with 735 additions and 736 deletions.
14 changes: 7 additions & 7 deletions integration/BackwardEuler/be_integrator.H
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ int single_step (BurnT& state, BeT& be, const amrex::Real dt)
// create our current guess for the solution -- just as a first
// order explicit prediction

Array1D<amrex::Real, 1, int_neqs> ydot;
amrex::Array1D<amrex::Real, 1, int_neqs> ydot;

rhs(be.t, state, be, ydot);

be.n_rhs += 1;

Array1D<amrex::Real, 1, int_neqs> y_old;
amrex::Array1D<amrex::Real, 1, int_neqs> y_old;

for (int n = 1; n <= int_neqs; n++) {
y_old(n) = be.y(n);
Expand Down Expand Up @@ -87,7 +87,7 @@ int single_step (BurnT& state, BeT& be, const amrex::Real dt)

// construct the RHS of our linear system

Array1D<amrex::Real, 1, int_neqs> b;
amrex::Array1D<amrex::Real, 1, int_neqs> b;
for (int n = 1; n <= int_neqs; n++) {
b(n) = y_old(n) - be.y(n) + dt * ydot(n);
}
Expand Down Expand Up @@ -181,7 +181,7 @@ int be_integrator (BurnT& state, BeT& be)

// estimate the timestep

Array1D<amrex::Real, 1, int_neqs> ydot;
amrex::Array1D<amrex::Real, 1, int_neqs> ydot;
rhs(be.t, state, be, ydot);

be.n_rhs += 1;
Expand All @@ -194,7 +194,7 @@ int be_integrator (BurnT& state, BeT& be)
be.n_step < ode_max_steps) {

// store the current solution -- we'll revert to this if a step fails
Array1D<amrex::Real, 1, int_neqs> y_old;
amrex::Array1D<amrex::Real, 1, int_neqs> y_old;
for (int n = 1; n <= int_neqs; ++n) {
y_old(n) = be.y(n);
}
Expand All @@ -213,7 +213,7 @@ int be_integrator (BurnT& state, BeT& be)

// first do 2 (fine) dt/2 steps

Array1D<amrex::Real, 1, int_neqs> y_fine;
amrex::Array1D<amrex::Real, 1, int_neqs> y_fine;

ierr = single_step(state, be, dt_sub/2);
if (ierr == IERR_SUCCESS) {
Expand All @@ -235,7 +235,7 @@ int be_integrator (BurnT& state, BeT& be)

// define a weight for each variable to use in checking the error

Array1D<amrex::Real, 1, int_neqs> w;
amrex::Array1D<amrex::Real, 1, int_neqs> w;
for (int n = 1; n <= NumSpec; n++) {
w(n) = 1.0_rt / (be.rtol_spec * std::abs(y_fine(n)) + be.atol_spec);
}
Expand Down
32 changes: 16 additions & 16 deletions integration/ForwardEuler/actual_integrator.H
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,28 @@ using namespace integrator_rp;

template <typename IntT, typename BurnT>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
Real calculate_dt (IntT& int_state, BurnT& state, Array1D<Real, 1, NumSpec>& spec_rhs, Real& ener_rhs)
amrex::Real calculate_dt (IntT& int_state, BurnT& state, amrex::Array1D<amrex::Real, 1, NumSpec>& spec_rhs, amrex::Real& ener_rhs)
{
using namespace microphysics::forward_euler;

// Our timestepping strategy is to prevent any quantity
// from changing by more than a certain factor in any
// timestep. We ignore this for species below atol_spec.

Real dt = 1.0e200_rt;
amrex::Real dt = 1.0e200_rt;

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

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

Real target_dX;
amrex::Real target_dX;
if (spec_rhs(n) > 0.0) {
target_dX = (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];
}

Real dXdt = amrex::max(std::abs(spec_rhs(n)), 1.0e-30_rt);
amrex::Real dXdt = amrex::max(std::abs(spec_rhs(n)), 1.0e-30_rt);

dt = amrex::min(dt, target_dX / dXdt);

Expand All @@ -50,14 +50,14 @@ Real calculate_dt (IntT& int_state, BurnT& state, Array1D<Real, 1, NumSpec>& spe

if (integrate_energy) {

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

Real dedt = amrex::max(std::abs(ener_rhs), 1.0e-30_rt);
amrex::Real dedt = amrex::max(std::abs(ener_rhs), 1.0e-30_rt);

dt = amrex::min(dt, target_de / dedt);

Expand All @@ -70,7 +70,7 @@ Real calculate_dt (IntT& int_state, BurnT& state, Array1D<Real, 1, NumSpec>& spe

template <typename IntT, typename BurnT>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void clean_state (const Real time, IntT& int_state, BurnT& state)
void clean_state (const amrex::Real time, IntT& int_state, BurnT& state)
{
using namespace microphysics::forward_euler;

Expand All @@ -92,13 +92,13 @@ void clean_state (const Real time, IntT& int_state, BurnT& state)

template <typename IntT, typename BurnT>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void evaluate_rhs (IntT& int_state, BurnT& state, Array1D<Real, 1, NumSpec>& spec_rhs, Real& ener_rhs)
void evaluate_rhs (IntT& int_state, BurnT& state, amrex::Array1D<amrex::Real, 1, NumSpec>& spec_rhs, amrex::Real& ener_rhs)
{
using namespace microphysics::forward_euler;

// Evaluate the RHS.

Array1D<Real, 1, neqs> ydot;
amrex::Array1D<amrex::Real, 1, neqs> ydot;

actual_rhs(state, ydot);

Expand Down Expand Up @@ -158,7 +158,7 @@ void initialize_int_state (IntT& int_state)

template <typename BurnT>
AMREX_GPU_HOST_DEVICE AMREX_INLINE
void actual_integrator (BurnT& state, Real dt, bool is_retry=false)
void actual_integrator (BurnT& state, amrex::Real dt, bool is_retry=false)
{
using namespace microphysics::forward_euler;

Expand All @@ -172,24 +172,24 @@ void actual_integrator (BurnT& state, Real dt, bool is_retry=false)

fe.tout = dt;

Real T_in = state.T;
Real e_in = state.e;
Real xn_in[NumSpec];
amrex::Real T_in = state.T;
amrex::Real e_in = state.e;
amrex::Real xn_in[NumSpec];
for (int n = 0; n < NumSpec; ++n) {
xn_in[n] = state.xn[n];
}

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

Array1D<Real, 1, NumSpec> spec_rhs;
Real ener_rhs;
amrex::Array1D<amrex::Real, 1, NumSpec> spec_rhs;
amrex::Real ener_rhs;

evaluate_rhs(fe, state, spec_rhs, ener_rhs);

// Calculate the timestep.

Real dt_sub = calculate_dt(fe, state, spec_rhs, ener_rhs);
amrex::Real dt_sub = calculate_dt(fe, state, spec_rhs, ener_rhs);

// Prevent the timestep from overshooting the final time.

Expand Down
4 changes: 2 additions & 2 deletions integration/ForwardEuler/fe_type.H
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace forward_euler {
// When checking the integration time to see if we're done,
// be careful with roundoff issues.

const Real timestep_safety_factor = 1.0e-12_rt;
const amrex::Real timestep_safety_factor = 1.0e-12_rt;

template <int int_neqs>
struct fe_t {
Expand All @@ -36,7 +36,7 @@ struct fe_t {
amrex::Real atol_enuc;
amrex::Real rtol_enuc;

Array1D<Real, 1, int_neqs> y;
amrex::Array1D<amrex::Real, 1, int_neqs> y;
};

} // namespace forward_euler
Expand Down
Loading

0 comments on commit f9e2e1d

Please sign in to comment.