Skip to content

Commit

Permalink
manifold eos: variance indicator and verbosity checks
Browse files Browse the repository at this point in the history
  • Loading branch information
baperry2 committed Dec 17, 2024
1 parent 760e2fe commit ad93707
Showing 1 changed file with 56 additions and 12 deletions.
68 changes: 56 additions & 12 deletions Source/Eos/EosParams.H
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ struct EosParm<Manifold>
int idx_density{0};
int idx_T{0};
int idx_Wdot[MANIFOLD_DIM];
int is_variance_of[MANIFOLD_DIM]{-1};
int verbose{1};
bool has_mani_src{true};
};
#endif
Expand Down Expand Up @@ -101,6 +103,8 @@ struct InitParm<eos::EosParm<eos::Manifold>>
// density)
AMREX_ALWAYS_ASSERT(h_manf_data_in->Ndim == NUM_SPECIES - 1);

pp.query("v", parm_in->m_h_parm.verbose);
int verbose = parm_in->m_h_parm.verbose;
pp.get("nominal_pressure_cgs", parm_in->m_h_parm.Pnom_cgs);
pp.query("has_mani_src", parm_in->m_h_parm.has_mani_src);
pp.get("compute_temperature", parm_in->m_h_parm.compute_temperature);
Expand All @@ -111,19 +115,27 @@ struct InitParm<eos::EosParm<eos::Manifold>>
if (density_lookup_type_string == "linear") {
parm_in->m_h_parm.dens_lookup = eos::density_lookup_type::linear;
parm_in->m_h_parm.idx_density = get_var_index("RHO", h_manf_data_in);
amrex::Print() << "Manifold EOS: Using linear density lookups : index = "
<< parm_in->m_h_parm.idx_density << std::endl;
if (verbose) {
amrex::Print()
<< "Manifold EOS: Using linear density lookups : index = "
<< parm_in->m_h_parm.idx_density << std::endl;
}
} else if (density_lookup_type_string == "log") {
parm_in->m_h_parm.dens_lookup = eos::density_lookup_type::log;
parm_in->m_h_parm.idx_density = get_var_index("lnRHO", h_manf_data_in);
amrex::Print()
<< "Manifold EOS: Using logarithmic density lookups : index = "
<< parm_in->m_h_parm.idx_density << std::endl;
if (verbose) {
amrex::Print()
<< "Manifold EOS: Using logarithmic density lookups : index = "
<< parm_in->m_h_parm.idx_density << std::endl;
}
} else if (density_lookup_type_string == "inverse") {
parm_in->m_h_parm.dens_lookup = eos::density_lookup_type::inverse;
parm_in->m_h_parm.idx_density = get_var_index("invRHO", h_manf_data_in);
amrex::Print() << "Manifold EOS: Using inverse density lookups : index = "
<< parm_in->m_h_parm.idx_density << std::endl;
if (verbose) {
amrex::Print()
<< "Manifold EOS: Using inverse density lookups : index = "
<< parm_in->m_h_parm.idx_density << std::endl;
}
} else {
amrex::Abort("Invalid density lookup type supplied");
}
Expand All @@ -145,11 +157,11 @@ struct InitParm<eos::EosParm<eos::Manifold>>
: "SRC_" + amrex::trim(dimname);
parm_in->m_h_parm.idx_Wdot[idim] =
get_var_index(dim_src.c_str(), h_manf_data_in, false);
if (parm_in->m_h_parm.idx_Wdot[idim] < 0) {
amrex::Print()
<< "Warning: No source term found for manifold parameter "
<< amrex::trim(dimname) << ", assuming SRC_" << amrex::trim(dimname)
<< " = 0" << std::endl;
if ((parm_in->m_h_parm.idx_Wdot[idim] < 0) && verbose) {
amrex::Print() << "Manifold EOS: Warning: No source term found for "
"manifold parameter "
<< amrex::trim(dimname) << ", assuming SRC_"
<< amrex::trim(dimname) << " = 0" << std::endl;
}
}
} else {
Expand All @@ -161,6 +173,38 @@ struct InitParm<eos::EosParm<eos::Manifold>>
"needs to be reimplemented");
}
}

// Variances - any manifold parameter ending in "VAR" is assumed to be
// the variance of another parameter - e.g. ZMIXVAR would be the variance
// of ZMIX
for (int idim = 0; idim < h_manf_data_in->Ndim; idim++) {
const std::string dimname = amrex::trim(std::string(
&h_manf_data_in->dimnames[idim * h_manf_data_in->len_str],
h_manf_data_in->len_str));
size_t suffix_start = std::max(dimname.length() - 3, size_t(0));
if (dimname.substr(suffix_start) == "VAR") {
const std::string variance_of = dimname.substr(0, suffix_start);
int jdim;
for (jdim = 0; jdim < h_manf_data_in->Ndim; jdim++) {
const std::string test_dimname = amrex::trim(std::string(
&h_manf_data_in->dimnames[jdim * h_manf_data_in->len_str],
h_manf_data_in->len_str));
if (variance_of == test_dimname) {
parm_in->m_h_parm.is_variance_of[idim] = jdim;
if (verbose) {
amrex::Print() << "Manifold EOS: using " << dimname
<< " as variance of " << variance_of << std::endl;
}
break;
}
}
if (jdim == h_manf_data_in->Ndim) {
amrex::Abort(
"Manifold EOS: variance " + dimname + " is used but " +
variance_of + "does not exist");
}
}
}
}

static void host_deallocate(PeleParams<eos::EosParm<eos::Manifold>>* parm_in)
Expand Down

0 comments on commit ad93707

Please sign in to comment.