Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-19 08:49:41

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/alongstep/detail/FieldFunctors.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/Assert.hh"
0010 #include "corecel/sys/ThreadId.hh"
0011 #include "celeritas/Types.hh"
0012 #include "celeritas/field/UniformFieldData.hh"
0013 
0014 namespace celeritas
0015 {
0016 namespace detail
0017 {
0018 //---------------------------------------------------------------------------//
0019 // CONDITIONS
0020 //---------------------------------------------------------------------------//
0021 /*!
0022  * Apply only to tracks in a volume with a field.
0023  */
0024 struct IsInUniformField
0025 {
0026     NativeCRef<UniformFieldParamsData> field;
0027 
0028     template<class T>
0029     CELER_FUNCTION bool operator()(T const& track) const
0030     {
0031         if (field.has_field.empty())
0032         {
0033             // Field is present in all volumes
0034             return true;
0035         }
0036         auto vol = track.geometry().volume_id();
0037         CELER_ASSERT(vol < field.has_field.size());
0038         return field.has_field[vol];
0039     }
0040 };
0041 
0042 //---------------------------------------------------------------------------//
0043 /*!
0044  * Apply to tracks in the uniform along-step action in volumes with field.
0045  */
0046 struct IsAlongStepUniformField
0047 {
0048     ActionId action;
0049     NativeCRef<UniformFieldParamsData> field;
0050 
0051     template<class T>
0052     CELER_FUNCTION bool operator()(T const& track) const
0053     {
0054         return IsAlongStepActionEqual{action}(track)
0055                && IsInUniformField{field}(track);
0056     }
0057 };
0058 
0059 //---------------------------------------------------------------------------//
0060 /*!
0061  * Apply to tracks in the uniform along-step action in volumes without field.
0062  */
0063 struct IsAlongStepLinear
0064 {
0065     ActionId action;
0066     NativeCRef<UniformFieldParamsData> field;
0067 
0068     template<class T>
0069     CELER_FUNCTION bool operator()(T const& track) const
0070     {
0071         return IsAlongStepActionEqual{action}(track)
0072                && !IsInUniformField{field}(track);
0073     }
0074 };
0075 
0076 //---------------------------------------------------------------------------//
0077 }  // namespace detail
0078 }  // namespace celeritas