diff --git a/Mechanisms/Null/mechanism.cpp b/Mechanisms/Null/mechanism.cpp index e4606e5cd..9947d067c 100644 --- a/Mechanisms/Null/mechanism.cpp +++ b/Mechanisms/Null/mechanism.cpp @@ -21,7 +21,11 @@ CKSYMS_STR(amrex::Vector& 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 } } diff --git a/Source/Eos/EOS.H b/Source/Eos/EOS.H index 53791e974..1a603a47e 100644 --- a/Source/Eos/EOS.H +++ b/Source/Eos/EOS.H @@ -32,13 +32,124 @@ static_assert(false, "Invalid EOS specified"); namespace eos { template -void atomic_weightsCHON(amrex::Real atwCHON[]); +void +atomic_weightsCHON(amrex::Real atwCHON[]) +{ + amrex::Vector 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 -void element_compositionCHON(int ecompCHON[]); +void +element_compositionCHON(int ecompCHON[]) +{ + amrex::Vector 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(amrex::Real* /*atwCHON[]*/) +{ + amrex::Error("atomic_weightsCHON not supported for GammaLaw EOS"); +} + +template <> +inline void +element_compositionCHON(int* /*ecompCHON[]*/) +{ + amrex::Error("element_compositionCHON not supported for GammaLaw EOS"); +} + +template <> +inline void +atomic_weightsCHON(amrex::Real* /*atwCHON[]*/) +{ + amrex::Error("atomic_weightsCHON not supported for Manifold EOS"); +} + +template <> +inline void +element_compositionCHON(int* /*ecompCHON[]*/) +{ + amrex::Error("element_compositionCHON not supported for Manifold EOS"); +} template -void speciesNames(amrex::Vector& spn); +void +speciesNames( + amrex::Vector& spn, const EosParm* /*eparm*/ = nullptr) +{ + CKSYMS_STR(spn); +} + +#ifndef AMREX_USE_SYCL +template <> +inline void +speciesNames( + amrex::Vector& spn, const EosParm* 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 diff --git a/Source/Eos/EOS.cpp b/Source/Eos/EOS.cpp deleted file mode 100644 index 759962707..000000000 --- a/Source/Eos/EOS.cpp +++ /dev/null @@ -1,162 +0,0 @@ -#include "EOS.H" - -namespace pele::physics::eos { - -template -void -atomic_weightsCHON(amrex::Real* /*atwCHON*/) -{ -} - -template -void -element_compositionCHON(int* /*ecompCHON*/) -{ -} - -template -void -speciesNames(amrex::Vector& /*spn*/) -{ -} - -template <> -void -atomic_weightsCHON(amrex::Real atwCHON[]) -{ - // CHON - for (int i = 0; i < 4; i++) { - atwCHON[i] = 0.0; - } -} - -template <> -void -element_compositionCHON(int ecompCHON[]) -{ - for (int k = 0; k < 4; k++) { - ecompCHON[k] = 0; - } -} - -template <> -void -speciesNames(amrex::Vector& spn) -{ - spn.resize(1); - spn[0] = "AIR"; -} - -template <> -void -atomic_weightsCHON(amrex::Real atwCHON[]) -{ - amrex::Vector 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 <> -void -element_compositionCHON(int ecompCHON[]) -{ - amrex::Vector 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 <> -void -speciesNames(amrex::Vector& spn) -{ - CKSYMS_STR(spn); -} - -template <> -void -atomic_weightsCHON(amrex::Real atwCHON[]) -{ - atomic_weightsCHON(atwCHON); -} - -template <> -void -element_compositionCHON(int ecompCHON[]) -{ - element_compositionCHON(ecompCHON); -} - -template <> -void -speciesNames(amrex::Vector& spn) -{ - speciesNames(spn); -} - -template <> -void -atomic_weightsCHON(amrex::Real* /*atwCHON[]*/) -{ - amrex::Error("atomic_weightsCHON not supported for Manifold EOS"); -} - -template <> -void -element_compositionCHON(int* /*ecompCHON[]*/) -{ - amrex::Error("element_compositionCHON not supported for Manifold EOS"); -} - -template <> -void -speciesNames(amrex::Vector& spn) -{ - speciesNames(spn); -} - -} // namespace pele::physics::eos diff --git a/Source/Eos/Make.package b/Source/Eos/Make.package index 34456518e..6704d6a61 100644 --- a/Source/Eos/Make.package +++ b/Source/Eos/Make.package @@ -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 \ No newline at end of file diff --git a/Source/Reactions/ReactorBase.H b/Source/Reactions/ReactorBase.H index 741a47fef..47dfcfb38 100644 --- a/Source/Reactions/ReactorBase.H +++ b/Source/Reactions/ReactorBase.H @@ -85,14 +85,17 @@ public: // the RK64 reactor virtual void set_eos_parm( const pele::physics::eos::EosParm* - eosparm) + h_eosparm, + const pele::physics::eos::EosParm* + 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; } } @@ -102,7 +105,9 @@ protected: int verbose{0}; amrex::GpuArray m_typ_vals = {0.0}; const pele::physics::eos::EosParm* - m_eosparm; + m_h_eosparm; + const pele::physics::eos::EosParm* + m_d_eosparm; }; } // namespace pele::physics::reactions #endif diff --git a/Source/Reactions/ReactorBase.cpp b/Source/Reactions/ReactorBase.cpp index 9ba8be72f..8a6b7daf7 100644 --- a/Source/Reactions/ReactorBase.cpp +++ b/Source/Reactions/ReactorBase.cpp @@ -8,7 +8,8 @@ ReactorBase::set_typ_vals_ode(const std::vector& ExtTypVals) const int size_ETV = static_cast(ExtTypVals.size()); AMREX_ALWAYS_ASSERT(size_ETV == static_cast(m_typ_vals.size())); amrex::Vector kname; - pele::physics::eos::speciesNames(kname); + pele::physics::eos::speciesNames( + kname, m_h_eosparm); int omp_thread = 0; #ifdef AMREX_USE_OMP diff --git a/Source/Reactions/ReactorNull.H b/Source/Reactions/ReactorNull.H index f438f62ed..fa089adf6 100644 --- a/Source/Reactions/ReactorNull.H +++ b/Source/Reactions/ReactorNull.H @@ -88,9 +88,12 @@ public: void set_eos_parm( const pele::physics::eos::EosParm* - eosparm) override + h_eosparm, + const pele::physics::eos::EosParm* + d_eosparm) override { - m_eosparm = eosparm; + m_h_eosparm = h_eosparm; + m_d_eosparm = d_eosparm; } private: diff --git a/Source/Reactions/ReactorNull.cpp b/Source/Reactions/ReactorNull.cpp index a38697c81..95af6dad7 100644 --- a/Source/Reactions/ReactorNull.cpp +++ b/Source/Reactions/ReactorNull.cpp @@ -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 = diff --git a/Source/Reactions/ReactorRK64.H b/Source/Reactions/ReactorRK64.H index 445c708d4..c6511abdb 100644 --- a/Source/Reactions/ReactorRK64.H +++ b/Source/Reactions/ReactorRK64.H @@ -122,9 +122,12 @@ public: void set_eos_parm( const pele::physics::eos::EosParm* - eosparm) override + h_eosparm, + const pele::physics::eos::EosParm* + d_eosparm) override { - m_eosparm = eosparm; + m_h_eosparm = h_eosparm; + m_d_eosparm = d_eosparm; } private: diff --git a/Source/Reactions/ReactorRK64.cpp b/Source/Reactions/ReactorRK64.cpp index 1c7679ee7..367d44245 100644 --- a/Source/Reactions/ReactorRK64.cpp +++ b/Source/Reactions/ReactorRK64.cpp @@ -64,7 +64,7 @@ ReactorRK64::react( const int captured_nsubsteps_min = rk64_nsubsteps_min; const int captured_nsubsteps_max = rk64_nsubsteps_max; const amrex::Real captured_abstol = absTol; - const auto* leosparm = m_eosparm; + const auto* leosparm = m_d_eosparm; RK64Params rkp; amrex::Gpu::DeviceVector v_nsteps(ncells, 0); @@ -193,7 +193,7 @@ ReactorRK64::react( const int captured_nsubsteps_min = rk64_nsubsteps_min; const int captured_nsubsteps_max = rk64_nsubsteps_max; const amrex::Real captured_abstol = absTol; - const auto* leosparm = m_eosparm; + const auto* leosparm = m_d_eosparm; RK64Params rkp; int ncells = static_cast(box.numPts()); diff --git a/Submodules/amrex b/Submodules/amrex index 00e6f755a..f27eb69d0 160000 --- a/Submodules/amrex +++ b/Submodules/amrex @@ -1 +1 @@ -Subproject commit 00e6f755affdd4f230414520c52e23ffb80324cb +Subproject commit f27eb69d0d505f56dd0dd42ebe95d68203f3dc23 diff --git a/Testing/Exec/IgnitionDelay/main.cpp b/Testing/Exec/IgnitionDelay/main.cpp index 66d417354..a28ba11a8 100644 --- a/Testing/Exec/IgnitionDelay/main.cpp +++ b/Testing/Exec/IgnitionDelay/main.cpp @@ -76,16 +76,19 @@ main(int argc, char* argv[]) eos_parms.initialize(); auto const* leosparm = eos_parms.device_parm(); - // Assign Fuel ID - int fuel_idx; - getFuelID(fuel_name, fuel_idx); + // Assign Fuel ID - don't need to do this for manifold + int fuel_idx = -1; + if (pele::physics::PhysicsType::eos_type::identifier() != "Manifold") { + getFuelID(fuel_name, fuel_idx); + } // Initialize reactor object inside OMP region, including tolerances BL_PROFILE_VAR("main::reactor_info()", reactInfo); std::unique_ptr reactor = pele::physics::reactions::ReactorBase::create(chem_integrator); reactor->init(ode_iE, ode_ncells); - reactor->set_eos_parm(leosparm); // only needed for manifold + reactor->set_eos_parm( + &(eos_parms.host_parm()), leosparm); // only needed for manifold BL_PROFILE_VAR_STOP(reactInfo); // Initialize Geometry