@@ -26,6 +26,9 @@ namespace
2626// ! Return correctly sized volume labels
2727std::vector<Label> make_volume_labels (RectArrayInput const & inp)
2828{
29+ CELER_EXPECT (std::all_of (inp.grid .begin (),
30+ inp.grid .end (),
31+ [](auto const & g) { return g.size () >= 2 ; }));
2932 std::vector<Label> result;
3033 for (auto i : range (inp.grid [to_int (Axis::x)].size () - 1 ))
3134 {
@@ -50,6 +53,34 @@ std::vector<Label> make_volume_labels(RectArrayInput const& inp)
5053// ---------------------------------------------------------------------------//
5154} // namespace
5255
56+ // ---------------------------------------------------------------------------//
57+ /* !
58+ * Number of surfaces created by the input.
59+ */
60+ std::size_t RectArrayInserter::num_surfaces (Input const & i)
61+ {
62+ std::size_t result{0 };
63+ for (auto ax : range (Axis::size_))
64+ {
65+ result += i.grid [to_int (ax)].size ();
66+ }
67+ return result;
68+ }
69+
70+ // ---------------------------------------------------------------------------//
71+ /* !
72+ * Number of volumes created by the input.
73+ */
74+ std::size_t RectArrayInserter::num_volumes (Input const & i)
75+ {
76+ std::size_t result{1 };
77+ for (auto ax : range (Axis::size_))
78+ {
79+ result *= i.grid [to_int (ax)].size () - 1 ;
80+ }
81+ return result;
82+ }
83+
5384// ---------------------------------------------------------------------------//
5485/* !
5586 * Construct from full parameter data.
@@ -70,7 +101,7 @@ RectArrayInserter::RectArrayInserter(UniverseInserter* insert_universe,
70101/* !
71102 * Create a rect array unit and return its ID.
72103 */
73- UnivId RectArrayInserter::operator ()(RectArrayInput const & inp)
104+ UnivId RectArrayInserter::operator ()(RectArrayInput& & inp)
74105{
75106 CELER_VALIDATE (
76107 inp, << " rect array '" << inp.label << " ' is not properly constructed" );
@@ -83,7 +114,7 @@ UnivId RectArrayInserter::operator()(RectArrayInput const& inp)
83114
84115 for (auto ax : range (Axis::size_))
85116 {
86- std::vector< double > grid = inp.grid [to_int (ax)];
117+ auto & grid = inp.grid [to_int (ax)];
87118 CELER_VALIDATE (grid.size () >= 2 ,
88119 << " grid for " << to_char (ax) << " axis in '"
89120 << inp.label << " ' is too small (size " << grid.size ()
@@ -94,6 +125,7 @@ UnivId RectArrayInserter::operator()(RectArrayInput const& inp)
94125
95126 // Suppress the outer grid boundaries to avoid coincident surfaces with
96127 // other universes
128+ // FIXME: replace with bump using orange_data.scalars.tol
97129 grid.front () = -std::numeric_limits<real_type>::infinity ();
98130 grid.back () = std::numeric_limits<real_type>::infinity ();
99131
@@ -104,13 +136,11 @@ UnivId RectArrayInserter::operator()(RectArrayInput const& inp)
104136 record.grid [to_int (ax)] = reals_.insert_back (grid.begin (), grid.end ());
105137
106138 // Create surface labels
107- for (auto i : range (inp. grid [ to_int (ax)] .size ()))
139+ for (auto i : range (grid.size ()))
108140 {
109- Label sl;
110- sl.name = std::string (" {" + std::string (1 , to_char (ax)) + " ,"
111- + std::to_string (i) + " }" );
112- sl.ext = inp.label .name ;
113- surface_labels.push_back (std::move (sl));
141+ auto name = std::string (" {" + std::string (1 , to_char (ax)) + " ,"
142+ + std::to_string (i) + " }" );
143+ surface_labels.emplace_back (std::move (name), inp.label .name );
114144 }
115145 }
116146
@@ -139,11 +169,16 @@ UnivId RectArrayInserter::operator()(RectArrayInput const& inp)
139169 CELER_ASSERT (record);
140170 rect_arrays_.push_back (record);
141171
172+ // Save labels and clear input
173+ auto vol_labels = make_volume_labels (inp);
174+ Label unit_label{std::move (inp.label )};
175+ std::move (inp) = {};
176+
142177 // Construct universe
143178 return (*insert_universe_)(UnivType::rect_array,
144- inp. label ,
179+ std::move (unit_label) ,
145180 std::move (surface_labels),
146- make_volume_labels (inp ));
181+ std::move (vol_labels ));
147182}
148183
149184// ---------------------------------------------------------------------------//
0 commit comments