Skip to content

Commit 124b71b

Browse files
authored
use a helper function to get the index into the NSE tables (#1495)
1 parent 95cb860 commit 124b71b

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

nse_tabular/nse_table.H

+10-8
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@
1919
using namespace amrex::literals;
2020
using namespace network_rp;
2121

22+
///
23+
/// given a rho, T, and Ye index, return the 1-d index into the NSE table arrays
24+
///
25+
AMREX_GPU_HOST_DEVICE AMREX_INLINE
26+
int nse_idx(const int ir, const int it, const int ic) {
27+
// this uses a 1-based indexing
28+
return (ir-1) * nse_table_size::ntemp * nse_table_size::nye + (it-1) * nse_table_size::nye + ic;
29+
}
30+
2231
AMREX_INLINE
2332
void init_nse() {
2433

@@ -46,8 +55,7 @@ void init_nse() {
4655
for (int irho = 1; irho <= nse_table_size::nden; irho++) {
4756
for (int it = 1; it <= nse_table_size::ntemp; it++) {
4857
for (int iye = 1; iye <= nse_table_size::nye; iye++) {
49-
int j = (irho-1) * nse_table_size::ntemp * nse_table_size::nye +
50-
(it-1) * nse_table_size::nye + iye;
58+
const int j = nse_idx(irho, it, iye);
5159

5260
std::getline(nse_table_file, line);
5361
if (line.empty()) {
@@ -70,12 +78,6 @@ void init_nse() {
7078

7179
}
7280

73-
AMREX_GPU_HOST_DEVICE AMREX_INLINE
74-
int nse_idx(const int ir, const int it, const int ic) {
75-
// this uses a 1-based indexing
76-
return (ir-1) * nse_table_size::ntemp * nse_table_size::nye + (it-1) * nse_table_size::nye + ic;
77-
}
78-
7981
AMREX_GPU_HOST_DEVICE AMREX_INLINE
8082
amrex::Real nse_table_logT(const int it) {
8183
return nse_table_size::logT_min + static_cast<amrex::Real>(it-1) * nse_table_size::dlogT;

0 commit comments

Comments
 (0)