Back to home page

EIC code displayed by LXR

 
 

    


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

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/MieData.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/Macros.hh"
0010 #include "corecel/Types.hh"
0011 #include "corecel/data/Collection.hh"
0012 #include "corecel/io/Logger.hh"
0013 #include "celeritas/Quantities.hh"
0014 #include "celeritas/Types.hh"
0015 
0016 namespace celeritas
0017 {
0018 namespace optical
0019 {
0020 //---------------------------------------------------------------------------//
0021 /*!
0022  * Material dependent data of Mie scattering.
0023  */
0024 struct MieMaterialData
0025 {
0026     //! g parameter for forward scattering
0027     real_type forward_g{};
0028     //! g parameter for backward scattering
0029     real_type backward_g{};
0030     //! Fraction of forward vs backward scattering
0031     real_type forward_ratio{};
0032     //! Whether all data are assigned and valid
0033     explicit operator bool() const
0034     {
0035         return forward_ratio >= 0 && forward_ratio <= 1 && forward_g >= -1
0036                && forward_g <= 1 && backward_g >= -1 && backward_g <= 1;
0037     }
0038 };
0039 
0040 //---------------------------------------------------------------------------//
0041 /*!
0042  * Mie scattering data.
0043  */
0044 template<Ownership W, MemSpace M>
0045 struct MieData
0046 {
0047     template<class T>
0048     using Items = Collection<T, W, M>;
0049     template<class T>
0050     using OpticalMaterialItems = Collection<T, W, M, OptMatId>;
0051 
0052     //// MEMBER DATA ////
0053 
0054     OpticalMaterialItems<MieMaterialData> mie_record;
0055 
0056     //// MEMBER FUNCTIONS ////
0057 
0058     //! Whether all data are assigned and valid
0059     explicit CELER_FUNCTION operator bool() const
0060     {
0061         return !mie_record.empty();
0062     }
0063 
0064     //! Assign from another set of data
0065     template<Ownership W2, MemSpace M2>
0066     MieData& operator=(MieData<W2, M2> const& other)
0067     {
0068         CELER_EXPECT(other);
0069         mie_record = other.mie_record;
0070         return *this;
0071     }
0072 };
0073 
0074 //---------------------------------------------------------------------------//
0075 }  // namespace optical
0076 }  // namespace celeritas