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

work around a CUDA linker issue with the NSE table #1395

Merged
merged 1 commit into from
Nov 26, 2023
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: 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