Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //----------------------------------*-C++-*----------------------------------//
0002 // Copyright 2021-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/CutoffData.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include "corecel/data/Collection.hh"
0011 #include "celeritas/Quantities.hh"
0012 #include "celeritas/Types.hh"
0013 
0014 namespace celeritas
0015 {
0016 //---------------------------------------------------------------------------//
0017 /*!
0018  * Store secondary cutoff information.
0019  */
0020 struct ParticleCutoff
0021 {
0022     units::MevEnergy energy{};  //!< Converted range value
0023     real_type range{};  //!< [len]
0024 };
0025 
0026 //---------------------------------------------------------------------------//
0027 /*!
0028  * IDs of particles that can be killed post-interaction.
0029  *
0030  * The ID will be valid if the \c apply_post_interaction option is enabled and
0031  * the particle is present in the problem.
0032  */
0033 struct CutoffIds
0034 {
0035     ParticleId gamma;
0036     ParticleId electron;
0037     ParticleId positron;
0038 };
0039 
0040 //---------------------------------------------------------------------------//
0041 /*!
0042  * Persistent shared cutoff data.
0043  *
0044  * Secondary production cuts are stored for every material and for only the
0045  * particle types to which production cuts apply. Positron production cuts are
0046  * only used when the post-interaction cutoff is enabled. Proton production
0047  * cuts are currently unused.
0048  *
0049  * \sa CutoffView
0050  * \sa CutoffParams
0051  */
0052 template<Ownership W, MemSpace M>
0053 struct CutoffParamsData
0054 {
0055     template<class T>
0056     using Items = Collection<T, W, M>;
0057     template<class T>
0058     using ParticleItems = Collection<T, W, M, ParticleId>;
0059 
0060     // Backend storage
0061     Items<ParticleCutoff> cutoffs;  //!< [num_materials][num_particles]
0062 
0063     // Direct address table for mapping particle ID to index in cutoffs
0064     ParticleItems<size_type> id_to_index;
0065 
0066     ParticleId::size_type num_particles;  //!< Particles with production cuts
0067     MaterialId::size_type num_materials;  //!< All materials in the problem
0068 
0069     bool apply_post_interaction{false};  //!< Apply cutoff post-interaction
0070     CutoffIds ids;  //!< Secondaries that can be killed post-interaction if
0071                     //!< their energy is below the production cut
0072 
0073     //// MEMBER FUNCTIONS ////
0074 
0075     //! True if assigned
0076     explicit CELER_FUNCTION operator bool() const
0077     {
0078         return cutoffs.size() == num_particles * num_materials
0079                && !cutoffs.empty() && !id_to_index.empty();
0080     }
0081 
0082     //! Assign from another set of data
0083     template<Ownership W2, MemSpace M2>
0084     CutoffParamsData& operator=(CutoffParamsData<W2, M2> const& other)
0085     {
0086         CELER_EXPECT(other);
0087 
0088         this->cutoffs = other.cutoffs;
0089         this->id_to_index = other.id_to_index;
0090         this->num_particles = other.num_particles;
0091         this->num_materials = other.num_materials;
0092         this->apply_post_interaction = other.apply_post_interaction;
0093         this->ids = other.ids;
0094 
0095         return *this;
0096     }
0097 };
0098 
0099 //---------------------------------------------------------------------------//
0100 }  // namespace celeritas