Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/orange/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ list(APPEND SOURCES
detail/BIHBuilder.cc
detail/BIHPartitioner.cc
detail/DepthCalculator.cc
detail/LogicUtils.cc
detail/ConvertLogic.cc
detail/LogicIO.cc
detail/OrangeInputIOImpl.json.cc
detail/RectArrayInserter.cc
detail/SurfacesRecordBuilder.cc
Expand All @@ -50,11 +51,11 @@ list(APPEND SOURCES
orangeinp/Shape.cc
orangeinp/Solid.cc
orangeinp/StackedExtrudedPolygon.cc
orangeinp/ScaleUtils.cc
orangeinp/Transformed.cc
orangeinp/Truncated.cc
orangeinp/UnitProto.cc
orangeinp/detail/BoundingZone.cc
orangeinp/detail/BuildLogic.cc
orangeinp/detail/BuildIntersectRegion.cc
orangeinp/detail/CsgUnitBuilder.cc
orangeinp/detail/DeMorganSimplifier.cc
Expand Down
8 changes: 1 addition & 7 deletions src/orange/OrangeData.hh
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ inline constexpr UnivId orange_global_univ{0};
inline constexpr UnivLevelId orange_global_univ_level{0};

//! Logic notation used for boolean expressions
CELER_FUNCTION inline constexpr auto orange_tracking_logic()
{
return LogicNotation::infix;
}
inline constexpr auto orange_tracking_logic{LogicNotation::infix};

//---------------------------------------------------------------------------//
/*!
Expand All @@ -64,9 +61,6 @@ struct OrangeParamsScalars
// Soft comparison and dynamic "bumping" values
Tolerance<> tol;

// Logic expression notation
LogicNotation logic{};

// Raw pointers to externally owned memory for debug output
OrangeParams const* host_geo_params{nullptr};
VolumeParams const* host_volume_params{nullptr};
Expand Down
4 changes: 2 additions & 2 deletions src/orange/OrangeInputIO.json.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "OrangeTypes.hh"
#include "OrangeTypesIO.json.hh" // IWYU pragma: keep

#include "detail/LogicUtils.hh"
#include "detail/LogicIO.hh"
#include "detail/OrangeInputIOImpl.json.hh"

namespace celeritas
Expand Down Expand Up @@ -133,7 +133,7 @@ void from_json(nlohmann::json const& j, VolumeInput& value)
{
// Background volumes should be "nowhere" explicitly using "inside"
// logic
value.logic = {logic::ltrue, logic::lnot};
value.logic = detail::make_nowhere_expr(LogicNotation::postfix);
value.bbox = {};
}
else
Expand Down
10 changes: 6 additions & 4 deletions src/orange/OrangeParams.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "geocel/BoundingBox.hh"
#include "geocel/GeantGeoParams.hh"
#include "geocel/VolumeParams.hh"
#include "orange/detail/LogicUtils.hh"

#include "OrangeData.hh" // IWYU pragma: associated
#include "OrangeInput.hh"
Expand All @@ -33,6 +32,7 @@
#include "g4org/Converter.hh"
#include "univ/detail/LogicStack.hh"

#include "detail/ConvertLogic.hh"
#include "detail/DepthCalculator.hh"
#include "detail/RectArrayInserter.hh"
#include "detail/UnitInserter.hh"
Expand Down Expand Up @@ -180,6 +180,10 @@ OrangeParams::OrangeParams(OrangeInput&& input, SPConstVolumes&& volumes)
<< (celeritas::device() ? " and copying to GPU" : "");
ScopedTimeLog scoped_time;

// First, preprocess the input logic expressions to match the tracker
detail::convert_logic(input, orange_tracking_logic);
CELER_ASSERT(input.logic == orange_tracking_logic);

// Save global bounding box
bbox_ = [&input] {
auto& global = input.universes[orange_global_univ.unchecked_get()];
Expand All @@ -191,14 +195,11 @@ OrangeParams::OrangeParams(OrangeInput&& input, SPConstVolumes&& volumes)
// Create host data for construction, setting tolerances first
HostVal<OrangeParamsData> host_data;
host_data.scalars.tol = input.tol;
host_data.scalars.logic = input.logic;
host_data.scalars.num_univ_levels
= detail::DepthCalculator{input.universes}();
host_data.scalars.num_vol_levels = volumes_ ? volumes_->num_volume_levels()
: 0;

detail::convert_logic(input, orange_tracking_logic());

// Insert all universes
{
std::vector<Label> universe_labels;
Expand Down Expand Up @@ -226,6 +227,7 @@ OrangeParams::OrangeParams(OrangeInput&& input, SPConstVolumes&& volumes)
impl_vol_labels_
= ImplVolumeMap{"impl volume", std::move(impl_volume_labels)};
}
// Clear captured input since we've consumed and modified it
std::move(input) = {};

// Simple safety if all SimpleUnits have simple safety and no RectArrays
Expand Down
1 change: 0 additions & 1 deletion src/orange/OrangeParamsOutput.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ void OrangeParamsOutput::output(JsonPimpl* j) const
OPO_PAIR(data.scalars, max_intersections),
OPO_PAIR(data.scalars, max_csg_levels),
OPO_PAIR(data.scalars, tol),
OPO_PAIR(data.scalars, logic),
};

// Save sizes
Expand Down
10 changes: 6 additions & 4 deletions src/orange/OrangeTypes.hh
Original file line number Diff line number Diff line change
Expand Up @@ -251,18 +251,20 @@ enum class Chirality : bool
*/
namespace logic
{
//! Special logical Evaluator tokens ordered by precedence.
// The enum values are set to the highest 6 values of logic_int.
/*!
* Special logical evaluator tokens ordered by precedence.
*
* The enum values are set to the highest 6 values of logic_int.
*/
enum OperatorToken : logic_int
{
lbegin = logic_int(~logic_int(6)),
lbegin = static_cast<logic_int>(-6),
lopen = lbegin, //!< Open parenthesis
lclose, //!< Close parenthesis
lor, //!< Binary logical OR
land, //!< Binary logical AND
lnot, //!< Unary negation
ltrue, //!< Push 'true'
lend
};
} // namespace logic

Expand Down
Loading
Loading