Skip to content

Commit 6a71ab6

Browse files
elliottbiondosethrj
authored andcommitted
Reduce ORANGE state size for models with background volumes (#2139)
Set max_intersections to zero for background volumes
1 parent ddf6c69 commit 6a71ab6

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/orange/detail/UnitInserter.cc

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,15 +409,26 @@ VolumeRecord UnitInserter::insert_volume(SurfacesRecord const& surf_record,
409409
auto params_cref = make_const_ref(*orange_data_);
410410
LocalSurfaceVisitor visit_surface(params_cref, surf_record);
411411

412-
// Mark as 'simple safety' if all the surfaces are simple
412+
// Mark this volume as "simple safety" if all of its constituent surfaces
413+
// support it, even in the case where the volume is implicit
413414
bool simple_safety = true;
414-
size_type max_intersections = 0;
415-
416415
for (LocalSurfaceId sid : v.faces)
417416
{
418417
simple_safety = simple_safety
419418
&& visit_surface(SimpleSafetyGetter{}, sid);
420-
max_intersections += visit_surface(NumIntersectionGetter{}, sid);
419+
}
420+
421+
// Calculate the max_intersection for the volume by summing up the
422+
// max_intersection for all constituent surfaces. If the volume is
423+
// background (implicit), no intersection is possible, thus
424+
// max_intersections is zero
425+
size_type max_intersections = 0;
426+
if (v.zorder != ZOrder::background)
427+
{
428+
for (LocalSurfaceId sid : v.faces)
429+
{
430+
max_intersections += visit_surface(NumIntersectionGetter{}, sid);
431+
}
421432
}
422433

423434
static logic_int const nowhere_logic[] = {logic::ltrue, logic::lnot};

test/orange/OrangeJson.test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ TEST_F(InputBuilderTest, bgspheres)
748748

749749
OrangeParamsOutput out(this->geometry());
750750
EXPECT_JSON_EQ(
751-
R"json({"_category":"internal","_label":"orange","scalars":{"max_depth":1,"max_faces":3,"max_intersections":6,"max_logic_depth":1,"tol":{"abs":1e-05,"rel":1e-05}},"sizes":{"bih":{"bboxes":4,"inner_nodes":1,"leaf_nodes":2,"local_volume_ids":3},"connectivity_records":3,"daughters":0,"local_surface_ids":6,"local_volume_ids":3,"logic_ints":5,"real_ids":3,"reals":9,"rect_arrays":0,"simple_units":1,"surface_types":3,"transforms":0,"universe_indices":1,"universe_types":1,"volume_records":4},"surfaces":{"label":["[EXTERIOR]@global","top@s","bottom@s"]}})json",
751+
R"json({"_category":"internal","_label":"orange","scalars":{"max_depth":1,"max_faces":3,"max_intersections":2,"max_logic_depth":1,"tol":{"abs":1e-05,"rel":1e-05}},"sizes":{"bih":{"bboxes":4,"inner_nodes":1,"leaf_nodes":2,"local_volume_ids":3},"connectivity_records":3,"daughters":0,"local_surface_ids":6,"local_volume_ids":3,"logic_ints":5,"real_ids":3,"reals":9,"rect_arrays":0,"simple_units":1,"surface_types":3,"transforms":0,"universe_indices":1,"universe_types":1,"volume_records":4},"surfaces":{"label":["[EXTERIOR]@global","top@s","bottom@s"]}})json",
752752
to_string(out));
753753
}
754754

0 commit comments

Comments
 (0)