Celeritas 0.6.0-dev.116+3fbab5e0
Loading...
Searching...
No Matches
Classes | Functions
SenseUtils.hh File Reference

Sense helper functions and types. More...

#include "corecel/Macros.hh"
#include "corecel/cont/Bitset.hh"
#include "OrangeTypes.hh"
This graph shows which files directly or indirectly include this file:

Classes

class  celeritas::SenseValue
 Wrapper for a sense value that is optionally set. More...
 

Functions

CELER_CONSTEXPR_FUNCTION Sense celeritas::to_sense (bool s)
 Convert a boolean value to a Sense enum.
 
CELER_CONSTEXPR_FUNCTION Sense celeritas::flip_sense (Sense orig)
 Change the sense across a surface.
 
CELER_CONSTEXPR_FUNCTION SignedSense celeritas::flip_sense (SignedSense orig)
 Change the sense across a surface.
 
CELER_CONSTEXPR_FUNCTION SignedSense celeritas::real_to_sense (real_type quadric)
 Evaluate the sense based on the LHS expression of the quadric equation.
 
CELER_CONSTEXPR_FUNCTION Sense celeritas::to_sense (SignedSense s)
 Convert a signed sense to a Sense enum.
 
CELER_CONSTEXPR_FUNCTION SurfaceState celeritas::to_surface_state (SignedSense s)
 Convert a signed sense to a surface state.
 
constexpr char celeritas::to_char (Sense s)
 Get a printable character corresponding to a sense.
 
char constceleritas::to_cstring (SignedSense s)
 

Detailed Description

Sense helper functions and types.

Function Documentation

◆ real_to_sense()

CELER_CONSTEXPR_FUNCTION SignedSense celeritas::real_to_sense ( real_type  quadric)

Evaluate the sense based on the LHS expression of the quadric equation.

This is an optimized jump-free version of:

return quadric == 0 ? SignedSense::on
: quadric < 0 ? SignedSense::inside
: SignedSense::outside;

as

int gz = !(quadric <= 0) ? 1 : 0;
int lz = quadric < 0 ? 1 : 0;
return static_cast<SignedSense>(gz - lz);

and compressed into a single line.

NaN values are treated as "outside".