File indexing completed on 2025-02-22 10:31:21
0001
0002
0003
0004
0005
0006
0007
0008 #pragma once
0009
0010 #include "corecel/Macros.hh"
0011 #include "corecel/Types.hh"
0012 #include "corecel/data/Collection.hh"
0013 #include "corecel/grid/UniformGridData.hh"
0014
0015 #include "FieldDriverOptions.hh"
0016
0017 namespace celeritas
0018 {
0019
0020
0021
0022
0023 struct FieldMapGridData
0024 {
0025 UniformGridData data_z;
0026 UniformGridData data_r;
0027 };
0028
0029
0030
0031
0032
0033 struct FieldMapElement
0034 {
0035 real_type value_z;
0036 real_type value_r;
0037 };
0038
0039
0040
0041
0042
0043 template<Ownership W, MemSpace M>
0044 struct RZMapFieldParamsData
0045 {
0046
0047 FieldMapGridData grids;
0048
0049
0050 FieldDriverOptions options;
0051
0052
0053 using ElementId = ItemId<size_type>;
0054
0055 template<class T>
0056 using ElementItems = Collection<T, W, M, ElementId>;
0057 ElementItems<FieldMapElement> fieldmap;
0058
0059
0060 explicit inline CELER_FUNCTION operator bool() const
0061 {
0062 return !fieldmap.empty();
0063 }
0064
0065 inline CELER_FUNCTION bool valid(real_type z, real_type r) const
0066 {
0067 CELER_EXPECT(grids.data_z);
0068 CELER_EXPECT(grids.data_r);
0069 return (z >= grids.data_z.front && z <= grids.data_z.back
0070 && r >= grids.data_r.front && r <= grids.data_r.back);
0071 }
0072
0073 inline CELER_FUNCTION ElementId id(size_type idx_z, size_type idx_r) const
0074 {
0075 CELER_EXPECT(grids.data_r);
0076 return ElementId(idx_z * grids.data_r.size + idx_r);
0077 }
0078
0079
0080 template<Ownership W2, MemSpace M2>
0081 RZMapFieldParamsData& operator=(RZMapFieldParamsData<W2, M2> const& other)
0082 {
0083 CELER_EXPECT(other);
0084 grids = other.grids;
0085 options = other.options;
0086 fieldmap = other.fieldmap;
0087 return *this;
0088 }
0089 };
0090
0091
0092 }