Celeritas  0.5.0-86+4a8eea4
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
celeritas::Tolerance< T > Struct Template Reference

Tolerance for construction and runtime bumping. More...

#include <OrangeTypes.hh>

Public Types

using real_type = T
 

Public Member Functions

CELER_CONSTEXPR_FUNCTION operator bool () const
 True if tolerances are valid.
 

Static Public Member Functions

static CELER_CONSTEXPR_FUNCTION real_type sqrt_quadratic ()
 Intercept tolerance for parallel-to-quadric cases.
 
static Tolerance from_default (real_type length=1)
 Use a relative error of \( \sqrt(\epsilon_\textrm{machine}) \) . More...
 
static Tolerance from_softequal ()
 Construct from the default "soft equivalence" tolerance.
 
static Tolerance from_relative (real_type rel, real_type length=1)
 Construct from a relative tolerance and a length scale.
 

Public Attributes

real_type rel {}
 Relative error for differences.
 
real_type abs {}
 Absolute error [native length].
 

Detailed Description

template<class T = ::celeritas::real_type>
struct celeritas::Tolerance< T >

Tolerance for construction and runtime bumping.

The relative error is used for comparisons of magnitudes of values, and the absolute error provides a lower bound for the comparison tolerance. In most cases (see SoftEqual, BoundingBoxBumper , detail::BumpCalculator) the tolerance used is a maximum of the absolute error and the 1- or 2-norm of some spatial coordinate. In other cases (SurfaceSimplifier, SoftSurfaceEqual) the similarity between surfaces is determined by solving for a change in surface coefficients that results in no more than a change in \( \epsilon \) of a particle intercept. A final special case (the sqrt_quadratic static variable) is used to approximate the degenerate condition \( a\sim 0\) for a particle traveling nearly parallel to a quadric surface: see CylAligned for a discussion.

The absolute error should typically be constructed from the relative error (since computers use floating point precision) and a characteristic length scale for the problem being used. For detector/reactor problems the length might be ~1 cm, for microbiology it might be ~1 um, and for astronomy might be ~1e6 m.

Note
For historical reasons, the absolute tolerance used by SoftEqual defaults to 1/100 of the relative tolerance, whereas with Tolerance the equivalent behavior is setting a length scale of 0.01.
Todo:
Move this to a separate file.

Member Function Documentation

◆ from_default()

template<class T >
Tolerance< T > celeritas::Tolerance< T >::from_default ( real_type  length = 1)
static

Use a relative error of \( \sqrt(\epsilon_\textrm{machine}) \) .

Technically we're rounding the machine epsilon to a nearby value. We could use numeric_limits<real_type>::epsilon instead.


The documentation for this struct was generated from the following files: