OpenLB 1.8.1
Loading...
Searching...
No Matches
olb::util Namespace Reference

Namespaces

namespace  ADtape
 
namespace  tensorIndices2D
 
namespace  tensorIndices3D
 

Classes

class  ADf
 Definition of a description of a algoritmic differentiation data type using the forward method. More...
 
struct  BaseTypeHelper
 
struct  BaseTypeHelper< double >
 
struct  BaseTypeHelper< float >
 
struct  BaseTypeHelper< int >
 
struct  BaseTypeHelper< long double >
 
class  BisectStepper
 Propose successive test values of a scalar (e.g. Re) to check stability of a system. More...
 
class  CircularBuffer
 Simple circular buffer to compute average and other quantities over pre-defined temporal windows. More...
 
struct  ContainerCreator
 Creates a container of type C. More...
 
struct  ContainerCreator< std::array< T, SIZE > >
 
struct  ContainerCreator< std::vector< T > >
 
struct  ContainerCreator< Vector< T, SIZE > >
 
struct  divides
 Wrapper of function object std::divides. More...
 
class  ExponentialMovingAverage
 Exponential moving average. More...
 
struct  has_identity_functor
 Indicates existence of F::identity_functor_type typedef. More...
 
struct  has_identity_functor< F, std::void_t< typename F::identity_functor_type > >
 Indicates existence of F::identity_functor_type typedef. More...
 
struct  is_adf
 
struct  is_adf< ADf< S, DIM > >
 
class  KahanSummator
 Accurate summation of floating point numbers with the Kahan algorithm Reduces round-off effects which arise if the total sum is significantly larger than the single summands. More...
 
struct  maxOp
 Wrapper function object for util::max. More...
 
struct  maxOp< void >
 
struct  minOp
 Wrapper function object for util::min. More...
 
struct  minOp< void >
 
struct  minus
 Wrapper of function object std::minus with special handling for bool. More...
 
struct  multiplies
 Wrapper of function object std::multiplies. More...
 
class  Newton1D
 1D Newton simple scheme More...
 
struct  plus
 Wrapper of function object std::plus. More...
 
struct  power
 Power function object. More...
 
class  Randomizer
 
struct  TensorVal
 Compute number of elements of a symmetric d-dimensional tensor. More...
 
class  TimeIntegrator
 Integration with the trapezoid rule. More...
 
class  TimeIntegratorsArray
 Helper class that manages an array of time integrators. More...
 
class  Timer
 How to use in Code: More...
 
class  TrapezRuleInt1D
 Trapezoidal rule. More...
 
class  ValueTracer
 Check time-convergence of a scalar. More...
 

Typedefs

template<typename S >
using StdVector = std::vector<S,std::allocator<S>>
 

Functions

Expr sqrt (Expr x)
 
Expr fabs (Expr x)
 
Expr pow (Expr base, Expr exp)
 
Expr exp (Expr x)
 
Expr max (Expr a, Expr b)
 
Expr min (Expr a, Expr b)
 
template<std::floating_point T>
cpu::simd::Pack< T > sqrt (cpu::simd::Pack< T > value)
 
template<std::floating_point T>
cpu::simd::Pack< T > fabs (cpu::simd::Pack< T > value)
 
template<std::floating_point T>
cpu::simd::Pack< T > pow (cpu::simd::Pack< T > base, cpu::simd::Pack< T > exp)
 
template<std::floating_point T, cpu::simd::concepts::convertible_to_pack S>
cpu::simd::Pack< T > pow (cpu::simd::Pack< T > base, S exp)
 
template<std::floating_point T>
cpu::simd::Pack< T > min (cpu::simd::Pack< T > rhs, cpu::simd::Pack< T > lhs)
 
template<std::floating_point T>
cpu::simd::Pack< T > max (cpu::simd::Pack< T > rhs, cpu::simd::Pack< T > lhs)
 
template<typename T >
norm (const std::vector< T > &a)
 l2 norm of a vector of arbitrary length
 
template<typename T >
int sign (T val) any_platform
 
template<typename T >
bool aligned_to_x (const std::vector< T > &vec)
 
template<typename T >
bool aligned_to_y (const std::vector< T > &vec)
 
template<typename T >
bool aligned_to_z (const std::vector< T > &vec)
 
template<typename T >
bool aligned_to_grid (const std::vector< T > &vec)
 
bool intersect (int x0, int x1, int y0, int y1, int x0_, int x1_, int y0_, int y1_, int &newX0, int &newX1, int &newY0, int &newY1)
 
bool intersect (int x0, int x1, int y0, int y1, int z0, int z1, int x0_, int x1_, int y0_, int y1_, int z0_, int z1_, int &newX0, int &newX1, int &newY0, int &newY1, int &newZ0, int &newZ1)
 
bool contained (int x, int y, int x0, int x1, int y0, int y1)
 
bool contained (int x, int y, int z, int x0, int x1, int y0, int y1, int z0, int z1)
 
template<typename T >
any_platformsqr (T arg) any_platform
 
template<typename T >
any_platformcube (T arg)
 
template<typename ARRAY_LIKE , unsigned D>
auto normSqr (const ARRAY_LIKE &u) any_platform
 Compute norm square of a d-dimensional vector.
 
template<unsigned D, typename ARRAY_LIKE >
auto norm (const ARRAY_LIKE &u) any_platform
 
template<typename T , unsigned D>
normSqr (const T *u) any_platform
 
template<typename T >
normSqr (std::initializer_list< T > data)
 
template<typename T , unsigned D, typename IMPL >
normSqr (const ScalarVector< T, D, IMPL > &u) any_platform
 Compute norm square of a d-dimensional vector.
 
template<typename T , int d>
scalarProduct (const Vector< T, d > &u1, const Vector< T, d > &u2) any_platform
 
template<typename T >
scalarProduct (const std::vector< T > &u1, const std::vector< T > &u2)
 
template<typename DESCRIPTOR , unsigned iVel, int value>
constexpr auto populationsContributingToVelocity () any_platform
 Return array of population indices where c[iVel] == value.
 
template<typename DESCRIPTOR , int... NORMAL>
constexpr auto populationsContributingToDirection () any_platform
 Return array of population indices where c[iPop][iD] == NORMAL[iD].
 
template<typename DESCRIPTORBASE >
int findVelocity (const int v[DESCRIPTORBASE::d]) any_platform
 
template<typename DESCRIPTOR , int direction, int orientation>
constexpr auto subIndexOutgoing () any_platform
 Compute opposites of wall-incoming population indices.
 
template<typename DESCRIPTOR , int direction, int orientation>
constexpr auto subIndexOutgoingRemaining () any_platform
 
template<typename DESCRIPTOR , int plane, int normal1, int normal2>
constexpr auto subIndexOutgoing3DonEdges () any_platform
 
template<typename DESCRIPTOR , int normalX, int normalY>
constexpr auto subIndexOutgoing2DonCorners () any_platform
 
template<typename DESCRIPTOR , int normalX, int normalY, int normalZ>
constexpr auto subIndexOutgoing3DonCorners () any_platform
 
template<typename DESCRIPTORBASE >
std::vector< int > remainingIndexes (const std::vector< int > &indices)
 finds all the remaining indexes of a lattice given some other indexes
 
template<typename T , typename DESCRIPTOR >
int get_nearest_link (const std::vector< T > &vec)
 Util Function for Wall Model of Malaspinas get link with smallest angle to a vector.
 
template<typename T , typename DESCRIPTOR >
any_platformdensityFromPressure (T latticePressure)
 compute lattice density from lattice pressure
 
template<typename T , typename DESCRIPTOR >
any_platformpressureFromDensity (T latticeDensity)
 compute lattice pressure from lattice density
 
template<typename T >
bool nearZero (T a) any_platform
 return true if a is close to zero
 
template<typename T >
bool nearZero (T a, T epsilon) any_platform
 
template<typename T , typename U = T, typename W = T>
bool approxEqual (T a, U b, W epsilon) any_platform
 
template<typename T , typename U = T>
bool approxEqual (T a, U b) any_platform
 
template<unsigned D, typename F >
void forEachOffset (F fn) any_platform
 
template<typename S , unsigned D, typename F1 , typename F2 >
bool distance (S &distance, const Vector< S, D > &origin, const Vector< S, D > &direction, S precision, S pitch, F1 isInside, F2 isInsideBoundingBox)
 
template<typename S , unsigned D, typename F1 , typename F2 >
bool distance (S &distance, const Vector< S, D > &origin, const Vector< S, D > &direction, S precision, F1 sdf, F2 isInsideBoundingBox, const unsigned maxIt=1e6)
 
template<typename S , unsigned D, bool normalizeDirection = true>
bool distance (S &distance, const Vector< S, D > &origin, const Vector< S, D > &direction, S precision, std::function< S(const Vector< S, D > &)> sdf, S maxDistance, const unsigned maxIt=1e6)
 
template<typename S , unsigned D, typename F1 , typename F2 >
bool bisectDistance (S &distance, const Vector< S, D > &origin, const Vector< S, D > &direction, S pitch, S precision, F1 isInside, F2 isInsideBoundingBox)
 Using a bisect to find the unsigned distance (false if distance was not found, true if distance was found)
 
template<typename S , unsigned D, typename F1 >
Vector< S, D > surfaceNormal (const Vector< S, D > &pos, const S meshSize, F1 sdf)
 
template<typename SAD >
void iniDiagonal (SAD *a, int dim)
 The variables of an array are set to be the differential variables.
 
template<typename C >
void iniDiagonal (C &a)
 
template<typename T , typename TAD >
void copyDerivatives (T *target, const TAD *source, int length)
 Copy the derivatives from an ADf array into an array.
 
template<typename T , typename S , template< typename > typename C>
C< T > copyAs (const C< S > &input)
 copy vector with specified typecast
 
template<typename S >
ADf< S, 1 > iniAD (const S source)
 copy value and initialize derivative
 
template<unsigned n, typename S >
ADf< S, n > * iniAD (const S *source)
 copy array values and initialize derivatives
 
template<unsigned n, typename S , template< typename > typename C>
C< ADf< S, n > > iniAD (const C< S > &source)
 copy values and initialize derivatives
 
template<typename S , typename F >
auto derivativeFAD (F f, const S input)
 Compute derivatives of a function f: S -> T via forward AD Signature is "V f(U)" so f is expected to accept and return a single value.
 
template<unsigned sourceDIM, typename S , typename F >
auto derivativeFAD (F f, const S *input)
 Compute derivatives of a function f: S^sourceDIM -> T via forward AD Signature is "V f(U*)" so f is expected to return a single value.
 
template<unsigned sourceDIM, typename T , typename S , typename F >
void derivativeFAD (F f, T *output, const S *input, unsigned targetDIM)
 Compute derivatives of a function f: S^sourceDIM -> T^targetDIM via forward AD Signature of f is "void f(V*, U*)", it is expected to modify the first argument in-place.
 
template<class T , unsigned DIM>
std::ostream & operator<< (std::ostream &os, const ADf< T, DIM > &o)
 
template<class T , unsigned DIM>
std::istream & operator>> (std::istream &is, ADf< T, DIM > &in)
 
template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
constexpr ADf< T, DIM > operator+ (const U &a, const ADf< T, DIM > &b)
 
template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
constexpr ADf< T, DIM > operator+ (const ADf< T, DIM > &a, const U &b)
 
template<class T , unsigned DIM>
constexpr ADf< T, DIM > operator+ (const ADf< T, DIM > &a, const ADf< T, DIM > &b)
 
template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
constexpr ADf< T, DIM > operator- (const U &a, const ADf< T, DIM > &b)
 
template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
constexpr ADf< T, DIM > operator- (const ADf< T, DIM > &a, const U &b)
 
template<class T , unsigned DIM>
constexpr ADf< T, DIM > operator- (const ADf< T, DIM > &a, const ADf< T, DIM > &b)
 
template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
constexpr ADf< T, DIM > operator* (const U &a, const ADf< T, DIM > &b)
 
template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
constexpr ADf< T, DIM > operator* (const ADf< T, DIM > &a, const U &b)
 
template<class T , unsigned DIM>
constexpr ADf< T, DIM > operator* (const ADf< T, DIM > &a, const ADf< T, DIM > &b)
 
template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
constexpr ADf< T, DIM > operator/ (const U &a, const ADf< T, DIM > &b)
 
template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
constexpr ADf< T, DIM > operator/ (const ADf< T, DIM > &a, const U &b)
 
template<class T , unsigned DIM>
constexpr ADf< T, DIM > operator/ (const ADf< T, DIM > &a, const ADf< T, DIM > &b)
 
template<class T , unsigned DIM>
constexpr ADf< T, DIM > operator+ (const ADf< T, DIM > &a)
 
template<class T , unsigned DIM>
constexpr ADf< T, DIM > operator- (const ADf< T, DIM > &a)
 
template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
ADf< T, DIM > pow (const U &a, const ADf< T, DIM > &b)
 
template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
ADf< T, DIM > pow (const ADf< T, DIM > &a, const U &b)
 
template<class T , unsigned DIM>
ADf< T, DIM > pow (const ADf< T, DIM > &a, const ADf< T, DIM > &b)
 
template<class T , unsigned DIM>
ADf< T, DIM > pow (const ADf< T, DIM > &a, int b)
 
template<class T , unsigned DIM>
ADf< T, DIM > sqr (const ADf< T, DIM > &a)
 
template<class T , unsigned DIM>
ADf< T, DIM > exp (const ADf< T, DIM > &a)
 
template<unsigned DIM>
ADf< float, DIM > expf (const ADf< float, DIM > &a)
 
template<unsigned DIM>
ADf< long double, DIM > expl (const ADf< long double, DIM > &a)
 
template<class T , unsigned DIM>
ADf< T, DIM > log (const ADf< T, DIM > &a)
 
template<unsigned DIM>
ADf< float, DIM > logf (const ADf< float, DIM > &a)
 
template<unsigned DIM>
ADf< long double, DIM > logl (const ADf< long double, DIM > &a)
 
template<class T , unsigned DIM>
ADf< T, DIM > log10 (const ADf< T, DIM > &a)
 
template<unsigned DIM>
ADf< float, DIM > log10f (const ADf< float, DIM > &a)
 
template<unsigned DIM>
ADf< long double, DIM > log10l (const ADf< long double, DIM > &a)
 
template<class T , unsigned DIM>
ADf< T, DIM > log2 (const ADf< T, DIM > &a)
 
template<unsigned DIM>
ADf< float, DIM > log2f (const ADf< float, DIM > &a)
 
template<unsigned DIM>
ADf< long double, DIM > log2l (const ADf< long double, DIM > &a)
 
template<class T , unsigned DIM>
ADf< T, DIM > log1p (const ADf< T, DIM > &a)
 
template<unsigned DIM>
ADf< float, DIM > log1pf (const ADf< float, DIM > &a)
 
template<unsigned DIM>
ADf< long double, DIM > log1pl (const ADf< long double, DIM > &a)
 
template<class T , unsigned DIM>
ADf< T, DIM > sqrt (const ADf< T, DIM > &a)
 
template<class T , unsigned DIM>
ADf< T, DIM > sin (const ADf< T, DIM > &a)
 
template<class T , unsigned DIM>
ADf< T, DIM > cos (const ADf< T, DIM > &a)
 
template<class T , unsigned DIM>
ADf< T, DIM > tan (const ADf< T, DIM > &a)
 
template<class T , unsigned DIM>
ADf< T, DIM > asin (const ADf< T, DIM > &a)
 
template<class T , unsigned DIM>
ADf< T, DIM > acos (const ADf< T, DIM > &a)
 
template<class T , unsigned DIM>
ADf< T, DIM > atan (const ADf< T, DIM > &a)
 
template<class T , unsigned DIM>
ADf< T, DIM > atan2 (const T &y, const ADf< T, DIM > &x)
 
template<class T , unsigned DIM>
ADf< T, DIM > atan2 (const ADf< T, DIM > &y, const T &x)
 
template<class T , unsigned DIM>
ADf< T, DIM > atan2 (const ADf< T, DIM > &y, const ADf< T, DIM > &x)
 
template<class T , unsigned DIM>
ADf< T, DIM > sinh (const ADf< T, DIM > &a)
 
template<class T , unsigned DIM>
ADf< T, DIM > cosh (const ADf< T, DIM > &a)
 
template<class T , unsigned DIM>
ADf< T, DIM > tanh (const ADf< T, DIM > &a)
 
template<class T , unsigned DIM>
ADf< T, DIM > asinh (const ADf< T, DIM > &a)
 
template<class T , unsigned DIM>
ADf< T, DIM > acosh (const ADf< T, DIM > &a)
 
template<class T , unsigned DIM>
ADf< T, DIM > atanh (const ADf< T, DIM > &a)
 
template<class T , unsigned DIM>
ADf< T, DIM > fmod (const ADf< T, DIM > &a, const ADf< T, DIM > &b)
 
template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
ADf< T, DIM > fmod (const ADf< T, DIM > &a, const U &b)
 
template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
ADf< T, DIM > fmod (const U &a, const ADf< T, DIM > &b)
 
template<class T , unsigned DIM>
constexpr bool operator== (const ADf< T, DIM > &a, const ADf< T, DIM > &b)
 
template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
constexpr bool operator== (const ADf< T, DIM > &a, const U &b)
 
template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
constexpr bool operator== (const U &a, const ADf< T, DIM > &b)
 
template<class T , unsigned DIM>
constexpr bool operator!= (const ADf< T, DIM > &a, const ADf< T, DIM > &b)
 
template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
constexpr bool operator!= (const ADf< T, DIM > &a, const U &b)
 
template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
constexpr bool operator!= (const U &a, const ADf< T, DIM > &b)
 
template<class T , unsigned DIM>
constexpr bool operator> (const ADf< T, DIM > &a, const ADf< T, DIM > &b)
 
template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
constexpr bool operator> (const ADf< T, DIM > &a, const U &b)
 
template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
constexpr bool operator> (const U &a, const ADf< T, DIM > &b)
 
template<class T , unsigned DIM>
constexpr bool operator>= (const ADf< T, DIM > &a, const ADf< T, DIM > &b)
 
template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
constexpr bool operator>= (const ADf< T, DIM > &a, const U &b)
 
template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
constexpr bool operator>= (const U &a, const ADf< T, DIM > &b)
 
template<class T , unsigned DIM>
constexpr bool operator< (const ADf< T, DIM > &a, const ADf< T, DIM > &b)
 
template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
constexpr bool operator< (const ADf< T, DIM > &a, const U &b)
 
template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
constexpr bool operator< (const U &a, const ADf< T, DIM > &b)
 
template<class T , unsigned DIM>
constexpr bool operator<= (const ADf< T, DIM > &a, const ADf< T, DIM > &b)
 
template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
constexpr bool operator<= (const ADf< T, DIM > &a, const U &b)
 
template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
constexpr bool operator<= (const U &a, const ADf< T, DIM > &b)
 
template<class T , unsigned DIM>
ADf< T, DIM > floor (const ADf< T, DIM > &a)
 
template<unsigned DIM>
ADf< float, DIM > floorf (const ADf< float, DIM > &a)
 
template<unsigned DIM>
ADf< long double, DIM > floorl (const ADf< long double, DIM > &a)
 
template<class T , unsigned DIM>
ADf< T, DIM > ceil (const ADf< T, DIM > &a)
 
template<unsigned DIM>
ADf< float, DIM > ceilf (const ADf< float, DIM > &a)
 
template<unsigned DIM>
ADf< long double, DIM > ceill (const ADf< long double, DIM > &a)
 
template<class T , unsigned DIM>
ADf< T, DIM > round (const ADf< T, DIM > &a)
 
template<unsigned DIM>
ADf< float, DIM > roundf (const ADf< float, DIM > &a)
 
template<unsigned DIM>
ADf< long double, DIM > roundl (const ADf< long double, DIM > &a)
 
template<class T , unsigned DIM>
ADf< T, DIM > lround (const ADf< T, DIM > &a)
 
template<unsigned DIM>
ADf< float, DIM > lroundf (const ADf< float, DIM > &a)
 
template<unsigned DIM>
ADf< long double, DIM > lroundl (const ADf< long double, DIM > &a)
 
template<class T , unsigned DIM>
ADf< T, DIM > llround (const ADf< T, DIM > &a)
 
template<unsigned DIM>
ADf< float, DIM > llroundf (const ADf< float, DIM > &a)
 
template<unsigned DIM>
ADf< long double, DIM > llroundl (const ADf< long double, DIM > &a)
 
template<class T , unsigned DIM>
ADf< T, DIM > fabs (const ADf< T, DIM > &a)
 
template<unsigned DIM>
ADf< float, DIM > fabsf (const ADf< float, DIM > &a)
 
template<unsigned DIM>
ADf< long double, DIM > fabsl (const ADf< long double, DIM > &a)
 
template<class T , unsigned DIM>
ADf< T, DIM > abs (const ADf< T, DIM > &a)
 
template<class T , unsigned DIM>
ADf< T, DIM > labs (const ADf< T, DIM > &a)
 
template<class T , unsigned DIM>
ADf< T, DIM > llabs (const ADf< T, DIM > &a)
 
template<class T , unsigned DIM>
constexpr ADf< T, DIM > max (const olb::BaseType< ADf< T, DIM > > &a, const ADf< T, DIM > &b)
 
template<class T , unsigned DIM>
constexpr ADf< T, DIM > max (const ADf< T, DIM > &a, const olb::BaseType< ADf< T, DIM > > &b)
 
template<class T , unsigned DIM>
constexpr ADf< T, DIM > max (const ADf< T, DIM > &a, const ADf< T, DIM > &b)
 
template<class T , unsigned DIM>
constexpr ADf< T, DIM > min (const olb::BaseType< ADf< T, DIM > > &a, const ADf< T, DIM > &b)
 
template<class T , unsigned DIM>
constexpr ADf< T, DIM > min (const ADf< T, DIM > &a, const olb::BaseType< ADf< T, DIM > > &b)
 
template<class T , unsigned DIM>
constexpr ADf< T, DIM > min (const ADf< T, DIM > &a, const ADf< T, DIM > &b)
 
template<class T , unsigned DIM>
bool nearZero (const ADf< T, DIM > &a)
 
template<typename T >
constexpr void throwADfException (T arg)
 
template<class TAPE >
auto sqrt (const util::ADtape::ActiveType< TAPE > &a)
 
template<typename T , typename S >
auto fmod_pos (T a, S b)
 Variant of fmod (floating point modulo) that always returns positive values.
 
template<typename T >
void kahanSum (T output[2], T summand)
 Accurate summation of floating point numbers with the Kahan algorithm.
 
template<typename T >
void kahanSum (T &output0, T &output1, T summand)
 
template<typename K >
crossSum (K k)
 Compute cross sum of an integer.
 
template<typename T , unsigned D>
decltype(Vector< decltype(util::sqrt(T())), D >()) degreeToRadian (const Vector< T, D > &angle)
 
template<typename T >
decltype(util::sqrt(T())) degreeToRadian (T angle)
 
template<typename T , unsigned D>
decltype(Vector< decltype(util::sqrt(T())), D >()) radianToDegree (const Vector< T, D > &angle)
 
template<typename T >
decltype(util::sqrt(T())) radianToDegree (T angle)
 
template<typename T , unsigned D>
Vector< T, utilities::dimensions::convert< D >::matrix > calculateRotationMatrix (const Vector< T, utilities::dimensions::convert< D >::rotation > &angle) any_platform
 
template<typename T >
Vector< T, 4 > inverseRotation (const Vector< T, 4 > &m) any_platform
 
template<typename T >
Vector< T, 9 > inverseRotation (const Vector< T, 9 > &m) any_platform
 
template<typename T , unsigned D>
Vector< T, D > matrixVectorProduct (const Vector< T, utilities::dimensions::convert< D >::matrix > &M, const Vector< T, D > &b) any_platform
 Compute v=M b.
 
template<typename T , unsigned D>
Vector< T, utilities::dimensions::convert< D >::matrix > matrixMatrixProduct (const Vector< T, utilities::dimensions::convert< D >::matrix > &A, const Vector< T, utilities::dimensions::convert< D >::matrix > &B) any_platform
 Compute C=AB for square matrices.
 
template<typename T , unsigned D>
Vector< T, utilities::dimensions::convert< D >::matrix > invertRotationMatrix (const Vector< T, utilities::dimensions::convert< D >::matrix > &rotationMatrix)
 
template<typename T , unsigned D>
Vector< T, utilities::dimensions::convert< D >::matrix > calculateInverseRotationMatrix (const Vector< T, utilities::dimensions::convert< D >::rotation > &angle)
 
template<typename T , unsigned D, bool OUTPUT_USES_ROTATION_CENTER_AS_ORIGIN = false>
Vector< T, D > executeRotation (const Vector< T, D > &input, const Vector< T, utilities::dimensions::convert< D >::matrix > &rotationMatrix, const Vector< T, D > &rotationCenter=Vector< T, D >(0.))
 Rotates the input around the rotationCenter with a given rotationMatrix.
 
template<typename T , unsigned D, bool OUTPUT_USES_ROTATION_CENTER_AS_ORIGIN = false>
Vector< T, D > invertRotation (const Vector< T, D > &input, const Vector< T, utilities::dimensions::convert< D >::matrix > &rotationMatrix, const Vector< T, D > &rotationCenter=Vector< T, D >(0.))
 Rotates the input around the rotationCenter with a given rotationMatrix in the opposite direction.
 
template<typename T , unsigned D>
constexpr Vector< T, D > calculateLocalVelocity (const Vector< T, D > &rotationCenter, const Vector< T, D > &velocity, const Vector< T, utilities::dimensions::convert< D >::rotation > &angularVelocity, const Vector< T, D > &position)
 Calculate local velocity.
 
template<typename T >
constexpr Matrix< T, 3, 3 > rotateMofi (const Vector< T, 3 > &mofi, const Vector< T, 9 > &rotationMatrix)
 Rotate moment of inertia (mofi)
 
template<typename T >
int evaluateIntegration (std::vector< T > &testValues, bool print=false)
 
template<typename T >
constexpr auto determinant (const Matrix< T, 2, 2 > &m)
 
template<typename T >
constexpr auto determinant (const Matrix< T, 3, 3 > &m)
 
template<typename T >
auto solveLinearSystem (const Matrix< T, 2, 2 > &a, const Vector< T, 2 > &rhs)
 Solve a * x = rhs.
 
template<typename T >
auto solveLinearSystem (const Matrix< T, 3, 3 > &a, const Vector< T, 3 > &rhs)
 Solve (a0 a1 a2) x = rhs.
 
template<typename T >
euklidN2 (const T x[], int dim)
 Squared Euclidean norm of an array.
 
template<typename T >
euklidDistance2 (const T x[], const T y[], int dim)
 Squared Euclidean distance between two arrays.
 
template<typename T >
euklidN (const T x[], int dim)
 Euclidean norm of an array.
 
template<typename T >
euklidDistance (const T x[], const T y[], int dim)
 Euclidean distance between two arrays.
 
template<typename C >
auto euklidN2 (const C &x)
 Squared Euclidean norm for Container-type array.
 
template<typename C >
auto euklidDistance2 (const C &x, const C &y)
 Squared Euclidean distance for Container-type array.
 
template<typename C >
auto euklidN (const C &x)
 Euclidean norm for Container-type array.
 
template<typename C >
auto euklidDistance (const C &x, const C &y)
 Euclidean distance for Container-type array.
 
template<typename T >
any_platform constexpr T max (T a, meta::id_t< T > b)
 
template<typename T >
constexpr T max (std::initializer_list< T > ilist)
 
template<typename T >
any_platform constexpr T min (T a, meta::id_t< T > b)
 
template<typename T >
constexpr T min (std::initializer_list< T > ilist)
 
template<typename T , typename S >
any_platform auto pow (T x, S y) -> std::enable_if_t< std::is_floating_point_v< T > &&std::is_floating_point_v< S >, decltype(std::pow(x, y))>
 
template<typename T , typename S >
any_platform std::enable_if_t< std::is_integral_v< T > &&std::is_integral_v< S >, double > pow (T x, S y)
 
any_platform float powf (float base, float exp)
 
any_platform float powf (int base, int exp)
 
long double powl (long double base, long double exp)
 
template<typename T , typename S >
any_platform auto fmod (T x, S y) -> std::enable_if_t< std::is_floating_point_v< T > &&std::is_floating_point_v< S >, decltype(std::fmod(x, y))>
 
template<typename T , typename S >
any_platform std::enable_if_t< std::is_integral_v< S > &&std::is_floating_point_v< T >, T > fmod (T x, S y)
 
template<typename T , typename S >
any_platform std::enable_if_t< std::is_integral_v< T > &&std::is_floating_point_v< S >, S > fmod (T x, S y)
 
any_platform float fmodf (float x, float y)
 
any_platform float fmodf (int x, int y)
 
long double fmodl (long double x, long double y)
 
template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > exp (T x)
 
template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > exp (T arg)
 
any_platform float expf (float arg)
 
any_platform float expf (int arg)
 
long double expl (long double arg)
 
template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > log (T x)
 
template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > log (T arg)
 
any_platform float logf (float arg)
 
any_platform float logf (int arg)
 
long double logl (long double arg)
 
template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > log10 (T x)
 
template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > log10 (T arg)
 
any_platform float log10f (float arg)
 
any_platform float log10f (int arg)
 
long double log10l (long double arg)
 
template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > log2 (T x)
 
template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > log2 (T arg)
 
any_platform float log2f (float arg)
 
any_platform float log2f (int arg)
 
long double log2l (long double arg)
 
template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > log1p (T x)
 
template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > log1p (T arg)
 
any_platform float log1pf (float arg)
 
any_platform float log1pf (int arg)
 
long double log1pl (long double arg)
 
template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > sqrt (T x)
 
template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > sqrt (T arg)
 
any_platform float sqrtf (float arg)
 
any_platform float sqrtf (int arg)
 
long double sqrtl (long double arg)
 
any_platform float sinf (float x)
 
any_platform float sinf (int x)
 
template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > sin (T x)
 
template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > sin (T x)
 
long double sinl (long double arg)
 
any_platform float sinhf (float x)
 
any_platform float sinhf (int x)
 
template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > sinh (T x)
 
template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > sinh (T x)
 
long double sinhl (long double arg)
 
any_platform float cosf (float x)
 
any_platform float cosf (int x)
 
template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > cos (T x)
 
template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > cos (T x)
 
long double cosl (long double arg)
 
any_platform float coshf (float x)
 
any_platform float coshf (int x)
 
template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > cosh (T x)
 
template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > cosh (T x)
 
long double coshl (long double arg)
 
any_platform float tanf (float x)
 
any_platform float tanf (int x)
 
template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > tan (T x)
 
template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > tan (T x)
 
long double tanl (long double arg)
 
any_platform float tanhf (float x)
 
any_platform float tanhf (int x)
 
template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > tanh (T x)
 
template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > tanh (T x)
 
long double tanhl (long double arg)
 
any_platform float asinf (float x)
 
any_platform float asinf (int x)
 
template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > asin (T x)
 
template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > asin (T x)
 
long double asinl (long double arg)
 
any_platform float asinhf (float x)
 
any_platform float asinhf (int x)
 
template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > asinh (T x)
 
template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > asinh (T x)
 
long double asinhl (long double arg)
 
any_platform float acosf (float x)
 
any_platform float acosf (int x)
 
template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > acos (T x)
 
template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > acos (T x)
 
long double acosl (long double arg)
 
any_platform float acoshf (float x)
 
any_platform float acoshf (int x)
 
template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > acosh (T x)
 
template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > acosh (T x)
 
long double acoshl (long double arg)
 
any_platform float atanf (float x)
 
any_platform float atanf (int x)
 
template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > atan (T x)
 
template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > atan (T x)
 
long double atanl (long double arg)
 
template<typename T , typename S >
any_platform auto atan2 (T x, S y) -> std::enable_if_t< std::is_floating_point_v< T > &&std::is_floating_point_v< S >, decltype(std::atan2(x, y))>
 
template<typename T , typename S >
any_platform std::enable_if_t< std::is_integral_v< S > &&std::is_floating_point_v< T >, T > atan2 (T x, S y)
 
template<typename T , typename S >
any_platform std::enable_if_t< std::is_integral_v< T > &&std::is_floating_point_v< S >, S > atan2 (T x, S y)
 
template<typename T , typename S >
any_platform std::enable_if_t< std::is_integral_v< T > &&std::is_integral_v< S >, double > atan2 (T x, S y)
 
any_platform float atan2f (float base, float exp)
 
any_platform float atan2f (int base, int exp)
 
any_platform float atanhf (float x)
 
any_platform float atanhf (int x)
 
template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > atanh (T x)
 
template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > atanh (T x)
 
long double atanhl (long double arg)
 
any_platform float floorf (float x)
 
any_platform float floorf (int x)
 
template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > floor (T x)
 
template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > floor (T x)
 
long double floorl (long double arg)
 
any_platform float ceilf (float x)
 
any_platform float ceilf (int x)
 
template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > ceil (T x)
 
template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > ceil (T x)
 
long double ceill (long double arg)
 
any_platform float truncf (float x)
 
any_platform float truncf (int x)
 
template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > trunc (T x)
 
template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > trunc (T x)
 
long double truncl (long double arg)
 
any_platform float roundf (float x)
 
any_platform float roundf (int x)
 
template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > round (T x)
 
template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > round (T x)
 
long double roundl (long double arg)
 
template<typename T >
std::enable_if_t< std::is_arithmetic_v< T >, long > lround (T arg)
 
long lroundf (float arg)
 
long lroundl (long double arg)
 
template<typename T >
std::enable_if_t< std::is_arithmetic_v< T >, long long > llround (T arg)
 
long long llroundf (float arg)
 
long long llroundl (long double arg)
 
any_platform float fabsf (float x)
 
any_platform float fabsf (int x)
 
template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > fabs (T x)
 
template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > fabs (T x)
 
template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > abs (T x)
 
template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, T > abs (T x)
 
long double fabs (long double arg)
 
template<std::integral T>
any_platform bool closeToZero (T x)
 
template<typename T >
any_platform bool isnan (T arg)
 
template<typename T , typename DESCRIPTOR >
Timer< T > * createTimer (XMLreader &param, const UnitConverter< T, DESCRIPTOR > &converter, size_t numLatticePoints)
 
template<class T >
void copyN (T c[], const T a[], const unsigned dim) any_platform
 
template<class S , class T >
void copyN (S c[], const T a[], const unsigned dim) any_platform
 
template<class T >
void copy3 (T c[], const T a[])
 
template<typename T >
std::vector< T > fromVector3 (const Vector< T, 3 > &vec)
 
template<typename T >
std::vector< T > fromVector2 (const Vector< T, 2 > &vec)
 
template<typename T >
norm2 (const T *a, unsigned size)
 l2 norm to the power of 2 of a vector of arbitrary length
 
template<typename T >
norm2 (const std::vector< T > &a)
 l2 norm to the power of 2 of a vector of arbitrary length
 
template<typename T >
norm (const T *a, unsigned size)
 l2 norm of a vector of arbitrary length
 
template<typename T >
dotProduct3D (const Vector< T, 3 > &a, const Vector< T, 3 > &b)
 dot product, only valid in 3d
 
template<typename T >
dotProduct2D (const Vector< T, 2 > &a, const Vector< T, 2 > &b)
 dot product, only valid in 2d
 
template<typename T , unsigned D>
dotProduct (const Vector< T, D > &a, const Vector< T, D > &b)
 dot product
 
template<typename T , unsigned D>
Vector< T, D > normalize (const Vector< T, D > &a)
 
template<typename T >
std::vector< T > normalize (const std::vector< T > &a)
 returns a normalized vector, works for arbitrary lengths
 
template<typename T , unsigned Size>
Vector< T, Size > floor (const Vector< T, Size > &a) any_platform
 applies floor to each component of a vector
 
template<typename T , unsigned Size>
Vector< T, Size > ceil (const Vector< T, Size > &a) any_platform
 applies ceil to each component of a vector
 
template<typename T , typename S , unsigned Size>
Vector< T, Size > fmod (const Vector< T, Size > &a, S b)
 applies fmod to each component of a vector
 
template<typename T , unsigned Size>
average (const Vector< T, Size > &a)
 computes the average of all elements
 
template<typename T , unsigned Size>
max_element (const Vector< T, Size > &a)
 finds maximum element of all elements
 
template<typename T , unsigned Size>
min_element (const Vector< T, Size > &a)
 finds minimum element of all elements
 
template<typename T , unsigned Size>
unsigned maxElementPos (const Vector< T, Size > &a)
 finds position of maximum element of all elements
 
template<typename T , unsigned Size>
unsigned minElementPos (const Vector< T, Size > &a)
 finds position of minimum element of all elements
 
template<typename T , unsigned Size>
maxElementAbs (const Vector< T, Size > &a)
 finds maximum element of all absolute elements
 
template<typename T , unsigned Size>
unsigned maxElementAbsPos (const Vector< T, Size > &a)
 finds position of maximum element of all absolute elements
 
template<typename T , bool ensureAngularBounds = true>
angleBetweenVectors (const Vector< T, 2 > &a, const Vector< T, 2 > &b)
 Calculates angles between two 2D vectors.
 
template<typename T , bool ensureAngularBounds = true>
Vector< T, 3 > angleBetweenVectors (const Vector< T, 3 > &a, const Vector< T, 3 > &b)
 Calculates angles between two 3D vectors.
 
template<typename T >
constexpr T determinant (const Vector< T, 2 > &v0, const Vector< T, 2 > &v1)
 
template<typename T >
constexpr T determinant (const Vector< T, 3 > &v0, const Vector< T, 3 > &v1, const Vector< T, 3 > &v2)
 
template<typename T >
Vector< T, 2 > solveLinearSystem (const Vector< T, 2 > &a0, const Vector< T, 2 > &a1, const Vector< T, 2 > &rhs)
 Solve (a0 a1) x = rhs.
 
template<typename T >
Vector< T, 3 > solveLinearSystem_help (const Vector< T, 3 > &a0, const Vector< T, 3 > &a1, const Vector< T, 3 > &a2, const Vector< T, 3 > &rhs, T det)
 
template<typename T >
Vector< T, 3 > solveLinearSystem (const Vector< T, 3 > &a0, const Vector< T, 3 > &a1, const Vector< T, 3 > &a2, const Vector< T, 3 > &rhs)
 Solve (a0 a1 a2) x = rhs.
 
template<typename T >
std::vector< T > assign (T a, T b)
 
template<typename T >
std::vector< T > assign (T a, T b, T c)
 
template<typename U >
void print (U data, const std::string &name="", OstreamManager clout=OstreamManager(std::cout,"print"), const char delimiter=',')
 
template<typename C , typename U >
bool isContained (const C &c, U object)
 Check, if object is contained in iteratable container c.
 
template<unsigned DIM>
unsigned serialSymmetricTensorIndex (unsigned i, unsigned j) any_platform
 Compute serial index of symmetric tensor.
 

Variables

template<class T >
constexpr bool is_adf_v = is_adf<T>::value
 

Typedef Documentation

◆ StdVector

template<typename S >
using olb::util::StdVector = std::vector<S,std::allocator<S>>

Definition at line 50 of file vectorHelpers.h.

Function Documentation

◆ abs() [1/3]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::abs ( const ADf< T, DIM > & a)
inline

Definition at line 1019 of file aDiff.h.

1020{
1021 return fabs(a);
1022}
Expr fabs(Expr x)
Definition expr.cpp:230

References fabs().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ abs() [2/3]

template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > olb::util::abs ( T x)
inline

Definition at line 1583 of file omath.h.

1584{
1585#ifdef __CUDA_ARCH__
1586 if constexpr (std::is_same_v<T, float>) {
1587 return ::fabsf(x);
1588 }
1589 else if constexpr (std::is_same_v<T, double>) {
1590 return ::fabs(x);
1591 }
1592 else {
1593 return ::fabs(static_cast<double>(x));
1594 //libcu++ of cuda supports double and float. You will get warning in device code if you use in e.g. long double.
1595 }
1596#else //__CUDA_ARCH__
1597 return std::abs(x);
1598#endif //__CUDA_ARCH__
1599}

◆ abs() [3/3]

template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, T > olb::util::abs ( T x)
inline

Definition at line 1602 of file omath.h.

1603{
1604#ifdef __CUDA_ARCH__
1605 return ::abs(x);
1606#else //__CUDA_ARCH__
1607 return std::abs(x);
1608#endif //__CUDA_ARCH__
1609}

◆ acos() [1/3]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::acos ( const ADf< T, DIM > & a)
inline

Definition at line 605 of file aDiff.h.

606{
607 ADf<T,DIM> c(std::acos(a._v), a._d);
608 T tmp(-T(1)/std::sqrt(T(1)-(a._v)*(a._v)));
609 c._d*=tmp;
610 return c;
611}
Definition of a description of a algoritmic differentiation data type using the forward method.
T _v
value
Definition aDiff.h:72
Vector< T, DIM > _d
derivatives
Definition aDiff.h:74
+ Here is the caller graph for this function:

◆ acos() [2/3]

template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > olb::util::acos ( T x)
inline

Definition at line 1007 of file omath.h.

1008{
1009#ifdef __CUDA_ARCH__
1010 if constexpr (std::is_same_v<T, float>) {
1011 return ::acosf(x);
1012 }
1013 else if constexpr (std::is_same_v<T, double>) {
1014 return ::acos(x);
1015 }
1016 else {
1017 return ::acos(static_cast<double>(x));
1018 //libcu++ of cuda supports double and float. You will get warning in device code if you use in e.g. long double.
1019 }
1020#else //__CUDA_ARCH__
1021 return std::acos(x);
1022#endif //__CUDA_ARCH__
1023}

◆ acos() [3/3]

template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > olb::util::acos ( T x)
inline

Definition at line 1026 of file omath.h.

1027{
1028#ifdef __CUDA_ARCH__
1029 return ::acos(x);
1030#else //__CUDA_ARCH__
1031 return std::acos(x);
1032#endif //__CUDA_ARCH__
1033}

◆ acosf() [1/2]

any_platform float olb::util::acosf ( float x)
inline

Definition at line 988 of file omath.h.

989{
990#ifdef __CUDA_ARCH__
991 return ::acosf(x);
992#else //__CUDA_ARCH__
993 return std::acos(x);
994#endif //__CUDA_ARCH__
995}

◆ acosf() [2/2]

any_platform float olb::util::acosf ( int x)
inline

Definition at line 997 of file omath.h.

998{
999#ifdef __CUDA_ARCH__
1000 return ::acosf(x);
1001#else //__CUDA_ARCH__
1002 return std::acos(x);
1003#endif //__CUDA_ARCH__
1004}

◆ acosh() [1/3]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::acosh ( const ADf< T, DIM > & a)
inline

Definition at line 675 of file aDiff.h.

676{
677 if (a._v >= 1) {
678 return log( a + sqrt(a*a-1) );
679 }
680 else {
681 ADf<T,DIM> c;
682 c._v = std::acosh(a._v);
683 c._d = ( std::numeric_limits<T>::quiet_NaN() );
684 return c;
685 }
686}
ADf< T, DIM > log(const ADf< T, DIM > &a)
Definition aDiff.h:475

References log(), and sqrt().

+ Here is the call graph for this function:

◆ acosh() [2/3]

template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > olb::util::acosh ( T x)
inline

Definition at line 1061 of file omath.h.

1062{
1063#ifdef __CUDA_ARCH__
1064 if constexpr (std::is_same_v<T, float>) {
1065 return ::acoshf(x);
1066 }
1067 else if constexpr (std::is_same_v<T, double>) {
1068 return ::acosh(x);
1069 }
1070 else {
1071 return ::acosh(static_cast<double>(x));
1072 //libcu++ of cuda supports double and float. You will get warning in device code if you use in e.g. long double.
1073 }
1074#else //__CUDA_ARCH__
1075 return std::acosh(x);
1076#endif //__CUDA_ARCH__
1077}

◆ acosh() [3/3]

template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > olb::util::acosh ( T x)
inline

Definition at line 1080 of file omath.h.

1081{
1082#ifdef __CUDA_ARCH__
1083 return ::acosh(x);
1084#else //__CUDA_ARCH__
1085 return std::acosh(x);
1086#endif //__CUDA_ARCH__
1087}

◆ acoshf() [1/2]

any_platform float olb::util::acoshf ( float x)
inline

Definition at line 1042 of file omath.h.

1043{
1044#ifdef __CUDA_ARCH__
1045 return ::acoshf(x);
1046#else //__CUDA_ARCH__
1047 return std::acosh(x);
1048#endif //__CUDA_ARCH__
1049}

◆ acoshf() [2/2]

any_platform float olb::util::acoshf ( int x)
inline

Definition at line 1051 of file omath.h.

1052{
1053#ifdef __CUDA_ARCH__
1054 return ::acoshf(x);
1055#else //__CUDA_ARCH__
1056 return std::acosh(x);
1057#endif //__CUDA_ARCH__
1058}

◆ acoshl()

long double olb::util::acoshl ( long double arg)
inline

Definition at line 1089 of file omath.h.

1090{
1091 return std::acoshl(arg);
1092 //cuda dose not support this function.
1093}

◆ acosl()

long double olb::util::acosl ( long double arg)
inline

Definition at line 1035 of file omath.h.

1036{
1037 return acos(arg);
1038 //cuda dose not support this function.
1039}
ADf< T, DIM > acos(const ADf< T, DIM > &a)
Definition aDiff.h:605

References acos().

+ Here is the call graph for this function:

◆ aligned_to_grid()

template<typename T >
bool olb::util::aligned_to_grid ( const std::vector< T > & vec)
inline

Definition at line 77 of file util.h.

78{
79 return (aligned_to_x<T>(vec) or
80 aligned_to_y<T>(vec) or
81 aligned_to_z<T>(vec));
82}

References aligned_to_x(), aligned_to_y(), and aligned_to_z().

+ Here is the call graph for this function:

◆ aligned_to_x()

template<typename T >
bool olb::util::aligned_to_x ( const std::vector< T > & vec)
inline

Definition at line 59 of file util.h.

60{
61 return (vec[0]!=0 and vec[1]==0 and vec[2]==0);
62}
+ Here is the caller graph for this function:

◆ aligned_to_y()

template<typename T >
bool olb::util::aligned_to_y ( const std::vector< T > & vec)
inline

Definition at line 65 of file util.h.

66{
67 return (vec[0]==0 and vec[1]!=0 and vec[2]==0);
68}
+ Here is the caller graph for this function:

◆ aligned_to_z()

template<typename T >
bool olb::util::aligned_to_z ( const std::vector< T > & vec)
inline

Definition at line 71 of file util.h.

72{
73 return (vec[0]==0 and vec[1]==0 and vec[2]!=0);
74}
+ Here is the caller graph for this function:

◆ angleBetweenVectors() [1/2]

template<typename T , bool ensureAngularBounds = true>
T olb::util::angleBetweenVectors ( const Vector< T, 2 > & a,
const Vector< T, 2 > & b )

Calculates angles between two 2D vectors.

Definition at line 291 of file vectorHelpers.h.

292{
293 if constexpr(ensureAngularBounds){
294 return std::fmod(util::atan2(b[1]*a[0]-b[0]*a[1], a[0]*b[0]+a[1]*b[1]), M_PI);
295 } else {
296 return util::atan2(b[1]*a[0]-b[0]*a[1], a[0]*b[0]+a[1]*b[1]);
297 }
298}
#define M_PI

References atan2(), and M_PI.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ angleBetweenVectors() [2/2]

template<typename T , bool ensureAngularBounds = true>
Vector< T, 3 > olb::util::angleBetweenVectors ( const Vector< T, 3 > & a,
const Vector< T, 3 > & b )

Calculates angles between two 3D vectors.

Definition at line 302 of file vectorHelpers.h.

303{
304 Vector<T,3> angles;
305 angles[0] = angleBetweenVectors<T,ensureAngularBounds>(Vector<T,2>(a[1], a[2]), Vector<T,2>(b[1], b[2]));
306 angles[1] = angleBetweenVectors<T,ensureAngularBounds>(Vector<T,2>(a[0], a[2]), Vector<T,2>(b[0], b[2]));
307 angles[2] = angleBetweenVectors<T,ensureAngularBounds>(Vector<T,2>(a[0], a[1]), Vector<T,2>(b[0], b[1]));
308 return angles;
309}
Plain old scalar vector.

References angleBetweenVectors().

+ Here is the call graph for this function:

◆ approxEqual() [1/2]

template<typename T , typename U = T>
bool olb::util::approxEqual ( T a,
U b )
inline

Definition at line 437 of file util.h.

438{
439 if (a==b) {
440 return true;
441 }
442 if (nearZero(a) && nearZero(b)) {
443 return true;
444 }
445 T EPSILON = std::numeric_limits<T>::epsilon()*4.*util::fabs(a);
446 return approxEqual(a,b,EPSILON);
447}

References approxEqual(), fabs(), and nearZero().

+ Here is the call graph for this function:

◆ approxEqual() [2/2]

template<typename T , typename U = T, typename W = T>
bool olb::util::approxEqual ( T a,
U b,
W epsilon )
inline

Definition at line 428 of file util.h.

429{
430 if (a==b) {
431 return true;
432 }
433 return nearZero<T>(a - b, epsilon);
434}

References nearZero().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ asin() [1/3]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::asin ( const ADf< T, DIM > & a)
inline

Definition at line 596 of file aDiff.h.

597{
598 ADf<T,DIM> c(std::asin(a._v), a._d);
599 T tmp(T(1)/std::sqrt(T(1)-(a._v)*(a._v)));
600 c._d*=tmp;
601 return c;
602}
+ Here is the caller graph for this function:

◆ asin() [2/3]

template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > olb::util::asin ( T x)
inline

Definition at line 899 of file omath.h.

900{
901#ifdef __CUDA_ARCH__
902 if constexpr (std::is_same_v<T, float>) {
903 return ::asinf(x);
904 }
905 else if constexpr (std::is_same_v<T, double>) {
906 return ::asin(x);
907 }
908 else {
909 return ::asin(static_cast<double>(x));
910 //libcu++ of cuda supports double and float. You will get warning in device code if you use in e.g. long double.
911 }
912#else //__CUDA_ARCH__
913 return std::asin(x);
914#endif //__CUDA_ARCH__
915}

◆ asin() [3/3]

template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > olb::util::asin ( T x)
inline

Definition at line 918 of file omath.h.

919{
920#ifdef __CUDA_ARCH__
921 return ::asin(x);
922#else //__CUDA_ARCH__
923 return std::asin(x);
924#endif //__CUDA_ARCH__
925}

◆ asinf() [1/2]

any_platform float olb::util::asinf ( float x)
inline

Definition at line 880 of file omath.h.

881{
882#ifdef __CUDA_ARCH__
883 return ::asinf(x);
884#else //__CUDA_ARCH__
885 return std::asin(x);
886#endif //__CUDA_ARCH__
887}

◆ asinf() [2/2]

any_platform float olb::util::asinf ( int x)
inline

Definition at line 889 of file omath.h.

890{
891#ifdef __CUDA_ARCH__
892 return ::asinf(x);
893#else //__CUDA_ARCH__
894 return std::asin(x);
895#endif //__CUDA_ARCH__
896}

◆ asinh() [1/3]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::asinh ( const ADf< T, DIM > & a)
inline

Definition at line 669 of file aDiff.h.

670{
671 return log( a + sqrt(a*a+1) );
672}

References log(), and sqrt().

+ Here is the call graph for this function:

◆ asinh() [2/3]

template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > olb::util::asinh ( T x)
inline

Definition at line 953 of file omath.h.

954{
955#ifdef __CUDA_ARCH__
956 if constexpr (std::is_same_v<T, float>) {
957 return ::asinhf(x);
958 }
959 else if constexpr (std::is_same_v<T, double>) {
960 return ::asinh(x);
961 }
962 else {
963 return ::asinh(static_cast<double>(x));
964 //libcu++ of cuda supports double and float. You will get warning in device code if you use in e.g. long double.
965 }
966#else //__CUDA_ARCH__
967 return std::asinh(x);
968#endif //__CUDA_ARCH__
969}

◆ asinh() [3/3]

template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > olb::util::asinh ( T x)
inline

Definition at line 972 of file omath.h.

973{
974#ifdef __CUDA_ARCH__
975 return ::asinh(x);
976#else //__CUDA_ARCH__
977 return std::asinh(x);
978#endif //__CUDA_ARCH__
979}

◆ asinhf() [1/2]

any_platform float olb::util::asinhf ( float x)
inline

Definition at line 934 of file omath.h.

935{
936#ifdef __CUDA_ARCH__
937 return ::asinhf(x);
938#else //__CUDA_ARCH__
939 return std::asinh(x);
940#endif //__CUDA_ARCH__
941}

◆ asinhf() [2/2]

any_platform float olb::util::asinhf ( int x)
inline

Definition at line 943 of file omath.h.

944{
945#ifdef __CUDA_ARCH__
946 return ::asinhf(x);
947#else //__CUDA_ARCH__
948 return std::asinh(x);
949#endif //__CUDA_ARCH__
950}

◆ asinhl()

long double olb::util::asinhl ( long double arg)
inline

Definition at line 981 of file omath.h.

982{
983 return std::asinhl(arg);
984 //cuda dose not support this function.
985}

◆ asinl()

long double olb::util::asinl ( long double arg)
inline

Definition at line 927 of file omath.h.

928{
929 return asin(arg);
930 //cuda dose not support this function.
931}
ADf< T, DIM > asin(const ADf< T, DIM > &a)
Definition aDiff.h:596

References asin().

+ Here is the call graph for this function:

◆ assign() [1/2]

template<typename T >
std::vector< T > olb::util::assign ( T a,
T b )

Definition at line 411 of file vectorHelpers.h.

412{
413 std::vector<T> v1;
414 v1.push_back(a);
415 v1.push_back(b);
416 return v1;
417}

◆ assign() [2/2]

template<typename T >
std::vector< T > olb::util::assign ( T a,
T b,
T c )

Definition at line 420 of file vectorHelpers.h.

421{
422 std::vector<T> v1;
423 v1.push_back(a);
424 v1.push_back(b);
425 v1.push_back(c);
426 return v1;
427}

◆ atan() [1/3]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::atan ( const ADf< T, DIM > & a)
inline

Definition at line 614 of file aDiff.h.

615{
616 ADf<T,DIM> c(std::atan(a._v), a._d);
617 T tmp(T(1)/(T(1)+(a._v)*(a._v)));
618 c._d*=tmp;
619 return c;
620}
+ Here is the caller graph for this function:

◆ atan() [2/3]

template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > olb::util::atan ( T x)
inline

Definition at line 1115 of file omath.h.

1116{
1117#ifdef __CUDA_ARCH__
1118 if constexpr (std::is_same_v<T, float>) {
1119 return ::atanf(x);
1120 }
1121 else if constexpr (std::is_same_v<T, double>) {
1122 return ::atan(x);
1123 }
1124 else {
1125 return ::atan(static_cast<double>(x));
1126 //libcu++ of cuda supports double and float. You will get warning in device code if you use in e.g. long double.
1127 }
1128#else //__CUDA_ARCH__
1129 return std::atan(x);
1130#endif //__CUDA_ARCH__
1131}

◆ atan() [3/3]

template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > olb::util::atan ( T x)
inline

Definition at line 1134 of file omath.h.

1135{
1136#ifdef __CUDA_ARCH__
1137 return ::atan(x);
1138#else //__CUDA_ARCH__
1139 return std::atan(x);
1140#endif //__CUDA_ARCH__
1141}

◆ atan2() [1/7]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::atan2 ( const ADf< T, DIM > & y,
const ADf< T, DIM > & x )
inline

Definition at line 641 of file aDiff.h.

642{
643 ADf<T,DIM> c(std::atan2(y._v, x._v));
644 T tmpA(x._v / (x._v*x._v + y._v*y._v));
645 T tmpB(-y._v / (x._v*x._v + y._v*y._v));
646 c._d = tmpA*y._d + tmpB*x._d;
647 return c;
648}

◆ atan2() [2/7]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::atan2 ( const ADf< T, DIM > & y,
const T & x )
inline

Definition at line 632 of file aDiff.h.

633{
634 ADf<T,DIM> c(std::atan2(y._v, x));
635 T tmpA(x / (x*x + y._v*y._v));
636 c._d = tmpA*y._d;
637 return c;
638}

◆ atan2() [3/7]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::atan2 ( const T & y,
const ADf< T, DIM > & x )
inline

Definition at line 623 of file aDiff.h.

624{
625 ADf<T,DIM> c(std::atan2(y, x._v));
626 T tmpB(-y / (x._v*x._v + y*y));
627 c._d = tmpB*x._d;
628 return c;
629}
+ Here is the caller graph for this function:

◆ atan2() [4/7]

template<typename T , typename S >
any_platform std::enable_if_t< std::is_integral_v< S > &&std::is_floating_point_v< T >, T > olb::util::atan2 ( T x,
S y )
inline

Definition at line 1175 of file omath.h.

1176{
1177#ifdef __CUDA_ARCH__
1178 if constexpr (std::is_same_v<T, float>) {
1179 return ::atan2f(x, y);
1180 }
1181 else if constexpr (std::is_same_v<T, double>) {
1182 return ::atan2(x, y);
1183 }
1184 else {
1185 return ::atan2(static_cast<double>(x), y);
1186 //libcu++ of cuda supports double and float. You will get warning in device code if you use in e.g. long double.
1187 }
1188#else //__CUDA_ARCH__
1189 return std::atan2(x, y);
1190#endif //__CUDA_ARCH__
1191}

◆ atan2() [5/7]

template<typename T , typename S >
any_platform std::enable_if_t< std::is_integral_v< T > &&std::is_floating_point_v< S >, S > olb::util::atan2 ( T x,
S y )
inline

Definition at line 1196 of file omath.h.

1197{
1198#ifdef __CUDA_ARCH__
1199 if constexpr (std::is_same_v<S, float>) {
1200 return ::atan2f(x, y);
1201 }
1202 else if constexpr (std::is_same_v<S, double>) {
1203 return ::atan2(x, y);
1204 }
1205 else {
1206 return ::atan2(x, static_cast<double>(y));
1207 //libcu++ of cuda supports double and float. You will get warning in device code if you use in e.g. long double.
1208 }
1209#else //__CUDA_ARCH__
1210 return std::atan2(x, y);
1211#endif //__CUDA_ARCH__
1212}

◆ atan2() [6/7]

template<typename T , typename S >
any_platform std::enable_if_t< std::is_integral_v< T > &&std::is_integral_v< S >, double > olb::util::atan2 ( T x,
S y )
inline

Definition at line 1216 of file omath.h.

1217{
1218#ifdef __CUDA_ARCH__
1219 return ::atan2(x, y);
1220#else //__CUDA_ARCH__
1221 return std::atan2(x, y);
1222#endif //__CUDA_ARCH__
1223}

◆ atan2() [7/7]

template<typename T , typename S >
any_platform auto olb::util::atan2 ( T x,
S y ) -> std::enable_if_t<std::is_floating_point_v<T> && std::is_floating_point_v<S>, decltype(std::atan2(x, y))>
inline

Definition at line 1151 of file omath.h.

1155{
1156#ifdef __CUDA_ARCH__
1157 if constexpr (std::is_same_v<T, float> && std::is_same_v<S, float>) {
1158 return ::atan2f(x, y);
1159 }
1160 else if constexpr (std::is_same_v<T, double> && std::is_same_v<S, double>) {
1161 return ::atan2(x, y);
1162 }
1163 else {
1164 return ::atan2(static_cast<double>(x), static_cast<double>(y));
1165 //libcu++ of cuda supports double and float. You will get warning in device code if you use in e.g. long double.
1166 }
1167#else // __CUDA_ARCH__
1168 return std::atan2(x, y);
1169#endif // __CUDA_ARCH__
1170}

◆ atan2f() [1/2]

any_platform float olb::util::atan2f ( float base,
float exp )
inline

Definition at line 1225 of file omath.h.

1226{
1227#ifdef __CUDA_ARCH__
1228 return ::atan2f(base, exp);
1229#else //__CUDA_ARCH__
1230 return std::atan2(base, exp);
1231#endif //__CUDA_ARCH__
1232}

References exp().

+ Here is the call graph for this function:

◆ atan2f() [2/2]

any_platform float olb::util::atan2f ( int base,
int exp )
inline

Definition at line 1234 of file omath.h.

1235{
1236#ifdef __CUDA_ARCH__
1237 return ::atan2f(base, exp);
1238#else //__CUDA_ARCH__
1239 return std::atan2(base, exp);
1240#endif //__CUDA_ARCH__
1241}

References exp().

+ Here is the call graph for this function:

◆ atanf() [1/2]

any_platform float olb::util::atanf ( float x)
inline

Definition at line 1096 of file omath.h.

1097{
1098#ifdef __CUDA_ARCH__
1099 return ::atanf(x);
1100#else //__CUDA_ARCH__
1101 return std::atan(x);
1102#endif //__CUDA_ARCH__
1103}

◆ atanf() [2/2]

any_platform float olb::util::atanf ( int x)
inline

Definition at line 1105 of file omath.h.

1106{
1107#ifdef __CUDA_ARCH__
1108 return ::atanf(x);
1109#else //__CUDA_ARCH__
1110 return std::atan(x);
1111#endif //__CUDA_ARCH__
1112}

◆ atanh() [1/3]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::atanh ( const ADf< T, DIM > & a)
inline

Definition at line 689 of file aDiff.h.

690{
691 if (std::abs(a._v) < 1) {
692 return 0.5 * log( (1+a) / (1-a) );
693 }
694 else {
695 ADf<T,DIM> c;
696 c._v = std::atanh(a._v);
697 c._d = ( std::numeric_limits<T>::quiet_NaN() );
698 return c;
699 }
700}

References log().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ atanh() [2/3]

template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > olb::util::atanh ( T x)
inline

Definition at line 1263 of file omath.h.

1264{
1265#ifdef __CUDA_ARCH__
1266 if constexpr (std::is_same_v<T, float>) {
1267 return ::atanhf(x);
1268 }
1269 else if constexpr (std::is_same_v<T, double>) {
1270 return ::atanh(x);
1271 }
1272 else {
1273 return ::atanh(static_cast<double>(x));
1274 //libcu++ of cuda supports double and float. You will get warning in device code if you use in e.g. long double.
1275 }
1276#else //__CUDA_ARCH__
1277 return std::atanh(x);
1278#endif //__CUDA_ARCH__
1279}

◆ atanh() [3/3]

template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > olb::util::atanh ( T x)
inline

Definition at line 1282 of file omath.h.

1283{
1284#ifdef __CUDA_ARCH__
1285 return ::atanh(x);
1286#else //__CUDA_ARCH__
1287 return std::atanh(x);
1288#endif //__CUDA_ARCH__
1289}

◆ atanhf() [1/2]

any_platform float olb::util::atanhf ( float x)
inline

Definition at line 1244 of file omath.h.

1245{
1246#ifdef __CUDA_ARCH__
1247 return ::atanhf(x);
1248#else //__CUDA_ARCH__
1249 return std::atanh(x);
1250#endif //__CUDA_ARCH__
1251}

◆ atanhf() [2/2]

any_platform float olb::util::atanhf ( int x)
inline

Definition at line 1253 of file omath.h.

1254{
1255#ifdef __CUDA_ARCH__
1256 return ::atanhf(x);
1257#else //__CUDA_ARCH__
1258 return std::atanh(x);
1259#endif //__CUDA_ARCH__
1260}

◆ atanhl()

long double olb::util::atanhl ( long double arg)
inline

Definition at line 1291 of file omath.h.

1292{
1293 return atanh(arg);
1294 //cuda dose not support this function.
1295}
ADf< T, DIM > atanh(const ADf< T, DIM > &a)
Definition aDiff.h:689

References atanh().

+ Here is the call graph for this function:

◆ atanl()

long double olb::util::atanl ( long double arg)
inline

Definition at line 1143 of file omath.h.

1144{
1145 return atan(arg);
1146 //cuda dose not support this function.
1147}
ADf< T, DIM > atan(const ADf< T, DIM > &a)
Definition aDiff.h:614

References atan().

+ Here is the call graph for this function:

◆ average()

template<typename T , unsigned Size>
T olb::util::average ( const Vector< T, Size > & a)

computes the average of all elements

Definition at line 206 of file vectorHelpers.h.

207{
208 T sum = a[0];
209 for (unsigned int iDim=1; iDim < Size; ++iDim) {
210 sum += a[iDim];
211 }
212 return sum/Size;
213}
+ Here is the caller graph for this function:

◆ bisectDistance()

template<typename S , unsigned D, typename F1 , typename F2 >
bool olb::util::bisectDistance ( S & distance,
const Vector< S, D > & origin,
const Vector< S, D > & direction,
S pitch,
S precision,
F1 isInside,
F2 isInsideBoundingBox )

Using a bisect to find the unsigned distance (false if distance was not found, true if distance was found)

Parameters
distancecomputed distance from origin to surface in direction
directionis saved here
originthe point we want to calculate the distance from
directionthe considered direction
pitcha first guess for the distance, must be > 0 (if origin is inside origin + normalize(direction) * pitch should be outside and if origin is outside origin + normalize(direction) * pitch should be inside)
precisionwhen the change of the found distance reaches the defined precision, the iteration stops
isInsidefunction that defines if a point is inside or outside a geometry (usually the ()-operator of an Indicator)
isInsideBoundingBoxfunction that defines if a point is inside the enclosing bounding box (maybe needs at least one extra layer between geometry surface and bounding box surface)

Definition at line 168 of file indicatorBase.h.

170{
171 distance = S(0);
172 Vector<S,D> dir = normalize(direction);
173
174 // Check if origin is on surface
175 bool isInsideDistance = isInside(origin + 5*precision*dir);
176 bool isInsideOppDistance = isInside(origin - 5*precision*dir);
177 if (isInsideDistance == !isInsideOppDistance) {
178 return true;
179 }
180
181 Vector<S,D> startPoint = origin;
182 S fixedDistance = S(0);
183 S oldDistance = distance;
184 std::function<Vector<S,D>()> calcCurrPoint = [&startPoint, &pitch, &dir]() {
185 return startPoint + pitch * dir;
186 };
187 Vector<S,D> currPoint = calcCurrPoint();
188
189 bool originValue = isInside(startPoint);
190 bool currentValue = isInside(currPoint);
191
192 // if aforementioned requirement for pitch is not given, try to find a proper pitch
193 while (originValue == currentValue) {
194 pitch *= 1.5;
195 currPoint = calcCurrPoint();
196 currentValue = isInside(currPoint);
197
198 // if both points are outside the bounding box return false indicating that no distance was found
199 if (!currentValue && !isInsideBoundingBox(startPoint) && !isInsideBoundingBox(currPoint)) {
200 return false;
201 }
202 }
203
204 for (unsigned iD=0; iD<D; ++iD) {
205 if (!std::isfinite(currPoint[iD])) {
206 return false;
207 }
208 }
209
210 // if we have one point inside and another outside, we can keep halving the line from origin to currPoint until we find the wanted precision
211 distance = norm(startPoint - currPoint);
212 while ( util::abs(distance - oldDistance) > precision ) {
213 pitch *= 0.5;
214 currPoint = calcCurrPoint();
215
216 // set distances
217 oldDistance = distance;
218 distance = norm(startPoint - currPoint);
219
220 // if both points are outside or inside run take result of same function with different start point (= current point)
221 currentValue = isInside(currPoint);
222 if (currentValue == originValue) {
223 startPoint = currPoint;
224 fixedDistance += distance;
225 // convert distances to distance to new start point
226 oldDistance -= distance;
227 distance = S(0);
228 }
229 }
230 distance += fixedDistance;
231
232 return true;
233}
bool distance(S &distance, const Vector< S, D > &origin, const Vector< S, D > &direction, S precision, S pitch, F1 isInside, F2 isInsideBoundingBox)
constexpr T norm(const ScalarVector< T, D, IMPL > &a) any_platform
Euclidean vector norm.
constexpr Vector< T, D > normalize(const ScalarVector< T, D, IMPL > &a, T scale=T{1})
Definition vector.h:284

References abs(), distance(), norm(), and normalize().

+ Here is the call graph for this function:

◆ calculateInverseRotationMatrix()

template<typename T , unsigned D>
Vector< T, utilities::dimensions::convert< D >::matrix > olb::util::calculateInverseRotationMatrix ( const Vector< T, utilities::dimensions::convert< D >::rotation > & angle)

Definition at line 182 of file geometricOperations.h.

184{
185 return invertRotationMatrix<T, D>(calculateRotationMatrix<T, D>(angle));
186}

References calculateRotationMatrix(), and invertRotationMatrix().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateLocalVelocity()

template<typename T , unsigned D>
Vector< T, D > olb::util::calculateLocalVelocity ( const Vector< T, D > & rotationCenter,
const Vector< T, D > & velocity,
const Vector< T, utilities::dimensions::convert< D >::rotation > & angularVelocity,
const Vector< T, D > & position )
constexpr

Calculate local velocity.

Definition at line 239 of file geometricOperations.h.

244{
245 if constexpr (D == 2) {
246 // two dimensions: u = U + w x r = (Ux, Uy, 0) + (0,0,w) x (X,Y,0) = (Ux, Uy, 0) + (-w*Y, w*X, 0)
247 return Vector<T, 2>(
248 velocity[0] - angularVelocity[0] * (position[1] - rotationCenter[1]),
249 velocity[1] + angularVelocity[0] * (position[0] - rotationCenter[0]));
250 }
251 else {
252 // three dimensions: u = U + w x r = (Ux, Uy, Uz) + (wx,wy,wz) x (X,Y,Z) = (Ux, Uy, Uz) + (wy*Z-wz*Y, wz*X-wx*Z, wx*Y-wy*X)
253 return velocity +
254 crossProduct3D(angularVelocity, position - rotationCenter);
255 }
256 __builtin_unreachable();
257}
constexpr Vector< T, 3 > crossProduct3D(const ScalarVector< T, 3, IMPL > &a, const ScalarVector< T, 3, IMPL_ > &b) any_platform
Definition vector.h:263

References olb::crossProduct3D().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateRotationMatrix()

template<typename T , unsigned D>
Vector< T, utilities::dimensions::convert< D >::matrix > olb::util::calculateRotationMatrix ( const Vector< T, utilities::dimensions::convert< D >::rotation > & angle)

Definition at line 69 of file geometricOperations.h.

71{
73
74 if constexpr (D == 2) {
75 T const cos = util::cos(angle[0]);
76 T const sin = util::sin(angle[0]);
77
78 // row 1
79 rotationMatrix[0] = cos;
80 rotationMatrix[1] = -sin;
81 // row 2
82 rotationMatrix[2] = sin;
83 rotationMatrix[3] = cos;
84 }
85 else {
86 T const cos[3] = {util::cos(angle[0]), util::cos(angle[1]),
87 util::cos(angle[2])};
88 T const sin[3] = {util::sin(angle[0]), util::sin(angle[1]),
89 util::sin(angle[2])};
90
91 // |x0| / 0 1 2 \ |x1|
92 // |y0| | 3 4 5 | = |x1|
93 // |z0| \ 6 7 8 / |x1|
94
95 // row 1
96 rotationMatrix[0] = cos[1] * cos[2];
97 rotationMatrix[1] = sin[0] * sin[1] * cos[2] - cos[0] * sin[2];
98 rotationMatrix[2] = cos[0] * sin[1] * cos[2] + sin[0] * sin[2];
99 // row 2
100 rotationMatrix[3] = cos[1] * sin[2];
101 rotationMatrix[4] = sin[0] * sin[1] * sin[2] + cos[0] * cos[2];
102 rotationMatrix[5] = cos[0] * sin[1] * sin[2] - sin[0] * cos[2];
103 // row 3
104 rotationMatrix[6] = -sin[1];
105 rotationMatrix[7] = sin[0] * cos[1];
106 rotationMatrix[8] = cos[0] * cos[1];
107 }
108
109 return rotationMatrix;
110}
ADf< T, DIM > sin(const ADf< T, DIM > &a)
Definition aDiff.h:569
ADf< T, DIM > cos(const ADf< T, DIM > &a)
Definition aDiff.h:578

References cos(), and sin().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ceil() [1/4]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::ceil ( const ADf< T, DIM > & a)
inline

Definition at line 900 of file aDiff.h.

901{
902 // Similar to floor
903 ADf<T,DIM> c (std::ceil(a._v));
904 if (a._v == c._v) {
905#ifdef AdWarnings
906 std::cout << "ADf WARNING: ceil(Adf) - ceil evaluated at non-differentiable point" << std::endl;
907#endif
908 for (unsigned i = 0; i < DIM; ++i) {
909 c._d[i] = (a.d(i) == 0) ? T(0) : std::numeric_limits<T>::quiet_NaN();
910 }
911 }
912 return c;
913}
constexpr T & d(unsigned i)
Definition aDiff.h:252
+ Here is the caller graph for this function:

◆ ceil() [2/4]

template<typename T , unsigned Size>
Vector< T, Size > olb::util::ceil ( const Vector< T, Size > & a)

applies ceil to each component of a vector

Definition at line 184 of file vectorHelpers.h.

185{
186 Vector<T,Size> out;
187 for (unsigned int iDim=0; iDim < Size; ++iDim) {
188 out[iDim] = util::ceil(a[iDim]);
189 }
190 return out;
191}

References ceil().

+ Here is the call graph for this function:

◆ ceil() [3/4]

template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > olb::util::ceil ( T x)
inline

Definition at line 1372 of file omath.h.

1373{
1374#ifdef __CUDA_ARCH__
1375 if constexpr (std::is_same_v<T, float>) {
1376 return ::ceilf(x);
1377 }
1378 else if constexpr (std::is_same_v<T, double>) {
1379 return ::ceil(x);
1380 }
1381 else {
1382 return ::ceil(static_cast<double>(x));
1383 //libcu++ of cuda supports double and float. You will get warning in device code if you use in e.g. long double.
1384 }
1385#else //__CUDA_ARCH__
1386 return std::ceil(x);
1387#endif //__CUDA_ARCH__
1388}

◆ ceil() [4/4]

template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > olb::util::ceil ( T x)
inline

Definition at line 1391 of file omath.h.

1392{
1393#ifdef __CUDA_ARCH__
1394 return ::ceil(x);
1395#else //__CUDA_ARCH__
1396 return std::ceil(x);
1397#endif //__CUDA_ARCH__
1398}

◆ ceilf() [1/3]

template<unsigned DIM>
ADf< float, DIM > olb::util::ceilf ( const ADf< float, DIM > & a)
inline

Definition at line 916 of file aDiff.h.

917{
918 return ceil(a);
919}
ADf< T, DIM > ceil(const ADf< T, DIM > &a)
Definition aDiff.h:900

References ceil().

+ Here is the call graph for this function:

◆ ceilf() [2/3]

any_platform float olb::util::ceilf ( float x)
inline

Definition at line 1353 of file omath.h.

1354{
1355#ifdef __CUDA_ARCH__
1356 return ::ceilf(x);
1357#else //__CUDA_ARCH__
1358 return std::ceil(x);
1359#endif //__CUDA_ARCH__
1360}

◆ ceilf() [3/3]

any_platform float olb::util::ceilf ( int x)
inline

Definition at line 1362 of file omath.h.

1363{
1364#ifdef __CUDA_ARCH__
1365 return ::ceilf(x);
1366#else //__CUDA_ARCH__
1367 return std::ceil(x);
1368#endif //__CUDA_ARCH__
1369}

◆ ceill() [1/2]

template<unsigned DIM>
ADf< long double, DIM > olb::util::ceill ( const ADf< long double, DIM > & a)
inline

Definition at line 922 of file aDiff.h.

923{
924 return ceil(a);
925}

References ceil().

+ Here is the call graph for this function:

◆ ceill() [2/2]

long double olb::util::ceill ( long double arg)
inline

Definition at line 1400 of file omath.h.

1401{
1402 return ceil(arg);
1403 //cuda dose not support this function.
1404}

References ceil().

+ Here is the call graph for this function:

◆ closeToZero()

template<std::integral T>
any_platform bool olb::util::closeToZero ( T x)

Definition at line 1614 of file omath.h.

1615{
1616 return fabs(x) <= std::numeric_limits<T>::epsilon();
1617}

References fabs().

+ Here is the call graph for this function:

◆ contained() [1/2]

bool olb::util::contained ( int x,
int y,
int x0,
int x1,
int y0,
int y1 )
inline

Definition at line 115 of file util.h.

117{
118 return x>=x0 && x<=x1 &&
119 y>=y0 && y<=y1;
120}
+ Here is the caller graph for this function:

◆ contained() [2/2]

bool olb::util::contained ( int x,
int y,
int z,
int x0,
int x1,
int y0,
int y1,
int z0,
int z1 )
inline

Definition at line 122 of file util.h.

124{
125 return x>=x0 && x<=x1 &&
126 y>=y0 && y<=y1 &&
127 z>=z0 && z<=z1;
128}

◆ copy3()

template<class T >
void olb::util::copy3 ( T c[],
const T a[] )
inline

Definition at line 69 of file vectorHelpers.h.

70{
71 for (unsigned i=0; i<3; i++) {
72 c[i] = a[i];
73 }
74}

◆ copyAs()

template<typename T , typename S , template< typename > typename C>
C< T > olb::util::copyAs ( const C< S > & input)

copy vector with specified typecast

Definition at line 72 of file adHelpers.h.

72 {
73 C<T> result = ContainerCreator<C<T>>::create(input.size());
74
75 for(std::size_t it = 0; it < input.size(); ++it) {
76 result[it] = T(input[it]);
77 }
78 return result;
79}
Creates a container of type C.
+ Here is the caller graph for this function:

◆ copyDerivatives()

template<typename T , typename TAD >
void olb::util::copyDerivatives ( T * target,
const TAD * source,
int length )

Copy the derivatives from an ADf array into an array.

Returns
target[j*dim+i] = source[j].d(i) = d/dx_i (s_j)
Parameters
length= length of the array

Definition at line 61 of file adHelpers.h.

61 {
62 for (int j = 0; j < length; ++j) {
63 for (unsigned i = 0; i < TAD::dim; ++i) {
64 target[j*(TAD::dim)+i] = source[j].d(i);
65 }
66 }
67}
+ Here is the caller graph for this function:

◆ copyN() [1/2]

template<class S , class T >
void olb::util::copyN ( S c[],
const T a[],
const unsigned dim )
inline

Definition at line 61 of file vectorHelpers.h.

62{
63 for (unsigned i=0; i<dim; i++) {
64 c[i] = a[i];
65 }
66}

◆ copyN() [2/2]

template<class T >
void olb::util::copyN ( T c[],
const T a[],
const unsigned dim )
inline

Definition at line 53 of file vectorHelpers.h.

54{
55 for (unsigned i=0; i<dim; i++) {
56 c[i] = a[i];
57 }
58}
+ Here is the caller graph for this function:

◆ cos() [1/3]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::cos ( const ADf< T, DIM > & a)
inline

Definition at line 578 of file aDiff.h.

579{
580 ADf<T,DIM> c(std::cos(a._v), a._d);
581 T tmp(-std::sin(a._v));
582 c._d*=tmp;
583 return c;
584}
+ Here is the caller graph for this function:

◆ cos() [2/3]

template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > olb::util::cos ( T x)
inline

Definition at line 683 of file omath.h.

684{
685#ifdef __CUDA_ARCH__
686 if constexpr (std::is_same_v<T, float>) {
687 return ::cosf(x);
688 }
689 else if constexpr (std::is_same_v<T, double>) {
690 return ::cos(x);
691 }
692 else {
693 return ::cos(static_cast<double>(x));
694 //libcu++ of cuda supports double and float. You will get warning in device code if you use in e.g. long double.
695 }
696#else //__CUDA_ARCH__
697 return std::cos(x);
698#endif //__CUDA_ARCH__
699}

◆ cos() [3/3]

template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > olb::util::cos ( T x)
inline

Definition at line 702 of file omath.h.

703{
704#ifdef __CUDA_ARCH__
705 return ::cos(x);
706#else //__CUDA_ARCH__
707 return std::cos(x);
708#endif //__CUDA_ARCH__
709}

◆ cosf() [1/2]

any_platform float olb::util::cosf ( float x)
inline

Definition at line 664 of file omath.h.

665{
666#ifdef __CUDA_ARCH__
667 return ::cosf(x);
668#else //__CUDA_ARCH__
669 return std::cos(x);
670#endif //__CUDA_ARCH__
671}

◆ cosf() [2/2]

any_platform float olb::util::cosf ( int x)
inline

Definition at line 673 of file omath.h.

674{
675#ifdef __CUDA_ARCH__
676 return ::cosf(x);
677#else //__CUDA_ARCH__
678 return std::cos(x);
679#endif //__CUDA_ARCH__
680}

◆ cosh() [1/3]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::cosh ( const ADf< T, DIM > & a)
inline

Definition at line 657 of file aDiff.h.

658{
659 return 0.5*(exp(a)+exp(-a));
660}
Expr exp(Expr x)
Definition expr.cpp:240

References exp().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cosh() [2/3]

template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > olb::util::cosh ( T x)
inline

Definition at line 738 of file omath.h.

739{
740#ifdef __CUDA_ARCH__
741 if constexpr (std::is_same_v<T, float>) {
742 return ::coshf(x);
743 }
744 else if constexpr (std::is_same_v<T, double>) {
745 return ::cosh(x);
746 }
747 else {
748 return ::cosh(static_cast<double>(x));
749 //libcu++ of cuda supports double and float. You will get warning in device code if you use in e.g. long double.
750 }
751#else //__CUDA_ARCH__
752 return std::cosh(x);
753#endif //__CUDA_ARCH__
754}

◆ cosh() [3/3]

template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > olb::util::cosh ( T x)
inline

Definition at line 757 of file omath.h.

758{
759#ifdef __CUDA_ARCH__
760 return ::cosh(x);
761#else //__CUDA_ARCH__
762 return std::cosh(x);
763#endif //__CUDA_ARCH__
764}

◆ coshf() [1/2]

any_platform float olb::util::coshf ( float x)
inline

Definition at line 719 of file omath.h.

720{
721#ifdef __CUDA_ARCH__
722 return ::coshf(x);
723#else //__CUDA_ARCH__
724 return std::cosh(x);
725#endif //__CUDA_ARCH__
726}

◆ coshf() [2/2]

any_platform float olb::util::coshf ( int x)
inline

Definition at line 728 of file omath.h.

729{
730#ifdef __CUDA_ARCH__
731 return ::coshf(x);
732#else //__CUDA_ARCH__
733 return std::cosh(x);
734#endif //__CUDA_ARCH__
735}

◆ coshl()

long double olb::util::coshl ( long double arg)
inline

Definition at line 766 of file omath.h.

767{
768 return cosh(arg);
769 //libcu++ of cuda dose not support long double. You will get warning in device code if you use.
770}
ADf< T, DIM > cosh(const ADf< T, DIM > &a)
Definition aDiff.h:657

References cosh().

+ Here is the call graph for this function:

◆ cosl()

long double olb::util::cosl ( long double arg)
inline

Definition at line 711 of file omath.h.

712{
713 return cos(arg);
714 //libcu++ of cuda dose not support long double. You will get warning in device code if you use.
715}

References cos().

+ Here is the call graph for this function:

◆ createTimer()

template<typename T , typename DESCRIPTOR >
Timer< T > * olb::util::createTimer ( XMLreader & param,
const UnitConverter< T, DESCRIPTOR > & converter,
size_t numLatticePoints )

Definition at line 260 of file timer.hh.

261{
262 OstreamManager clout(std::cout,"createTimer");
263
264 // initialize parameters with some default values
265 T physMaxT = T();
266 T physStartT = T();
267 int printModeSummary = 0;
268
269 // fetch xml Data and error handling
270 if ( ! param["Application"]["PhysParameters"]["PhysMaxTime"].read(physMaxT) ) {
271 if ( ! param["Application"]["PhysParam"]["MaxTime"].read(physStartT) ) {
272 clout << "PhysMaxTime not found" << std::endl;
273 }
274 else {
275 clout << "Application::PhysParam::MaxTime needs to be renamed to Application::PhysParameters::PhysMaxTime" << std::endl;
276 }
277 }
278 // read the variable for the mode of printSummary
279 param.readOrWarn<int>("Output","Timer","PrintModeSummary", printModeSummary,true,false,false);
280
281// if ( ! param["Application"]["PhysParam"]["MaxStartTime"].read(physStartT) ) {
282// clout << "PhysStartTime not found" << std::endl;
283// }
284
285 // variable processing according to the constructor
286 int maxT = converter.getLatticeTime(physMaxT) + converter.getLatticeTime(physStartT);
287
288 //return some default values that produce reasonable output (e.g.
289 // zero); in best case there should be no output at all (TODO)
290 return new Timer<T>(maxT, numLatticePoints, printModeSummary);
291}
class for marking output with some text
constexpr size_t getLatticeTime(T physTime) const
conversion from physical to lattice time
bool readOrWarn(std::string name_parameter_1, std::string name_parameter_2, std::string name_parameter_3, ParameterType &var, bool defaultAvailable=true, bool exitIfMissing=false, bool showWarning=true) const
This wrapper function reads the given parameter from the "type_parameter" and "name_parameter_1" or "...
Definition xmlReader.h:183

References olb::UnitConverter< T, DESCRIPTOR >::getLatticeTime(), and olb::XMLreader::readOrWarn().

+ Here is the call graph for this function:

◆ crossSum()

template<typename K >
K olb::util::crossSum ( K k)

Compute cross sum of an integer.

Template Parameters
Kinteger type
Parameters
kan integer
Returns
cross sum

Definition at line 103 of file calc.h.

103 {
104 if (k < 0) {
105 k = -k;
106 }
107 K res (0);
108 while (k > 0) {
109 res += k % 10;
110 k /= 10;
111 }
112 return res;
113}

◆ cube()

template<typename T >
any_platform T olb::util::cube ( T arg)

Definition at line 138 of file util.h.

139{
140 return arg*arg*arg;
141}
+ Here is the caller graph for this function:

◆ degreeToRadian() [1/2]

template<typename T , unsigned D>
decltype(Vector< decltype(util::sqrt(T())), D >()) olb::util::degreeToRadian ( const Vector< T, D > & angle)

Definition at line 42 of file geometricOperations.h.

43{
44 constexpr BaseType<decltype(util::sqrt(T()))> conversionFactor = M_PI / 180.;
45 return conversionFactor * angle;
46}
typename util::BaseTypeHelper< T >::type BaseType
Definition baseType.h:59

References M_PI, and sqrt().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ degreeToRadian() [2/2]

template<typename T >
decltype(util::sqrt(T())) olb::util::degreeToRadian ( T angle)

Definition at line 49 of file geometricOperations.h.

50{
51 return degreeToRadian(Vector<T, 1>(angle))[0];
52}
decltype(Vector< decltype(util::sqrt(T())), D >()) degreeToRadian(const Vector< T, D > &angle)

References degreeToRadian().

+ Here is the call graph for this function:

◆ densityFromPressure()

template<typename T , typename DESCRIPTOR >
any_platform T olb::util::densityFromPressure ( T latticePressure)

compute lattice density from lattice pressure

Definition at line 386 of file util.h.

387{
388 // rho = p / c_s^2 + 1
389 return latticePressure * descriptors::invCs2<T,DESCRIPTOR>() + 1.0;
390}

References olb::descriptors::invCs2().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ derivativeFAD() [1/3]

template<unsigned sourceDIM, typename S , typename F >
auto olb::util::derivativeFAD ( F f,
const S * input )

Compute derivatives of a function f: S^sourceDIM -> T via forward AD Signature is "V f(U*)" so f is expected to return a single value.

It must be (captured by) a lambda function that handles arbitrary types, so "auto f(auto x)" is to be written.

Definition at line 128 of file adHelpers.h.

128 {
129 using SAD = ADf<S,sourceDIM>;
130 using T = decltype(f(input));
131 using TAD = ADf<T,sourceDIM>;
132
133 SAD inputAD[sourceDIM];
134 util::copyN(inputAD, input, sourceDIM);
135 util::iniDiagonal(inputAD, sourceDIM);
136
137 TAD resultAD = f(inputAD);
138 T* result = new T[sourceDIM];
139 copyDerivatives(result, &resultAD, 1);
140 return result;
141}
void copyDerivatives(T *target, const TAD *source, int length)
Copy the derivatives from an ADf array into an array.
Definition adHelpers.h:61

References copyDerivatives(), copyN(), and iniDiagonal().

+ Here is the call graph for this function:

◆ derivativeFAD() [2/3]

template<typename S , typename F >
auto olb::util::derivativeFAD ( F f,
const S input )

Compute derivatives of a function f: S -> T via forward AD Signature is "V f(U)" so f is expected to accept and return a single value.

It must be (captured by) a lambda function that handles arbitrary types, so "auto f(auto x)" is to be written.

Definition at line 115 of file adHelpers.h.

115 {
116 ADf<S,1> inputAD = input;
117 inputAD.setDiffVariable(0);
118
119 return f(inputAD).d(0);
120}
constexpr void setDiffVariable(unsigned iD)
Definition aDiff.h:270

References olb::util::ADf< T, DIM >::setDiffVariable().

+ Here is the call graph for this function:

◆ derivativeFAD() [3/3]

template<unsigned sourceDIM, typename T , typename S , typename F >
void olb::util::derivativeFAD ( F f,
T * output,
const S * input,
unsigned targetDIM )

Compute derivatives of a function f: S^sourceDIM -> T^targetDIM via forward AD Signature of f is "void f(V*, U*)", it is expected to modify the first argument in-place.

f must be (captured by) a lambda function that handles arbitrary types, so "void f(auto y, auto x)" is to be written.

Definition at line 150 of file adHelpers.h.

150 {
151 using SAD = ADf<S,sourceDIM>;
152 using TAD = ADf<T,sourceDIM>;
153
154 SAD inputAD[sourceDIM];
155 util::copyN(inputAD, input, sourceDIM);
156 util::iniDiagonal(inputAD, sourceDIM);
157 TAD outputAD[targetDIM];
158
159 f(outputAD, inputAD);
160 copyDerivatives(output, outputAD, targetDIM);
161 return;
162}

References copyDerivatives(), copyN(), and iniDiagonal().

+ Here is the call graph for this function:

◆ determinant() [1/4]

template<typename T >
auto olb::util::determinant ( const Matrix< T, 2, 2 > & m)
constexpr

Definition at line 143 of file matrix.h.

144{
145 return determinant<T>(m[0], m[1]);
146}

References determinant().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ determinant() [2/4]

template<typename T >
auto olb::util::determinant ( const Matrix< T, 3, 3 > & m)
constexpr

Definition at line 149 of file matrix.h.

150{
151 return determinant<T>(m[0], m[1], m[2]);
152}

References determinant().

+ Here is the call graph for this function:

◆ determinant() [3/4]

template<typename T >
T olb::util::determinant ( const Vector< T, 2 > & v0,
const Vector< T, 2 > & v1 )
constexpr

Definition at line 312 of file vectorHelpers.h.

313{
314 return crossProduct2D(v0, v1);
315}
constexpr T crossProduct2D(const ScalarVector< T, 2, IMPL > &a, const ScalarVector< T, 2, IMPL_ > &b)
Definition vector.h:256

References olb::crossProduct2D().

+ Here is the call graph for this function:

◆ determinant() [4/4]

template<typename T >
T olb::util::determinant ( const Vector< T, 3 > & v0,
const Vector< T, 3 > & v1,
const Vector< T, 3 > & v2 )
constexpr

Definition at line 318 of file vectorHelpers.h.

320{
321 return v0[0]*v1[1]*v2[2] + v1[0]*v2[1]*v0[2] + v2[0]*v0[1]*v1[2]
322 - v0[2]*v1[1]*v2[0] - v1[2]*v2[1]*v0[0] - v2[2]*v0[1]*v1[0];
323}

◆ distance() [1/3]

template<typename S , unsigned D, typename F1 , typename F2 >
bool olb::util::distance ( S & distance,
const Vector< S, D > & origin,
const Vector< S, D > & direction,
S precision,
F1 sdf,
F2 isInsideBoundingBox,
const unsigned maxIt = 1e6 )

Definition at line 95 of file indicatorBase.h.

97{
98 S signedDistance{sdf(origin)};
99 Vector<S,D> currPos{origin};
100 const Vector<S,D> dir{util::sign(signedDistance) * normalize(direction)};
101
102 if (util::fabs(signedDistance) <= precision) {
103 distance = util::fabs(signedDistance);
104 return true;
105 }
106
107 distance = S{0};
108 for(unsigned i=0; util::fabs(signedDistance) > precision && i<maxIt; ++i) {
109 distance += signedDistance;
110 currPos += signedDistance * dir;
111 signedDistance = sdf(currPos);
112 if (!isInsideBoundingBox(currPos)) {
113 distance = S{0};
114 return false;
115 }
116 }
117
118 distance = util::fabs(distance);
119 return true;
120}

References distance(), fabs(), normalize(), and sign().

+ Here is the call graph for this function:

◆ distance() [2/3]

template<typename S , unsigned D, typename F1 , typename F2 >
bool olb::util::distance ( S & distance,
const Vector< S, D > & origin,
const Vector< S, D > & direction,
S precision,
S pitch,
F1 isInside,
F2 isInsideBoundingBox )

Definition at line 36 of file indicatorBase.h.

38{
39 // Check if point is on surface
40 bool isInsideDistance;
41 bool isInsideOppDistance;
42 Vector<S,D> currentPoint = origin + 10*precision*direction;
43 isInside(&isInsideDistance, currentPoint.data());
44 currentPoint = origin - 10*precision*direction;
45 isInside(&isInsideOppDistance, currentPoint.data());
46 if (isInsideDistance == !isInsideOppDistance) {
47 distance = 0;
48 return true;
49 }
50
51 bool originValue;
52 bool currentValue;
53
54 isInside(&originValue, origin.data());
55
56 // start at origin and move into given direction
57 currentPoint = origin;
58 currentValue = originValue;
59
60 while (currentValue == originValue && isInsideBoundingBox(currentPoint)) {
61 currentPoint += direction;
62 // update currentValue until the first point on the other side (inside/outside) is found
63 isInside(&currentValue, currentPoint.data());
64 }
65
66 // return false if no point was found in given direction
67 if (!isInsideBoundingBox(currentPoint) && !originValue) {
68 return false;
69 }
70
71
72 while (pitch >= precision) {
73 if (!isInsideBoundingBox(currentPoint) && originValue) {
74 currentPoint -= pitch * direction;
75 pitch *= 0.5;
76 }
77 else {
78 isInside(&currentValue, currentPoint.data());
79 if (currentValue == originValue) {
80 currentPoint += pitch * direction;
81 pitch *= 0.5;
82 }
83 else {
84 currentPoint -= pitch * direction;
85 pitch *= 0.5;
86 }
87 }
88 }
89
90 distance = norm(currentPoint - origin);
91 return true;
92}
constexpr const T * data() const any_platform
Definition vector.h:172

References olb::Vector< T, Size >::data(), distance(), and norm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ distance() [3/3]

template<typename S , unsigned D, bool normalizeDirection = true>
bool olb::util::distance ( S & distance,
const Vector< S, D > & origin,
const Vector< S, D > & direction,
S precision,
std::function< S(const Vector< S, D > &)> sdf,
S maxDistance,
const unsigned maxIt = 1e6 )

Definition at line 123 of file indicatorBase.h.

125{
126 S signedDistance{sdf(origin)};
127 Vector<S,D> currPos{origin};
128 Vector<S,D> dir;
129 if constexpr(normalizeDirection) {
130 dir = util::sign(signedDistance) * normalize(direction);
131 }
132 else {
133 dir = util::sign(signedDistance) * direction;
134 }
135
136 if (util::fabs(signedDistance) <= precision) {
137 distance = util::fabs(signedDistance);
138 return true;
139 }
140
141 distance = S{0};
142 for(unsigned i=0; util::fabs(signedDistance) > precision && i<maxIt; ++i) {
143 distance += signedDistance;
144 currPos += signedDistance * dir;
145 signedDistance = sdf(currPos);
146 if (signedDistance > maxDistance) {
147 distance = S{0};
148 return false;
149 }
150 }
151
152 distance = util::fabs(distance);
153 return true;
154}

References distance(), fabs(), normalize(), and sign().

+ Here is the call graph for this function:

◆ dotProduct()

template<typename T , unsigned D>
T olb::util::dotProduct ( const Vector< T, D > & a,
const Vector< T, D > & b )

dot product

Definition at line 143 of file vectorHelpers.h.

144{
145 if constexpr (D==2){
146 return dotProduct2D(a, b);
147 } else {
148 return dotProduct3D(a, b);
149 }
150}
T dotProduct2D(const Vector< T, 2 > &a, const Vector< T, 2 > &b)
dot product, only valid in 2d

References dotProduct2D(), and dotProduct3D().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dotProduct2D()

template<typename T >
T olb::util::dotProduct2D ( const Vector< T, 2 > & a,
const Vector< T, 2 > & b )

dot product, only valid in 2d

Definition at line 136 of file vectorHelpers.h.

137{
138 return a[0]*b[0] + a[1]*b[1];
139}
+ Here is the caller graph for this function:

◆ dotProduct3D()

template<typename T >
T olb::util::dotProduct3D ( const Vector< T, 3 > & a,
const Vector< T, 3 > & b )

dot product, only valid in 3d

Definition at line 129 of file vectorHelpers.h.

130{
131 return a[0]*b[0] + a[1]*b[1] + a[2]*b[2];
132}
+ Here is the caller graph for this function:

◆ euklidDistance() [1/2]

template<typename C >
auto olb::util::euklidDistance ( const C & x,
const C & y )

Euclidean distance for Container-type array.

Definition at line 97 of file norm.h.

98{
99 OLB_ASSERT((x.size() == y.size()), "Arrays must have same dimension");
100 return euklidDistance(x.data(), y.data(), x.size());
101}
T euklidDistance(const T x[], const T y[], int dim)
Euclidean distance between two arrays.
Definition norm.h:67
#define OLB_ASSERT(COND, MESSAGE)
Definition olbDebug.h:45

References euklidDistance(), and OLB_ASSERT.

+ Here is the call graph for this function:

◆ euklidDistance() [2/2]

template<typename T >
T olb::util::euklidDistance ( const T x[],
const T y[],
int dim )

Euclidean distance between two arrays.

Definition at line 67 of file norm.h.

68{
69 return olb::util::sqrt(euklidDistance2(x,y,dim));
70}
Expr sqrt(Expr x)
Definition expr.cpp:225
T euklidDistance2(const T x[], const T y[], int dim)
Squared Euclidean distance between two arrays.
Definition norm.h:48

References euklidDistance2(), and sqrt().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ euklidDistance2() [1/2]

template<typename C >
auto olb::util::euklidDistance2 ( const C & x,
const C & y )

Squared Euclidean distance for Container-type array.

Definition at line 82 of file norm.h.

83{
84 OLB_ASSERT((x.size() == y.size()), "Arrays must have same dimension");
85 return euklidDistance2(x.data(), y.data(), x.size());
86}

References euklidDistance2(), and OLB_ASSERT.

+ Here is the call graph for this function:

◆ euklidDistance2() [2/2]

template<typename T >
T olb::util::euklidDistance2 ( const T x[],
const T y[],
int dim )

Squared Euclidean distance between two arrays.

Definition at line 48 of file norm.h.

49{
50 T euklid = 0;
51 for (int iDim=0; iDim<dim; iDim++) {
52 euklid += (x[iDim]-y[iDim])*(x[iDim]-y[iDim]);
53 }
54 return euklid;
55}
+ Here is the caller graph for this function:

◆ euklidN() [1/2]

template<typename C >
auto olb::util::euklidN ( const C & x)

Euclidean norm for Container-type array.

Definition at line 90 of file norm.h.

91{
92 return euklidN(x.data(), x.size());
93}
T euklidN(const T x[], int dim)
Euclidean norm of an array.
Definition norm.h:60

References euklidN().

+ Here is the call graph for this function:

◆ euklidN() [2/2]

template<typename T >
T olb::util::euklidN ( const T x[],
int dim )

Euclidean norm of an array.

Definition at line 60 of file norm.h.

61{
62 return olb::util::sqrt(euklidN2(x,dim));
63}
T euklidN2(const T x[], int dim)
Squared Euclidean norm of an array.
Definition norm.h:37

References euklidN2(), and sqrt().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ euklidN2() [1/2]

template<typename C >
auto olb::util::euklidN2 ( const C & x)

Squared Euclidean norm for Container-type array.

Definition at line 75 of file norm.h.

76{
77 return euklidN2(x.data(), x.size());
78}

References euklidN2().

+ Here is the call graph for this function:

◆ euklidN2() [2/2]

template<typename T >
T olb::util::euklidN2 ( const T x[],
int dim )

Squared Euclidean norm of an array.

Definition at line 37 of file norm.h.

38{
39 T euklid = 0;
40 for (int iDim=0; iDim<dim; iDim++) {
41 euklid += x[iDim]*x[iDim];
42 }
43 return euklid;
44}
+ Here is the caller graph for this function:

◆ evaluateIntegration()

template<typename T >
int olb::util::evaluateIntegration ( std::vector< T > & testValues,
bool print = false )

Definition at line 34 of file integrationTestUtils.h.

34 {
35 OstreamManager clout( std::cout,"Integrationtest" );
36 bool allPassed = true;
37 for (int i=0; i<testValues.size(); i+=3){
38 T val = testValues[i];
39 T ref = testValues[i+1];
40 T maxErr = testValues[i+2];
41 T err = std::abs(ref-val)/ref;
42 bool passed = err <= maxErr;
43 if (print || !passed ){
44 clout << std::setprecision(16);
45 clout << "i:|" << "Value: |"
46 << "Reference: |"
47 << "Error: |"
48 << "MaxError: |"
49 << "Passed:" << std::endl;
50 clout << i << " |" << std::setw(22) << val
51 << " |" << std::setw(22) << ref
52 << " |" << std::setw(22) << err
53 << " |" << std::setw(22) << maxErr
54 << " |" << passed << std::endl;
55 clout << std::setprecision(6);
56 }
57 if (!passed){ allPassed=false; };
58 }
59 if (allPassed){
60 return 0;
61 } else {
62 return 1;
63 }
64}

References print().

+ Here is the call graph for this function:

◆ executeRotation()

template<typename T , unsigned D, bool OUTPUT_USES_ROTATION_CENTER_AS_ORIGIN = false>
Vector< T, D > olb::util::executeRotation ( const Vector< T, D > & input,
const Vector< T, utilities::dimensions::convert< D >::matrix > & rotationMatrix,
const Vector< T, D > & rotationCenter = Vector<T, D>(0.) )

Rotates the input around the rotationCenter with a given rotationMatrix.

Definition at line 191 of file geometricOperations.h.

195{
196 const Vector<T, D> dist = input - rotationCenter;
197 Vector<T, D> rotated;
198
199 if constexpr (D == 2) {
200 rotated =
201 Vector<T, 2>(dist[0] * rotationMatrix[0] + dist[1] * rotationMatrix[1],
202 dist[0] * rotationMatrix[2] + dist[1] * rotationMatrix[3]);
203 }
204 else {
205 rotated =
206 Vector<T, 3>(rotationMatrix[0] * dist[0] + rotationMatrix[1] * dist[1] +
207 rotationMatrix[2] * dist[2],
208 rotationMatrix[3] * dist[0] + rotationMatrix[4] * dist[1] +
209 rotationMatrix[5] * dist[2],
210 rotationMatrix[6] * dist[0] + rotationMatrix[7] * dist[1] +
211 rotationMatrix[8] * dist[2]);
212 }
213
214 if constexpr (!OUTPUT_USES_ROTATION_CENTER_AS_ORIGIN) {
215 return rotationCenter + rotated;
216 }
217 else {
218 return rotated;
219 }
220
221 __builtin_unreachable();
222}
+ Here is the caller graph for this function:

◆ exp() [1/4]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::exp ( const ADf< T, DIM > & a)
inline

Definition at line 455 of file aDiff.h.

456{
457 ADf<T,DIM> c(std::exp(a._v), a._d);
458 c._d*=c._v;
459 return c;
460}

◆ exp() [2/4]

Expr olb::util::exp ( Expr x)

Definition at line 240 of file expr.cpp.

240 {
241 Expr::increment(Expr::Op::Exp);
242 return Expr(Expr::Op::Exp, x);
243}
Basic value-substitute enabling extraction of expression trees for code generation.
Definition expr.h:39

References olb::Expr::Exp, and olb::Expr::increment().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exp() [3/4]

template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > olb::util::exp ( T arg)
inline

Definition at line 248 of file omath.h.

249{
250#ifdef __CUDA_ARCH__
251 return ::exp(arg);
252#else //__CUDA_ARCH__
253 return std::exp(arg);
254#endif //__CUDA_ARCH__
255}

◆ exp() [4/4]

template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > olb::util::exp ( T x)
inline

Definition at line 229 of file omath.h.

230{
231#ifdef __CUDA_ARCH__
232 if constexpr (std::is_same_v<T, float>) {
233 return ::expf(x);
234 }
235 else if constexpr (std::is_same_v<T, double>) {
236 return ::exp(x);
237 }
238 else {
239 return ::exp(static_cast<double>(x));
240 //libcu++ of cuda supports double and float. You will get warning in device code if you use in e.g. long double.
241 }
242#else //__CUDA_ARCH__
243 return std::exp(x);
244#endif //__CUDA_ARCH__
245}

◆ expf() [1/3]

template<unsigned DIM>
ADf< float, DIM > olb::util::expf ( const ADf< float, DIM > & a)
inline

Definition at line 463 of file aDiff.h.

464{
465 return exp(a);
466}

References exp().

+ Here is the call graph for this function:

◆ expf() [2/3]

any_platform float olb::util::expf ( float arg)
inline

Definition at line 257 of file omath.h.

258{
259#ifdef __CUDA_ARCH__
260 return ::expf(arg);
261#else //__CUDA_ARCH__
262 return std::exp(arg);
263#endif //__CUDA_ARCH__
264}

◆ expf() [3/3]

any_platform float olb::util::expf ( int arg)
inline

Definition at line 266 of file omath.h.

267{
268#ifdef __CUDA_ARCH__
269 return ::expf(arg);
270#else //__CUDA_ARCH__
271 return std::exp(arg);
272#endif //__CUDA_ARCH__
273}

◆ expl() [1/2]

template<unsigned DIM>
ADf< long double, DIM > olb::util::expl ( const ADf< long double, DIM > & a)
inline

Definition at line 469 of file aDiff.h.

470{
471 return exp(a);
472}

References exp().

+ Here is the call graph for this function:

◆ expl() [2/2]

long double olb::util::expl ( long double arg)
inline

Definition at line 275 of file omath.h.

276{
277 return exp(arg);
278 //cuda dose not support this function.
279}

References exp().

+ Here is the call graph for this function:

◆ fabs() [1/6]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::fabs ( const ADf< T, DIM > & a)
inline

Definition at line 996 of file aDiff.h.

997{
998#ifdef AdWarnings
999 if (a._v == T(0)) {
1000 std::cout << "ADf WARNING: fabs(Adf) - fabs evaluated at non-differentiable point" << std::endl;
1001 }
1002#endif
1003 return ADf<T,DIM>( util::sign(a._v) * a );
1004}

References sign().

+ Here is the call graph for this function:

◆ fabs() [2/6]

template<std::floating_point T>
cpu::simd::Pack< T > olb::util::fabs ( cpu::simd::Pack< T > value)

Definition at line 116 of file pack.h.

117{
118 return cpu::simd::fabs(value);
119}

References olb::cpu::simd::fabs().

+ Here is the call graph for this function:

◆ fabs() [3/6]

Expr olb::util::fabs ( Expr x)

Definition at line 230 of file expr.cpp.

230 {
231 Expr::increment(Expr::Op::Abs);
232 return Expr(Expr::Op::Abs, x);
233}

References olb::Expr::Abs, and olb::Expr::increment().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fabs() [4/6]

long double olb::util::fabs ( long double arg)
inline

Definition at line 1611 of file omath.h.

1611{ return std::abs(arg); }

◆ fabs() [5/6]

template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > olb::util::fabs ( T x)
inline

Definition at line 1554 of file omath.h.

1555{
1556#ifdef __CUDA_ARCH__
1557 if constexpr (std::is_same_v<T, float>) {
1558 return ::fabsf(x);
1559 }
1560 else if constexpr (std::is_same_v<T, double>) {
1561 return ::fabs(x);
1562 }
1563 else {
1564 return ::fabs(static_cast<double>(x));
1565 //libcu++ of cuda supports double and float. You will get warning in device code if you use in e.g. long double.
1566 }
1567#else //__CUDA_ARCH__
1568 return std::fabs(x);
1569#endif //__CUDA_ARCH__
1570}

◆ fabs() [6/6]

template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > olb::util::fabs ( T x)
inline

Definition at line 1573 of file omath.h.

1574{
1575#ifdef __CUDA_ARCH__
1576 return ::fabs(x);
1577#else //__CUDA_ARCH__
1578 return std::fabs(x);
1579#endif //__CUDA_ARCH__
1580}

◆ fabsf() [1/3]

template<unsigned DIM>
ADf< float, DIM > olb::util::fabsf ( const ADf< float, DIM > & a)
inline

Definition at line 1007 of file aDiff.h.

1008{
1009 return fabs(a);
1010}

References fabs().

+ Here is the call graph for this function:

◆ fabsf() [2/3]

any_platform float olb::util::fabsf ( float x)
inline

Definition at line 1535 of file omath.h.

1536{
1537#ifdef __CUDA_ARCH__
1538 return ::fabsf(x);
1539#else //__CUDA_ARCH__
1540 return std::abs(x);
1541#endif //__CUDA_ARCH__
1542}

◆ fabsf() [3/3]

any_platform float olb::util::fabsf ( int x)
inline

Definition at line 1544 of file omath.h.

1545{
1546#ifdef __CUDA_ARCH__
1547 return ::fabsf(x);
1548#else //__CUDA_ARCH__
1549 return std::abs(x);
1550#endif //__CUDA_ARCH__
1551}

◆ fabsl()

template<unsigned DIM>
ADf< long double, DIM > olb::util::fabsl ( const ADf< long double, DIM > & a)
inline

Definition at line 1013 of file aDiff.h.

1014{
1015 return fabs(a);
1016}

References fabs().

+ Here is the call graph for this function:

◆ findVelocity()

template<typename DESCRIPTORBASE >
int olb::util::findVelocity ( const int v[DESCRIPTORBASE::d])

Definition at line 243 of file util.h.

244{
245 for (int iPop=0; iPop<DESCRIPTORBASE::q; ++iPop) {
246 bool fit = true;
247 for (int iD=0; iD<DESCRIPTORBASE::d; ++iD) {
248 if (descriptors::c<DESCRIPTORBASE>(iPop,iD) != v[iD]) {
249 fit = false;
250 break;
251 }
252 }
253 if (fit) {
254 return iPop;
255 }
256 }
257 return DESCRIPTORBASE::q;
258}

References olb::descriptors::c().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ floor() [1/4]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::floor ( const ADf< T, DIM > & a)
inline

Definition at line 869 of file aDiff.h.

870{
871 ADf<T,DIM> c;
872 if (a._v == std::floor(a._v)) {
873 c._v = a._v;
874#ifdef AdWarnings
875 std::cout << "ADf WARNING: floor(Adf) - floor evaluated at non-differentiable point" << std::endl;
876#endif
877 for (unsigned i = 0; i < DIM; ++i) {
878 c._d[i] = (a.d(i) == 0) ? T(0) : std::numeric_limits<T>::quiet_NaN();
879 }
880 return c;
881 }
882 c._v = std::floor(a._v);
883 c._d = ( T(0) );
884 return c;
885}
+ Here is the caller graph for this function:

◆ floor() [2/4]

template<typename T , unsigned Size>
Vector< T, Size > olb::util::floor ( const Vector< T, Size > & a)

applies floor to each component of a vector

Definition at line 173 of file vectorHelpers.h.

174{
175 Vector<T,Size> out;
176 for (unsigned int iDim=0; iDim < Size; ++iDim) {
177 out[iDim] = util::floor(a[iDim]);
178 }
179 return out;
180}

References floor().

+ Here is the call graph for this function:

◆ floor() [3/4]

template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > olb::util::floor ( T x)
inline

Definition at line 1318 of file omath.h.

1319{
1320#ifdef __CUDA_ARCH__
1321 if constexpr (std::is_same_v<T, float>) {
1322 return ::floorf(x);
1323 }
1324 else if constexpr (std::is_same_v<T, double>) {
1325 return ::floor(x);
1326 }
1327 else {
1328 return ::floor(static_cast<double>(x));
1329 //libcu++ of cuda supports double and float. You will get warning in device code if you use in e.g. long double.
1330 }
1331#else //__CUDA_ARCH__
1332 return std::floor(x);
1333#endif //__CUDA_ARCH__
1334}

◆ floor() [4/4]

template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > olb::util::floor ( T x)
inline

Definition at line 1337 of file omath.h.

1338{
1339#ifdef __CUDA_ARCH__
1340 return ::floor(x);
1341#else //__CUDA_ARCH__
1342 return std::floor(x);
1343#endif //__CUDA_ARCH__
1344}

◆ floorf() [1/3]

template<unsigned DIM>
ADf< float, DIM > olb::util::floorf ( const ADf< float, DIM > & a)
inline

Definition at line 888 of file aDiff.h.

889{
890 return floor(a);
891}
ADf< T, DIM > floor(const ADf< T, DIM > &a)
Definition aDiff.h:869

References floor().

+ Here is the call graph for this function:

◆ floorf() [2/3]

any_platform float olb::util::floorf ( float x)
inline

Definition at line 1299 of file omath.h.

1300{
1301#ifdef __CUDA_ARCH__
1302 return ::floorf(x);
1303#else //__CUDA_ARCH__
1304 return std::floor(x);
1305#endif //__CUDA_ARCH__
1306}

◆ floorf() [3/3]

any_platform float olb::util::floorf ( int x)
inline

Definition at line 1308 of file omath.h.

1309{
1310#ifdef __CUDA_ARCH__
1311 return ::floorf(x);
1312#else //__CUDA_ARCH__
1313 return std::floor(x);
1314#endif //__CUDA_ARCH__
1315}

◆ floorl() [1/2]

template<unsigned DIM>
ADf< long double, DIM > olb::util::floorl ( const ADf< long double, DIM > & a)
inline

Definition at line 894 of file aDiff.h.

895{
896 return floor(a);
897}

References floor().

+ Here is the call graph for this function:

◆ floorl() [2/2]

long double olb::util::floorl ( long double arg)
inline

Definition at line 1346 of file omath.h.

1347{
1348 return floor(arg);
1349 //cuda dose not support this function.
1350}

References floor().

+ Here is the call graph for this function:

◆ fmod() [1/7]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::fmod ( const ADf< T, DIM > & a,
const ADf< T, DIM > & b )
inline

Definition at line 703 of file aDiff.h.

704{
705 const T k = std::floor(T(a) / T(b));
706 return ADf<T,DIM>(a - k * b);
707}
+ Here is the caller graph for this function:

◆ fmod() [2/7]

template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
ADf< T, DIM > olb::util::fmod ( const ADf< T, DIM > & a,
const U & b )
inline

Definition at line 710 of file aDiff.h.

711{
712 return fmod(a, ADf<T,DIM>(b));
713}
ADf< T, DIM > fmod(const ADf< T, DIM > &a, const ADf< T, DIM > &b)
Definition aDiff.h:703

References fmod().

+ Here is the call graph for this function:

◆ fmod() [3/7]

template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
ADf< T, DIM > olb::util::fmod ( const U & a,
const ADf< T, DIM > & b )
inline

Definition at line 716 of file aDiff.h.

717{
718 return fmod( ADf<T,DIM>(a),b);
719}

References fmod().

+ Here is the call graph for this function:

◆ fmod() [4/7]

template<typename T , typename S , unsigned Size>
Vector< T, Size > olb::util::fmod ( const Vector< T, Size > & a,
S b )

applies fmod to each component of a vector

Definition at line 195 of file vectorHelpers.h.

196{
197 Vector<T,Size> out;
198 for (unsigned int iDim=0; iDim < Size; ++iDim) {
199 out[iDim] = util::fmod(a[iDim], b);
200 }
201 return out;
202}

References fmod().

+ Here is the call graph for this function:

◆ fmod() [5/7]

template<typename T , typename S >
any_platform std::enable_if_t< std::is_integral_v< S > &&std::is_floating_point_v< T >, T > olb::util::fmod ( T x,
S y )
inline

Definition at line 164 of file omath.h.

165{
166#ifdef __CUDA_ARCH__
167 if constexpr (std::is_same_v<T, float>) {
168 return ::fmodf(x, y);
169 }
170 else if constexpr (std::is_same_v<T, double>) {
171 return ::fmod(x, y);
172 }
173 else {
174 return ::fmod(static_cast<double>(x), y);
175 //libcu++ of cuda supports double and float. You will get warning in device code if you use in e.g. long double.
176 }
177#else //__CUDA_ARCH__
178 return std::fmod(x, y);
179#endif //__CUDA_ARCH__
180}

◆ fmod() [6/7]

template<typename T , typename S >
any_platform std::enable_if_t< std::is_integral_v< T > &&std::is_floating_point_v< S >, S > olb::util::fmod ( T x,
S y )
inline

Definition at line 185 of file omath.h.

186{
187#ifdef __CUDA_ARCH__
188 if constexpr (std::is_same_v<S, float>) {
189 return ::fmodf(x, y);
190 }
191 else if constexpr (std::is_same_v<S, double>) {
192 return ::fmod(x, y);
193 }
194 else {
195 return ::fmod(x, static_cast<double>(y));
196 //libcu++ of cuda supports double and float. You will get warning in device code if you use in e.g. long double.
197 }
198#else //__CUDA_ARCH__
199 return std::fmod(x, y);
200#endif //__CUDA_ARCH__
201}

◆ fmod() [7/7]

template<typename T , typename S >
any_platform auto olb::util::fmod ( T x,
S y ) -> std::enable_if_t<std::is_floating_point_v<T> && std::is_floating_point_v<S>, decltype(std::fmod(x, y))>
inline

Definition at line 140 of file omath.h.

144{
145#ifdef __CUDA_ARCH__
146 if constexpr (std::is_same_v<T, float> && std::is_same_v<S, float>) {
147 return ::fmodf(x, y);
148 }
149 else if constexpr (std::is_same_v<T, double> && std::is_same_v<S, double>) {
150 return ::fmod(x, y);
151 }
152 else {
153 return ::fmod(static_cast<double>(x), static_cast<double>(y));
154 //libcu++ of cuda supports double and float. You will get warning in device code if you use in e.g. long double.
155 }
156#else //__CUDA_ARCH__
157 return std::fmod(x, y);
158#endif //__CUDA_ARCH__
159}

◆ fmod_pos()

template<typename T , typename S >
auto olb::util::fmod_pos ( T a,
S b )
inline

Variant of fmod (floating point modulo) that always returns positive values.

Definition at line 39 of file calc.h.

39 {
40 const auto res = util::fmod(a, b);
41 if (res < 0) {
42 return (res + b);
43 } else {
44 return res;
45 }
46}

References fmod().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fmodf() [1/2]

any_platform float olb::util::fmodf ( float x,
float y )
inline

Definition at line 203 of file omath.h.

204{
205#ifdef __CUDA_ARCH__
206 return ::fmodf(x, y);
207#else //__CUDA_ARCH__
208 return std::fmod(x, y);
209#endif //__CUDA_ARCH__
210}

◆ fmodf() [2/2]

any_platform float olb::util::fmodf ( int x,
int y )
inline

Definition at line 212 of file omath.h.

213{
214#ifdef __CUDA_ARCH__
215 return ::fmodf(x, y);
216#else //__CUDA_ARCH__
217 return std::fmod(x, y);
218#endif //__CUDA_ARCH__
219}

◆ fmodl()

long double olb::util::fmodl ( long double x,
long double y )
inline

Definition at line 221 of file omath.h.

222{
223 return fmod(x, y);
224 //cuda dose not support this function.
225}

References fmod().

+ Here is the call graph for this function:

◆ forEachOffset()

template<unsigned D, typename F >
void olb::util::forEachOffset ( F fn)

Definition at line 450 of file util.h.

450 {
451 for (int i = -1; i <= 1; ++i) {
452 for (int j = -1; j <= 1; ++j) {
453 if constexpr (D == 3) {
454 for (int k = -1; k <= 1; ++k) { fn(i, j, k); }
455 }
456 else { fn(i, j); }
457 }
458 }
459}

◆ fromVector2()

template<typename T >
std::vector< T > olb::util::fromVector2 ( const Vector< T, 2 > & vec)

Definition at line 87 of file vectorHelpers.h.

88{
89 std::vector<T> v;
90 v.push_back(vec[0]);
91 v.push_back(vec[1]);
92 return v;
93}

◆ fromVector3()

template<typename T >
std::vector< T > olb::util::fromVector3 ( const Vector< T, 3 > & vec)

Definition at line 78 of file vectorHelpers.h.

79{
80 std::vector<T> v;
81 v.push_back(vec[0]);
82 v.push_back(vec[1]);
83 v.push_back(vec[2]);
84 return v;
85}
+ Here is the caller graph for this function:

◆ get_nearest_link()

template<typename T , typename DESCRIPTOR >
int olb::util::get_nearest_link ( const std::vector< T > & vec)

Util Function for Wall Model of Malaspinas get link with smallest angle to a vector.

Definition at line 360 of file util.h.

361{
362 T max=-1;
363 int max_index = 0;
364 for (int iQ=1; iQ<DESCRIPTOR::q; ++iQ) {
365 std::vector<T> c_i(DESCRIPTOR::c[iQ], DESCRIPTOR::c[iQ]+3);
366 T tmp = util::scalarProduct<T>(c_i, vec)/util::norm(c_i);
367 if (tmp > max) {
368 max = tmp;
369 max_index = iQ;
370 }
371 }
372 return max_index;
373}

References norm(), and scalarProduct().

+ Here is the call graph for this function:

◆ iniAD() [1/3]

template<unsigned n, typename S , template< typename > typename C>
C< ADf< S, n > > olb::util::iniAD ( const C< S > & source)

copy values and initialize derivatives

Definition at line 101 of file adHelpers.h.

101 {
102 auto result = copyAs<ADf<S,n>,S,C> (source);
103 util::iniDiagonal (result);
104 return result;
105}

References copyAs(), and iniDiagonal().

+ Here is the call graph for this function:

◆ iniAD() [2/3]

template<unsigned n, typename S >
ADf< S, n > * olb::util::iniAD ( const S * source)

copy array values and initialize derivatives

Definition at line 92 of file adHelpers.h.

92 {
93 ADf<S,n>* result = new ADf<S,n>[n];
94 util::copyN (result, source, n);
95 util::iniDiagonal (result, n);
96 return result;
97}

References copyN(), and iniDiagonal().

+ Here is the call graph for this function:

◆ iniAD() [3/3]

template<typename S >
ADf< S, 1 > olb::util::iniAD ( const S source)

copy value and initialize derivative

Definition at line 84 of file adHelpers.h.

84 {
85 ADf<S,1> result(source);
86 result.setDiffVariable(0);
87 return result;
88}

References olb::util::ADf< T, DIM >::setDiffVariable().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ iniDiagonal() [1/2]

template<typename C >
void olb::util::iniDiagonal ( C & a)

Definition at line 49 of file adHelpers.h.

49 {
50 for (unsigned i = 0; i < a.size(); ++i) {
51 a[i].setDiffVariable(i);
52 }
53}

◆ iniDiagonal() [2/2]

template<typename SAD >
void olb::util::iniDiagonal ( SAD * a,
int dim )

The variables of an array are set to be the differential variables.

--> d/di a_j = 1 if (i==j) else 0.

Definition at line 42 of file adHelpers.h.

42 {
43 for (int i = 0; i < dim; ++i) {
44 a[i].setDiffVariable(i);
45 }
46}
+ Here is the caller graph for this function:

◆ intersect() [1/2]

bool olb::util::intersect ( int x0,
int x1,
int y0,
int y1,
int x0_,
int x1_,
int y0_,
int y1_,
int & newX0,
int & newX1,
int & newY0,
int & newY1 )
inline

Definition at line 85 of file util.h.

89{
90 newX0 = util::max(x0,x0_);
91 newY0 = util::max(y0,y0_);
92
93 newX1 = util::min(x1,x1_);
94 newY1 = util::min(y1,y1_);
95
96 return newX1>=newX0 && newY1>=newY0;
97}

References max(), and min().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ intersect() [2/2]

bool olb::util::intersect ( int x0,
int x1,
int y0,
int y1,
int z0,
int z1,
int x0_,
int x1_,
int y0_,
int y1_,
int z0_,
int z1_,
int & newX0,
int & newX1,
int & newY0,
int & newY1,
int & newZ0,
int & newZ1 )
inline

Definition at line 99 of file util.h.

103{
104 newX0 = util::max(x0,x0_);
105 newY0 = util::max(y0,y0_);
106 newZ0 = util::max(z0,z0_);
107
108 newX1 = util::min(x1,x1_);
109 newY1 = util::min(y1,y1_);
110 newZ1 = util::min(z1,z1_);
111
112 return newX1>=newX0 && newY1>=newY0 && newZ1>=newZ0;
113}

References max(), and min().

+ Here is the call graph for this function:

◆ inverseRotation() [1/2]

template<typename T >
Vector< T, 4 > olb::util::inverseRotation ( const Vector< T, 4 > & m)

Definition at line 113 of file geometricOperations.h.

113 {
114 return Vector{m[0], m[2],
115 m[1], m[3]};
116}
+ Here is the caller graph for this function:

◆ inverseRotation() [2/2]

template<typename T >
Vector< T, 9 > olb::util::inverseRotation ( const Vector< T, 9 > & m)

Definition at line 119 of file geometricOperations.h.

119 {
120 return Vector{m[0], m[3], m[6],
121 m[1], m[4], m[7],
122 m[2], m[5], m[8]};
123}

◆ invertRotation()

template<typename T , unsigned D, bool OUTPUT_USES_ROTATION_CENTER_AS_ORIGIN = false>
Vector< T, D > olb::util::invertRotation ( const Vector< T, D > & input,
const Vector< T, utilities::dimensions::convert< D >::matrix > & rotationMatrix,
const Vector< T, D > & rotationCenter = Vector<T, D>(0.) )

Rotates the input around the rotationCenter with a given rotationMatrix in the opposite direction.

Definition at line 227 of file geometricOperations.h.

231{
233 invertRotationMatrix<T, D>(rotationMatrix);
234 return executeRotation(input, invRotationMatrix, rotationCenter);
235}
Vector< T, D > executeRotation(const Vector< T, D > &input, const Vector< T, utilities::dimensions::convert< D >::matrix > &rotationMatrix, const Vector< T, D > &rotationCenter=Vector< T, D >(0.))
Rotates the input around the rotationCenter with a given rotationMatrix.

References executeRotation(), and invertRotationMatrix().

+ Here is the call graph for this function:

◆ invertRotationMatrix()

template<typename T , unsigned D>
Vector< T, utilities::dimensions::convert< D >::matrix > olb::util::invertRotationMatrix ( const Vector< T, utilities::dimensions::convert< D >::matrix > & rotationMatrix)

Definition at line 158 of file geometricOperations.h.

160{
161 if constexpr (D == 2) {
162 return Vector<T, 4>(rotationMatrix[0], rotationMatrix[2], rotationMatrix[1],
163 rotationMatrix[3]);
164 }
165 else {
166
167 //Individual Entries ( source: https://doi.org/10.1016/j.compfluid.2018.02.027 )
168 // |x0| / 0 3 6 \ |x1|
169 // |y0| | 1 4 7 | = |x1|
170 // |z0| \ 2 5 8 / |x1|
171
172 return Vector<T, 9>(rotationMatrix[0], rotationMatrix[3], rotationMatrix[6],
173 rotationMatrix[1], rotationMatrix[4], rotationMatrix[7],
174 rotationMatrix[2], rotationMatrix[5],
175 rotationMatrix[8]);
176 }
177 __builtin_unreachable();
178}

References olb::Vector().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isContained()

template<typename C , typename U >
bool olb::util::isContained ( const C & c,
U object )

Check, if object is contained in iteratable container c.

Definition at line 447 of file vectorHelpers.h.

447 {
448 return (std::find(c.begin(), c.end(), object) != c.end());
449}
+ Here is the caller graph for this function:

◆ isnan()

template<typename T >
any_platform bool olb::util::isnan ( T arg)
inline

Definition at line 1621 of file omath.h.

1622{
1623#ifdef __CUDA_ARCH__
1624 return ::isnan(arg);
1625#else
1626 return std::isnan(arg);
1627#endif
1628}
+ Here is the caller graph for this function:

◆ kahanSum() [1/2]

template<typename T >
void olb::util::kahanSum ( T & output0,
T & output1,
T summand )

Definition at line 59 of file calc.h.

60{
61 const T y {summand - output1};
62 const T t {output0 + y};
63 output1 = (t - output0) - y;
64 output0 = t;
65}

◆ kahanSum() [2/2]

template<typename T >
void olb::util::kahanSum ( T output[2],
T summand )

Accurate summation of floating point numbers with the Kahan algorithm.

Definition at line 51 of file calc.h.

52{
53 const T y {summand - output[1]};
54 const T t {output[0] + y};
55 output[1] = (t - output[0]) - y;
56 output[0] = t;
57}
+ Here is the caller graph for this function:

◆ labs()

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::labs ( const ADf< T, DIM > & a)
inline

Definition at line 1025 of file aDiff.h.

1026{
1027#ifdef AdWarnings
1028 std::cout << "ADf WARNING: ADf is not supporting integer types. Using abs() instead." << std::endl;
1029#endif
1030 return abs(a);
1031}

References abs().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ llabs()

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::llabs ( const ADf< T, DIM > & a)
inline

Definition at line 1034 of file aDiff.h.

1035{
1036 return labs(a);
1037}
ADf< T, DIM > labs(const ADf< T, DIM > &a)
Definition aDiff.h:1025

References labs().

+ Here is the call graph for this function:

◆ llround() [1/2]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::llround ( const ADf< T, DIM > & a)
inline

Definition at line 978 of file aDiff.h.

979{
980 return lround(a);
981}
ADf< T, DIM > lround(const ADf< T, DIM > &a)
Definition aDiff.h:957

References lround().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ llround() [2/2]

template<typename T >
std::enable_if_t< std::is_arithmetic_v< T >, long long > olb::util::llround ( T arg)
inline

Definition at line 1525 of file omath.h.

1526{
1527 return std::llround(arg);
1528}

◆ llroundf() [1/2]

template<unsigned DIM>
ADf< float, DIM > olb::util::llroundf ( const ADf< float, DIM > & a)
inline

Definition at line 984 of file aDiff.h.

985{
986 return llround(a);
987}
ADf< T, DIM > llround(const ADf< T, DIM > &a)
Definition aDiff.h:978

References llround().

+ Here is the call graph for this function:

◆ llroundf() [2/2]

long long olb::util::llroundf ( float arg)
inline

Definition at line 1530 of file omath.h.

1530{ return std::llroundf(arg); }

◆ llroundl() [1/2]

template<unsigned DIM>
ADf< long double, DIM > olb::util::llroundl ( const ADf< long double, DIM > & a)
inline

Definition at line 990 of file aDiff.h.

991{
992 return llround(a);
993}

References llround().

+ Here is the call graph for this function:

◆ llroundl() [2/2]

long long olb::util::llroundl ( long double arg)
inline

Definition at line 1532 of file omath.h.

1532{ return std::llroundl(arg); }

◆ log() [1/3]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::log ( const ADf< T, DIM > & a)
inline

Definition at line 475 of file aDiff.h.

476{
477 ADf<T,DIM> c(std::log(a._v), a._d);
478 T tmp (T(1)/a._v);
479 c._d*=tmp;
480 return c;
481}
+ Here is the caller graph for this function:

◆ log() [2/3]

template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > olb::util::log ( T arg)
inline

Definition at line 301 of file omath.h.

302{
303#ifdef __CUDA_ARCH__
304 return ::log(arg);
305#else //__CUDA_ARCH__
306 return std::log(arg);
307#endif //__CUDA_ARCH__
308}

◆ log() [3/3]

template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > olb::util::log ( T x)
inline

Definition at line 282 of file omath.h.

283{
284#ifdef __CUDA_ARCH__
285 if constexpr (std::is_same_v<T, float>) {
286 return ::logf(x);
287 }
288 else if constexpr (std::is_same_v<T, double>) {
289 return ::log(x);
290 }
291 else {
292 return ::log(static_cast<double>(x));
293 //libcu++ of cuda supports double and float. You will get warning in device code if you use in e.g. long double.
294 }
295#else //__CUDA_ARCH__
296 return std::log(x);
297#endif //__CUDA_ARCH__
298}

◆ log10() [1/3]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::log10 ( const ADf< T, DIM > & a)
inline

Definition at line 496 of file aDiff.h.

497{
498 ADf<T,DIM> c(std::log10(a._v), a._d);
499 T tmp (T(1)/(a._v*std::log(T(10))));
500 c._d*=tmp;
501 return c;
502}
+ Here is the caller graph for this function:

◆ log10() [2/3]

template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > olb::util::log10 ( T arg)
inline

Definition at line 356 of file omath.h.

357{
358#ifdef __CUDA_ARCH__
359 return ::log10(arg);
360#else //__CUDA_ARCH__
361 return std::log10(arg);
362#endif //__CUDA_ARCH__
363}

◆ log10() [3/3]

template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > olb::util::log10 ( T x)
inline

Definition at line 337 of file omath.h.

338{
339#ifdef __CUDA_ARCH__
340 if constexpr (std::is_same_v<T, float>) {
341 return ::log10f(x);
342 }
343 else if constexpr (std::is_same_v<T, double>) {
344 return ::log10(x);
345 }
346 else {
347 return ::log10(static_cast<double>(x));
348 //libcu++ of cuda supports double and float. You will get warning in device code if you use in e.g. long double.
349 }
350#else //__CUDA_ARCH__
351 return std::log10(x);
352#endif //__CUDA_ARCH__
353}

◆ log10f() [1/3]

template<unsigned DIM>
ADf< float, DIM > olb::util::log10f ( const ADf< float, DIM > & a)
inline

Definition at line 505 of file aDiff.h.

506{
507 return log10(a);
508}
ADf< T, DIM > log10(const ADf< T, DIM > &a)
Definition aDiff.h:496

References log10().

+ Here is the call graph for this function:

◆ log10f() [2/3]

any_platform float olb::util::log10f ( float arg)
inline

Definition at line 365 of file omath.h.

366{
367#ifdef __CUDA_ARCH__
368 return ::log10f(arg);
369#else //__CUDA_ARCH__
370 return std::log10(arg);
371#endif //__CUDA_ARCH__
372}

◆ log10f() [3/3]

any_platform float olb::util::log10f ( int arg)
inline

Definition at line 374 of file omath.h.

375{
376#ifdef __CUDA_ARCH__
377 return ::log10f(arg);
378#else //__CUDA_ARCH__
379 return std::log10(arg);
380#endif //__CUDA_ARCH__
381}

◆ log10l() [1/2]

template<unsigned DIM>
ADf< long double, DIM > olb::util::log10l ( const ADf< long double, DIM > & a)
inline

Definition at line 511 of file aDiff.h.

512{
513 return log10(a);
514}

References log10().

+ Here is the call graph for this function:

◆ log10l() [2/2]

long double olb::util::log10l ( long double arg)
inline

Definition at line 383 of file omath.h.

384{
385 return log10(arg);
386 //libcu++ of cuda dose not support long double. You will get warning in device code if you use.
387}

References log10().

+ Here is the call graph for this function:

◆ log1p() [1/3]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::log1p ( const ADf< T, DIM > & a)
inline

Definition at line 538 of file aDiff.h.

539{
540 return log(a+T(1));
541}

References log().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ log1p() [2/3]

template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > olb::util::log1p ( T arg)
inline

Definition at line 465 of file omath.h.

466{
467#ifdef __CUDA_ARCH__
468 return ::log1p(arg);
469#else //__CUDA_ARCH__
470 return std::log1p(arg);
471#endif //__CUDA_ARCH__
472}

◆ log1p() [3/3]

template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > olb::util::log1p ( T x)
inline

Definition at line 446 of file omath.h.

447{
448#ifdef __CUDA_ARCH__
449 if constexpr (std::is_same_v<T, float>) {
450 return ::log1pf(x);
451 }
452 else if constexpr (std::is_same_v<T, double>) {
453 return ::log1p(x);
454 }
455 else {
456 return ::log1p(static_cast<double>(x));
457 //libcu++ of cuda supports double and float. You will get warning in device code if you use in e.g. long double.
458 }
459#else //__CUDA_ARCH__
460 return std::log1p(x);
461#endif //__CUDA_ARCH__
462}

◆ log1pf() [1/3]

template<unsigned DIM>
ADf< float, DIM > olb::util::log1pf ( const ADf< float, DIM > & a)
inline

Definition at line 544 of file aDiff.h.

545{
546 return log1p(a);
547}
ADf< T, DIM > log1p(const ADf< T, DIM > &a)
Definition aDiff.h:538

References log1p().

+ Here is the call graph for this function:

◆ log1pf() [2/3]

any_platform float olb::util::log1pf ( float arg)
inline

Definition at line 474 of file omath.h.

475{
476#ifdef __CUDA_ARCH__
477 return ::log1pf(arg);
478#else //__CUDA_ARCH__
479 return std::log1p(arg);
480#endif //__CUDA_ARCH__
481}

◆ log1pf() [3/3]

any_platform float olb::util::log1pf ( int arg)
inline

Definition at line 483 of file omath.h.

484{
485#ifdef __CUDA_ARCH__
486 return ::log1pf(arg);
487#else //__CUDA_ARCH__
488 return std::log1p(arg);
489#endif //__CUDA_ARCH__
490}

◆ log1pl() [1/2]

template<unsigned DIM>
ADf< long double, DIM > olb::util::log1pl ( const ADf< long double, DIM > & a)
inline

Definition at line 550 of file aDiff.h.

551{
552 return log1p(a);
553}

References log1p().

+ Here is the call graph for this function:

◆ log1pl() [2/2]

long double olb::util::log1pl ( long double arg)
inline

Definition at line 492 of file omath.h.

493{
494 return log1p(arg);
495 //libcu++ of cuda dose not support long double. You will get warning in device code if you use.
496}

References log1p().

+ Here is the call graph for this function:

◆ log2() [1/3]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::log2 ( const ADf< T, DIM > & a)
inline

Definition at line 517 of file aDiff.h.

518{
519 ADf<T,DIM> c(std::log2(a._v), a._d);
520 T tmp (T(1)/(a._v*std::log(T(2))));
521 c._d*=tmp;
522 return c;
523}
+ Here is the caller graph for this function:

◆ log2() [2/3]

template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > olb::util::log2 ( T arg)
inline

Definition at line 411 of file omath.h.

412{
413#ifdef __CUDA_ARCH__
414 return ::log2(arg);
415#else //__CUDA_ARCH__
416 return std::log2(arg);
417#endif //__CUDA_ARCH__
418}

◆ log2() [3/3]

template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > olb::util::log2 ( T x)
inline

Definition at line 392 of file omath.h.

393{
394#ifdef __CUDA_ARCH__
395 if constexpr (std::is_same_v<T, float>) {
396 return ::log2f(x);
397 }
398 else if constexpr (std::is_same_v<T, double>) {
399 return ::log2(x);
400 }
401 else {
402 return ::log2(static_cast<double>(x));
403 //libcu++ of cuda supports double and float. You will get warning in device code if you use in e.g. long double.
404 }
405#else //__CUDA_ARCH__
406 return std::log2(x);
407#endif //__CUDA_ARCH__
408}

◆ log2f() [1/3]

template<unsigned DIM>
ADf< float, DIM > olb::util::log2f ( const ADf< float, DIM > & a)
inline

Definition at line 526 of file aDiff.h.

527{
528 return log2(a);
529}
ADf< T, DIM > log2(const ADf< T, DIM > &a)
Definition aDiff.h:517

References log2().

+ Here is the call graph for this function:

◆ log2f() [2/3]

any_platform float olb::util::log2f ( float arg)
inline

Definition at line 420 of file omath.h.

421{
422#ifdef __CUDA_ARCH__
423 return ::log2f(arg);
424#else //__CUDA_ARCH__
425 return std::log2(arg);
426#endif //__CUDA_ARCH__
427}

◆ log2f() [3/3]

any_platform float olb::util::log2f ( int arg)
inline

Definition at line 429 of file omath.h.

430{
431#ifdef __CUDA_ARCH__
432 return ::log2f(arg);
433#else //__CUDA_ARCH__
434 return std::log2(arg);
435#endif //__CUDA_ARCH__
436}

◆ log2l() [1/2]

template<unsigned DIM>
ADf< long double, DIM > olb::util::log2l ( const ADf< long double, DIM > & a)
inline

Definition at line 532 of file aDiff.h.

533{
534 return log2(a);
535}

References log2().

+ Here is the call graph for this function:

◆ log2l() [2/2]

long double olb::util::log2l ( long double arg)
inline

Definition at line 438 of file omath.h.

439{
440 return log2(arg);
441 //libcu++ of cuda dose not support long double. You will get warning in device code if you use.
442}

References log2().

+ Here is the call graph for this function:

◆ logf() [1/3]

template<unsigned DIM>
ADf< float, DIM > olb::util::logf ( const ADf< float, DIM > & a)
inline

Definition at line 484 of file aDiff.h.

485{
486 return log(a);
487}

References log().

+ Here is the call graph for this function:

◆ logf() [2/3]

any_platform float olb::util::logf ( float arg)
inline

Definition at line 310 of file omath.h.

311{
312#ifdef __CUDA_ARCH__
313 return ::logf(arg);
314#else //__CUDA_ARCH__
315 return std::log(arg);
316#endif //__CUDA_ARCH__
317}

◆ logf() [3/3]

any_platform float olb::util::logf ( int arg)
inline

Definition at line 319 of file omath.h.

320{
321#ifdef __CUDA_ARCH__
322 return ::logf(arg);
323#else //__CUDA_ARCH__
324 return std::log(arg);
325#endif //__CUDA_ARCH__
326}

◆ logl() [1/2]

template<unsigned DIM>
ADf< long double, DIM > olb::util::logl ( const ADf< long double, DIM > & a)
inline

Definition at line 490 of file aDiff.h.

491{
492 return log(a);
493}

References log().

+ Here is the call graph for this function:

◆ logl() [2/2]

long double olb::util::logl ( long double arg)
inline

Definition at line 328 of file omath.h.

329{
330 return log(arg);
331 //cuda dose not support this function.
332}

References log().

+ Here is the call graph for this function:

◆ lround() [1/2]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::lround ( const ADf< T, DIM > & a)
inline

Definition at line 957 of file aDiff.h.

958{
959#ifdef AdWarnings
960 std::cout << "ADf WARNING: ADf does not support integer types. Using round() instead." << std::endl;
961#endif
962 return round(a);
963}
constexpr Vector< T, D > round(const ScalarVector< T, D, IMPL > &a) any_platform
Definition vector.h:302

References round().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lround() [2/2]

template<typename T >
std::enable_if_t< std::is_arithmetic_v< T >, long > olb::util::lround ( T arg)
inline

Definition at line 1515 of file omath.h.

1516{
1517 return std::lround(arg);
1518}

◆ lroundf() [1/2]

template<unsigned DIM>
ADf< float, DIM > olb::util::lroundf ( const ADf< float, DIM > & a)
inline

Definition at line 966 of file aDiff.h.

967{
968 return lround(a);
969}

References lround().

+ Here is the call graph for this function:

◆ lroundf() [2/2]

long olb::util::lroundf ( float arg)
inline

Definition at line 1520 of file omath.h.

1520{ return std::lroundf(arg); }

◆ lroundl() [1/2]

template<unsigned DIM>
ADf< long double, DIM > olb::util::lroundl ( const ADf< long double, DIM > & a)
inline

Definition at line 972 of file aDiff.h.

973{
974 return lround(a);
975}

References lround().

+ Here is the call graph for this function:

◆ lroundl() [2/2]

long olb::util::lroundl ( long double arg)
inline

Definition at line 1522 of file omath.h.

1522{ return std::lroundl(arg); }

◆ matrixMatrixProduct()

template<typename T , unsigned D>
Vector< T, utilities::dimensions::convert< D >::matrix > olb::util::matrixMatrixProduct ( const Vector< T, utilities::dimensions::convert< D >::matrix > & A,
const Vector< T, utilities::dimensions::convert< D >::matrix > & B )

Compute C=AB for square matrices.

Definition at line 142 of file geometricOperations.h.

145{
147 for (unsigned i=0; i < D; ++i) {
148 for (unsigned j=0; j < D; ++j) {
149 for (unsigned k=0; k < D; ++k) {
150 C[i*D + j] += A[i*D + k] * B[k*D + j];
151 }
152 }
153 }
154 return C;
155}

◆ matrixVectorProduct()

template<typename T , unsigned D>
Vector< T, D > olb::util::matrixVectorProduct ( const Vector< T, utilities::dimensions::convert< D >::matrix > & M,
const Vector< T, D > & b )

Compute v=M b.

Definition at line 127 of file geometricOperations.h.

130{
131 return Vector<T,D>([&](unsigned iD) -> T {
132 T element{};
133 for (unsigned jD=0; jD < D; ++jD) {
134 element += M[iD*D + jD] * b[jD];
135 }
136 return element;
137 });
138}
+ Here is the caller graph for this function:

◆ max() [1/7]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::max ( const ADf< T, DIM > & a,
const ADf< T, DIM > & b )
inlineconstexpr

Definition at line 1056 of file aDiff.h.

1057{
1058 ADf<T,DIM> c((a + b + fabs(a - b) ) * T(0.5));
1059 return c;
1060}

References fabs().

+ Here is the call graph for this function:

◆ max() [2/7]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::max ( const ADf< T, DIM > & a,
const olb::BaseType< ADf< T, DIM > > & b )
inlineconstexpr

Definition at line 1048 of file aDiff.h.

1049{
1050 ADf<T,DIM> c(b);
1051 c = max(a, c);
1052 return c;
1053}

References max().

+ Here is the call graph for this function:

◆ max() [3/7]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::max ( const olb::BaseType< ADf< T, DIM > > & a,
const ADf< T, DIM > & b )
inlineconstexpr

Definition at line 1040 of file aDiff.h.

1041{
1042 ADf<T,DIM> c(a);
1043 c = max(c, b);
1044 return c;
1045}

References max().

+ Here is the call graph for this function:

◆ max() [4/7]

template<std::floating_point T>
cpu::simd::Pack< T > olb::util::max ( cpu::simd::Pack< T > rhs,
cpu::simd::Pack< T > lhs )

Definition at line 140 of file pack.h.

141{
142 return cpu::simd::max(rhs, lhs);
143}

References olb::cpu::simd::max().

+ Here is the call graph for this function:

◆ max() [5/7]

Expr olb::util::max ( Expr a,
Expr b )

Definition at line 245 of file expr.cpp.

245 {
246 throw std::domain_error("Invalid operator for Expr type: 'max'");
247}
+ Here is the caller graph for this function:

◆ max() [6/7]

template<typename T >
T olb::util::max ( std::initializer_list< T > ilist)
constexpr

Definition at line 48 of file oalgorithm.h.

48 {
49 return std::max(ilist);
50}

◆ max() [7/7]

template<typename T >
any_platform constexpr T olb::util::max ( T a,
meta::id_t< T > b )
constexpr

Definition at line 39 of file oalgorithm.h.

39 {
40#ifdef __CUDA_ARCH__
41 return ::max(a, b);
42#else
43 return std::max(a, b);
44#endif
45}

◆ max_element()

template<typename T , unsigned Size>
T olb::util::max_element ( const Vector< T, Size > & a)

finds maximum element of all elements

Definition at line 217 of file vectorHelpers.h.

218{
219 T max = a[0];
220 for (unsigned int iDim=1; iDim < Size; ++iDim) {
221 max = std::max(max,a[iDim]);
222 }
223 return max;
224}

References max().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ maxElementAbs()

template<typename T , unsigned Size>
T olb::util::maxElementAbs ( const Vector< T, Size > & a)

finds maximum element of all absolute elements

Definition at line 265 of file vectorHelpers.h.

266{
267 T maxAbs = a[0];
268 for (unsigned int iDim=1; iDim < Size; ++iDim) {
269 if (abs(a[iDim])>abs(maxAbs)){
270 maxAbs = a[iDim];
271 }
272 }
273 return maxAbs;
274}

References abs().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ maxElementAbsPos()

template<typename T , unsigned Size>
unsigned olb::util::maxElementAbsPos ( const Vector< T, Size > & a)

finds position of maximum element of all absolute elements

Definition at line 278 of file vectorHelpers.h.

279{
280 unsigned maxAbsPos = 0;
281 for (unsigned int iDim=1; iDim < Size; ++iDim) {
282 if (abs(a[iDim])>abs(a[maxAbsPos])){
283 maxAbsPos = iDim;
284 }
285 }
286 return maxAbsPos;
287}

References abs().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ maxElementPos()

template<typename T , unsigned Size>
unsigned olb::util::maxElementPos ( const Vector< T, Size > & a)

finds position of maximum element of all elements

Definition at line 239 of file vectorHelpers.h.

240{
241 unsigned maxPos = 0;
242 for (unsigned int iDim=1; iDim < Size; ++iDim) {
243 if (a[iDim]>a[maxPos]){
244 maxPos = iDim;
245 }
246 }
247 return maxPos;
248}

◆ min() [1/7]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::min ( const ADf< T, DIM > & a,
const ADf< T, DIM > & b )
inlineconstexpr

Definition at line 1079 of file aDiff.h.

1080{
1081 ADf<T,DIM> c((a + b - fabs(a - b) ) * T(0.5));
1082 return c;
1083}

References fabs().

+ Here is the call graph for this function:

◆ min() [2/7]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::min ( const ADf< T, DIM > & a,
const olb::BaseType< ADf< T, DIM > > & b )
inlineconstexpr

Definition at line 1071 of file aDiff.h.

1072{
1073 ADf<T,DIM> c(b);
1074 c = min(a, c);
1075 return c;
1076}

References min().

+ Here is the call graph for this function:

◆ min() [3/7]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::min ( const olb::BaseType< ADf< T, DIM > > & a,
const ADf< T, DIM > & b )
inlineconstexpr

Definition at line 1063 of file aDiff.h.

1064{
1065 ADf<T,DIM> c(a);
1066 c = min(c, b);
1067 return c;
1068}

References min().

+ Here is the call graph for this function:

◆ min() [4/7]

template<std::floating_point T>
cpu::simd::Pack< T > olb::util::min ( cpu::simd::Pack< T > rhs,
cpu::simd::Pack< T > lhs )

Definition at line 134 of file pack.h.

135{
136 return cpu::simd::min(rhs, lhs);
137}

References olb::cpu::simd::min().

+ Here is the call graph for this function:

◆ min() [5/7]

Expr olb::util::min ( Expr a,
Expr b )

Definition at line 249 of file expr.cpp.

249 {
250 throw std::domain_error("Invalid operator for Expr type: 'min'");
251}
+ Here is the caller graph for this function:

◆ min() [6/7]

template<typename T >
T olb::util::min ( std::initializer_list< T > ilist)
inlineconstexpr

Definition at line 65 of file oalgorithm.h.

65 {
66 return std::min(ilist);
67}

◆ min() [7/7]

template<typename T >
any_platform constexpr T olb::util::min ( T a,
meta::id_t< T > b )
constexpr

Definition at line 56 of file oalgorithm.h.

56 {
57#ifdef __CUDA_ARCH__
58 return ::min(a, b);
59#else
60 return std::min(a, b);
61#endif
62}

◆ min_element()

template<typename T , unsigned Size>
T olb::util::min_element ( const Vector< T, Size > & a)

finds minimum element of all elements

Definition at line 228 of file vectorHelpers.h.

229{
230 T min = a[0];
231 for (unsigned int iDim=1; iDim < Size; ++iDim) {
232 min = std::min(min,a[iDim]);
233 }
234 return min;
235}

References min().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ minElementPos()

template<typename T , unsigned Size>
unsigned olb::util::minElementPos ( const Vector< T, Size > & a)

finds position of minimum element of all elements

Definition at line 252 of file vectorHelpers.h.

253{
254 unsigned minPos = 0;
255 for (unsigned int iDim=1; iDim < Size; ++iDim) {
256 if (a[iDim]<a[minPos]){
257 minPos = iDim;
258 }
259 }
260 return minPos;
261}

◆ nearZero() [1/3]

template<class T , unsigned DIM>
bool olb::util::nearZero ( const ADf< T, DIM > & a)
inline

Definition at line 1087 of file aDiff.h.

1088{
1089 const T EPSILON = std::numeric_limits<T>::epsilon();
1090 if (a._v > -EPSILON && a._v < EPSILON) {
1091 return true;
1092 }
1093 else {
1094 return false;
1095 }
1096}

◆ nearZero() [2/3]

template<typename T >
bool olb::util::nearZero ( T a)
inline

return true if a is close to zero

Definition at line 402 of file util.h.

403{
404 if (a==T()) {
405 return true;
406 }
407 T EPSILON = std::numeric_limits<T>::epsilon();
408 if (a > -EPSILON && a < EPSILON) {
409 return true;
410 }
411 else {
412 return false;
413 }
414}
+ Here is the caller graph for this function:

◆ nearZero() [3/3]

template<typename T >
bool olb::util::nearZero ( T a,
T epsilon )
inline

Definition at line 417 of file util.h.

418{
419 if (a > -epsilon && a < epsilon) {
420 return true;
421 }
422 else {
423 return false;
424 }
425}

◆ norm() [1/3]

template<unsigned D, typename ARRAY_LIKE >
auto olb::util::norm ( const ARRAY_LIKE & u)

Definition at line 155 of file util.h.

156{
157 return sqrt(normSqr<ARRAY_LIKE,D>(u));
158}

References normSqr(), and sqrt().

+ Here is the call graph for this function:

◆ norm() [2/3]

template<typename T >
T olb::util::norm ( const std::vector< T > & a)

l2 norm of a vector of arbitrary length

Definition at line 122 of file vectorHelpers.h.

123{
124 return norm(a.data(), a.size());
125}

References norm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ norm() [3/3]

template<typename T >
T olb::util::norm ( const T * a,
unsigned size )

l2 norm of a vector of arbitrary length

Definition at line 115 of file vectorHelpers.h.

116{
117 return util::sqrt(norm2(a, size));
118}
T norm2(const T *a, unsigned size)
l2 norm to the power of 2 of a vector of arbitrary length

References norm2(), and sqrt().

+ Here is the call graph for this function:

◆ norm2() [1/2]

template<typename T >
T olb::util::norm2 ( const std::vector< T > & a)

l2 norm to the power of 2 of a vector of arbitrary length

Definition at line 108 of file vectorHelpers.h.

109{
110 return norm2(a.data(), a.size());
111}

References norm2().

+ Here is the call graph for this function:

◆ norm2() [2/2]

template<typename T >
T olb::util::norm2 ( const T * a,
unsigned size )

l2 norm to the power of 2 of a vector of arbitrary length

Definition at line 97 of file vectorHelpers.h.

98{
99 T v{};
100 for (unsigned iD=0; iD<size; ++iD) {
101 v += a[iD]*a[iD];
102 }
103 return v;
104}
+ Here is the caller graph for this function:

◆ normalize() [1/2]

template<typename T >
std::vector< T > olb::util::normalize ( const std::vector< T > & a)

returns a normalized vector, works for arbitrary lengths

Definition at line 160 of file vectorHelpers.h.

161{
162 std::vector<T> out(a);
163 T scale = norm(a);
164 assert(scale>0);
165 for (unsigned int iDim=0; iDim<a.size(); iDim++) {
166 out[iDim] /= scale;
167 }
168 return out;
169}

References norm().

+ Here is the call graph for this function:

◆ normalize() [2/2]

template<typename T , unsigned D>
Vector< T, D > olb::util::normalize ( const Vector< T, D > & a)

Definition at line 153 of file vectorHelpers.h.

154{
155 return a / norm(a);
156}

References norm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ normSqr() [1/4]

template<typename ARRAY_LIKE , unsigned D>
auto olb::util::normSqr ( const ARRAY_LIKE & u)

Compute norm square of a d-dimensional vector.

Definition at line 145 of file util.h.

146{
147 auto uSqr = decltype(u[0]){};
148 for (unsigned iD=0; iD < D; ++iD) {
149 uSqr += u[iD]*u[iD];
150 }
151 return uSqr;
152}
+ Here is the caller graph for this function:

◆ normSqr() [2/4]

template<typename T , unsigned D, typename IMPL >
T olb::util::normSqr ( const ScalarVector< T, D, IMPL > & u)

Compute norm square of a d-dimensional vector.

Definition at line 179 of file util.h.

180{
181 T uSqr = T();
182 for (unsigned iD=0; iD < D; ++iD) {
183 uSqr += u[iD]*u[iD];
184 }
185 return uSqr;
186}

◆ normSqr() [3/4]

template<typename T , unsigned D>
T olb::util::normSqr ( const T * u)

Definition at line 161 of file util.h.

162{
163 auto uSqr = T{};
164 for (unsigned iD=0; iD < D; ++iD) {
165 uSqr += u[iD]*u[iD];
166 }
167 return uSqr;
168}

◆ normSqr() [4/4]

template<typename T >
T olb::util::normSqr ( std::initializer_list< T > data)

Definition at line 171 of file util.h.

172{
173 return std::inner_product(data.begin(), data.end(), data.begin(), T(0));
174}

◆ operator!=() [1/3]

template<class T , unsigned DIM>
bool olb::util::operator!= ( const ADf< T, DIM > & a,
const ADf< T, DIM > & b )
inlineconstexpr

Definition at line 762 of file aDiff.h.

763{
764 return a._v!=b._v;
765}

◆ operator!=() [2/3]

template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
bool olb::util::operator!= ( const ADf< T, DIM > & a,
const U & b )
inlineconstexpr

Definition at line 768 of file aDiff.h.

769{
770 return a._v!=olb::BaseType<ADf<T,DIM>>(b);
771}

◆ operator!=() [3/3]

template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
bool olb::util::operator!= ( const U & a,
const ADf< T, DIM > & b )
inlineconstexpr

Definition at line 774 of file aDiff.h.

775{
776 return olb::BaseType<ADf<T,DIM>>(a)!=b._v;
777}

◆ operator*() [1/3]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::operator* ( const ADf< T, DIM > & a,
const ADf< T, DIM > & b )
inlineconstexpr

Definition at line 349 of file aDiff.h.

350{
351 return ADf<T,DIM>(a) *= b;
352}

◆ operator*() [2/3]

template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
ADf< T, DIM > olb::util::operator* ( const ADf< T, DIM > & a,
const U & b )
inlineconstexpr

Definition at line 343 of file aDiff.h.

344{
345 return ADf<T,DIM>(a) *= olb::BaseType<ADf<T,DIM>>(b);
346}

◆ operator*() [3/3]

template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
ADf< T, DIM > olb::util::operator* ( const U & a,
const ADf< T, DIM > & b )
inlineconstexpr

Definition at line 337 of file aDiff.h.

338{
339 return ADf<T,DIM>(b) *= olb::BaseType<ADf<T,DIM>>(a);
340}

◆ operator+() [1/4]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::operator+ ( const ADf< T, DIM > & a)
inlineconstexpr

Definition at line 375 of file aDiff.h.

376{
377 return ADf<T,DIM>(a);
378}

◆ operator+() [2/4]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::operator+ ( const ADf< T, DIM > & a,
const ADf< T, DIM > & b )
inlineconstexpr

Definition at line 313 of file aDiff.h.

314{
315 return ADf<T,DIM>(a) += b;
316}

◆ operator+() [3/4]

template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
ADf< T, DIM > olb::util::operator+ ( const ADf< T, DIM > & a,
const U & b )
inlineconstexpr

Definition at line 307 of file aDiff.h.

308{
309 return ADf<T,DIM>(a) += olb::BaseType<ADf<T,DIM>>(b);
310}

◆ operator+() [4/4]

template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
ADf< T, DIM > olb::util::operator+ ( const U & a,
const ADf< T, DIM > & b )
inlineconstexpr

Definition at line 301 of file aDiff.h.

302{
303 return ADf<T,DIM>(b) += olb::BaseType<ADf<T,DIM>>(a);
304}

◆ operator-() [1/4]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::operator- ( const ADf< T, DIM > & a)
inlineconstexpr

Definition at line 381 of file aDiff.h.

382{
383 return ADf<T,DIM>(a) *= -1;
384}

◆ operator-() [2/4]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::operator- ( const ADf< T, DIM > & a,
const ADf< T, DIM > & b )
inlineconstexpr

Definition at line 331 of file aDiff.h.

332{
333 return ADf<T,DIM>(a)-=b;
334}

◆ operator-() [3/4]

template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
ADf< T, DIM > olb::util::operator- ( const ADf< T, DIM > & a,
const U & b )
inlineconstexpr

Definition at line 325 of file aDiff.h.

326{
327 return ADf<T,DIM>(a) -= olb::BaseType<ADf<T,DIM>>(b);
328}

◆ operator-() [4/4]

template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
ADf< T, DIM > olb::util::operator- ( const U & a,
const ADf< T, DIM > & b )
inlineconstexpr

Definition at line 319 of file aDiff.h.

320{
322}

◆ operator/() [1/3]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::operator/ ( const ADf< T, DIM > & a,
const ADf< T, DIM > & b )
inlineconstexpr

Definition at line 368 of file aDiff.h.

369{
370 return ADf<T,DIM>(a) /= b;
371}

◆ operator/() [2/3]

template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
ADf< T, DIM > olb::util::operator/ ( const ADf< T, DIM > & a,
const U & b )
inlineconstexpr

Definition at line 361 of file aDiff.h.

362{
363 return ADf<T,DIM>(a) /= olb::BaseType<ADf<T,DIM>>(b);
364}

◆ operator/() [3/3]

template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
ADf< T, DIM > olb::util::operator/ ( const U & a,
const ADf< T, DIM > & b )
inlineconstexpr

Definition at line 355 of file aDiff.h.

356{
357 return ADf<T,DIM>(a) /= b;
358}

◆ operator<() [1/3]

template<class T , unsigned DIM>
bool olb::util::operator< ( const ADf< T, DIM > & a,
const ADf< T, DIM > & b )
inlineconstexpr

Definition at line 818 of file aDiff.h.

819{
820 return a._v<b._v;
821}

◆ operator<() [2/3]

template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
bool olb::util::operator< ( const ADf< T, DIM > & a,
const U & b )
inlineconstexpr

Definition at line 824 of file aDiff.h.

825{
826 return a._v<olb::BaseType<ADf<T,DIM>>(b);
827}

◆ operator<() [3/3]

template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
bool olb::util::operator< ( const U & a,
const ADf< T, DIM > & b )
inlineconstexpr

Definition at line 830 of file aDiff.h.

831{
832 return olb::BaseType<ADf<T,DIM>>(a)<b._v;
833}

◆ operator<<()

template<class T , unsigned DIM>
std::ostream & olb::util::operator<< ( std::ostream & os,
const ADf< T, DIM > & o )
inline

Definition at line 277 of file aDiff.h.

278{
279 os << o._v;
280 if constexpr (DIM>0) {
281 os << o._d;
282 }
283 return os;
284}

◆ operator<=() [1/3]

template<class T , unsigned DIM>
bool olb::util::operator<= ( const ADf< T, DIM > & a,
const ADf< T, DIM > & b )
inlineconstexpr

Definition at line 836 of file aDiff.h.

837{
838 return a._v<=b._v;
839}

◆ operator<=() [2/3]

template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
bool olb::util::operator<= ( const ADf< T, DIM > & a,
const U & b )
inlineconstexpr

Definition at line 842 of file aDiff.h.

843{
844 return a._v<=olb::BaseType<ADf<T,DIM>>(b);
845}

◆ operator<=() [3/3]

template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
bool olb::util::operator<= ( const U & a,
const ADf< T, DIM > & b )
inlineconstexpr

Definition at line 848 of file aDiff.h.

849{
850 return olb::BaseType<ADf<T,DIM>>(a)<=b._v;
851}

◆ operator==() [1/3]

template<class T , unsigned DIM>
bool olb::util::operator== ( const ADf< T, DIM > & a,
const ADf< T, DIM > & b )
inlineconstexpr

Definition at line 744 of file aDiff.h.

745{
746 return a._v==b._v;
747}

◆ operator==() [2/3]

template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
bool olb::util::operator== ( const ADf< T, DIM > & a,
const U & b )
inlineconstexpr

Definition at line 750 of file aDiff.h.

751{
752 return a._v==olb::BaseType<ADf<T,DIM>>(b);
753}

◆ operator==() [3/3]

template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
bool olb::util::operator== ( const U & a,
const ADf< T, DIM > & b )
inlineconstexpr

Definition at line 756 of file aDiff.h.

757{
758 return olb::BaseType<ADf<T,DIM>>(a)==b._v;
759}

◆ operator>() [1/3]

template<class T , unsigned DIM>
bool olb::util::operator> ( const ADf< T, DIM > & a,
const ADf< T, DIM > & b )
inlineconstexpr

Definition at line 781 of file aDiff.h.

782{
783 return a._v>b._v;
784}

◆ operator>() [2/3]

template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
bool olb::util::operator> ( const ADf< T, DIM > & a,
const U & b )
inlineconstexpr

Definition at line 787 of file aDiff.h.

788{
789 return a._v>olb::BaseType<ADf<T,DIM>>(b);
790}

◆ operator>() [3/3]

template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
bool olb::util::operator> ( const U & a,
const ADf< T, DIM > & b )
inlineconstexpr

Definition at line 793 of file aDiff.h.

794{
795 return olb::BaseType<ADf<T,DIM>>(a)>b._v;
796}

◆ operator>=() [1/3]

template<class T , unsigned DIM>
bool olb::util::operator>= ( const ADf< T, DIM > & a,
const ADf< T, DIM > & b )
inlineconstexpr

Definition at line 799 of file aDiff.h.

800{
801 return a._v>=b._v;
802}

◆ operator>=() [2/3]

template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
bool olb::util::operator>= ( const ADf< T, DIM > & a,
const U & b )
inlineconstexpr

Definition at line 805 of file aDiff.h.

806{
807 return a._v>=olb::BaseType<ADf<T,DIM>>(b);
808}

◆ operator>=() [3/3]

template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
bool olb::util::operator>= ( const U & a,
const ADf< T, DIM > & b )
inlineconstexpr

Definition at line 811 of file aDiff.h.

812{
813 return olb::BaseType<ADf<T,DIM>>(a)>=b._v;
814}

◆ operator>>()

template<class T , unsigned DIM>
std::istream & olb::util::operator>> ( std::istream & is,
ADf< T, DIM > & in )
inline

Definition at line 288 of file aDiff.h.

289{
290 is >> in._v;
291 in._d = T{0};
292 return is;
293}

◆ populationsContributingToDirection()

template<typename DESCRIPTOR , int... NORMAL>
auto olb::util::populationsContributingToDirection ( )
constexpr

Return array of population indices where c[iPop][iD] == NORMAL[iD].

Definition at line 232 of file util.h.

232 {
233 constexpr auto velocity_matches_direction = [](unsigned iPop) -> bool {
234 return meta::indexed_pack_contains<NORMAL...>([iPop](unsigned iD, int x) -> bool {
235 return x != 0 && x == descriptors::c<DESCRIPTOR>(iPop,iD);
236 });
237 };
238 return meta::array_from_index_sequence(
239 descriptors::filter_population_indices<DESCRIPTOR>(velocity_matches_direction));
240};

References olb::meta::array_from_index_sequence(), olb::descriptors::c(), olb::descriptors::filter_population_indices(), and olb::meta::indexed_pack_contains().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populationsContributingToVelocity()

template<typename DESCRIPTOR , unsigned iVel, int value>
auto olb::util::populationsContributingToVelocity ( )
constexpr

Return array of population indices where c[iVel] == value.

Definition at line 222 of file util.h.

222 {
223 constexpr auto velocity_matches_value = [](unsigned iPop) -> bool {
224 return descriptors::c<DESCRIPTOR>(iPop,iVel) == value;
225 };
226 return meta::array_from_index_sequence(
227 descriptors::filter_population_indices<DESCRIPTOR>(velocity_matches_value));
228};

References olb::meta::array_from_index_sequence(), olb::descriptors::c(), and olb::descriptors::filter_population_indices().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pow() [1/9]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::pow ( const ADf< T, DIM > & a,
const ADf< T, DIM > & b )
inline

Definition at line 415 of file aDiff.h.

416{
417 if (!util::nearZero(a._v)) {
418 return exp(b*log(a));
419 }
420 else {
421 ADf<T,DIM> c(std::pow(a._v, b._v), Vector<T,DIM> {std::numeric_limits<T>::quiet_NaN()});
422#ifdef AdWarnings
423 std::cout << "ADf WARNING: pow(Adf) - pow evaluated at non-differentiable point" << std::endl;
424#endif
425 if (std::isfinite(c._v)) {
426 for (unsigned i = 0; i < DIM; ++i) {
427 if (util::nearZero(a.d(i))) {
428 c._d[i] = T(0);
429 }
430 }
431 }
432 return c;
433 }
434}
platform_constant int c[Q][D]
Definition functions.h:57

References exp(), log(), and nearZero().

+ Here is the call graph for this function:

◆ pow() [2/9]

template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
ADf< T, DIM > olb::util::pow ( const ADf< T, DIM > & a,
const U & b )
inline

Definition at line 405 of file aDiff.h.

406{
407 ADf<T,DIM> c(std::pow(a._v,T(b)), a._d);
408 T tmp(T(b)*std::pow(a._v,b-T(1)));
409 c._d*=tmp;
410 return c;
411}

◆ pow() [3/9]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::pow ( const ADf< T, DIM > & a,
int b )
inline

Definition at line 437 of file aDiff.h.

438{
439 ADf<T,DIM> c(std::pow(a._v,b), a._d);
440 T tmp(b*std::pow(a._v, b-1));
441 c._d*=tmp;
442 return c;
443}

◆ pow() [4/9]

template<class T , unsigned DIM, typename U , typename std::enable_if< std::is_integral< U >::value|std::is_floating_point< U >::value, int >::type = 0>
ADf< T, DIM > olb::util::pow ( const U & a,
const ADf< T, DIM > & b )
inline

Definition at line 396 of file aDiff.h.

397{
398 ADf<T,DIM> c(std::pow(T(a),b._v), b._d);
399 T tmp(c._v*std::log(T(a)));
400 c._d*=tmp;
401 return c;
402}

◆ pow() [5/9]

template<std::floating_point T>
cpu::simd::Pack< T > olb::util::pow ( cpu::simd::Pack< T > base,
cpu::simd::Pack< T > exp )

Definition at line 122 of file pack.h.

123{
124 return cpu::simd::pow(base, exp);
125}

References exp(), and olb::cpu::simd::pow().

+ Here is the call graph for this function:

◆ pow() [6/9]

template<std::floating_point T, cpu::simd::concepts::convertible_to_pack S>
cpu::simd::Pack< T > olb::util::pow ( cpu::simd::Pack< T > base,
S exp )

Definition at line 128 of file pack.h.

129{
130 return cpu::simd::pow(base, cpu::simd::Pack<T>(exp));
131}

References exp(), and olb::cpu::simd::pow().

+ Here is the call graph for this function:

◆ pow() [7/9]

Expr olb::util::pow ( Expr base,
Expr exp )

Definition at line 235 of file expr.cpp.

235 {
236 Expr::increment(Expr::Op::Pow);
237 return Expr(base, Expr::Op::Pow, exp);
238}

References exp(), olb::Expr::increment(), and olb::Expr::Pow.

+ Here is the call graph for this function:

◆ pow() [8/9]

template<typename T , typename S >
any_platform std::enable_if_t< std::is_integral_v< T > &&std::is_integral_v< S >, double > olb::util::pow ( T x,
S y )
inline

Definition at line 105 of file omath.h.

106{
107#ifdef __CUDA_ARCH__
108 return ::pow(x, y);
109#else //__CUDA_ARCH__
110 return std::pow(x, y);
111#endif //__CUDA_ARCH__
112}

◆ pow() [9/9]

template<typename T , typename S >
any_platform auto olb::util::pow ( T x,
S y ) -> std::enable_if_t<std::is_floating_point_v<T> && std::is_floating_point_v<S>, decltype(std::pow(x, y))>
inline

Definition at line 40 of file omath.h.

44{
45#ifdef __CUDA_ARCH__
46 if constexpr (std::is_same_v<T, float> && std::is_same_v<S, float>) {
47 return ::powf(x, y);
48 }
49 else if constexpr (std::is_same_v<T, double> && std::is_same_v<S, double>) {
50 return ::pow(x, y);
51 }
52 else {
53 return ::pow(static_cast<double>(x), static_cast<double>(y));
54 //libcu++ of cuda supports double and float. You will get warning in device code if you use in e.g. long double.
55 }
56#else // __CUDA_ARCH__
57 return std::pow(x, y);
58#endif // __CUDA_ARCH__
59}

◆ powf() [1/2]

any_platform float olb::util::powf ( float base,
float exp )
inline

Definition at line 114 of file omath.h.

115{
116#ifdef __CUDA_ARCH__
117 return ::powf(base, exp);
118#else //__CUDA_ARCH__
119 return std::pow(base, exp);
120#endif //__CUDA_ARCH__
121}

References exp().

+ Here is the call graph for this function:

◆ powf() [2/2]

any_platform float olb::util::powf ( int base,
int exp )
inline

Definition at line 123 of file omath.h.

124{
125#ifdef __CUDA_ARCH__
126 return ::powf(base, exp);
127#else //__CUDA_ARCH__
128 return std::pow(base, exp);
129#endif //__CUDA_ARCH__
130}

References exp().

+ Here is the call graph for this function:

◆ powl()

long double olb::util::powl ( long double base,
long double exp )
inline

Definition at line 132 of file omath.h.

133{
134 return pow(base, exp);
135 //cuda dose not support this function.
136}

References exp(), and pow().

+ Here is the call graph for this function:

◆ pressureFromDensity()

template<typename T , typename DESCRIPTOR >
any_platform T olb::util::pressureFromDensity ( T latticeDensity)

compute lattice pressure from lattice density

Definition at line 394 of file util.h.

395{
396 // p = (rho - 1) * c_s^2
397 return (latticeDensity - 1.0) / descriptors::invCs2<T,DESCRIPTOR>();
398}

References olb::descriptors::invCs2().

+ Here is the call graph for this function:

◆ print()

template<typename U >
void olb::util::print ( U data,
const std::string & name = "",
OstreamManager clout = OstreamManager(std::cout,"print"),
const char delimiter = ',' )

Definition at line 431 of file vectorHelpers.h.

433{
434 static_assert(!std::is_integral<U>::value && !std::is_floating_point<U>::value, "passed integral or floating_point value to function print()");
435 if (name != "") {
436 clout << name << " = ";
437 }
438 for ( auto& element : data ) {
439 clout << std::fixed << element << delimiter << ' ';
440 }
441 clout << std::endl;
442}
+ Here is the caller graph for this function:

◆ radianToDegree() [1/2]

template<typename T , unsigned D>
decltype(Vector< decltype(util::sqrt(T())), D >()) olb::util::radianToDegree ( const Vector< T, D > & angle)

Definition at line 56 of file geometricOperations.h.

57{
58 constexpr BaseType<decltype(util::sqrt(T()))> conversionFactor = 180. / M_PI;
59 return conversionFactor * angle;
60}

References M_PI, and sqrt().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ radianToDegree() [2/2]

template<typename T >
decltype(util::sqrt(T())) olb::util::radianToDegree ( T angle)

Definition at line 63 of file geometricOperations.h.

64{
65 return radianToDegree(Vector<T, 1>(angle))[0];
66}
decltype(Vector< decltype(util::sqrt(T())), D >()) radianToDegree(const Vector< T, D > &angle)

References radianToDegree().

+ Here is the call graph for this function:

◆ remainingIndexes()

template<typename DESCRIPTORBASE >
std::vector< int > olb::util::remainingIndexes ( const std::vector< int > & indices)

finds all the remaining indexes of a lattice given some other indexes

Definition at line 339 of file util.h.

340{
341 std::vector<int> remaining;
342 for (int iPop = 0; iPop < DESCRIPTORBASE::q; ++iPop) {
343 bool found = false;
344 for (unsigned jPop = 0; jPop < indices.size(); ++jPop) {
345 if (indices[jPop] == iPop) {
346 found = true;
347 }
348 }
349 if (!found) {
350 remaining.push_back(iPop);
351 }
352 }
353 return remaining;
354}

◆ rotateMofi()

template<typename T >
Matrix< T, 3, 3 > olb::util::rotateMofi ( const Vector< T, 3 > & mofi,
const Vector< T, 9 > & rotationMatrix )
constexpr

Rotate moment of inertia (mofi)

Definition at line 261 of file geometricOperations.h.

263{
264 // I' = R(angle) * I * R(angle)^T
265 // TODO: The inertia tensor is symmetric - make use of it
266 T data[3][3] = {
267 {mofi[0], T {}, T {}},
268 { T {}, mofi[1], T {}},
269 { T {}, T {}, mofi[2]}
270 };
271 Matrix<T, 3, 3> inertiaTensor(data);
272 const Matrix<T, 3, 3> _rotationMatrix(rotationMatrix);
273 inertiaTensor =
274 _rotationMatrix * inertiaTensor * (_rotationMatrix.transpose());
275
276 return inertiaTensor;
277}

References olb::Matrix< T, ROWS, COLS >::transpose().

+ Here is the call graph for this function:

◆ round() [1/3]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::round ( const ADf< T, DIM > & a)
inline

Definition at line 928 of file aDiff.h.

929{
930 ADf<T,DIM> c (std::round(a._v));
931 constexpr T EPSILON (std::numeric_limits<T>::epsilon());
932 if (std::round(a._v - EPSILON) != std::round(a._v + EPSILON)) {
933#ifdef AdWarnings
934 std::cout << "ADf WARNING: round(Adf) - round evaluated at non-differentiable point" << std::endl;
935#endif
936 for (unsigned i = 0; i < DIM; ++i) {
937 c._d[i] = (a.d(i) == 0) ? T(0) : std::numeric_limits<T>::quiet_NaN();
938 }
939 }
940 return c;
941}
+ Here is the caller graph for this function:

◆ round() [2/3]

template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > olb::util::round ( T x)
inline

Definition at line 1480 of file omath.h.

1481{
1482#ifdef __CUDA_ARCH__
1483 if constexpr (std::is_same_v<T, float>) {
1484 return ::roundf(x);
1485 }
1486 else if constexpr (std::is_same_v<T, double>) {
1487 return ::round(x);
1488 }
1489 else {
1490 return ::round(static_cast<double>(x));
1491 //libcu++ of cuda supports double and float. You will get warning in device code if you use in e.g. long double.
1492 }
1493#else //__CUDA_ARCH__
1494 return std::round(x);
1495#endif //__CUDA_ARCH__
1496}

◆ round() [3/3]

template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > olb::util::round ( T x)
inline

Definition at line 1499 of file omath.h.

1500{
1501#ifdef __CUDA_ARCH__
1502 return ::round(x);
1503#else //__CUDA_ARCH__
1504 return std::round(x);
1505#endif //__CUDA_ARCH__
1506}

◆ roundf() [1/3]

template<unsigned DIM>
ADf< float, DIM > olb::util::roundf ( const ADf< float, DIM > & a)
inline

Definition at line 944 of file aDiff.h.

945{
946 return round(a);
947}

References round().

+ Here is the call graph for this function:

◆ roundf() [2/3]

any_platform float olb::util::roundf ( float x)
inline

Definition at line 1461 of file omath.h.

1462{
1463#ifdef __CUDA_ARCH__
1464 return ::roundf(x);
1465#else //__CUDA_ARCH__
1466 return std::round(x);
1467#endif //__CUDA_ARCH__
1468}

◆ roundf() [3/3]

any_platform float olb::util::roundf ( int x)
inline

Definition at line 1470 of file omath.h.

1471{
1472#ifdef __CUDA_ARCH__
1473 return ::roundf(x);
1474#else //__CUDA_ARCH__
1475 return std::round(x);
1476#endif //__CUDA_ARCH__
1477}

◆ roundl() [1/2]

template<unsigned DIM>
ADf< long double, DIM > olb::util::roundl ( const ADf< long double, DIM > & a)
inline

Definition at line 950 of file aDiff.h.

951{
952 return round(a);
953}

References round().

+ Here is the call graph for this function:

◆ roundl() [2/2]

long double olb::util::roundl ( long double arg)
inline

Definition at line 1508 of file omath.h.

1509{
1510 return std::roundl(arg);
1511 //cuda dose not support this function.
1512}

◆ scalarProduct() [1/2]

template<typename T >
T olb::util::scalarProduct ( const std::vector< T > & u1,
const std::vector< T > & u2 )

Definition at line 203 of file util.h.

204{
205 T prod = T();
206 if (u1.size() == u2.size()) {
207 for (unsigned iD=0; iD<u1.size(); ++iD) {
208 prod += u1[iD]*u2[iD];
209 }
210 }
211 return prod;
212}

◆ scalarProduct() [2/2]

template<typename T , int d>
T olb::util::scalarProduct ( const Vector< T, d > & u1,
const Vector< T, d > & u2 )

Definition at line 191 of file util.h.

192{
193 T prod = T();
194 if (u1.size() == u2.size()) {
195 for (unsigned iD=0; iD < u1.size(); ++iD) {
196 prod += u1[iD]*u2[iD];
197 }
198 }
199 return prod;
200}
static constexpr unsigned size()
+ Here is the caller graph for this function:

◆ serialSymmetricTensorIndex()

template<unsigned DIM>
unsigned olb::util::serialSymmetricTensorIndex ( unsigned i,
unsigned j )

Compute serial index of symmetric tensor.

Template Parameters
DIMSpatial dimension
Parameters
iFirst spatial index
jSecond spatial index
Returns
Serialized index, as it is used in computeStress

Definition at line 491 of file vectorHelpers.h.

492{
493 OLB_PRECONDITION(DIM > 1);
494 OLB_PRECONDITION(DIM < 4);
495 if constexpr (DIM==2) {
496 return i+j;
497 }
498 else if constexpr (DIM==3) {
499 const unsigned res = i+j;
500 if ((i>0) && (j>0)) {
501 return res+1;
502 } else {
503 return res;
504 }
505 }
506 else {
507 // other dimensions are not implemented
508 exit(1);
509 }
510}
void exit(int exitcode)
Definition singleton.h:177
#define OLB_PRECONDITION(COND)
Definition olbDebug.h:46

References OLB_PRECONDITION.

+ Here is the caller graph for this function:

◆ sign()

template<typename T >
int olb::util::sign ( T val)
inline

Definition at line 53 of file util.h.

54{
55 return (0 < val) - (val < 0);
56}
+ Here is the caller graph for this function:

◆ sin() [1/3]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::sin ( const ADf< T, DIM > & a)
inline

Definition at line 569 of file aDiff.h.

570{
571 ADf<T,DIM> c(std::sin(a._v), a._d);
572 T tmp(std::cos(a._v));
573 c._d*=tmp;
574 return c;
575}
+ Here is the caller graph for this function:

◆ sin() [2/3]

template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > olb::util::sin ( T x)
inline

Definition at line 573 of file omath.h.

574{
575#ifdef __CUDA_ARCH__
576 if constexpr (std::is_same_v<T, float>) {
577 return ::sinf(x);
578 }
579 else if constexpr (std::is_same_v<T, double>) {
580 return ::sin(x);
581 }
582 else {
583 return ::sin(static_cast<double>(x));
584 //libcu++ of cuda supports double and float. You will get warning in device code if you use in e.g. long double.
585 }
586#else //__CUDA_ARCH__
587 return std::sin(x);
588#endif //__CUDA_ARCH__
589}

◆ sin() [3/3]

template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > olb::util::sin ( T x)
inline

Definition at line 592 of file omath.h.

593{
594#ifdef __CUDA_ARCH__
595 return ::sin(x);
596#else //__CUDA_ARCH__
597 return std::sin(x);
598#endif //__CUDA_ARCH__
599}

◆ sinf() [1/2]

any_platform float olb::util::sinf ( float x)
inline

Definition at line 554 of file omath.h.

555{
556#ifdef __CUDA_ARCH__
557 return ::sinf(x);
558#else //__CUDA_ARCH__
559 return std::sin(x);
560#endif //__CUDA_ARCH__
561}

◆ sinf() [2/2]

any_platform float olb::util::sinf ( int x)
inline

Definition at line 563 of file omath.h.

564{
565#ifdef __CUDA_ARCH__
566 return ::sinf(x);
567#else //__CUDA_ARCH__
568 return std::sin(x);
569#endif //__CUDA_ARCH__
570}

◆ sinh() [1/3]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::sinh ( const ADf< T, DIM > & a)
inline

Definition at line 651 of file aDiff.h.

652{
653 return 0.5*(exp(a)-exp(-a));
654}

References exp().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sinh() [2/3]

template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > olb::util::sinh ( T x)
inline

Definition at line 628 of file omath.h.

629{
630#ifdef __CUDA_ARCH__
631 if constexpr (std::is_same_v<T, float>) {
632 return ::sinhf(x);
633 }
634 else if constexpr (std::is_same_v<T, double>) {
635 return ::sinh(x);
636 }
637 else {
638 return ::sinh(static_cast<double>(x));
639 //libcu++ of cuda supports double and float. You will get warning in device code if you use in e.g. long double.
640 }
641#else //__CUDA_ARCH__
642 return std::sinh(x);
643#endif //__CUDA_ARCH__
644}

◆ sinh() [3/3]

template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > olb::util::sinh ( T x)
inline

Definition at line 647 of file omath.h.

648{
649#ifdef __CUDA_ARCH__
650 return ::sinh(x);
651#else //__CUDA_ARCH__
652 return std::sinh(x);
653#endif //__CUDA_ARCH__
654}

◆ sinhf() [1/2]

any_platform float olb::util::sinhf ( float x)
inline

Definition at line 609 of file omath.h.

610{
611#ifdef __CUDA_ARCH__
612 return ::sinhf(x);
613#else //__CUDA_ARCH__
614 return std::sinh(x);
615#endif //__CUDA_ARCH__
616}

◆ sinhf() [2/2]

any_platform float olb::util::sinhf ( int x)
inline

Definition at line 618 of file omath.h.

619{
620#ifdef __CUDA_ARCH__
621 return ::sinhf(x);
622#else //__CUDA_ARCH__
623 return std::sinh(x);
624#endif //__CUDA_ARCH__
625}

◆ sinhl()

long double olb::util::sinhl ( long double arg)
inline

Definition at line 656 of file omath.h.

657{
658
659 return sinh(arg);
660 //libcu++ of cuda dose not support long double. You will get warning in device code if you use.
661}
ADf< T, DIM > sinh(const ADf< T, DIM > &a)
Definition aDiff.h:651

References sinh().

+ Here is the call graph for this function:

◆ sinl()

long double olb::util::sinl ( long double arg)
inline

Definition at line 601 of file omath.h.

602{
603 return sin(arg);
604 //libcu++ of cuda dose not support long double. You will get warning in device code if you use.
605}

References sin().

+ Here is the call graph for this function:

◆ solveLinearSystem() [1/4]

template<typename T >
auto olb::util::solveLinearSystem ( const Matrix< T, 2, 2 > & a,
const Vector< T, 2 > & rhs )

Solve a * x = rhs.

Definition at line 158 of file matrix.h.

159{
160 return solveLinearSystem(a[0], a[1], rhs);
161}
auto solveLinearSystem(const Matrix< T, 2, 2 > &a, const Vector< T, 2 > &rhs)
Solve a * x = rhs.
Definition matrix.h:158

References solveLinearSystem().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ solveLinearSystem() [2/4]

template<typename T >
auto olb::util::solveLinearSystem ( const Matrix< T, 3, 3 > & a,
const Vector< T, 3 > & rhs )

Solve (a0 a1 a2) x = rhs.

Definition at line 167 of file matrix.h.

168{
169 return solveLinearSystem(a[0], a[1], a[2], rhs);
170}

References solveLinearSystem().

+ Here is the call graph for this function:

◆ solveLinearSystem() [3/4]

template<typename T >
Vector< T, 2 > olb::util::solveLinearSystem ( const Vector< T, 2 > & a0,
const Vector< T, 2 > & a1,
const Vector< T, 2 > & rhs )

Solve (a0 a1) x = rhs.

Definition at line 330 of file vectorHelpers.h.

332{
333 const T det = crossProduct2D(a0, a1);
334 return Vector<T,2> (crossProduct2D(rhs, a1) / det, crossProduct2D(a0, rhs) / det);
335}

References olb::crossProduct2D().

+ Here is the call graph for this function:

◆ solveLinearSystem() [4/4]

template<typename T >
Vector< T, 3 > olb::util::solveLinearSystem ( const Vector< T, 3 > & a0,
const Vector< T, 3 > & a1,
const Vector< T, 3 > & a2,
const Vector< T, 3 > & rhs )

Solve (a0 a1 a2) x = rhs.

Definition at line 355 of file vectorHelpers.h.

357{
358 const T det = determinant(a0, a1, a2);
359 return solveLinearSystem_help(a0, a1, a2, rhs, det);
360}
Vector< T, 3 > solveLinearSystem_help(const Vector< T, 3 > &a0, const Vector< T, 3 > &a1, const Vector< T, 3 > &a2, const Vector< T, 3 > &rhs, T det)
constexpr auto determinant(const Matrix< T, 2, 2 > &m)
Definition matrix.h:143

References determinant(), and solveLinearSystem_help().

+ Here is the call graph for this function:

◆ solveLinearSystem_help()

template<typename T >
Vector< T, 3 > olb::util::solveLinearSystem_help ( const Vector< T, 3 > & a0,
const Vector< T, 3 > & a1,
const Vector< T, 3 > & a2,
const Vector< T, 3 > & rhs,
T det )

Definition at line 338 of file vectorHelpers.h.

341{
342 Vector<T,3> res;
343 res[0] = determinant(rhs, a1, a2) / det;
344 res[1] = determinant(a0, rhs, a2) / det;
345 res[2] = determinant(a0, a1, rhs) / det;
346 return res;
347}

References determinant().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sqr() [1/2]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::sqr ( const ADf< T, DIM > & a)
inline

Definition at line 446 of file aDiff.h.

447{
448 ADf<T,DIM> c((a._v)*(a._v), a._d);
449 T tmp(T(2)*a._v);
450 c._d*=tmp;
451 return c;
452}

◆ sqr() [2/2]

template<typename T >
any_platform T olb::util::sqr ( T arg)

Definition at line 132 of file util.h.

133{
134 return arg*arg;
135}
+ Here is the caller graph for this function:

◆ sqrt() [1/6]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::sqrt ( const ADf< T, DIM > & a)
inline

Definition at line 556 of file aDiff.h.

557{
558 ADf<T,DIM> c(std::sqrt(a._v), a._d);
559 T tmp(T(1.)/(c._v*T(2)));
560 for (unsigned i = 0; i < DIM; ++i) {
561 if (!util::nearZero(a.d(i))) {
562 c._d[i] *= tmp;
563 }
564 }
565 return c;
566}

References nearZero().

+ Here is the call graph for this function:

◆ sqrt() [2/6]

template<class TAPE >
auto olb::util::sqrt ( const util::ADtape::ActiveType< TAPE > & a)
inline

Definition at line 366 of file aDiffTape.h.

367{
368 return util::ADtape::sqrt(a);
369}

References olb::util::ADtape::sqrt().

+ Here is the call graph for this function:

◆ sqrt() [3/6]

template<std::floating_point T>
cpu::simd::Pack< T > olb::util::sqrt ( cpu::simd::Pack< T > value)

Definition at line 110 of file pack.h.

111{
112 return value.sqrt();
113}

◆ sqrt() [4/6]

Expr olb::util::sqrt ( Expr x)

Definition at line 225 of file expr.cpp.

225 {
226 Expr::increment(Expr::Op::Sqrt);
227 return Expr(Expr::Op::Sqrt, x);
228}

References olb::Expr::increment(), and olb::Expr::Sqrt.

+ Here is the call graph for this function:

◆ sqrt() [5/6]

template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > olb::util::sqrt ( T arg)
inline

Definition at line 519 of file omath.h.

520{
521#ifdef __CUDA_ARCH__
522 return ::sqrt(arg);
523#else //__CUDA_ARCH__
524 return std::sqrt(arg);
525#endif //__CUDA_ARCH__
526}

◆ sqrt() [6/6]

template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > olb::util::sqrt ( T x)
inline

Definition at line 500 of file omath.h.

501{
502#ifdef __CUDA_ARCH__
503 if constexpr (std::is_same_v<T, float>) {
504 return ::sqrtf(x);
505 }
506 else if constexpr (std::is_same_v<T, double>) {
507 return ::sqrt(x);
508 }
509 else {
510 return ::sqrt(static_cast<double>(x));
511 //libcu++ of cuda supports double and float. You will get warning in device code if you use in e.g. long double.
512 }
513#else //__CUDA_ARCH__
514 return std::sqrt(x);
515#endif //__CUDA_ARCH__
516}

◆ sqrtf() [1/2]

any_platform float olb::util::sqrtf ( float arg)
inline

Definition at line 528 of file omath.h.

529{
530#ifdef __CUDA_ARCH__
531 return ::sqrtf(arg);
532#else //__CUDA_ARCH__
533 return std::sqrt(arg);
534#endif //__CUDA_ARCH__
535}

◆ sqrtf() [2/2]

any_platform float olb::util::sqrtf ( int arg)
inline

Definition at line 537 of file omath.h.

538{
539#ifdef __CUDA_ARCH__
540 return ::sqrtf(arg);
541#else //__CUDA_ARCH__
542 return std::sqrt(arg);
543#endif //__CUDA_ARCH__
544}

◆ sqrtl()

long double olb::util::sqrtl ( long double arg)
inline

Definition at line 546 of file omath.h.

547{
548 return sqrt(arg);
549 //libcu++ of cuda dose not support long double. You will get warning in device code if you use.
550}

References sqrt().

+ Here is the call graph for this function:

◆ subIndexOutgoing()

template<typename DESCRIPTOR , int direction, int orientation>
auto olb::util::subIndexOutgoing ( )
constexpr

Compute opposites of wall-incoming population indices.

Definition at line 262 of file util.h.

262 {
263 // Should be expressed in terms of populationsContributingToVelocity
264 // but std::array / std::index_sequence distinction makes this ugly
265 // To be revisitited
266 constexpr auto velocity_matches_value = [](unsigned iPop) {
267 return descriptors::c<DESCRIPTOR>(iPop,direction) == orientation;
268 };
269 constexpr auto opposite_population = [](unsigned iPop) {
270 return descriptors::opposite<DESCRIPTOR>(iPop);
271 };
272 return meta::array_from_index_sequence(
273 meta::map_index_sequence(opposite_population,
274 descriptors::filter_population_indices<DESCRIPTOR>(velocity_matches_value)));
275}

References olb::meta::array_from_index_sequence(), olb::descriptors::c(), olb::descriptors::filter_population_indices(), olb::meta::map_index_sequence(), and olb::descriptors::opposite().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ subIndexOutgoing2DonCorners()

template<typename DESCRIPTOR , int normalX, int normalY>
auto olb::util::subIndexOutgoing2DonCorners ( )
constexpr

Definition at line 316 of file util.h.

316 {
317 constexpr auto velocity_matches = [](unsigned iPop) {
318 return ( descriptors::c<DESCRIPTOR>(iPop,0) * normalX
319 + descriptors::c<DESCRIPTOR>(iPop,1) * normalY) < 0;
320 };
321 return meta::array_from_index_sequence(
322 descriptors::filter_population_indices<DESCRIPTOR>(velocity_matches));
323}

References olb::meta::array_from_index_sequence(), olb::descriptors::c(), and olb::descriptors::filter_population_indices().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ subIndexOutgoing3DonCorners()

template<typename DESCRIPTOR , int normalX, int normalY, int normalZ>
auto olb::util::subIndexOutgoing3DonCorners ( )
constexpr

Definition at line 327 of file util.h.

327 {
328 constexpr auto velocity_matches = [](unsigned iPop) {
329 return ( descriptors::c<DESCRIPTOR>(iPop,0) * normalX
330 + descriptors::c<DESCRIPTOR>(iPop,1) * normalY
331 + descriptors::c<DESCRIPTOR>(iPop,2) * normalZ) < 0;
332 };
333 return meta::array_from_index_sequence(
334 descriptors::filter_population_indices<DESCRIPTOR>(velocity_matches));
335}

References olb::meta::array_from_index_sequence(), olb::descriptors::c(), and olb::descriptors::filter_population_indices().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ subIndexOutgoing3DonEdges()

template<typename DESCRIPTOR , int plane, int normal1, int normal2>
auto olb::util::subIndexOutgoing3DonEdges ( )
constexpr

Definition at line 292 of file util.h.

292 {
293 constexpr auto velocity_matches = [](unsigned iPop) {
294 if constexpr (plane == 0) {
295 return ( descriptors::c<DESCRIPTOR>(iPop,0) * 0
296 + descriptors::c<DESCRIPTOR>(iPop,1) * (normal1 == 1 ? 1 : -1)
297 + descriptors::c<DESCRIPTOR>(iPop,2) * (normal2 == 1 ? 1 : -1)) < 0;
298 } else if constexpr (plane == 1) {
299 return ( descriptors::c<DESCRIPTOR>(iPop,0) * (normal1 == 1 ? 1 : -1)
300 + descriptors::c<DESCRIPTOR>(iPop,1) * 0
301 + descriptors::c<DESCRIPTOR>(iPop,2) * (normal2 == 1 ? 1 : -1)) < 0;
302 } else if constexpr (plane == 2) {
303 return ( descriptors::c<DESCRIPTOR>(iPop,0) * (normal1 == 1 ? 1 : -1)
304 + descriptors::c<DESCRIPTOR>(iPop,1) * (normal2 == 1 ? 1 : -1)
305 + descriptors::c<DESCRIPTOR>(iPop,2) * 0) < 0;
306 } else {
307 return false;
308 }
309 };
310 return meta::array_from_index_sequence(
311 descriptors::filter_population_indices<DESCRIPTOR>(velocity_matches));
312}

References olb::meta::array_from_index_sequence(), olb::descriptors::c(), and olb::descriptors::filter_population_indices().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ subIndexOutgoingRemaining()

template<typename DESCRIPTOR , int direction, int orientation>
auto olb::util::subIndexOutgoingRemaining ( )
constexpr

Definition at line 278 of file util.h.

278 {
279 constexpr auto velocity_matches = [](unsigned iPop) {
280 for (unsigned jPop : subIndexOutgoing<DESCRIPTOR,direction,orientation>()) {
281 if (iPop == jPop) {
282 return false;
283 }
284 }
285 return true;
286 };
287 return meta::array_from_index_sequence(
288 descriptors::filter_population_indices<DESCRIPTOR>(velocity_matches));
289}

References olb::meta::array_from_index_sequence(), olb::descriptors::filter_population_indices(), and subIndexOutgoing().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ surfaceNormal()

template<typename S , unsigned D, typename F1 >
Vector< S, D > olb::util::surfaceNormal ( const Vector< S, D > & pos,
const S meshSize,
F1 sdf )

Definition at line 236 of file indicatorBase.h.

237{
238 Vector<S,D> normal( S(0) );
239
240 for (unsigned iD=0; iD<D; ++iD) {
241 Vector<S,D> delta(S(0));
242 delta[iD] = meshSize;
243 normal[iD] = (sdf(pos+delta) - sdf(pos-delta)) / (2*meshSize);
244 }
245
246 return normal;
247}
+ Here is the caller graph for this function:

◆ tan() [1/3]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::tan ( const ADf< T, DIM > & a)
inline

Definition at line 587 of file aDiff.h.

588{
589 ADf<T,DIM> c(std::tan(a._v), a._d);
590 T tmp(T(1)+c._v*c._v);
591 c._d*=tmp;
592 return c;
593}
+ Here is the caller graph for this function:

◆ tan() [2/3]

template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > olb::util::tan ( T x)
inline

Definition at line 792 of file omath.h.

793{
794#ifdef __CUDA_ARCH__
795 if constexpr (std::is_same_v<T, float>) {
796 return ::tanf(x);
797 }
798 else if constexpr (std::is_same_v<T, double>) {
799 return ::tan(x);
800 }
801 else {
802 return ::tan(static_cast<double>(x));
803 //libcu++ of cuda supports double and float. You will get warning in device code if you use in e.g. long double.
804 }
805#else //__CUDA_ARCH__
806 return std::tan(x);
807#endif //__CUDA_ARCH__
808}

◆ tan() [3/3]

template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > olb::util::tan ( T x)
inline

Definition at line 811 of file omath.h.

812{
813#ifdef __CUDA_ARCH__
814 return ::tan(x);
815#else //__CUDA_ARCH__
816 return std::tan(x);
817#endif //__CUDA_ARCH__
818}

◆ tanf() [1/2]

any_platform float olb::util::tanf ( float x)
inline

Definition at line 773 of file omath.h.

774{
775#ifdef __CUDA_ARCH__
776 return ::tanf(x);
777#else //__CUDA_ARCH__
778 return std::tan(x);
779#endif //__CUDA_ARCH__
780}

◆ tanf() [2/2]

any_platform float olb::util::tanf ( int x)
inline

Definition at line 782 of file omath.h.

783{
784#ifdef __CUDA_ARCH__
785 return ::tanf(x);
786#else //__CUDA_ARCH__
787 return std::tan(x);
788#endif //__CUDA_ARCH__
789}

◆ tanh() [1/3]

template<class T , unsigned DIM>
ADf< T, DIM > olb::util::tanh ( const ADf< T, DIM > & a)
inline

Definition at line 663 of file aDiff.h.

664{
665 return 1 - 2.0 / (exp(2*a) + 1);
666}

References exp().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tanh() [2/3]

template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > olb::util::tanh ( T x)
inline

Definition at line 846 of file omath.h.

847{
848#ifdef __CUDA_ARCH__
849 if constexpr (std::is_same_v<T, float>) {
850 return ::tanhf(x);
851 }
852 else if constexpr (std::is_same_v<T, double>) {
853 return ::tanh(x);
854 }
855 else {
856 return ::tanh(static_cast<double>(x));
857 //libcu++ of cuda supports double and float. You will get warning in device code if you use in e.g. long double.
858 }
859#else //__CUDA_ARCH__
860 return std::tanh(x);
861#endif //__CUDA_ARCH__
862}

◆ tanh() [3/3]

template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > olb::util::tanh ( T x)
inline

Definition at line 865 of file omath.h.

866{
867#ifdef __CUDA_ARCH__
868 return ::tanh(x);
869#else //__CUDA_ARCH__
870 return std::tanh(x);
871#endif //__CUDA_ARCH__
872}

◆ tanhf() [1/2]

any_platform float olb::util::tanhf ( float x)
inline

Definition at line 827 of file omath.h.

828{
829#ifdef __CUDA_ARCH__
830 return ::tanhf(x);
831#else //__CUDA_ARCH__
832 return std::tanh(x);
833#endif //__CUDA_ARCH__
834}

◆ tanhf() [2/2]

any_platform float olb::util::tanhf ( int x)
inline

Definition at line 836 of file omath.h.

837{
838#ifdef __CUDA_ARCH__
839 return ::tanhf(x);
840#else //__CUDA_ARCH__
841 return std::tanh(x);
842#endif //__CUDA_ARCH__
843}

◆ tanhl()

long double olb::util::tanhl ( long double arg)
inline

Definition at line 874 of file omath.h.

875{
876 return tanh(arg);
877 //libcu++ of cuda dose not support long double. You will get warning in device code if you use.
878}
ADf< T, DIM > tanh(const ADf< T, DIM > &a)
Definition aDiff.h:663

References tanh().

+ Here is the call graph for this function:

◆ tanl()

long double olb::util::tanl ( long double arg)
inline

Definition at line 820 of file omath.h.

821{
822 return tan(arg);
823 //libcu++ of cuda dose not support long double. You will get warning in device code if you use.
824}
ADf< T, DIM > tan(const ADf< T, DIM > &a)
Definition aDiff.h:587

References tan().

+ Here is the call graph for this function:

◆ throwADfException()

template<typename T >
void olb::util::throwADfException ( T arg)
inlineconstexpr

Definition at line 1099 of file aDiff.h.

1100{
1101 static_assert(std::is_floating_point<T>::value,
1102 "The data type ADf has slipped in here. If you really want to use it here and lose all derivation information, then perform an explicit typecast.");
1103}

◆ trunc() [1/2]

template<typename T >
any_platform std::enable_if_t< std::is_floating_point_v< T >, T > olb::util::trunc ( T x)
inline

Definition at line 1426 of file omath.h.

1427{
1428#ifdef __CUDA_ARCH__
1429 if constexpr (std::is_same_v<T, float>) {
1430 return ::truncf(x);
1431 }
1432 else if constexpr (std::is_same_v<T, double>) {
1433 return ::trunc(x);
1434 }
1435 else {
1436 return ::trunc(static_cast<double>(x));
1437 //libcu++ of cuda supports double and float. You will get warning in device code if you use in e.g. long double.
1438 }
1439#else //__CUDA_ARCH__
1440 return std::trunc(x);
1441#endif //__CUDA_ARCH__
1442}

◆ trunc() [2/2]

template<typename T >
any_platform std::enable_if_t< std::is_integral_v< T >, double > olb::util::trunc ( T x)
inline

Definition at line 1445 of file omath.h.

1446{
1447#ifdef __CUDA_ARCH__
1448 return ::trunc(x);
1449#else //__CUDA_ARCH__
1450 return std::trunc(x);
1451#endif //__CUDA_ARCH__
1452}

◆ truncf() [1/2]

any_platform float olb::util::truncf ( float x)
inline

Definition at line 1407 of file omath.h.

1408{
1409#ifdef __CUDA_ARCH__
1410 return ::truncf(x);
1411#else //__CUDA_ARCH__
1412 return std::trunc(x);
1413#endif //__CUDA_ARCH__
1414}

◆ truncf() [2/2]

any_platform float olb::util::truncf ( int x)
inline

Definition at line 1416 of file omath.h.

1417{
1418#ifdef __CUDA_ARCH__
1419 return ::truncf(x);
1420#else //__CUDA_ARCH__
1421 return std::trunc(x);
1422#endif //__CUDA_ARCH__
1423}

◆ truncl()

long double olb::util::truncl ( long double arg)
inline

Definition at line 1454 of file omath.h.

1455{
1456 return std::truncl(arg);
1457 //cuda dose not support this function.
1458}

Variable Documentation

◆ is_adf_v

template<class T >
bool olb::util::is_adf_v = is_adf<T>::value
inlineconstexpr

Definition at line 124 of file aDiff.h.