File indexing completed on 2025-09-17 08:53:40
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include <utility>
0010 #include <vector>
0011
0012 #include "corecel/Types.hh"
0013 #include "corecel/data/Collection.hh"
0014 #include "corecel/data/CollectionBuilder.hh"
0015 #include "corecel/grid/NonuniformGridData.hh"
0016 #include "celeritas/Types.hh"
0017 #include "celeritas/inp/Grid.hh"
0018
0019 #include "NonuniformGridBuilder.hh"
0020
0021 namespace celeritas
0022 {
0023
0024
0025
0026
0027 template<class Index>
0028 class NonuniformGridInserter
0029 {
0030 public:
0031
0032
0033 using Values = Collection<real_type, Ownership::value, MemSpace::host>;
0034 using GridValues
0035 = Collection<NonuniformGridRecord, Ownership::value, MemSpace::host, Index>;
0036
0037
0038 public:
0039
0040 NonuniformGridInserter(Values* reals, GridValues* grids);
0041
0042
0043 Index operator()(inp::Grid const&);
0044
0045
0046 Index operator()();
0047
0048 private:
0049 NonuniformGridBuilder build_;
0050 CollectionBuilder<NonuniformGridRecord, MemSpace::host, Index> grids_;
0051 };
0052
0053
0054
0055
0056
0057 template<class Index>
0058 NonuniformGridInserter<Index>::NonuniformGridInserter(Values* reals,
0059 GridValues* grids)
0060 : build_(reals), grids_(grids)
0061 {
0062 CELER_EXPECT(reals && grids);
0063 }
0064
0065
0066
0067
0068
0069
0070
0071 template<class Index>
0072 auto NonuniformGridInserter<Index>::operator()(inp::Grid const& grid) -> Index
0073 {
0074 CELER_EXPECT(grid);
0075 return grids_.push_back(build_(grid));
0076 }
0077
0078
0079
0080
0081
0082
0083
0084 template<class Index>
0085 auto NonuniformGridInserter<Index>::operator()() -> Index
0086 {
0087 return grids_.push_back({});
0088 }
0089
0090
0091 }