Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/celeritas/global/CoreTrackData.hh was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 //------------------------------- -*- C++ -*- -------------------------------//
0002 // Copyright Celeritas contributors: see top-level COPYRIGHT file for details
0003 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0004 //---------------------------------------------------------------------------//
0005 //! \file celeritas/global/CoreTrackData.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/Assert.hh"
0010 #include "corecel/data/Collection.hh"
0011 #include "corecel/data/ObserverPtr.hh"
0012 #include "corecel/random/data/RngData.hh"
0013 #include "celeritas/Types.hh"
0014 #include "celeritas/em/data/WentzelOKVIData.hh"
0015 #include "celeritas/geo/GeoData.hh"
0016 #include "celeritas/geo/GeoMaterialData.hh"
0017 #include "celeritas/mat/MaterialData.hh"
0018 #include "celeritas/phys/CutoffData.hh"
0019 #include "celeritas/phys/ParticleData.hh"
0020 #include "celeritas/phys/PhysicsData.hh"
0021 #include "celeritas/track/SimData.hh"
0022 #include "celeritas/track/TrackInitData.hh"
0023 
0024 #include "CoreTrackDataFwd.hh"
0025 
0026 namespace celeritas
0027 {
0028 //---------------------------------------------------------------------------//
0029 class CoreParams;
0030 
0031 //---------------------------------------------------------------------------//
0032 /*!
0033  * Memspace-independent core variables.
0034  */
0035 struct CoreScalars
0036 {
0037     ActionId boundary_action;
0038     ActionId propagation_limit_action;
0039     ActionId tracking_cut_action;  //!< Deposit a track's energy locally
0040 
0041     // TODO: this is a hack until we improve the along-step interface
0042     ActionId along_step_user_action;
0043     ActionId along_step_neutral_action;
0044 
0045     StreamId::size_type max_streams{0};
0046 
0047     // Non-owning pointer to core params ONLY for diagnostics:
0048     // see DebugIO.json.cc
0049     ObserverPtr<CoreParams const, MemSpace::host> host_core_params{nullptr};
0050 
0051     //! True if assigned and valid
0052     explicit CELER_FUNCTION operator bool() const
0053     {
0054         return boundary_action && propagation_limit_action
0055                && tracking_cut_action && along_step_user_action
0056                && along_step_neutral_action && max_streams > 0;
0057     }
0058 };
0059 
0060 //---------------------------------------------------------------------------//
0061 /*!
0062  * Immutable problem data.
0063  */
0064 template<Ownership W, MemSpace M>
0065 struct CoreParamsData
0066 {
0067     GeoParamsData<W, M> geometry;
0068     GeoMaterialParamsData<W, M> geo_mats;
0069     MaterialParamsData<W, M> materials;
0070     ParticleParamsData<W, M> particles;
0071     CutoffParamsData<W, M> cutoffs;
0072     PhysicsParamsData<W, M> physics;
0073     RngParamsData<W, M> rng;
0074     SimParamsData<W, M> sim;
0075     TrackInitParamsData<W, M> init;
0076     WentzelOKVIData<W, M> wentzel;
0077 
0078     CoreScalars scalars;
0079 
0080     //! True if all params are assigned
0081     explicit CELER_FUNCTION operator bool() const
0082     {
0083         return geometry && geo_mats && materials && particles && cutoffs
0084                && physics && rng && sim && init && scalars;
0085     }
0086 
0087     //! Assign from another set of data
0088     template<Ownership W2, MemSpace M2>
0089     CoreParamsData& operator=(CoreParamsData<W2, M2> const& other)
0090     {
0091         CELER_EXPECT(other);
0092         geometry = other.geometry;
0093         geo_mats = other.geo_mats;
0094         materials = other.materials;
0095         particles = other.particles;
0096         cutoffs = other.cutoffs;
0097         physics = other.physics;
0098         rng = other.rng;
0099         sim = other.sim;
0100         init = other.init;
0101         wentzel = other.wentzel;
0102         scalars = other.scalars;
0103         return *this;
0104     }
0105 };
0106 
0107 //---------------------------------------------------------------------------//
0108 /*!
0109  * Thread-local state data.
0110  *
0111  * TODO: standardize variable names
0112  */
0113 template<Ownership W, MemSpace M>
0114 struct CoreStateData
0115 {
0116     template<class T>
0117     using ThreadItems = Collection<T, W, M, ThreadId>;
0118 
0119     GeoStateData<W, M> geometry;
0120     MaterialStateData<W, M> materials;
0121     ParticleStateData<W, M> particles;
0122     PhysicsStateData<W, M> physics;
0123     RngStateData<W, M> rng;
0124     SimStateData<W, M> sim;
0125     TrackInitStateData<W, M> init;
0126 
0127     //! Indirection array for sorting (empty if unsorted)
0128     ThreadItems<TrackSlotId::size_type> track_slots;
0129 
0130     //! Unique identifier for "thread-local" data.
0131     StreamId stream_id;
0132 
0133     //! Number of state elements
0134     CELER_FUNCTION size_type size() const { return particles.size(); }
0135 
0136     //! Whether the data are assigned
0137     explicit CELER_FUNCTION operator bool() const
0138     {
0139         return geometry && materials && particles && physics && rng && sim
0140                && init && stream_id;
0141     }
0142 
0143     //! Assign from another set of data
0144     template<Ownership W2, MemSpace M2>
0145     CoreStateData& operator=(CoreStateData<W2, M2>& other)
0146     {
0147         CELER_EXPECT(other);
0148         geometry = other.geometry;
0149         materials = other.materials;
0150         particles = other.particles;
0151         physics = other.physics;
0152         rng = other.rng;
0153         sim = other.sim;
0154         init = other.init;
0155         track_slots = other.track_slots;
0156         stream_id = other.stream_id;
0157         return *this;
0158     }
0159 };
0160 
0161 //---------------------------------------------------------------------------//
0162 /*!
0163  * Resize states in host code.
0164  *
0165  * Initialize threads to track slots mapping.
0166  * Resize core states using parameter data, stream ID, and track slots.
0167  */
0168 template<MemSpace M>
0169 void resize(CoreStateData<Ownership::value, M>* state,
0170             HostCRef<CoreParamsData> const& params,
0171             StreamId stream_id,
0172             size_type size);
0173 
0174 //---------------------------------------------------------------------------//
0175 }  // namespace celeritas