Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-07 10:11:39

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/optical/surface/model/DielectricInteractionData.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/Macros.hh"
0010 #include "corecel/cont/EnumArray.hh"
0011 #include "corecel/data/Collection.hh"
0012 #include "corecel/grid/NonuniformGridData.hh"
0013 #include "celeritas/Quantities.hh"
0014 #include "celeritas/grid/NonuniformGridCalculator.hh"
0015 #include "celeritas/optical/Types.hh"
0016 
0017 namespace celeritas
0018 {
0019 namespace optical
0020 {
0021 //---------------------------------------------------------------------------//
0022 // TYPE ALIASES
0023 //---------------------------------------------------------------------------//
0024 // Dielectric interface type
0025 enum class DielectricInterface
0026 {
0027     metal,
0028     dielectric,
0029 };
0030 
0031 //---------------------------------------------------------------------------//
0032 // CLASSES
0033 //---------------------------------------------------------------------------//
0034 /*!
0035  * Data for the dielectric model denoting which interfaces are
0036  * dielectric-dielectric and dielectric-metal.
0037  */
0038 template<Ownership W, MemSpace M>
0039 struct DielectricData
0040 {
0041     //!@{
0042     //! \name Type aliases
0043     template<class T>
0044     using SurfaceItems = Collection<T, W, M, SubModelId>;
0045     //!@}
0046 
0047     SurfaceItems<DielectricInterface> interface;
0048 
0049     //! Whether data is assigned and valid
0050     explicit CELER_FUNCTION operator bool() const
0051     {
0052         return !interface.empty();
0053     }
0054 
0055     //! Assign from another set of data
0056     template<Ownership W2, MemSpace M2>
0057     DielectricData<W, M>& operator=(DielectricData<W2, M2> const& other)
0058     {
0059         CELER_EXPECT(other);
0060         interface = other.interface;
0061         CELER_ENSURE(*this);
0062         return *this;
0063     }
0064 };
0065 
0066 //---------------------------------------------------------------------------//
0067 /*!
0068  * Physics grids for the UNIFIED reflection model.
0069  */
0070 template<Ownership W, MemSpace M>
0071 struct UnifiedReflectionData
0072 {
0073     //!@{
0074     //! \name Type aliases
0075     template<class T>
0076     using UnifiedModeArray = EnumArray<ReflectionMode, T>;
0077 
0078     template<class T>
0079     using Items = Collection<T, W, M>;
0080 
0081     using SurfaceGrids = Collection<NonuniformGridRecord, W, M, SubModelId>;
0082     //!@}
0083 
0084     UnifiedModeArray<SurfaceGrids> reflection_grids;
0085 
0086     //! Backend storage
0087     Items<real_type> reals;
0088 
0089     //! Number of supported surfaces
0090     CELER_FUNCTION SubModelId::size_type size() const
0091     {
0092         return reflection_grids.front().size();
0093     }
0094 
0095     //! Whether data is assigned and valid
0096     explicit CELER_FUNCTION operator bool() const
0097     {
0098         return this->size() > 0
0099                && all_of(reflection_grids.begin(),
0100                          reflection_grids.end(),
0101                          [this](auto const& grid) {
0102                              return grid.size() == this->size();
0103                          });
0104     }
0105 
0106     //! Assign from another set of data
0107     template<Ownership W2, MemSpace M2>
0108     UnifiedReflectionData<W, M>& operator=(
0109         UnifiedReflectionData<W2, M2> const& other)
0110     {
0111         CELER_EXPECT(other);
0112         for (auto mode : range(ReflectionMode::size_))
0113         {
0114             reflection_grids[mode] = other.reflection_grids[mode];
0115         }
0116         reals = other.reals;
0117         return *this;
0118     }
0119 };
0120 
0121 //---------------------------------------------------------------------------//
0122 }  // namespace optical
0123 }  // namespace celeritas