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

Use the allow_negative_energy flag to control assertions #59

Merged
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
4 changes: 3 additions & 1 deletion Source/Hydro/CAMR_construct_hydro_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,14 @@ CAMR::construct_hydro_source (const MultiFab& S,
BL_PROFILE_VAR("ctoprim()", ctop);
const Real small_num = CAMRConstants::small_num;
const Real dual_energy_eta = CAMR::dual_energy_eta1;
int l_allow_negative_energy = CAMR::allow_negative_energy;
ParallelFor(
qbx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
#ifdef AMREX_USE_EB
if (!flag_arr(i,j,k).isCovered()) {
#endif
hydro_ctoprim(i, j, k, sarr, qarr, qauxar, *lpmap, small_num, dual_energy_eta);
hydro_ctoprim(i, j, k, sarr, qarr, qauxar, *lpmap,
small_num, dual_energy_eta, l_allow_negative_energy);
#ifdef AMREX_USE_EB
} else {
for (int n=0; n<QVAR; n++) qarr(i,j,k,n) = 0.;
Expand Down
17 changes: 11 additions & 6 deletions Source/Hydro/Hydro_ctoprim.H
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ hydro_ctoprim(
amrex::Array4< amrex::Real> const& q,
amrex::Array4< amrex::Real> const& qa,
PassMap const& pmap,
amrex::Real small_num,
amrex::Real dual_energy_eta1)
amrex::Real l_small_num,
amrex::Real l_dual_energy_eta1,
const int l_allow_negative_energy)
{
const amrex::Real rho = u(i, j, k, URHO);

Expand Down Expand Up @@ -51,17 +52,21 @@ hydro_ctoprim(
// of the separately updated internal energy equation.
// Otherwise, we'll set e = E - K.

AMREX_ALWAYS_ASSERT(u(i,j,k,UEDEN) > 0.);
if (!l_allow_negative_energy) {
AMREX_ALWAYS_ASSERT(u(i,j,k,UEDEN) > 0.);
}

if ( (u(i,j,k,UEDEN) - kineng) / u(i,j,k,UEDEN) > dual_energy_eta1) {
if ( (u(i,j,k,UEDEN) - kineng) / u(i,j,k,UEDEN) > l_dual_energy_eta1) {
q(i,j,k,QREINT) = (u(i,j,k,UEDEN) - kineng) * rhoinv;
} else {
q(i,j,k,QREINT) = u(i,j,k,UEINT) * rhoinv;
}

const amrex::Real e = q(i,j,k,QREINT);

AMREX_ALWAYS_ASSERT(u(i,j,k,UEINT) > 0.);
if (!l_allow_negative_energy) {
AMREX_ALWAYS_ASSERT(u(i,j,k,UEINT) > 0.);
}

amrex::Real T = u(i, j, k, UTEMP);
amrex::Real massfrac[NUM_SPECIES];
Expand Down Expand Up @@ -91,7 +96,7 @@ hydro_ctoprim(
qa(i, j, k, QGAMC) = gam1;
cs = std::sqrt(gam1*p/rho);
qa(i, j, k, QC) = cs;
qa(i, j, k, QCSML) = std::max(small_num, small_num * cs);
qa(i, j, k, QCSML) = std::max(l_small_num, l_small_num * cs);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Params/_cpp_parameters
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ dual_energy_eta2 Real 1.0e-4
use_pslope int 0

# Whether or not to allow internal energy to be less than zero
allow_negative_energy int 1
allow_negative_energy int 0

# Whether or not to allow the internal energy to be less than the
# internal energy corresponding to small\_temp
Expand Down
2 changes: 1 addition & 1 deletion Source/Params/param_includes/CAMR_defaults.H
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ int CAMR::dual_energy_update_E_from_e = 1;
amrex::Real CAMR::dual_energy_eta1 = 1.0e0;
amrex::Real CAMR::dual_energy_eta2 = 1.0e-4;
int CAMR::use_pslope = 0;
int CAMR::allow_negative_energy = 1;
int CAMR::allow_negative_energy = 0;
int CAMR::allow_small_energy = 1;
int CAMR::transverse_reset_density = 1;
int CAMR::eb_weights_type = 2;
Expand Down