diff --git a/singularity-opac/constants/constants.hpp b/singularity-opac/constants/constants.hpp index f5bbede..652276f 100644 --- a/singularity-opac/constants/constants.hpp +++ b/singularity-opac/constants/constants.hpp @@ -16,6 +16,9 @@ #ifndef SINGULARITY_OPAC_CONSTANTS_CONSTANTS_ #define SINGULARITY_OPAC_CONSTANTS_CONSTANTS_ +#include +#include + #include namespace singularity { @@ -230,6 +233,11 @@ struct RuntimePhysicalConstants { const Real Fc; const Real nu_sigma0; const Real gA; + + // Runtime physical constants are trivially copyable + bool operator==(const RuntimePhysicalConstants &other) const { + return std::memcmp(this, &other, sizeof(*this)); + } }; using PhysicalConstantsUnity = diff --git a/singularity-opac/neutrinos/mean_opacity_neutrinos.hpp b/singularity-opac/neutrinos/mean_opacity_neutrinos.hpp index 9cd578e..fa2aa1f 100644 --- a/singularity-opac/neutrinos/mean_opacity_neutrinos.hpp +++ b/singularity-opac/neutrinos/mean_opacity_neutrinos.hpp @@ -140,9 +140,11 @@ 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, - "Error: MeanOpacity physical constants do not match those of " - "Opacity used for construction."); +#ifndef NDEBUG + auto RPC = RuntimePhysicalConstants(PC); + auto opc = opac.GetRuntimePhysicalConstants(); + assert(RPC == opc && "Physical constants are the same"); +#endif lkappaPlanck_.resize(NRho, NT, NYe, NEUTRINO_NTYPES); // index 0 is the species and is not interpolatable diff --git a/singularity-opac/photons/mean_opacity_photons.hpp b/singularity-opac/photons/mean_opacity_photons.hpp index 6c91613..e00e61b 100644 --- a/singularity-opac/photons/mean_opacity_photons.hpp +++ b/singularity-opac/photons/mean_opacity_photons.hpp @@ -149,9 +149,11 @@ 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, - "Error: MeanOpacity physical constants do not match those of " - "Opacity used for construction."); +#ifndef NDEBUG + auto RPC = RuntimePhysicalConstants(PC); + auto opc = opac.GetRuntimePhysicalConstants(); + assert(RPC == opc && "Physical constants are the same"); +#endif lkappa_.resize(NRho, NT, 2); lkappa_.setRange(1, lTMin, lTMax, NT);