Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:55

0001 //----------------------------------*-C++-*----------------------------------//
0002 // Copyright 2023-2024 UT-Battelle, LLC, and other Celeritas developers.
0003 // See the top-level COPYRIGHT file for details.
0004 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0005 //---------------------------------------------------------------------------//
0006 //! \file orange/detail/DepthCalculator.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include <unordered_map>
0011 #include <vector>
0012 
0013 #include "corecel/cont/VariantUtils.hh"
0014 
0015 #include "../OrangeInput.hh"
0016 
0017 namespace celeritas
0018 {
0019 namespace detail
0020 {
0021 //---------------------------------------------------------------------------//
0022 /*!
0023  * Calculate the maximum number of levels deep in a geometry.
0024  */
0025 class DepthCalculator
0026 {
0027   public:
0028     //!@{
0029     //! \name Type aliases
0030     using VecVarUniv = std::vector<VariantUniverseInput>;
0031     //!@}
0032 
0033   public:
0034     // Construct with a reference to all universe inputs
0035     explicit DepthCalculator(VecVarUniv const&);
0036 
0037     // Calculate the depth of the global unit
0038     size_type operator()();
0039 
0040     // Calculate the depth of a unit
0041     size_type operator()(UnitInput const& u);
0042 
0043     // Calculate the depth of a rect array
0044     size_type operator()(RectArrayInput const& u);
0045 
0046   private:
0047     ContainerVisitor<VecVarUniv const&> visit_univ_;
0048     std::size_t num_univ_{0};
0049     std::unordered_map<UniverseId, size_type> depths_;
0050 
0051     // Check cache or calculate
0052     size_type operator()(UniverseId uid);
0053 };
0054 
0055 //---------------------------------------------------------------------------//
0056 }  // namespace detail
0057 }  // namespace celeritas