Skip to content

Commit

Permalink
Fix ORANGE namespaces (celeritas-project#1117)
Browse files Browse the repository at this point in the history
* Fix CSG namespaces
* Fix clang-format for detail classes
* Update git ignore revs
* Fix missing namespaces for ORANGE details
  • Loading branch information
sethrj committed Feb 21, 2024
1 parent 797d796 commit f1862f3
Show file tree
Hide file tree
Showing 19 changed files with 74 additions and 34 deletions.
10 changes: 5 additions & 5 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,18 @@ IncludeCategories:
SortPriority: 9
CaseSensitive: true
- Regex: '^"[^/]+"'
Priority: 5
SortPriority: 10
- Regex: '^"detail/"'
Priority: 5
SortPriority: 11
- Regex: '^"detail/'
Priority: 6
SortPriority: 13
- Regex: '"(^gtest/|TestBase|\.test\.hh|celeritas_test\.hh)'
Priority: 7
CaseSensitive: true
SortPriority: 12
SortPriority: 14
- Regex: '.*'
Priority: 5
SortPriority: 13
SortPriority: 12 # higher than detail, lower than no-slash
IncludeIsMainRegex: '(\.[^.]+)?$'
IncludeIsMainSourceRegex: '(\.cu|\.t\.hh)$' # Allow CU/template files as main
IndentCaseLabels: true
Expand Down
1 change: 1 addition & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ f27dc24aac631ebfea4f487a0d122a0e69d3c083
350a3c60a4cf34a63b342daa3de6e09de22ec06b
638f7f9665222a1f49f9e1275d43bb8c74ce66e2
cfc407b09185786e4b4939d3b9b720215afcc7f2
0b805058892830cbad5aee2dd52fcc9c1bc8a09c
# consolidate .hh, i.hh
128b0eff32a159005019a8f18619e3630181d9d0
d90f9cb55c0df92e36ccfd0646f9ffd1a51bbd14
2 changes: 1 addition & 1 deletion src/orange/OrangeParams.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ OrangeParams::OrangeParams(OrangeInput input)
// Create host data for construction, setting tolerances first
HostVal<OrangeParamsData> host_data;
host_data.scalars.tol = input.tol;
host_data.scalars.max_depth = DepthCalculator{input.universes}();
host_data.scalars.max_depth = detail::DepthCalculator{input.universes}();

// Insert all universes
{
Expand Down
28 changes: 16 additions & 12 deletions src/orange/OrangeTrackView.hh
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@

#include "OrangeData.hh"
#include "OrangeTypes.hh"
#include "detail/LevelStateAccessor.hh"
#include "detail/UniverseIndexer.hh"
#include "transform/TransformVisitor.hh"
#include "univ/SimpleUnitTracker.hh"
#include "univ/TrackerVisitor.hh"
#include "univ/UniverseTypeTraits.hh"
#include "univ/detail/Types.hh"

#include "detail/LevelStateAccessor.hh"
#include "detail/UniverseIndexer.hh"

namespace celeritas
{
//---------------------------------------------------------------------------//
Expand Down Expand Up @@ -123,6 +124,10 @@ class OrangeTrackView
inline CELER_FUNCTION void set_dir(Real3 const& newdir);

private:
//// TYPES ////

using LSA = detail::LevelStateAccessor;

//// DATA ////

ParamsRef const& params_;
Expand Down Expand Up @@ -204,13 +209,13 @@ class OrangeTrackView
inline CELER_FUNCTION void clear_surface();

// Make a LevelStateAccessor for the current thread and level
inline CELER_FUNCTION LevelStateAccessor make_lsa() const;
inline CELER_FUNCTION LSA make_lsa() const;

// Make a LevelStateAccessor for the current thread and a given level
inline CELER_FUNCTION LevelStateAccessor make_lsa(LevelId level) const;
inline CELER_FUNCTION LSA make_lsa(LevelId level) const;

// Get the daughter ID for the volume in the universe (or null)
inline CELER_FUNCTION DaughterId get_daughter(LevelStateAccessor const& lsa);
inline CELER_FUNCTION DaughterId get_daughter(LSA const& lsa);

// Get the transform ID for the given daughter.
inline CELER_FUNCTION TransformId get_transform(DaughterId daughter_id);
Expand Down Expand Up @@ -1056,7 +1061,7 @@ CELER_FUNCTION void OrangeTrackView::clear_surface()
/*!
* Make a LevelStateAccessor for the current thread and level.
*/
CELER_FORCEINLINE_FUNCTION LevelStateAccessor OrangeTrackView::make_lsa() const
CELER_FORCEINLINE_FUNCTION auto OrangeTrackView::make_lsa() const -> LSA
{
return this->make_lsa(this->level());
}
Expand All @@ -1065,10 +1070,10 @@ CELER_FORCEINLINE_FUNCTION LevelStateAccessor OrangeTrackView::make_lsa() const
/*!
* Make a LevelStateAccessor for the current thread and a given level.
*/
CELER_FORCEINLINE_FUNCTION LevelStateAccessor
OrangeTrackView::make_lsa(LevelId level) const
CELER_FORCEINLINE_FUNCTION auto OrangeTrackView::make_lsa(LevelId level) const
-> LSA
{
return LevelStateAccessor(&states_, track_slot_, level);
return LSA(&states_, track_slot_, level);
}

//---------------------------------------------------------------------------//
Expand All @@ -1077,8 +1082,7 @@ OrangeTrackView::make_lsa(LevelId level) const
*
* \return DaughterId or {} if the current volume is a leaf.
*/
CELER_FUNCTION DaughterId
OrangeTrackView::get_daughter(LevelStateAccessor const& lsa)
CELER_FUNCTION DaughterId OrangeTrackView::get_daughter(LSA const& lsa)
{
TrackerVisitor visit_tracker{params_};
return visit_tracker([&lsa](auto&& t) { return t.daughter(lsa.vol()); },
Expand All @@ -1102,7 +1106,7 @@ CELER_FUNCTION TransformId OrangeTrackView::get_transform(DaughterId daughter_id
CELER_FUNCTION TransformId OrangeTrackView::get_transform(LevelId lev)
{
CELER_EXPECT(lev < this->level());
LevelStateAccessor lsa(&states_, track_slot_, lev);
LSA lsa(&states_, track_slot_, lev);
return this->get_transform(this->get_daughter(lsa));
}

Expand Down
3 changes: 3 additions & 0 deletions src/orange/detail/DepthCalculator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

namespace celeritas
{
namespace detail
{
//---------------------------------------------------------------------------//
/*!
* Construct with a reference to all universe inputs.
Expand Down Expand Up @@ -74,4 +76,5 @@ size_type DepthCalculator::operator()(UniverseId uid)
}

//---------------------------------------------------------------------------//
} // namespace detail
} // namespace celeritas
3 changes: 3 additions & 0 deletions src/orange/detail/DepthCalculator.hh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

namespace celeritas
{
namespace detail
{
//---------------------------------------------------------------------------//
/*!
* Calculate the maximum number of levels deep in a geometry.
Expand Down Expand Up @@ -51,4 +53,5 @@ class DepthCalculator
};

//---------------------------------------------------------------------------//
} // namespace detail
} // namespace celeritas
3 changes: 3 additions & 0 deletions src/orange/detail/LevelStateAccessor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

namespace celeritas
{
namespace detail
{
//---------------------------------------------------------------------------//
/*!
* Accesss the 2D fields (i.e., {thread, level}) of OrangeStateData
Expand Down Expand Up @@ -116,4 +118,5 @@ LevelStateAccessor::operator=(LevelStateAccessor const& other)
}

//---------------------------------------------------------------------------//
} // namespace detail
} // namespace celeritas
8 changes: 4 additions & 4 deletions src/orange/orangeinp/CsgTree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ auto CsgTree::insert(Node&& n) -> NodeId

{
// Try to simplify the node up to one level when inserting.
Node repl = std::visit(NodeSimplifier{*this}, n);
if (repl != Node{NodeSimplifier::no_simplification()})
Node repl = std::visit(detail::NodeSimplifier{*this}, n);
if (repl != Node{detail::NodeSimplifier::no_simplification()})
{
n = std::move(repl);
if (auto* a = std::get_if<orangeinp::Aliased>(&n))
Expand Down Expand Up @@ -112,8 +112,8 @@ auto CsgTree::exchange(NodeId node_id, Node&& n) -> Node
&& std::visit(IsUserNodeValid{node_id.unchecked_get()}, n));

//! Simplify the node first
Node repl = std::visit(NodeSimplifier{*this}, n);
if (repl != Node{NodeSimplifier::no_simplification()})
Node repl = std::visit(detail::NodeSimplifier{*this}, n);
if (repl != Node{detail::NodeSimplifier::no_simplification()})
{
n = std::move(repl);
}
Expand Down
10 changes: 5 additions & 5 deletions src/orange/orangeinp/CsgTreeUtils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ NodeId replace_down(CsgTree* tree, NodeId n, Node repl)
{
CELER_EXPECT(is_boolean_node(repl));

NodeReplacementInserter::VecNode stack{{n, std::move(repl)}};
detail::NodeReplacementInserter::VecNode stack{{n, std::move(repl)}};

NodeId lowest_node{n};

Expand All @@ -52,7 +52,7 @@ NodeId replace_down(CsgTree* tree, NodeId n, Node repl)
lowest_node = std::min(n, lowest_node);

Node prev = tree->exchange(n, std::move(repl));
std::visit(NodeReplacementInserter{&stack, repl}, prev);
std::visit(detail::NodeReplacementInserter{&stack, repl}, prev);
}
return lowest_node;
}
Expand Down Expand Up @@ -107,13 +107,13 @@ void simplify(CsgTree* tree, NodeId start)
* Convert a node to postfix notation.
*/
std::vector<LocalSurfaceId::size_type>
build_postfix(CsgTree const& tree, orangeinp::NodeId n)
build_postfix(CsgTree const& tree, NodeId n)
{
CELER_EXPECT(n < tree.size());
std::vector<LocalSurfaceId::size_type> result;
orangeinp::PostfixLogicBuilder build_logic{tree, &result};
detail::PostfixLogicBuilder build_impl{tree, &result};

build_logic(n);
build_impl(n);
return result;
}

Expand Down
2 changes: 0 additions & 2 deletions src/orange/orangeinp/detail/CsgUnitBuilder.hh
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ class CsgUnitBuilder
void set_exterior(NodeId);

private:
using LocalSurfaceInserter = ::celeritas::detail::LocalSurfaceInserter;

CsgUnit* unit_;
Tol tol_;
LocalSurfaceInserter insert_surface_;
Expand Down
3 changes: 3 additions & 0 deletions src/orange/orangeinp/detail/LocalSurfaceInserter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

namespace celeritas
{
namespace orangeinp
{
namespace detail
{
//---------------------------------------------------------------------------//
Expand Down Expand Up @@ -46,4 +48,5 @@ LocalSurfaceInserter::merge_impl(LocalSurfaceId source, LocalSurfaceId target)

//---------------------------------------------------------------------------//
} // namespace detail
} // namespace orangeinp
} // namespace celeritas
3 changes: 3 additions & 0 deletions src/orange/orangeinp/detail/LocalSurfaceInserter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

namespace celeritas
{
namespace orangeinp
{
namespace detail
{
//---------------------------------------------------------------------------//
Expand Down Expand Up @@ -125,4 +127,5 @@ LocalSurfaceId LocalSurfaceInserter::operator()(S const& source)

//---------------------------------------------------------------------------//
} // namespace detail
} // namespace orangeinp
} // namespace celeritas
3 changes: 3 additions & 0 deletions src/orange/orangeinp/detail/NodeReplacementInserter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ namespace celeritas
{
namespace orangeinp
{
namespace detail
{
//---------------------------------------------------------------------------//
/*!
* Add a node ID and its "replaced" value.
Expand Down Expand Up @@ -142,5 +144,6 @@ void NodeReplacementInserter::operator()(Joined const& n)
}

//---------------------------------------------------------------------------//
} // namespace detail
} // namespace orangeinp
} // namespace celeritas
3 changes: 3 additions & 0 deletions src/orange/orangeinp/detail/NodeSimplifier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ namespace celeritas
{
namespace orangeinp
{
namespace detail
{
namespace
{
//---------------------------------------------------------------------------//
Expand Down Expand Up @@ -160,5 +162,6 @@ auto NodeSimplifier::operator()(Joined& j) const -> Node
}

//---------------------------------------------------------------------------//
} // namespace detail
} // namespace orangeinp
} // namespace celeritas
3 changes: 3 additions & 0 deletions src/orange/orangeinp/detail/NodeSimplifier.hh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ namespace celeritas
{
namespace orangeinp
{
namespace detail
{
//---------------------------------------------------------------------------//
/*!
* Simplify a node by visiting up to one level below.
Expand Down Expand Up @@ -58,5 +60,6 @@ class NodeSimplifier
};

//---------------------------------------------------------------------------//
} // namespace detail
} // namespace orangeinp
} // namespace celeritas
5 changes: 4 additions & 1 deletion src/orange/orangeinp/detail/PostfixLogicBuilder.hh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ namespace celeritas
{
namespace orangeinp
{
namespace detail
{
//---------------------------------------------------------------------------//
/*!
* Recursively construct a logic vector from a node with postfix operation.
Expand All @@ -38,7 +40,7 @@ class PostfixLogicBuilder

public:
// Construct with pointer to vector to append to
explicit inline PostfixLogicBuilder(CsgTree const& tree, VecLogic* logic);
inline PostfixLogicBuilder(CsgTree const& tree, VecLogic* logic);

//! Build from a node ID
inline void operator()(NodeId const& n);
Expand Down Expand Up @@ -156,5 +158,6 @@ void PostfixLogicBuilder::operator()(Joined const& n)
}

//---------------------------------------------------------------------------//
} // namespace detail
} // namespace orangeinp
} // namespace celeritas
3 changes: 3 additions & 0 deletions test/orange/orangeinp/detail/LocalSurfaceInserter.test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

namespace celeritas
{
namespace orangeinp
{
namespace detail
{
namespace test
Expand Down Expand Up @@ -130,4 +132,5 @@ TEST_F(LocalSurfaceInserterTest, DISABLED_performance_test)
//---------------------------------------------------------------------------//
} // namespace test
} // namespace detail
} // namespace orangeinp
} // namespace celeritas
5 changes: 3 additions & 2 deletions test/orange/univ/SimpleUnitTracker.test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ auto SimpleUnitTrackerTest::setup_heuristic_states(size_type num_tracks) const
IsotropicDistribution<> sample_isotropic;
for (auto i : range(num_tracks))
{
auto lsa = LevelStateAccessor(&result_ref, TrackSlotId{i}, LevelId{0});
auto lsa = detail::LevelStateAccessor(
&result_ref, TrackSlotId{i}, LevelId{0});
lsa.pos() = sample_box(rng);
lsa.dir() = sample_isotropic(rng);
}
Expand Down Expand Up @@ -310,7 +311,7 @@ auto SimpleUnitTrackerTest::reduce_heuristic_init(StateHostRef const& host,
{
auto tid = TrackSlotId{i};
// TODO Update for multiple universes
LevelStateAccessor lsa(&host, tid, LevelId{0});
detail::LevelStateAccessor lsa(&host, tid, LevelId{0});
auto vol = lsa.vol();

if (vol < counts.size())
Expand Down

0 comments on commit f1862f3

Please sign in to comment.