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 a helper function to get the index into the NSE tables #1495

Merged
merged 3 commits into from
Mar 12, 2024
Merged
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
18 changes: 10 additions & 8 deletions nse_tabular/nse_table.H
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@
using namespace amrex::literals;
using namespace network_rp;

///
/// given a rho, T, and Ye index, return the 1-d index into the NSE table arrays
///
AMREX_GPU_HOST_DEVICE AMREX_INLINE
int nse_idx(const int ir, const int it, const int ic) {
// this uses a 1-based indexing
return (ir-1) * nse_table_size::ntemp * nse_table_size::nye + (it-1) * nse_table_size::nye + ic;
}

AMREX_INLINE
void init_nse() {

Expand Down Expand Up @@ -46,8 +55,7 @@ void init_nse() {
for (int irho = 1; irho <= nse_table_size::nden; irho++) {
for (int it = 1; it <= nse_table_size::ntemp; it++) {
for (int iye = 1; iye <= nse_table_size::nye; iye++) {
int j = (irho-1) * nse_table_size::ntemp * nse_table_size::nye +
(it-1) * nse_table_size::nye + iye;
const int j = nse_idx(irho, it, iye);

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

}

AMREX_GPU_HOST_DEVICE AMREX_INLINE
int nse_idx(const int ir, const int it, const int ic) {
// this uses a 1-based indexing
return (ir-1) * nse_table_size::ntemp * nse_table_size::nye + (it-1) * nse_table_size::nye + ic;
}

AMREX_GPU_HOST_DEVICE AMREX_INLINE
amrex::Real nse_table_logT(const int it) {
return nse_table_size::logT_min + static_cast<amrex::Real>(it-1) * nse_table_size::dlogT;
Expand Down