Skip to content

Commit 0ddc337

Browse files
committed
Construct BIH based options in OrangeInput
1 parent 4bdcf5c commit 0ddc337

File tree

5 files changed

+36
-6
lines changed

5 files changed

+36
-6
lines changed

src/orange/OrangeInput.hh

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include "surf/VariantSurface.hh"
2222
#include "transform/VariantTransform.hh"
2323

24+
#include "detail/BIHBuilder.hh"
25+
2426
namespace celeritas
2527
{
2628
//---------------------------------------------------------------------------//
@@ -159,6 +161,19 @@ struct RectArrayInput
159161
}
160162
};
161163

164+
//---------------------------------------------------------------------------//
165+
/*!
166+
* Options that govern the geometry construction process.
167+
*/
168+
struct ConstructionOptions
169+
{
170+
//! Options for Bounding Interval Hierarchy (BIH) construction
171+
detail::BIHBuilder::Options bih_options;
172+
173+
//! Whether the options are valid
174+
explicit operator bool() const { return static_cast<bool>(bih_options); }
175+
};
176+
162177
//---------------------------------------------------------------------------//
163178
//! Possible types of universe inputs
164179
using VariantUniverseInput = std::variant<UnitInput, RectArrayInput>;
@@ -171,11 +186,18 @@ struct OrangeInput
171186
{
172187
std::vector<VariantUniverseInput> universes;
173188

189+
ConstructionOptions construction_opts;
190+
174191
//! Relative and absolute error for construction and transport
175192
Tolerance<> tol;
176193

177194
//! Whether the unit definition is valid
178-
explicit operator bool() const { return !universes.empty() && tol; }
195+
explicit operator bool() const
196+
{
197+
return !universes.empty() &&
198+
199+
static_cast<bool>(construction_opts) && tol;
200+
}
179201
};
180202

181203
//---------------------------------------------------------------------------//

src/orange/OrangeParams.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,8 @@ OrangeParams::OrangeParams(OrangeInput&& input, SPConstVolumes&& volumes)
204204
&impl_volume_labels,
205205
&host_data};
206206
Overload insert_universe{
207-
detail::UnitInserter{&insert_universe_base, &host_data},
207+
detail::UnitInserter{
208+
&insert_universe_base, &host_data, &(input.construction_opts)},
208209
detail::RectArrayInserter{&insert_universe_base, &host_data}};
209210

210211
for (auto&& u : input.universes)

src/orange/detail/BIHBuilder.hh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ class BIHBuilder
5555
struct Options
5656
{
5757
//! Minimum number of bboxes needed to trigger a partitioning attempt
58-
size_type min_split_size;
58+
size_type min_split_size = 2;
59+
60+
//! Whether the options are valid
61+
explicit operator bool() const { return min_split_size >= 2; }
5962
};
6063

6164
using VecBBox = std::vector<FastBBox>;

src/orange/detail/UnitInserter.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,11 @@ std::string to_string(VolumeInput::VariantLabel const& vlabel)
266266
/*!
267267
* Construct from full parameter data.
268268
*/
269-
UnitInserter::UnitInserter(UniverseInserter* insert_universe, Data* orange_data)
269+
UnitInserter::UnitInserter(UniverseInserter* insert_universe,
270+
Data* orange_data,
271+
ConstructionOptions* opts)
270272
: orange_data_(orange_data)
271-
, build_bih_tree_{&orange_data_->bih_tree_data, BIHBuilder::Options{2}}
273+
, build_bih_tree_{&orange_data_->bih_tree_data, opts->bih_options}
272274
, insert_transform_{&orange_data_->transforms, &orange_data_->reals}
273275
, build_surfaces_{&orange_data_->surface_types,
274276
&orange_data_->real_ids,

src/orange/detail/UnitInserter.hh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ class UnitInserter
3939

4040
public:
4141
// Construct from full parameter data
42-
UnitInserter(UniverseInserter* insert_universe, Data* orange_data);
42+
UnitInserter(UniverseInserter* insert_universe,
43+
Data* orange_data,
44+
ConstructionOptions* opts);
4345

4446
// Create a simple unit and store in in OrangeParamsData
4547
UniverseId operator()(UnitInput&& inp);

0 commit comments

Comments
 (0)