File indexing completed on 2025-09-17 08:53:44
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include "corecel/Macros.hh"
0010 #include "corecel/Types.hh"
0011 #include "celeritas/Types.hh"
0012 #include "celeritas/grid/NonuniformGridCalculator.hh"
0013
0014 #include "MaterialData.hh"
0015
0016 namespace celeritas
0017 {
0018 namespace optical
0019 {
0020
0021
0022
0023
0024 class MaterialView
0025 {
0026 public:
0027
0028
0029 using ParamsRef = NativeCRef<MaterialParamsData>;
0030 using MatId = OptMatId;
0031
0032
0033 public:
0034
0035 inline CELER_FUNCTION MaterialView(ParamsRef const& params, MatId id);
0036
0037
0038 inline CELER_FUNCTION MaterialView(ParamsRef const& params, VolumeId vol);
0039
0040
0041 inline CELER_FUNCTION operator bool() const;
0042
0043
0044
0045
0046 CELER_FORCEINLINE_FUNCTION MatId material_id() const;
0047
0048
0049 CELER_FORCEINLINE_FUNCTION PhysMatId core_material_id() const;
0050
0051
0052
0053
0054 inline CELER_FUNCTION NonuniformGridCalculator
0055 make_refractive_index_calculator() const;
0056
0057 private:
0058
0059
0060 ParamsRef const& params_;
0061 MatId mat_id_;
0062 };
0063
0064
0065
0066
0067
0068
0069
0070 CELER_FUNCTION
0071 MaterialView::MaterialView(ParamsRef const& params, MatId id)
0072 : params_(params), mat_id_(id)
0073 {
0074 CELER_EXPECT(id < params_.refractive_index.size());
0075 }
0076
0077
0078
0079
0080
0081 CELER_FUNCTION
0082 MaterialView::MaterialView(ParamsRef const& params, VolumeId id)
0083 : params_{params}
0084 {
0085 CELER_EXPECT(id < params_.optical_id.size());
0086 mat_id_ = params_.optical_id[id];
0087 }
0088
0089
0090
0091
0092
0093
0094
0095
0096 CELER_FORCEINLINE_FUNCTION MaterialView::operator bool() const
0097 {
0098 return static_cast<bool>(mat_id_);
0099 }
0100
0101
0102
0103
0104
0105 CELER_FUNCTION auto MaterialView::material_id() const -> MatId
0106 {
0107 return mat_id_;
0108 }
0109
0110
0111
0112
0113
0114 CELER_FUNCTION PhysMatId MaterialView::core_material_id() const
0115 {
0116 return params_.core_material_id[mat_id_];
0117 }
0118
0119
0120
0121
0122
0123 CELER_FUNCTION NonuniformGridCalculator
0124 MaterialView::make_refractive_index_calculator() const
0125 {
0126 CELER_EXPECT(*this);
0127 return NonuniformGridCalculator(params_.refractive_index[mat_id_],
0128 params_.reals);
0129 }
0130
0131
0132 }
0133 }