Skip to content

Commit

Permalink
work around a CUDA linker issue with the NSE table (#1395)
Browse files Browse the repository at this point in the history
  • Loading branch information
zingale committed Nov 26, 2023
1 parent 5ab809a commit 965a061
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 14 deletions.
4 changes: 4 additions & 0 deletions networks/aprox19/nse_table_size.H
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

#include <string>

#include <AMReX_REAL.H>

using namespace amrex;

namespace nse_table_size {

const std::string table_name{"nse_aprox19.tbl"};
Expand Down
46 changes: 32 additions & 14 deletions nse_tabular/nse_table.H
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include <extern_parameters.H>
#include <nse_table_data.H>
#include <nse_table_size.H>

using namespace amrex;
using namespace network_rp;
Expand All @@ -22,31 +23,31 @@ void init_nse() {
// set table parameters

// read in table
std::ifstream nse_table;
std::ifstream nse_table_file;

amrex::Print() << "reading the NSE table (C++) ..." << std::endl;

nse_table.open(nse_table_size::table_name, std::ios::in);
if (nse_table.fail()) {
nse_table_file.open(nse_table_size::table_name, std::ios::in);
if (nse_table_file.fail()) {
amrex::Error("unable to open NSE table: " + nse_table_size::table_name);
}

Real ttemp, tdens, tye;

// skip the header -- it is 4 lines
std::string line;
std::getline(nse_table, line);
std::getline(nse_table, line);
std::getline(nse_table, line);
std::getline(nse_table, line);
std::getline(nse_table_file, line);
std::getline(nse_table_file, line);
std::getline(nse_table_file, line);
std::getline(nse_table_file, line);

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;

std::getline(nse_table, line);
std::getline(nse_table_file, line);
if (line.empty()) {
amrex::Error("Error reading from the NSE table");
}
Expand Down Expand Up @@ -243,12 +244,29 @@ void nse_interp(const Real T, const Real rho, const Real ye,
using namespace nse_table;
using namespace AuxZero;

Real rholog = amrex::max(nse_table_size::logrho_min,
amrex::min(nse_table_size::logrho_max, std::log10(rho)));
Real tlog = amrex::max(nse_table_size::logT_min,
amrex::min(nse_table_size::logT_max, std::log10(T)));
Real yet = amrex::max(nse_table_size::ye_min,
amrex::min(nse_table_size::ye_max, ye));
Real rholog = std::log10(rho);
{
Real rmin = nse_table_size::logrho_min;
Real rmax = nse_table_size::logrho_max;

rholog = std::max(rmin, std::min(rmax, rholog));
}

Real tlog = std::log10(T);
{
Real tmin = nse_table_size::logT_min;
Real tmax = nse_table_size::logT_max;

tlog = std::max(tmin, std::min(tmax, tlog));
}

Real yet = ye;
{
Real yemin = nse_table_size::ye_min;
Real yemax = nse_table_size::ye_max;

yet = std::max(yemin, std::min(yemax, yet));
}

if (nse_table_interp_linear) {

Expand Down

0 comments on commit 965a061

Please sign in to comment.