Skip to content

Commit

Permalink
Fix bug in indexing for EB-inflow hyperbolics (#895)
Browse files Browse the repository at this point in the history
  • Loading branch information
baperry2 authored Jan 22, 2025
1 parent 88608a0 commit 99caa9e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 43 deletions.
6 changes: 0 additions & 6 deletions Exec/RegTests/EB-InflowBC/prob.H
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,6 @@ struct MyProblemSpecificFunctions : public DefaultProblemSpecificFunctions
prob_lo[1] + static_cast<amrex::Real>(iv[1] + 0.5) * dx[1],
prob_lo[2] + static_cast<amrex::Real>(iv[2] + 0.5) * dx[2])};

const int R_RHO = 0;
const int R_UN = 1;
const int R_UT1 = 2;
const int R_UT2 = 3;
const int R_P = 4;

const amrex::Real max_r = 0.1;
const amrex::Real radius =
std::sqrt(AMREX_D_TERM(, x[1] * x[1], +x[2] * x[2]));
Expand Down
10 changes: 10 additions & 0 deletions Source/IndexDefines.H
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@
#define NQAUX 6
#define NGDNV 6

#define R_RHO 0
#define R_UN 1
#define R_UT1 2
#define R_UT2 3
#define R_P 4
#define R_ADV 5
#define R_Y (R_ADV + NUM_ADV)
#define R_LIN (R_Y + NUM_SPECIES + NUM_AUX)
#define R_NUM (5 + NUM_SPECIES + NUM_ADV + NUM_LIN + NUM_AUX)

#if AMREX_SPACEDIM == 1
// hopefully we won't do EB in 1D
#define NLSPTS 1
Expand Down
46 changes: 9 additions & 37 deletions Source/MOL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ pc_compute_hyp_mol_flux(
int axisdir,
bool do_rf)
{
const int R_RHO = 0;
const int R_UN = 1;
const int R_UT1 = 2;
const int R_UT2 = 3;
const int R_P = 4;
const int R_ADV = 5;
const int R_Y = R_ADV + NUM_ADV;
const int R_NUM = 5 + NUM_SPECIES + NUM_ADV + NUM_LIN + NUM_AUX;
const int bc_test_val = 1;
const bool using_rotframe = do_rf; // local capture
const auto geomdata = geom.data();
Expand Down Expand Up @@ -114,7 +106,6 @@ pc_compute_hyp_mol_flux(
}
#endif
#if NUM_LIN > 0
const int R_LIN = R_Y + NUM_SPECIES + NUM_AUX;
for (int n = 0; n < NUM_LIN; n++) {
qtempl[R_LIN + n] = q(ivm, QLIN + n) + 0.5 * dq(ivm, QLIN + n);
qtempr[R_LIN + n] = q(iv, QLIN + n) - 0.5 * dq(iv, QLIN + n);
Expand All @@ -123,15 +114,8 @@ pc_compute_hyp_mol_flux(

const amrex::Real cavg = 0.5 * (qaux(iv, QC) + qaux(ivm, QC));

amrex::Real spl[NUM_SPECIES];
for (int n = 0; n < NUM_SPECIES; n++) {
spl[n] = qtempl[R_Y + n];
}

amrex::Real spr[NUM_SPECIES];
for (int n = 0; n < NUM_SPECIES; n++) {
spr[n] = qtempr[R_Y + n];
}
amrex::Real* spl = &qtempl[R_Y];
amrex::Real* spr = &qtempr[R_Y];

amrex::Real flux_tmp[NVAR] = {0.0};
amrex::Real ustar = 0.0;
Expand Down Expand Up @@ -220,14 +204,6 @@ pc_compute_hyp_mol_flux_eb(
{

const int nextra = 0;

const int R_RHO = 0;
const int R_UN = 1;
const int R_UT1 = 2;
const int R_UT2 = 3;
const int R_P = 4;
const int R_ADV = 5;
const int R_Y = R_ADV + NUM_ADV;
const int bc_test_val = 1;

const amrex::Real full_area = AMREX_D_PICK(1.0, dx[0], dx[0] * dx[1]);
Expand All @@ -254,8 +230,8 @@ pc_compute_hyp_mol_flux_eb(
, flux_tmp[UMZ] = -q(iv, QPRES) * ebnorm[2];)
} else {
auto eos = pele::physics::PhysicsType::eos();
amrex::Real qtempl[5 + NUM_SPECIES] = {0.0};
amrex::Real spl[NUM_SPECIES] = {0.0};
amrex::Real qtempl[R_NUM] = {0.0};
amrex::Real* spl = &qtempl[R_Y];
qtempl[R_UN] = -(AMREX_D_TERM(
q(iv, QU) * ebnorm[0], +q(iv, QV) * ebnorm[1],
+q(iv, QW) * ebnorm[2]));
Expand All @@ -270,14 +246,12 @@ pc_compute_hyp_mol_flux_eb(

// Flip the velocity about the normal for the right state - will use
// left state for remainder of right state
amrex::Real qtempr[5 + NUM_SPECIES] = {0.0};
amrex::Real qtempr[R_NUM] = {0.0};
qtempr[R_UN] = -1.0 * qtempl[R_UN];

amrex::Real eos_state_rho = qtempl[R_RHO];
amrex::Real eos_state_p = qtempl[R_P];
for (int n = 0; n < NUM_SPECIES; n++) {
spl[n] = qtempl[R_Y + n];
}

amrex::Real eos_state_T;
eos.RYP2T(eos_state_rho, spl, eos_state_p, eos_state_T);
amrex::Real eos_state_e;
Expand All @@ -292,10 +266,10 @@ pc_compute_hyp_mol_flux_eb(
qtempr[R_UT1] = qtempl[R_UT1];
qtempr[R_UT2] = qtempl[R_UT2];
qtempr[R_P] = qtempl[R_P];
amrex::Real spr[NUM_SPECIES] = {0.0};
for (int n = 0; n < NUM_SPECIES; n++) {
spr[n] = spl[n];
for (int n = R_ADV; n < R_NUM; n++) {
qtempr[n] = qtempl[n];
}
amrex::Real* spr = &qtempr[R_Y];
amrex::Real rhoe_r = rhoe_l;
amrex::Real gamc_r = gamc_l;

Expand Down Expand Up @@ -325,7 +299,6 @@ pc_compute_hyp_mol_flux_eb(
}
#endif
#if NUM_LIN > 0
const int R_LIN = R_Y + NUM_SPECIES + NUM_AUX;
for (int n = 0; n < NUM_LIN; n++) {
pc_cmpflx_passive(
ustar, qint_iu, qtempl[R_LIN + n], qtempr[R_LIN + n],
Expand All @@ -349,7 +322,6 @@ pc_compute_hyp_mol_flux_eb(
}
#endif
#if NUM_LIN > 0
const int R_LIN = R_Y + NUM_SPECIES + NUM_AUX;
for (int n = 0; n < NUM_LIN; n++) {
pc_lax_cmpflx_passive(
qtempl[R_UN], qtempr[R_UN], 1., 1., qtempl[R_LIN + n],
Expand Down

0 comments on commit 99caa9e

Please sign in to comment.