File indexing completed on 2025-01-18 10:05:58
0001
0002
0003
0004
0005
0006
0007
0008 #pragma once
0009
0010 #include <cmath>
0011
0012 #include "corecel/Assert.hh"
0013 #include "corecel/Macros.hh"
0014 #include "corecel/math/Algorithms.hh"
0015 #include "corecel/math/NumericLimits.hh"
0016
0017 #include "Types.hh"
0018 #include "../VolumeView.hh"
0019
0020 namespace celeritas
0021 {
0022 namespace detail
0023 {
0024
0025
0026
0027
0028
0029
0030 struct IsFinite
0031 {
0032 CELER_FORCEINLINE_FUNCTION bool operator()(real_type distance) const
0033 {
0034 return distance < numeric_limits<real_type>::max();
0035 }
0036 };
0037
0038
0039
0040
0041
0042 class IsNotFurtherThan
0043 {
0044 public:
0045 explicit CELER_FORCEINLINE_FUNCTION IsNotFurtherThan(real_type md)
0046 : max_dist_(md)
0047 {
0048 }
0049
0050 CELER_FORCEINLINE_FUNCTION bool operator()(real_type distance) const
0051 {
0052 return distance <= max_dist_;
0053 }
0054
0055 private:
0056 real_type max_dist_;
0057 };
0058
0059
0060
0061
0062
0063 class BumpCalculator
0064 {
0065 public:
0066 explicit CELER_FORCEINLINE_FUNCTION BumpCalculator(Tolerance<> const& tol)
0067 : tol_(tol)
0068 {
0069 }
0070
0071 CELER_FUNCTION real_type operator()(Real3 const& pos) const
0072 {
0073 real_type result = tol_.abs;
0074 for (real_type p : pos)
0075 {
0076 result = celeritas::max(result, tol_.rel * std::fabs(p));
0077 }
0078 CELER_ENSURE(result > 0);
0079 return result;
0080 }
0081
0082 private:
0083 Tolerance<> tol_;
0084 };
0085
0086
0087
0088
0089
0090
0091
0092 inline CELER_FUNCTION OnFace find_face(VolumeView const& vol,
0093 OnLocalSurface surf)
0094 {
0095 return {surf ? vol.find_face(surf.id()) : FaceId{}, surf.unchecked_sense()};
0096 }
0097
0098
0099
0100
0101
0102 inline CELER_FUNCTION OnLocalSurface get_surface(VolumeView const& vol,
0103 OnFace face)
0104 {
0105 return {face ? vol.get_surface(face.id()) : LocalSurfaceId{},
0106 face.unchecked_sense()};
0107 }
0108
0109
0110 }
0111 }