Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 10:31:28

0001 //----------------------------------*-C++-*----------------------------------//
0002 // Copyright 2020-2024 UT-Battelle, LLC, and other Celeritas developers.
0003 // See the top-level COPYRIGHT file for details.
0004 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0005 //---------------------------------------------------------------------------//
0006 //! \file celeritas/phys/Applicability.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include <functional>
0011 #include <tuple>
0012 
0013 #include "corecel/Assert.hh"
0014 #include "corecel/OpaqueId.hh"
0015 #include "corecel/Types.hh"
0016 #include "celeritas/Quantities.hh"
0017 #include "celeritas/Types.hh"
0018 
0019 namespace celeritas
0020 {
0021 //---------------------------------------------------------------------------//
0022 /*!
0023  * Range where a model and/or process is valid.
0024  *
0025  * This class is used during setup for specifying the ranges of applicability
0026  * for a physics model or process. The interval is *closed* on the lower energy
0027  * range and *open* on the upper energy. So a threshold reaction should have
0028  * the lower energy set to the threshold.
0029  *
0030  * An unset value for "material" means it applies to all materials; however,
0031  * the particle ID should always be set.
0032  */
0033 struct Applicability
0034 {
0035     using EnergyUnits = units::Mev;
0036     using Energy = Quantity<EnergyUnits>;
0037 
0038     MaterialId material{};
0039     ParticleId particle{};
0040     Energy lower = zero_quantity();
0041     Energy upper = max_quantity();
0042 
0043     //! Whether applicability is in a valid state
0044     inline explicit operator bool() const
0045     {
0046         return static_cast<bool>(particle) && lower < upper;
0047     }
0048 };
0049 
0050 //!@{
0051 //! Comparators
0052 inline bool operator==(Applicability const& lhs, Applicability const& rhs)
0053 {
0054     return std::make_tuple(lhs.material, lhs.particle, lhs.lower, lhs.upper)
0055            == std::make_tuple(rhs.material, rhs.particle, rhs.lower, rhs.upper);
0056 }
0057 
0058 inline bool operator<(Applicability const& lhs, Applicability const& rhs)
0059 {
0060     return std::make_tuple(lhs.material, lhs.particle, lhs.lower, lhs.upper)
0061            < std::make_tuple(rhs.material, rhs.particle, rhs.lower, rhs.upper);
0062 }
0063 //!@}
0064 
0065 //---------------------------------------------------------------------------//
0066 }  // namespace celeritas