File indexing completed on 2025-01-18 10:05:58
0001
0002
0003
0004
0005
0006
0007
0008 #pragma once
0009
0010 #include "corecel/cont/Span.hh"
0011 #include "corecel/data/Collection.hh"
0012 #include "corecel/math/Algorithms.hh"
0013 #include "orange/OrangeData.hh"
0014 #include "orange/OrangeTypes.hh"
0015
0016 namespace celeritas
0017 {
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 class VolumeView
0035 {
0036 public:
0037
0038
0039 using ParamsRef = NativeCRef<OrangeParamsData>;
0040
0041
0042 public:
0043
0044 inline CELER_FUNCTION VolumeView(ParamsRef const& params,
0045 SimpleUnitRecord const& unit_record,
0046 LocalVolumeId id);
0047
0048
0049
0050
0051 CELER_FORCEINLINE_FUNCTION FaceId::size_type num_faces() const;
0052
0053
0054 inline CELER_FUNCTION LocalSurfaceId get_surface(FaceId id) const;
0055
0056
0057 inline CELER_FUNCTION FaceId find_face(LocalSurfaceId id) const;
0058
0059
0060 CELER_FORCEINLINE_FUNCTION LdgSpan<LocalSurfaceId const> faces() const;
0061
0062
0063 CELER_FORCEINLINE_FUNCTION LdgSpan<logic_int const> logic() const;
0064
0065
0066 CELER_FORCEINLINE_FUNCTION logic_int max_intersections() const;
0067
0068
0069 CELER_FORCEINLINE_FUNCTION bool internal_surfaces() const;
0070
0071
0072 CELER_FORCEINLINE_FUNCTION bool implicit_vol() const;
0073
0074
0075 CELER_FORCEINLINE_FUNCTION bool simple_safety() const;
0076
0077
0078 CELER_FORCEINLINE_FUNCTION bool simple_intersection() const;
0079
0080 private:
0081 ParamsRef const& params_;
0082 VolumeRecord const& def_;
0083
0084 static inline CELER_FUNCTION VolumeRecord const&
0085 volume_record(ParamsRef const&,
0086 SimpleUnitRecord const& unit_record,
0087 LocalVolumeId id);
0088 };
0089
0090
0091
0092
0093
0094 CELER_FUNCTION
0095 VolumeView::VolumeView(ParamsRef const& params,
0096 SimpleUnitRecord const& unit_record,
0097 LocalVolumeId id)
0098 : params_(params), def_(VolumeView::volume_record(params, unit_record, id))
0099 {
0100 }
0101
0102
0103
0104
0105
0106 CELER_FUNCTION FaceId::size_type VolumeView::num_faces() const
0107 {
0108 return def_.faces.size();
0109 }
0110
0111
0112
0113
0114
0115
0116
0117 CELER_FUNCTION LocalSurfaceId VolumeView::get_surface(FaceId id) const
0118 {
0119 CELER_EXPECT(id < this->num_faces());
0120 auto offset = def_.faces.begin()->unchecked_get();
0121 offset += id.unchecked_get();
0122 return params_.local_surface_ids[ItemId<LocalSurfaceId>(offset)];
0123 }
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137 CELER_FUNCTION FaceId VolumeView::find_face(LocalSurfaceId surface) const
0138 {
0139 CELER_EXPECT(surface);
0140 auto surface_list = this->faces();
0141 auto iter = lower_bound(surface_list.begin(), surface_list.end(), surface);
0142 if (iter == surface_list.end() || *iter != surface)
0143 {
0144
0145 return {};
0146 }
0147
0148 FaceId result(iter - surface_list.begin());
0149 CELER_ENSURE(result < this->num_faces());
0150 return result;
0151 }
0152
0153
0154
0155
0156
0157 CELER_FUNCTION LdgSpan<LocalSurfaceId const> VolumeView::faces() const
0158 {
0159 return params_.local_surface_ids[def_.faces];
0160 }
0161
0162
0163
0164
0165
0166 CELER_FUNCTION LdgSpan<logic_int const> VolumeView::logic() const
0167 {
0168 return params_.logic_ints[def_.logic];
0169 }
0170
0171
0172
0173
0174
0175 CELER_FUNCTION logic_int VolumeView::max_intersections() const
0176 {
0177 return def_.max_intersections;
0178 }
0179
0180
0181
0182
0183
0184 CELER_FUNCTION bool VolumeView::internal_surfaces() const
0185 {
0186 return def_.flags & VolumeRecord::internal_surfaces;
0187 }
0188
0189
0190
0191
0192
0193 CELER_FUNCTION bool VolumeView::implicit_vol() const
0194 {
0195 return def_.flags & VolumeRecord::implicit_vol;
0196 }
0197
0198
0199
0200
0201
0202 CELER_FUNCTION bool VolumeView::simple_safety() const
0203 {
0204 return def_.flags & VolumeRecord::simple_safety;
0205 }
0206
0207
0208
0209
0210
0211 CELER_FUNCTION bool VolumeView::simple_intersection() const
0212 {
0213 return !(def_.flags
0214 & (VolumeRecord::internal_surfaces | VolumeRecord::implicit_vol));
0215 }
0216
0217
0218
0219
0220
0221
0222
0223 inline CELER_FUNCTION VolumeRecord const&
0224 VolumeView::volume_record(ParamsRef const& params,
0225 SimpleUnitRecord const& unit,
0226 LocalVolumeId local_vol_id)
0227 {
0228 CELER_EXPECT(local_vol_id < unit.volumes.size());
0229 return params.volume_records[unit.volumes[local_vol_id]];
0230 }
0231
0232
0233 }