File indexing completed on 2025-09-18 09:09:00
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include "corecel/data/CollectionBuilder.hh"
0010 #include "celeritas/em/data/LivermorePEData.hh"
0011 #include "celeritas/grid/NonuniformGridBuilder.hh"
0012 #include "celeritas/io/ImportLivermorePE.hh"
0013
0014 namespace celeritas
0015 {
0016 namespace detail
0017 {
0018
0019
0020
0021
0022 class LivermoreXsInserter
0023 {
0024 public:
0025
0026
0027 using Data = HostVal<LivermorePEXsData>;
0028
0029
0030 public:
0031
0032 explicit inline LivermoreXsInserter(Data* data);
0033
0034
0035 inline void operator()(ImportLivermorePE const& inp);
0036
0037 private:
0038 NonuniformGridBuilder build_grid_;
0039
0040 CollectionBuilder<LivermoreSubshell> shells_;
0041 CollectionBuilder<LivermoreElement, MemSpace::host, ElementId> elements_;
0042 };
0043
0044
0045
0046
0047
0048
0049
0050 LivermoreXsInserter::LivermoreXsInserter(Data* data)
0051 : build_grid_{&data->reals}
0052 , shells_{&data->shells}
0053 , elements_{&data->elements}
0054 {
0055 CELER_EXPECT(data);
0056 }
0057
0058
0059
0060
0061
0062 void LivermoreXsInserter::operator()(ImportLivermorePE const& inp)
0063 {
0064 CELER_EXPECT(!inp.shells.empty());
0065 if constexpr (CELERITAS_DEBUG)
0066 {
0067 CELER_EXPECT(inp.thresh_lo <= inp.thresh_hi);
0068 for (auto const& shell : inp.shells)
0069 {
0070 CELER_EXPECT(shell.param_lo.size() == 6);
0071 CELER_EXPECT(shell.param_hi.size() == 6);
0072 CELER_EXPECT(shell.binding_energy <= inp.thresh_lo);
0073 }
0074 }
0075 using units::MevEnergy;
0076
0077 LivermoreElement el;
0078
0079
0080
0081 if (inp.xs_lo)
0082 {
0083
0084 el.xs_lo = build_grid_(inp.xs_lo);
0085 }
0086 el.xs_hi = build_grid_(inp.xs_hi);
0087
0088
0089 el.thresh_lo = MevEnergy(inp.thresh_lo);
0090 el.thresh_hi = MevEnergy(inp.thresh_hi);
0091
0092
0093 std::vector<LivermoreSubshell> shells(inp.shells.size());
0094
0095
0096 for (auto i : range(inp.shells.size()))
0097 {
0098
0099 shells[i].binding_energy = MevEnergy(inp.shells[i].binding_energy);
0100
0101
0102 shells[i].xs = build_grid_(inp.shells[i].xs);
0103
0104
0105 std::copy(inp.shells[i].param_lo.begin(),
0106 inp.shells[i].param_lo.end(),
0107 shells[i].param[0].begin());
0108 std::copy(inp.shells[i].param_hi.begin(),
0109 inp.shells[i].param_hi.end(),
0110 shells[i].param[1].begin());
0111
0112 CELER_ASSERT(shells[i]);
0113 }
0114 el.shells = shells_.insert_back(shells.begin(), shells.end());
0115
0116
0117 CELER_ASSERT(el);
0118 elements_.push_back(el);
0119
0120 CELER_ENSURE(el.shells.size() == inp.shells.size());
0121 }
0122
0123
0124 }
0125 }