From b7668f28e9ec0f9a7902610b69217f5c5c926ffe Mon Sep 17 00:00:00 2001 From: Ben Ryan Date: Fri, 27 Sep 2024 19:56:11 -0600 Subject: [PATCH] Tests pass but ugly impl:: usage --- .../neutrinos/mean_opacity_neutrinos.hpp | 14 ++++---------- .../photons/gray_opacity_photons.hpp | 1 - .../photons/mean_opacity_photons.hpp | 12 +++--------- .../photons/powerlaw_opacity_photons.hpp | 4 ---- test/test_gray_opacities.cpp | 3 +-- test/test_mean_opacities.cpp | 16 ++++------------ 6 files changed, 12 insertions(+), 38 deletions(-) diff --git a/singularity-opac/neutrinos/mean_opacity_neutrinos.hpp b/singularity-opac/neutrinos/mean_opacity_neutrinos.hpp index ba7dbe8..71c5033 100644 --- a/singularity-opac/neutrinos/mean_opacity_neutrinos.hpp +++ b/singularity-opac/neutrinos/mean_opacity_neutrinos.hpp @@ -1,5 +1,5 @@ // ====================================================================== -// © 2022. Triad National Security, LLC. All rights reserved. This +// © 2022-2024. Triad National Security, LLC. All rights reserved. This // program was produced under U.S. Government contract // 89233218CNA000001 for Los Alamos National Laboratory (LANL), which // is operated by Triad National Security, LLC for the U.S. @@ -37,12 +37,9 @@ namespace impl { // TODO(BRR) Note: It is assumed that lambda is constant for all densities, // temperatures, and Ye -template class MeanOpacity { public: - using PC = pc; - MeanOpacity() = default; template MeanOpacity(const Opacity &opac, const Real lRhoMin, const Real lRhoMax, @@ -136,8 +133,7 @@ class MeanOpacity { const Real lTMax, const int NT, const Real YeMin, const Real YeMax, const int NYe, Real lNuMin, Real lNuMax, const int NNu, Real *lambda = nullptr) { - static_assert(std::is_same::value, - "Mean opacity constants must match opacity constants"); + using PC = typename Opacity::PC; lkappaPlanck_.resize(NRho, NT, NYe, NEUTRINO_NTYPES); // index 0 is the species and is not interpolatable @@ -224,10 +220,8 @@ class MeanOpacity { } // namespace impl -using MeanOpacityScaleFree = impl::MeanOpacity; -using MeanOpacityCGS = impl::MeanOpacity; -using MeanOpacity = impl::MeanVariant>; +using MeanOpacity = + impl::MeanVariant>; } // namespace neutrinos } // namespace singularity diff --git a/singularity-opac/photons/gray_opacity_photons.hpp b/singularity-opac/photons/gray_opacity_photons.hpp index 417f10c..c6bb1a0 100644 --- a/singularity-opac/photons/gray_opacity_photons.hpp +++ b/singularity-opac/photons/gray_opacity_photons.hpp @@ -44,7 +44,6 @@ class GrayOpacity { void PrintParams() const noexcept { printf("Gray opacity. kappa = %g\n", kappa_); } - inline void Finalize() noexcept {} PORTABLE_INLINE_FUNCTION diff --git a/singularity-opac/photons/mean_opacity_photons.hpp b/singularity-opac/photons/mean_opacity_photons.hpp index 98b81a3..1ca9ce2 100644 --- a/singularity-opac/photons/mean_opacity_photons.hpp +++ b/singularity-opac/photons/mean_opacity_photons.hpp @@ -37,12 +37,9 @@ namespace impl { // TODO(BRR) Note: It is assumed that lambda is constant for all densities and // temperatures -template class MeanOpacity { public: - using PC = pc; - MeanOpacity() = default; template MeanOpacity(const Opacity &opac, const Real lRhoMin, const Real lRhoMax, @@ -126,8 +123,7 @@ class MeanOpacity { const Real lRhoMax, const int NRho, const Real lTMin, const Real lTMax, const int NT, Real lNuMin, Real lNuMax, const int NNu, Real *lambda = nullptr) { - static_assert(std::is_same::value, - "Mean opacity constants must match opacity constants"); + using PC = typename Opacity::PC; lkappaPlanck_.resize(NRho, NT); lkappaPlanck_.setRange(0, lTMin, lTMax, NT); @@ -200,10 +196,8 @@ class MeanOpacity { } // namespace impl -using MeanOpacityScaleFree = impl::MeanOpacity; -using MeanOpacityCGS = impl::MeanOpacity; -using MeanOpacity = impl::MeanVariant>; +using MeanOpacity = + impl::MeanVariant>; } // namespace photons } // namespace singularity diff --git a/singularity-opac/photons/powerlaw_opacity_photons.hpp b/singularity-opac/photons/powerlaw_opacity_photons.hpp index 2794e2c..33a4c3f 100644 --- a/singularity-opac/photons/powerlaw_opacity_photons.hpp +++ b/singularity-opac/photons/powerlaw_opacity_photons.hpp @@ -47,10 +47,6 @@ class PowerLawOpacity { printf("Power law opacity. kappa0 = %g rho_exp = %g temp_exp = %g\n", kappa0_, rho_exp_, temp_exp_); } - - PORTABLE_INLINE_FUNCTION - pc GetPhysicalConstants() const { return pc(); } - inline void Finalize() noexcept {} PORTABLE_INLINE_FUNCTION diff --git a/test/test_gray_opacities.cpp b/test/test_gray_opacities.cpp index cb069be..aba0158 100644 --- a/test/test_gray_opacities.cpp +++ b/test/test_gray_opacities.cpp @@ -54,8 +54,7 @@ TEST_CASE("Gray neutrino opacities", "[GrayNeutrinos]") { constexpr RadiationType type = RadiationType::NU_ELECTRON; constexpr Real nu = 1.25 * MeV2Hz; // 1 MeV - // neutrinos::Gray opac_host(1); - neutrinos::Opacity opac_host = neutrinos::Gray(1); + neutrinos::Opacity opac_host = neutrinos::Gray(1.); neutrinos::Opacity opac = opac_host.GetOnDevice(); // Check constants from opacity diff --git a/test/test_mean_opacities.cpp b/test/test_mean_opacities.cpp index 9b556ab..026114a 100644 --- a/test/test_mean_opacities.cpp +++ b/test/test_mean_opacities.cpp @@ -87,7 +87,7 @@ TEST_CASE("Mean neutrino opacities", "[MeanNeutrinos]") { neutrinos::Gray opac_host(kappa); neutrinos::Opacity opac = opac_host.GetOnDevice(); - neutrinos::MeanOpacity mean_opac_host = neutrinos::MeanOpacityCGS( + neutrinos::MeanOpacity mean_opac_host = neutrinos::impl::MeanOpacity( opac_host, lRhoMin, lRhoMax, NRho, lTMin, lTMax, NT, YeMin, YeMax, NYe); auto mean_opac = mean_opac_host.GetOnDevice(); @@ -412,12 +412,8 @@ TEST_CASE("Mean photon opacities", "[MeanPhotons]") { photons::Gray opac_host(kappa); photons::Opacity opac = opac_host.GetOnDevice(); - // photons::MeanOpacity mean_opac_host = photons::MeanOpacityCGS( - // opac_host, lRhoMin, lRhoMax, NRho, lTMin, lTMax, NT); - // auto mean_opac = mean_opac_host.GetOnDevice(); - - photons::MeanOpacityCGS mean_opac_host(opac_host, lRhoMin, lRhoMax, NRho, - lTMin, lTMax, NT); + photons::MeanOpacity mean_opac_host = photons::impl::MeanOpacity( + opac_host, lRhoMin, lRhoMax, NRho, lTMin, lTMax, NT); auto mean_opac = mean_opac_host.GetOnDevice(); THEN("The emissivity per nu omega is consistent with the emissity per nu") { @@ -451,7 +447,7 @@ TEST_CASE("Mean photon opacities", "[MeanPhotons]") { #ifdef SPINER_USE_HDF THEN("We can save to disk and reload") { mean_opac.Save(grayname); - photons::MeanOpacity mean_opac_host_load(grayname); + photons::MeanOpacityCGS mean_opac_host_load(grayname); AND_THEN("The reloaded table matches the gray opacities") { auto mean_opac_load = mean_opac_host_load.GetOnDevice(); @@ -498,10 +494,6 @@ TEST_CASE("Mean photon opacities", "[MeanPhotons]") { constexpr Real rho_unit = mass_unit / (length_unit * length_unit * length_unit); - // auto funny_units_host = - // photons::MeanNonCGSUnits( - // std::forward(mean_opac_host), time_unit, - // mean_opac_host, time_unit, mass_unit, length_unit, temp_unit); auto funny_units_host = photons::MeanNonCGSUnits( std::forward(mean_opac_host), time_unit, mass_unit, length_unit, temp_unit);