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

speciesNames for Manifold EOS #542

Merged
merged 7 commits into from
Dec 6, 2024
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 Mechanisms/Null/mechanism.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ CKSYMS_STR(amrex::Vector<std::string>& kname)
{
kname.resize(NUM_SPECIES);
for (int i = 0; i < NUM_SPECIES; ++i) {
#if NUM_SPECIES == 1
kname[i] = "AIR";
#else
kname[i] = "X" + std::to_string(i);
#endif
}
}

Expand Down
117 changes: 114 additions & 3 deletions Source/Eos/EOS.H
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,124 @@ static_assert(false, "Invalid EOS specified");
namespace eos {

template <typename EOSType>
void atomic_weightsCHON(amrex::Real atwCHON[]);
void
atomic_weightsCHON(amrex::Real atwCHON[])
{
amrex::Vector<std::string> ename;
CKSYME_STR(ename);
amrex::Real atw[NUM_ELEMENTS];
CKAWT(atw);
// CHON
for (int i = 0; i < 4; i++) {
atwCHON[i] = 0.0;
}
for (int i = 0; i < NUM_ELEMENTS; i++) {
if (ename[i] == "C") {
atwCHON[0] = atw[i];
}
if (ename[i] == "H") {
atwCHON[1] = atw[i];
}
if (ename[i] == "O") {
atwCHON[2] = atw[i];
}
if (ename[i] == "N") {
atwCHON[3] = atw[i];
}
}
}

template <typename EOSType>
void element_compositionCHON(int ecompCHON[]);
void
element_compositionCHON(int ecompCHON[])
{
amrex::Vector<std::string> ename;
CKSYME_STR(ename);
// CHON
int CHON[4] = {-1};
for (int i = 0; i < NUM_ELEMENTS; i++) {
if (ename[i] == "C") {
CHON[0] = i;
}
if (ename[i] == "H") {
CHON[1] = i;
}
if (ename[i] == "O") {
CHON[2] = i;
}
if (ename[i] == "N") {
CHON[3] = i;
}
}
int ecomp[NUM_SPECIES * NUM_ELEMENTS];
CKNCF(ecomp);
for (int i = 0; i < NUM_SPECIES; i++) {
for (int k = 0; k < 4; k++) {
if (CHON[k] > -1) {
ecompCHON[i * 4 + k] = ecomp[i * NUM_ELEMENTS + CHON[k]];
} else {
ecompCHON[i * 4 + k] = 0;
}
}
}
}

template <>
inline void
atomic_weightsCHON<GammaLaw>(amrex::Real* /*atwCHON[]*/)
{
amrex::Error("atomic_weightsCHON not supported for GammaLaw EOS");
}

template <>
inline void
element_compositionCHON<GammaLaw>(int* /*ecompCHON[]*/)
{
amrex::Error("element_compositionCHON not supported for GammaLaw EOS");
}

template <>
inline void
atomic_weightsCHON<Manifold>(amrex::Real* /*atwCHON[]*/)
{
amrex::Error("atomic_weightsCHON not supported for Manifold EOS");
}

template <>
inline void
element_compositionCHON<Manifold>(int* /*ecompCHON[]*/)
{
amrex::Error("element_compositionCHON not supported for Manifold EOS");
}

template <typename EOSType>
void speciesNames(amrex::Vector<std::string>& spn);
void
speciesNames(
amrex::Vector<std::string>& spn, const EosParm<EOSType>* /*eparm*/ = nullptr)
{
CKSYMS_STR(spn);
}

#ifndef AMREX_USE_SYCL
template <>
inline void
speciesNames<Manifold>(
amrex::Vector<std::string>& spn, const EosParm<Manifold>* eparm)
{
if (eparm == nullptr) {
amrex::Abort("Manifold EOS requires an EosParm input in order to determine "
"species names");
}
spn.resize(NUM_SPECIES);
const auto* mani_data = eparm->manf_data;
for (int n = 0; n < MANIFOLD_DIM; n++) {
std::string nametmp = std::string(
&(mani_data->dimnames)[n * mani_data->len_str], mani_data->len_str);
spn[n] = amrex::trim(nametmp);
}
spn[MANIFOLD_DIM] = "XRHO";
}
#endif

} // namespace eos
} // namespace pele::physics
Expand Down
162 changes: 0 additions & 162 deletions Source/Eos/EOS.cpp

This file was deleted.

1 change: 0 additions & 1 deletion Source/Eos/Make.package
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
CEXE_headers += EOS.H GammaLaw.H Fuego.H SRK.H
CEXE_sources += EOS.cpp

VPATH_LOCATIONS += $(PELE_PHYSICS_HOME)/Source/Eos
INCLUDE_LOCATIONS += $(PELE_PHYSICS_HOME)/Source/Eos
13 changes: 9 additions & 4 deletions Source/Reactions/ReactorBase.H
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,17 @@ public:
// the RK64 reactor
virtual void set_eos_parm(
const pele::physics::eos::EosParm<pele::physics::PhysicsType::eos_type>*
eosparm)
h_eosparm,
const pele::physics::eos::EosParm<pele::physics::PhysicsType::eos_type>*
d_eosparm)
{
auto eos = pele::physics::PhysicsType::eos(eosparm);
auto eos = pele::physics::PhysicsType::eos(h_eosparm);
if (eos.identifier() == "Manifold") {
amrex::Abort(
"Manifold EOS only supported with ReactorRK64 and ReactorNull for now");
} else {
m_eosparm = eosparm;
m_h_eosparm = h_eosparm;
m_d_eosparm = d_eosparm;
}
}

Expand All @@ -102,7 +105,9 @@ protected:
int verbose{0};
amrex::GpuArray<amrex::Real, NUM_SPECIES + 1> m_typ_vals = {0.0};
const pele::physics::eos::EosParm<pele::physics::PhysicsType::eos_type>*
m_eosparm;
m_h_eosparm;
const pele::physics::eos::EosParm<pele::physics::PhysicsType::eos_type>*
m_d_eosparm;
};
} // namespace pele::physics::reactions
#endif
3 changes: 2 additions & 1 deletion Source/Reactions/ReactorBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ ReactorBase::set_typ_vals_ode(const std::vector<amrex::Real>& ExtTypVals)
const int size_ETV = static_cast<int>(ExtTypVals.size());
AMREX_ALWAYS_ASSERT(size_ETV == static_cast<int>(m_typ_vals.size()));
amrex::Vector<std::string> kname;
pele::physics::eos::speciesNames<pele::physics::PhysicsType::eos_type>(kname);
pele::physics::eos::speciesNames<pele::physics::PhysicsType::eos_type>(
kname, m_h_eosparm);
int omp_thread = 0;

#ifdef AMREX_USE_OMP
Expand Down
7 changes: 5 additions & 2 deletions Source/Reactions/ReactorNull.H
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,12 @@ public:

void set_eos_parm(
const pele::physics::eos::EosParm<pele::physics::PhysicsType::eos_type>*
eosparm) override
h_eosparm,
const pele::physics::eos::EosParm<pele::physics::PhysicsType::eos_type>*
d_eosparm) override
{
m_eosparm = eosparm;
m_h_eosparm = h_eosparm;
m_d_eosparm = d_eosparm;
}

private:
Expand Down
2 changes: 1 addition & 1 deletion Source/Reactions/ReactorNull.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ ReactorNull::react(
#endif

int captured_reactor_type = m_reactor_type;
const auto* leosparm = m_eosparm;
const auto* leosparm = m_d_eosparm;

ParallelFor(box, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
amrex::Real renergy_loc =
Expand Down
7 changes: 5 additions & 2 deletions Source/Reactions/ReactorRK64.H
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,12 @@ public:

void set_eos_parm(
const pele::physics::eos::EosParm<pele::physics::PhysicsType::eos_type>*
eosparm) override
h_eosparm,
const pele::physics::eos::EosParm<pele::physics::PhysicsType::eos_type>*
d_eosparm) override
{
m_eosparm = eosparm;
m_h_eosparm = h_eosparm;
m_d_eosparm = d_eosparm;
}

private:
Expand Down
Loading
Loading