|
||||
File indexing completed on 2025-01-18 10:05:55
0001 //----------------------------------*-C++-*----------------------------------// 0002 // Copyright 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/orangeinp/detail/SurfaceGridHash.hh 0007 //---------------------------------------------------------------------------// 0008 #pragma once 0009 0010 #include <cstdlib> 0011 #include <utility> 0012 0013 #include "corecel/Types.hh" 0014 #include "corecel/cont/Array.hh" 0015 #include "orange/OrangeTypes.hh" 0016 0017 namespace celeritas 0018 { 0019 namespace orangeinp 0020 { 0021 namespace detail 0022 { 0023 //---------------------------------------------------------------------------// 0024 /*! 0025 * Hash "similar" surfaces for faster lookups. 0026 * 0027 * This is meant to generate one or more "key" values for a hash of surfaces. 0028 * 0029 * This creates a hash map of local surfaces based on a characteristic 0030 * dimension (i.e. the radius of a sphere), which is used to accelerate surface 0031 * deduplication. For a given surface in bin N, possible duplicates may be 0032 * found in bins N-1, N, N+1. 0033 * 0034 * - Nearby surfaces should always have nearby "hash points", within some 0035 * comparison tolerance. 0036 * - The comparison tolerance must be less than the grid width, probably \em 0037 * much less. 0038 * - Different surfaces can have an identical hash point but have 0039 * different surface types. 0040 * - The bin values will *always* be unique given a surface type. 0041 * 0042 * \sa LocalSurfaceInserter 0043 */ 0044 class SurfaceGridHash 0045 { 0046 public: 0047 //!@{ 0048 //! \name Type aliases 0049 using key_type = std::size_t; 0050 using result_type = Array<key_type, 2>; 0051 //!@} 0052 0053 public: 0054 // Construct with maximum tolerance and characteristic scale of grid 0055 SurfaceGridHash(real_type grid_scale, real_type tol); 0056 0057 // Construct keys for the grid 0058 result_type operator()(SurfaceType type, real_type hash_point) const; 0059 0060 //! Sentinel value for a hash point being redundant 0061 static constexpr key_type redundant() { return static_cast<key_type>(-1); } 0062 0063 private: 0064 real_type eps_; 0065 real_type grid_offset_; 0066 real_type inv_grid_width_; 0067 0068 // Calculate the bin of a new data point 0069 key_type calc_bin(SurfaceType type, real_type hash_point) const; 0070 }; 0071 0072 //---------------------------------------------------------------------------// 0073 } // namespace detail 0074 } // namespace orangeinp 0075 } // namespace celeritas
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |