From 4e611f59b9ac60839fa0224a91be929572f0dbc3 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 20 Oct 2021 06:53:20 -0500 Subject: [PATCH] Make incoherent XS polymorphic in MixedElasticAE --- include/openmc/secondary_thermal.h | 4 ++-- src/secondary_thermal.cpp | 5 +++-- src/thermal.cpp | 3 +-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/openmc/secondary_thermal.h b/include/openmc/secondary_thermal.h index 81de5c4510..5b18902afb 100644 --- a/include/openmc/secondary_thermal.h +++ b/include/openmc/secondary_thermal.h @@ -160,7 +160,7 @@ public: // //! \param[in] group HDF5 group explicit MixedElasticAE( - hid_t group, const CoherentElasticXS& coh_xs, const Tabulated1D& incoh_xs); + hid_t group, const CoherentElasticXS& coh_xs, const Function1D& incoh_xs); //! Sample distribution for an angle and energy //! \param[in] E_in Incoming energy in [eV] @@ -175,7 +175,7 @@ private: unique_ptr incoherent_dist_; //!< Incoherent distribution const CoherentElasticXS& coherent_xs_; //!< Ref. to coherent XS - const Tabulated1D& incoherent_xs_; //!< Ref. to incoherent XS + const Function1D& incoherent_xs_; //!< Polymorphic ref. to incoherent XS }; } // namespace openmc diff --git a/src/secondary_thermal.cpp b/src/secondary_thermal.cpp index e5e8274da7..0b8e1ab42d 100644 --- a/src/secondary_thermal.cpp +++ b/src/secondary_thermal.cpp @@ -337,7 +337,7 @@ void IncoherentInelasticAE::sample( //============================================================================== MixedElasticAE::MixedElasticAE( - hid_t group, const CoherentElasticXS& coh_xs, const Tabulated1D& incoh_xs) + hid_t group, const CoherentElasticXS& coh_xs, const Function1D& incoh_xs) : coherent_dist_(coh_xs), coherent_xs_(coh_xs), incoherent_xs_(incoh_xs) { // Read incoherent elastic distribution @@ -347,8 +347,9 @@ MixedElasticAE::MixedElasticAE( if (temp == "incoherent_elastic") { incoherent_dist_ = make_unique(incoherent_group); } else if (temp == "incoherent_elastic_discrete") { + auto xs = dynamic_cast(&incoh_xs); incoherent_dist_ = - make_unique(incoherent_group, incoh_xs.x()); + make_unique(incoherent_group, xs->x()); } close_group(incoherent_group); } diff --git a/src/thermal.cpp b/src/thermal.cpp index 3037869153..1a9592d0af 100644 --- a/src/thermal.cpp +++ b/src/thermal.cpp @@ -221,8 +221,7 @@ ThermalData::ThermalData(hid_t group) auto mixed_xs = dynamic_cast(elastic_.xs.get()); const auto& coh_xs = dynamic_cast(mixed_xs->functions(0).get()); - const auto& incoh_xs = - dynamic_cast(mixed_xs->functions(1).get()); + const auto& incoh_xs = mixed_xs->functions(1).get(); // Create mixed elastic distribution elastic_.distribution =