Back to home page

EIC code displayed by LXR

 
 

    


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

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/SurfaceHashPoint.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include <cmath>
0011 
0012 #include "orange/surf/VariantSurface.hh"
0013 
0014 namespace celeritas
0015 {
0016 namespace orangeinp
0017 {
0018 namespace detail
0019 {
0020 //---------------------------------------------------------------------------//
0021 /*!
0022  * Construct a point to hash for deduplicating surfaces.
0023  *
0024  * Surfaces that *can* be soft equal *must* result in a point that is less than
0025  * or equal to epsilon.
0026  *
0027  * \todo We could potentially reduce the number of collisions by turning this
0028  * into a two- or three-dimensional point that's then hashed in an infinite
0029  * grid.
0030  */
0031 struct SurfaceHashPoint
0032 {
0033     template<Axis T>
0034     real_type operator()(PlaneAligned<T> const& s) const
0035     {
0036         return s.position();
0037     }
0038 
0039     template<Axis T>
0040     real_type operator()(CylCentered<T> const& s) const
0041     {
0042         return std::sqrt(s.radius_sq());
0043     }
0044 
0045     real_type operator()(SphereCentered const& s) const
0046     {
0047         return std::sqrt(s.radius_sq());
0048     }
0049 
0050     template<Axis T>
0051     real_type operator()(CylAligned<T> const& s) const
0052     {
0053         return std::sqrt(s.radius_sq());
0054     }
0055 
0056     real_type operator()(Plane const& p) const { return p.displacement(); }
0057 
0058     real_type operator()(Sphere const& s) const
0059     {
0060         return std::sqrt(s.radius_sq());
0061     }
0062 
0063     template<Axis T>
0064     real_type operator()(ConeAligned<T> const& s) const
0065     {
0066         return norm(s.origin());
0067     }
0068 
0069     real_type operator()(Involute const& s) const
0070     {
0071         return s.displacement_angle();
0072     }
0073 
0074     real_type operator()(SimpleQuadric const& s) const
0075     {
0076         return std::sqrt(s.zeroth());
0077     }
0078 
0079     real_type operator()(GeneralQuadric const& s) const
0080     {
0081         return std::sqrt(s.zeroth());
0082     }
0083 };
0084 
0085 //---------------------------------------------------------------------------//
0086 }  // namespace detail
0087 }  // namespace orangeinp
0088 }  // namespace celeritas