OpenLB 1.7
Loading...
Searching...
No Matches
Namespaces | Classes | Typedefs | Functions | Variables
olb::util Namespace Reference

Namespaces

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

template<typename T >
cpu::simd::Pack< T > sqrt (cpu::simd::Pack< T > value)
 
template<typename T >
cpu::simd::Pack< T > fabs (cpu::simd::Pack< T > value)
 
template<typename T >
cpu::simd::Pack< T > pow (cpu::simd::Pack< T > base, cpu::simd::Pack< T > exp)
 
template<typename T , typename S >
cpu::simd::Pack< T > pow (cpu::simd::Pack< T > base, S exp)
 
template<typename T >
cpu::simd::Pack< T > min (cpu::simd::Pack< T > rhs, cpu::simd::Pack< T > lhs)
 
template<typename 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)
 
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 >
sqr (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)
 
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 T u1[d], const T u2[d])
 
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 >
densityFromPressure (T latticePressure)
 compute lattice density from lattice pressure
 
template<typename T , typename DESCRIPTOR >
pressureFromDensity (T latticeDensity)
 compute lattice pressure from lattice density
 
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<typename T , typename S >
auto fmod_pos (T a, S b)
 Variant of fmod (floating point modulo) that always returns positive values.
 
Expr sqrt (Expr x)
 
Expr fabs (Expr x)
 
Expr pow (Expr base, Expr exp)
 
Expr exp (Expr x)
 
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)
 
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 >
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 >
constexpr T max (T a, meta::id_t< T > b)
 
template<typename T , class Compare >
constexpr T max (T a, meta::id_t< T > b, Compare comp)
 
template<typename T >
constexpr T max (std::initializer_list< T > ilist)
 
template<typename T , class Compare >
constexpr T max (std::initializer_list< T > ilist, Compare comp)
 
template<>
float max< float > (float x, float y) any_platform
 
template<>
double max< double > (double x, double y) any_platform
 
template<typename T >
constexpr T min (T a, meta::id_t< T > b)
 
template<typename T , class Compare >
constexpr T min (T a, meta::id_t< T > b, Compare comp)
 
template<typename T >
constexpr T min (std::initializer_list< T > ilist)
 
template<typename T , class Compare >
constexpr T min (std::initializer_list< T > ilist, Compare comp)
 
template<>
float min< float > (float x, float y) any_platform
 
template<>
double min< double > (double x, double y) any_platform
 
template<typename T , typename S >
any_platform auto pow (T base, S exp) -> std::enable_if_t< std::is_arithmetic_v< T >, decltype(std::pow(base, exp))>
 
any_platform float powf (float base, float exp)
 
long double powl (long double base, long double exp)
 
float fmod (float x, float y)
 
float fmodf (float x, float y)
 
double fmod (double x, double y)
 
long double fmod (long double x, long double y)
 
long double fmodl (long double x, long double y)
 
float fmod (float x, int y)
 
double fmod (double x, int y)
 
long double fmod (long double x, int y)
 
template<typename T , typename S >
auto fmod (T x, S y)
 
template<typename T >
std::enable_if_t< std::is_floating_point_v< T >, T > exp (T arg) any_platform
 
template<typename T >
std::enable_if_t< std::is_integral_v< T >, double > exp (T arg) any_platform
 
float expf (float arg)
 
long double expl (long double arg)
 
float log (float arg)
 
float logf (float arg)
 
double log (double arg)
 
long double log (long double arg)
 
long double logl (long double arg)
 
template<typename T >
std::enable_if_t< std::is_integral_v< T >, double > log (T arg)
 
float log10 (float arg)
 
float log10f (float arg)
 
double log10 (double arg)
 
long double log10 (long double arg)
 
long double log10l (long double arg)
 
template<typename T >
std::enable_if_t< std::is_integral_v< T >, double > log10 (T arg)
 
float log2 (float arg)
 
float log2f (float arg)
 
double log2 (double arg)
 
long double log2 (long double arg)
 
long double log2l (long double arg)
 
template<typename T >
std::enable_if_t< std::is_integral_v< T >, double > log2 (T arg)
 
float log1p (float arg)
 
float log1pf (float arg)
 
double log1p (double arg)
 
long double log1p (long double arg)
 
long double log1pl (long double arg)
 
template<typename T >
std::enable_if_t< std::is_integral_v< T >, double > log1p (T arg)
 
any_platform float sqrtf (float arg)
 
long double sqrtl (long double arg)
 
template<typename T >
std::enable_if_t< std::is_floating_point_v< T >, T > sqrt (T arg) any_platform
 
template<typename T >
std::enable_if_t< std::is_integral_v< T >, double > sqrt (T arg) any_platform
 
float sin (float arg)
 
float sinf (float arg)
 
double sin (double arg)
 
long double sin (long double arg)
 
long double sinl (long double arg)
 
template<typename T >
std::enable_if_t< std::is_integral_v< T >, double > sin (T arg)
 
float sinh (float arg)
 
float sinhf (float arg)
 
double sinh (double arg)
 
long double sinh (long double arg)
 
long double sinhl (long double arg)
 
template<typename T >
std::enable_if_t< std::is_integral_v< T >, double > sinh (T arg)
 
float cos (float arg)
 
float cosf (float arg)
 
double cos (double arg)
 
long double cos (long double arg)
 
long double cosl (long double arg)
 
template<typename T >
std::enable_if_t< std::is_integral_v< T >, double > cos (T arg)
 
float cosh (float arg)
 
float coshf (float arg)
 
double cosh (double arg)
 
long double cosh (long double arg)
 
long double coshl (long double arg)
 
template<typename T >
std::enable_if_t< std::is_integral_v< T >, double > cosh (T arg)
 
float tan (float arg)
 
float tanf (float arg)
 
double tan (double arg)
 
long double tan (long double arg)
 
long double tanl (long double arg)
 
template<typename T >
std::enable_if_t< std::is_integral_v< T >, double > tan (T arg)
 
float tanh (float arg)
 
float tanhf (float arg)
 
double tanh (double arg)
 
long double tanh (long double arg)
 
long double tanhl (long double arg)
 
template<typename T >
std::enable_if_t< std::is_integral_v< T >, double > tanh (T arg)
 
float asin (float arg)
 
float asinf (float arg)
 
double asin (double arg)
 
long double asin (long double arg)
 
long double asinl (long double arg)
 
template<typename T >
std::enable_if_t< std::is_integral_v< T >, double > asin (T arg)
 
float asinh (float arg)
 
float asinhf (float arg)
 
double asinh (double arg)
 
long double asinh (long double arg)
 
long double asinhl (long double arg)
 
template<typename T >
std::enable_if_t< std::is_integral_v< T >, double > asinh (T arg)
 
float acos (float arg)
 
float acosf (float arg)
 
double acos (double arg)
 
long double acos (long double arg)
 
long double acosl (long double arg)
 
template<typename T >
std::enable_if_t< std::is_integral_v< T >, double > acos (T arg)
 
float acosh (float arg)
 
float acoshf (float arg)
 
double acosh (double arg)
 
long double acosh (long double arg)
 
long double acoshl (long double arg)
 
template<typename T >
std::enable_if_t< std::is_integral_v< T >, double > acosh (T arg)
 
float atan (float arg)
 
float atanf (float arg)
 
double atan (double arg)
 
long double atan (long double arg)
 
long double atanl (long double arg)
 
template<typename T >
std::enable_if_t< std::is_integral_v< T >, double > atan (T arg)
 
float atan2 (float y, float x)
 
float atan2f (float y, float x)
 
double atan2 (double y, double x)
 
long double atan2 (long double y, long double x)
 
long double atan2l (long double y, long double x)
 
template<typename T >
std::enable_if_t< std::is_integral_v< T >, double > atan2 (T y, T x)
 
float atanh (float arg)
 
float atanhf (float arg)
 
double atanh (double arg)
 
long double atanh (long double arg)
 
long double atanhl (long double arg)
 
template<typename T >
std::enable_if_t< std::is_integral_v< T >, double > atanh (T arg)
 
float floor (float arg)
 
double floor (double arg)
 
long double floor (long double arg)
 
float floorf (float arg)
 
long double floorl (long double arg)
 
template<typename T >
std::enable_if_t< std::is_integral_v< T >, double > floor (T arg)
 
float ceil (float arg)
 
double ceil (double arg)
 
long double ceil (long double arg)
 
float ceilf (float arg)
 
long double ceill (long double arg)
 
template<typename T >
std::enable_if_t< std::is_integral_v< T >, double > ceil (T arg)
 
float trunc (float arg)
 
float truncf (float arg)
 
double trunc (double arg)
 
long double trunc (long double arg)
 
long double truncl (long double arg)
 
template<typename T >
std::enable_if_t< std::is_integral_v< T >, double > trunc (T arg)
 
template<typename T >
std::enable_if_t< std::is_integral_v< T >, double > round (T arg)
 
float round (float arg)
 
double round (double arg)
 
long double round (long double arg)
 
float roundf (float arg)
 
double roundf (double arg)
 
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)
 
template<typename T >
std::enable_if_t< std::is_arithmetic_v< T >, T > abs (T arg) any_platform
 
template<typename T >
std::enable_if_t< std::is_floating_point_v< T >, T > fabs (T arg) any_platform
 
template<typename T >
std::enable_if_t< std::is_integral_v< T >, double > fabs (T arg) any_platform
 
long labs (long arg)
 
long long llabs (long long arg)
 
float fabsf (float arg)
 
long double fabs (long double arg)
 
long double fabsl (long double arg)
 
template<typename T , typename DESCRIPTOR >
Timer< T > * createTimer (XMLreader &param, const UnitConverter< T, DESCRIPTOR > &converter, size_t numLatticePoints)
 
template<typename T >
bool nearZero (T a)
 return true if a is close to zero
 
template<typename T >
bool nearZero (T a, T epsilon)
 
template<typename T , typename U = T, typename W = T>
bool approxEqual (T a, U b, W epsilon)
 
template<typename T , typename U = T>
bool approxEqual (T a, U b)
 
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 std::vector< T > &a)
 l2 norm to the power of 2 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)
 applies floor to each component of a vector
 
template<typename T , unsigned Size>
Vector< T, Size > ceil (const Vector< T, Size > &a)
 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 >
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.
 

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 49 of file vectorHelpers.h.

Function Documentation

◆ abs() [1/2]

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}

References fabs().

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

◆ abs() [2/2]

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

Definition at line 881 of file omath.h.

882{
883#ifdef __CUDA_ARCH__
884 return ::fabs(arg);
885#else
886 return std::abs(arg);
887#endif
888}

◆ acos() [1/5]

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.
Definition aDiff.h:64
T _v
value
Definition aDiff.h:72
Vector< T, DIM > _d
derivatives
Definition aDiff.h:74

References olb::util::ADf< T, DIM >::_d, and olb::util::ADf< T, DIM >::_v.

+ Here is the caller graph for this function:

◆ acos() [2/5]

double olb::util::acos ( double arg)
inline

Definition at line 562 of file omath.h.

563{
564 return std::acos(arg);
565}

◆ acos() [3/5]

float olb::util::acos ( float arg)
inline

Definition at line 552 of file omath.h.

553{
554 return std::acos(arg);
555}

◆ acos() [4/5]

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

Definition at line 567 of file omath.h.

568{
569 return std::acos(arg);
570}

◆ acos() [5/5]

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

Definition at line 578 of file omath.h.

579{
580 return std::acos(arg);
581}

◆ acosf()

float olb::util::acosf ( float arg)
inline

Definition at line 557 of file omath.h.

558{
559 return acos(arg);
560}
ADf< T, DIM > acos(const ADf< T, DIM > &a)
Definition aDiff.h:605

References acos().

+ Here is the call graph for this function:

◆ acosh() [1/5]

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 olb::util::ADf< T, DIM >::_v, log(), and sqrt().

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

◆ acosh() [2/5]

double olb::util::acosh ( double arg)
inline

Definition at line 594 of file omath.h.

595{
596 return std::acosh(arg);
597}

◆ acosh() [3/5]

float olb::util::acosh ( float arg)
inline

Definition at line 584 of file omath.h.

585{
586 return std::acosh(arg);
587}

◆ acosh() [4/5]

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

Definition at line 599 of file omath.h.

600{
601 return std::acosh(arg);
602}

◆ acosh() [5/5]

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

Definition at line 610 of file omath.h.

611{
612 return std::acosh(arg);
613}

◆ acoshf()

float olb::util::acoshf ( float arg)
inline

Definition at line 589 of file omath.h.

590{
591 return acosh(arg);
592}
ADf< T, DIM > acosh(const ADf< T, DIM > &a)
Definition aDiff.h:675

References acosh().

+ Here is the call graph for this function:

◆ acoshl()

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

Definition at line 604 of file omath.h.

605{
606 return acosh(arg);
607}

References acosh().

+ Here is the call graph for this function:

◆ acosl()

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

Definition at line 572 of file omath.h.

573{
574 return acos(arg);
575}

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 78 of file util.h.

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

◆ aligned_to_x()

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

Definition at line 60 of file util.h.

61{
62 return (vec[0]!=0 and vec[1]==0 and vec[2]==0);
63}

◆ aligned_to_y()

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

Definition at line 66 of file util.h.

67{
68 return (vec[0]==0 and vec[1]!=0 and vec[2]==0);
69}

◆ aligned_to_z()

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

Definition at line 72 of file util.h.

73{
74 return (vec[0]==0 and vec[1]==0 and vec[2]!=0);
75}

◆ 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 331 of file vectorHelpers.h.

332{
333 if constexpr(ensureAngularBounds){
334 return std::fmod(util::atan2(b[1]*a[0]-b[0]*a[1], a[0]*b[0]+a[1]*b[1]), M_PI);
335 } else {
336 return util::atan2(b[1]*a[0]-b[0]*a[1], a[0]*b[0]+a[1]*b[1]);
337 }
338}
#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 342 of file vectorHelpers.h.

343{
344 Vector<T,3> angles;
345 angles[0] = angleBetweenVectors<T,ensureAngularBounds>(Vector<T,2>(a[1], a[2]), Vector<T,2>(b[1], b[2]));
346 angles[1] = angleBetweenVectors<T,ensureAngularBounds>(Vector<T,2>(a[0], a[2]), Vector<T,2>(b[0], b[2]));
347 angles[2] = angleBetweenVectors<T,ensureAngularBounds>(Vector<T,2>(a[0], a[1]), Vector<T,2>(b[0], b[1]));
348 return angles;
349}
Plain old scalar vector.
Definition vector.h:47

◆ approxEqual() [1/2]

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

Definition at line 88 of file vectorHelpers.h.

89{
90 if (a==b) {
91 return true;
92 }
93 if (nearZero(a) && nearZero(b)) {
94 return true;
95 }
96 T EPSILON = std::numeric_limits<T>::epsilon()*4.*util::fabs(a);
97 return approxEqual(a,b,EPSILON);
98}

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 79 of file vectorHelpers.h.

80{
81 if (a==b) {
82 return true;
83 }
84 return nearZero<T>(a - b, epsilon);
85}
+ Here is the caller graph for this function:

◆ asin() [1/5]

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}

References olb::util::ADf< T, DIM >::_d, and olb::util::ADf< T, DIM >::_v.

+ Here is the caller graph for this function:

◆ asin() [2/5]

double olb::util::asin ( double arg)
inline

Definition at line 498 of file omath.h.

499{
500 return std::asin(arg);
501}

◆ asin() [3/5]

float olb::util::asin ( float arg)
inline

Definition at line 488 of file omath.h.

489{
490 return std::asin(arg);
491}

◆ asin() [4/5]

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

Definition at line 503 of file omath.h.

504{
505 return std::asin(arg);
506}

◆ asin() [5/5]

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

Definition at line 514 of file omath.h.

515{
516 return std::asin(arg);
517}

◆ asinf()

float olb::util::asinf ( float arg)
inline

Definition at line 493 of file omath.h.

494{
495 return asin(arg);
496}
ADf< T, DIM > asin(const ADf< T, DIM > &a)
Definition aDiff.h:596

References asin().

+ Here is the call graph for this function:

◆ asinh() [1/5]

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:
+ Here is the caller graph for this function:

◆ asinh() [2/5]

double olb::util::asinh ( double arg)
inline

Definition at line 530 of file omath.h.

531{
532 return std::asinh(arg);
533}

◆ asinh() [3/5]

float olb::util::asinh ( float arg)
inline

Definition at line 520 of file omath.h.

521{
522 return std::asinh(arg);
523}

◆ asinh() [4/5]

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

Definition at line 535 of file omath.h.

536{
537 return std::asinh(arg);
538}

◆ asinh() [5/5]

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

Definition at line 546 of file omath.h.

547{
548 return std::asinh(arg);
549}

◆ asinhf()

float olb::util::asinhf ( float arg)
inline

Definition at line 525 of file omath.h.

526{
527 return asinh(arg);
528}
ADf< T, DIM > asinh(const ADf< T, DIM > &a)
Definition aDiff.h:669

References asinh().

+ Here is the call graph for this function:

◆ asinhl()

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

Definition at line 540 of file omath.h.

541{
542 return asinh(arg);
543}

References asinh().

+ Here is the call graph for this function:

◆ asinl()

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

Definition at line 508 of file omath.h.

509{
510 return asin(arg);
511}

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 399 of file vectorHelpers.h.

400{
401 std::vector<T> v1;
402 v1.push_back(a);
403 v1.push_back(b);
404 return v1;
405}

◆ assign() [2/2]

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

Definition at line 408 of file vectorHelpers.h.

409{
410 std::vector<T> v1;
411 v1.push_back(a);
412 v1.push_back(b);
413 v1.push_back(c);
414 return v1;
415}

◆ atan() [1/5]

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}

References olb::util::ADf< T, DIM >::_d, and olb::util::ADf< T, DIM >::_v.

+ Here is the caller graph for this function:

◆ atan() [2/5]

double olb::util::atan ( double arg)
inline

Definition at line 626 of file omath.h.

627{
628 return std::atan(arg);
629}

◆ atan() [3/5]

float olb::util::atan ( float arg)
inline

Definition at line 616 of file omath.h.

617{
618 return std::atan(arg);
619}

◆ atan() [4/5]

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

Definition at line 631 of file omath.h.

632{
633 return std::atan(arg);
634}

◆ atan() [5/5]

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

Definition at line 642 of file omath.h.

643{
644 return std::atan(arg);
645}

◆ 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}

References olb::util::ADf< T, DIM >::_d, and olb::util::ADf< T, DIM >::_v.

◆ 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}

References olb::util::ADf< T, DIM >::_d, and olb::util::ADf< T, DIM >::_v.

◆ 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}

References olb::util::ADf< T, DIM >::_d, and olb::util::ADf< T, DIM >::_v.

+ Here is the caller graph for this function:

◆ atan2() [4/7]

double olb::util::atan2 ( double y,
double x )
inline

Definition at line 658 of file omath.h.

659{
660 return std::atan2(y, x);
661}

◆ atan2() [5/7]

float olb::util::atan2 ( float y,
float x )
inline

Definition at line 648 of file omath.h.

649{
650 return std::atan2(y, x);
651}

◆ atan2() [6/7]

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

Definition at line 663 of file omath.h.

664{
665 return std::atan2(y, x);
666}

◆ atan2() [7/7]

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

Definition at line 674 of file omath.h.

675{
676 return std::atan2(y, x);
677}

◆ atan2f()

float olb::util::atan2f ( float y,
float x )
inline

Definition at line 653 of file omath.h.

654{
655 return atan2(y, x);
656}
ADf< T, DIM > atan2(const T &y, const ADf< T, DIM > &x)
Definition aDiff.h:623

References atan2().

+ Here is the call graph for this function:

◆ atan2l()

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

Definition at line 668 of file omath.h.

669{
670 return atan2(y, x);
671}

References atan2().

+ Here is the call graph for this function:

◆ atanf()

float olb::util::atanf ( float arg)
inline

Definition at line 621 of file omath.h.

622{
623 return atan(arg);
624}
ADf< T, DIM > atan(const ADf< T, DIM > &a)
Definition aDiff.h:614

References atan().

+ Here is the call graph for this function:

◆ atanh() [1/5]

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 olb::util::ADf< T, DIM >::_v, and log().

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

◆ atanh() [2/5]

double olb::util::atanh ( double arg)
inline

Definition at line 690 of file omath.h.

691{
692 return std::atanh(arg);
693}

◆ atanh() [3/5]

float olb::util::atanh ( float arg)
inline

Definition at line 680 of file omath.h.

681{
682 return std::atanh(arg);
683}

◆ atanh() [4/5]

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

Definition at line 695 of file omath.h.

696{
697 return std::atanh(arg);
698}

◆ atanh() [5/5]

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

Definition at line 706 of file omath.h.

707{
708 return std::atanh(arg);
709}

◆ atanhf()

float olb::util::atanhf ( float arg)
inline

Definition at line 685 of file omath.h.

686{
687 return atanh(arg);
688}
ADf< T, DIM > atanh(const ADf< T, DIM > &a)
Definition aDiff.h:689

References atanh().

+ Here is the call graph for this function:

◆ atanhl()

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

Definition at line 700 of file omath.h.

701{
702 return atanh(arg);
703}

References atanh().

+ Here is the call graph for this function:

◆ atanl()

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

Definition at line 636 of file omath.h.

637{
638 return atan(arg);
639}

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 246 of file vectorHelpers.h.

247{
248 T sum = a[0];
249 for (unsigned int iDim=1; iDim < Size; ++iDim) {
250 sum += a[iDim];
251 }
252 return sum/Size;
253}
+ 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)
Euclidean vector norm.
constexpr Vector< T, D > normalize(const ScalarVector< T, D, IMPL > &a, T scale=T{1})
Definition vector.h:245

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 137 of file geometricOperations.h.

139{
140 return invertRotationMatrix<T, D>(calculateRotationMatrix<T, D>(angle));
141}

◆ calculateLocalVelocity()

template<typename T , unsigned D>
constexpr 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 194 of file geometricOperations.h.

199{
200 if constexpr (D == 2) {
201 // 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)
202 return Vector<T, 2>(
203 velocity[0] - angularVelocity[0] * (position[1] - rotationCenter[1]),
204 velocity[1] + angularVelocity[0] * (position[0] - rotationCenter[0]));
205 }
206 else {
207 // 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)
208 return velocity +
209 crossProduct3D(angularVelocity, position - rotationCenter);
210 }
211 __builtin_unreachable();
212}
constexpr Vector< T, 3 > crossProduct3D(const ScalarVector< T, 3, IMPL > &a, const ScalarVector< T, 3, IMPL_ > &b) any_platform
Definition vector.h:224

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:

◆ ceil() [1/6]

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

References olb::util::ADf< T, DIM >::_v, and olb::util::ADf< T, DIM >::d().

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

◆ ceil() [2/6]

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 224 of file vectorHelpers.h.

225{
226 Vector<T,Size> out;
227 for (unsigned int iDim=0; iDim < Size; ++iDim) {
228 out[iDim] = util::ceil(a[iDim]);
229 }
230 return out;
231}

References ceil().

+ Here is the call graph for this function:

◆ ceil() [3/6]

double olb::util::ceil ( double arg)
inline

Definition at line 751 of file omath.h.

752{
753 return std::ceil(arg);
754}

◆ ceil() [4/6]

float olb::util::ceil ( float arg)
inline

Definition at line 746 of file omath.h.

747{
748 return std::ceil(arg);
749}

◆ ceil() [5/6]

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

Definition at line 756 of file omath.h.

757{
758 return std::ceil(arg);
759}

◆ ceil() [6/6]

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

Definition at line 772 of file omath.h.

773{
774 return std::ceil(arg);
775}

◆ ceilf() [1/2]

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/2]

float olb::util::ceilf ( float arg)
inline

Definition at line 761 of file omath.h.

762{
763 return ceil(arg);
764}

References ceil().

+ Here is the call graph for this function:

◆ 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 766 of file omath.h.

767{
768 return ceil(arg);
769}

References ceil().

+ 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 119 of file util.h.

121{
122 return x>=x0 && x<=x1 &&
123 y>=y0 && y<=y1;
124}
+ 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 126 of file util.h.

128{
129 return x>=x0 && x<=x1 &&
130 y>=y0 && y<=y1 &&
131 z>=z0 && z<=z1;
132}

◆ copy3()

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

Definition at line 117 of file vectorHelpers.h.

118{
119 for (unsigned i=0; i<3; i++) {
120 c[i] = a[i];
121 }
122}

◆ 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.

◆ 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 109 of file vectorHelpers.h.

110{
111 for (unsigned i=0; i<dim; i++) {
112 c[i] = a[i];
113 }
114}

◆ copyN() [2/2]

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

Definition at line 101 of file vectorHelpers.h.

102{
103 for (unsigned i=0; i<dim; i++) {
104 c[i] = a[i];
105 }
106}
+ Here is the caller graph for this function:

◆ cos() [1/5]

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}

References olb::util::ADf< T, DIM >::_d, and olb::util::ADf< T, DIM >::_v.

+ Here is the caller graph for this function:

◆ cos() [2/5]

double olb::util::cos ( double arg)
inline

Definition at line 370 of file omath.h.

371{
372 return std::cos(arg);
373}

◆ cos() [3/5]

float olb::util::cos ( float arg)
inline

Definition at line 360 of file omath.h.

361{
362 return std::cos(arg);
363}

◆ cos() [4/5]

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

Definition at line 375 of file omath.h.

376{
377 return std::cos(arg);
378}

◆ cos() [5/5]

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

Definition at line 386 of file omath.h.

387{
388 return std::cos(arg);
389}

◆ cosf()

float olb::util::cosf ( float arg)
inline

Definition at line 365 of file omath.h.

366{
367 return cos(arg);
368}

References cos().

+ Here is the call graph for this function:

◆ cosh() [1/5]

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}
ADf< T, DIM > exp(const ADf< T, DIM > &a)
Definition aDiff.h:455

References exp().

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

◆ cosh() [2/5]

double olb::util::cosh ( double arg)
inline

Definition at line 402 of file omath.h.

403{
404 return std::cosh(arg);
405}

◆ cosh() [3/5]

float olb::util::cosh ( float arg)
inline

Definition at line 392 of file omath.h.

393{
394 return std::cosh(arg);
395}

◆ cosh() [4/5]

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

Definition at line 407 of file omath.h.

408{
409 return std::cosh(arg);
410}

◆ cosh() [5/5]

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

Definition at line 418 of file omath.h.

419{
420 return std::cosh(arg);
421}

◆ coshf()

float olb::util::coshf ( float arg)
inline

Definition at line 397 of file omath.h.

398{
399 return cosh(arg);
400}
ADf< T, DIM > cosh(const ADf< T, DIM > &a)
Definition aDiff.h:657

References cosh().

+ Here is the call graph for this function:

◆ coshl()

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

Definition at line 412 of file omath.h.

413{
414 return cosh(arg);
415}

References cosh().

+ Here is the call graph for this function:

◆ cosl()

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

Definition at line 380 of file omath.h.

381{
382 return cos(arg);
383}

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:178

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

+ Here is the call 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 >
T olb::util::densityFromPressure ( T latticePressure)

compute lattice density from lattice pressure

Definition at line 379 of file util.h.

380{
381 // rho = p / c_s^2 + 1
382 return latticePressure * descriptors::invCs2<T,DESCRIPTOR>() + 1.0;
383}

◆ 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:

◆ 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:161

References olb::Vector< T, D >::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 183 of file vectorHelpers.h.

184{
185 if constexpr (D==2){
186 return dotProduct2D(a, b);
187 } else {
188 return dotProduct3D(a, b);
189 }
190}
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:

◆ 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 176 of file vectorHelpers.h.

177{
178 return a[0]*b[0] + a[1]*b[1];
179}
+ 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 169 of file vectorHelpers.h.

170{
171 return a[0]*b[0] + a[1]*b[1] + a[2]*b[2];
172}
+ 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}
cpu::simd::Pack< T > sqrt(cpu::simd::Pack< T > value)
Definition pack.h:100
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 146 of file geometricOperations.h.

150{
151 const Vector<T, D> dist = input - rotationCenter;
152 Vector<T, D> rotated;
153
154 if constexpr (D == 2) {
155 rotated =
156 Vector<T, 2>(dist[0] * rotationMatrix[0] + dist[1] * rotationMatrix[1],
157 dist[0] * rotationMatrix[2] + dist[1] * rotationMatrix[3]);
158 }
159 else {
160 rotated =
161 Vector<T, 3>(rotationMatrix[0] * dist[0] + rotationMatrix[1] * dist[1] +
162 rotationMatrix[2] * dist[2],
163 rotationMatrix[3] * dist[0] + rotationMatrix[4] * dist[1] +
164 rotationMatrix[5] * dist[2],
165 rotationMatrix[6] * dist[0] + rotationMatrix[7] * dist[1] +
166 rotationMatrix[8] * dist[2]);
167 }
168
169 if constexpr (!OUTPUT_USES_ROTATION_CENTER_AS_ORIGIN) {
170 return rotationCenter + rotated;
171 }
172 else {
173 return rotated;
174 }
175
176 __builtin_unreachable();
177}
+ 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}

References olb::util::ADf< T, DIM >::_d, and olb::util::ADf< T, DIM >::_v.

+ Here is the caller graph for this function:

◆ exp() [2/4]

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

Definition at line 192 of file expr.h.

192 {
193 return Expr(Expr::Op::Exp, x);
194}
Basic value-substitute enabling extraction of expression trees for code generation.
Definition expr.h:38

References olb::Expr::Exp.

◆ exp() [3/4]

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

Definition at line 111 of file omath.h.

112{
113 return std::exp(arg);
114}

◆ exp() [4/4]

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

Definition at line 117 of file omath.h.

118{
119 return std::exp(arg);
120}

◆ expf() [1/2]

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/2]

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

Definition at line 122 of file omath.h.

123{
124 return exp(arg);
125}

References exp().

+ Here is the call graph for this function:

◆ 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 127 of file omath.h.

128{
129 return exp(arg);
130}

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 olb::util::ADf< T, DIM >::_v, and sign().

+ Here is the call graph for this function:

◆ fabs() [2/6]

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

Definition at line 106 of file pack.h.

107{
108 return cpu::simd::fabs(value);
109}

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

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

◆ fabs() [3/6]

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

Definition at line 184 of file expr.h.

184 {
185 return Expr(Expr::Op::Abs, x);
186}

References olb::Expr::Abs.

◆ fabs() [4/6]

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

Definition at line 925 of file omath.h.

926{
927 return std::fabs(arg);
928}

◆ fabs() [5/6]

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

Definition at line 891 of file omath.h.

892{
893#ifdef __CUDA_ARCH__
894 return ::fabs(arg);
895#else
896 return std::fabs(arg);
897#endif
898}

◆ fabs() [6/6]

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

Definition at line 901 of file omath.h.

902{
903#ifdef __CUDA_ARCH__
904 return ::fabs(arg);
905#else
906 return std::fabs(arg);
907#endif
908}

◆ fabsf() [1/2]

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:
+ Here is the caller graph for this function:

◆ fabsf() [2/2]

float olb::util::fabsf ( float arg)
inline

Definition at line 920 of file omath.h.

921{
922 return fabs(arg);
923}

References fabs().

+ Here is the call graph for this function:

◆ fabsl() [1/2]

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:
+ Here is the caller graph for this function:

◆ fabsl() [2/2]

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

Definition at line 930 of file omath.h.

931{
932 return fabs(arg);
933}

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 237 of file util.h.

238{
239 for (int iPop=0; iPop<DESCRIPTORBASE::q; ++iPop) {
240 bool fit = true;
241 for (int iD=0; iD<DESCRIPTORBASE::d; ++iD) {
242 if (descriptors::c<DESCRIPTORBASE>(iPop,iD) != v[iD]) {
243 fit = false;
244 break;
245 }
246 }
247 if (fit) {
248 return iPop;
249 }
250 }
251 return DESCRIPTORBASE::q;
252}

◆ floor() [1/6]

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}

References olb::util::ADf< T, DIM >::_v, and olb::util::ADf< T, DIM >::d().

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

◆ floor() [2/6]

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 213 of file vectorHelpers.h.

214{
215 Vector<T,Size> out;
216 for (unsigned int iDim=0; iDim < Size; ++iDim) {
217 out[iDim] = util::floor(a[iDim]);
218 }
219 return out;
220}

References floor().

+ Here is the call graph for this function:

◆ floor() [3/6]

double olb::util::floor ( double arg)
inline

Definition at line 719 of file omath.h.

720{
721 return std::floor(arg);
722}

◆ floor() [4/6]

float olb::util::floor ( float arg)
inline

Definition at line 714 of file omath.h.

715{
716 return std::floor(arg);
717}

◆ floor() [5/6]

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

Definition at line 724 of file omath.h.

725{
726 return std::floor(arg);
727}

◆ floor() [6/6]

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

Definition at line 740 of file omath.h.

741{
742 return std::floor(arg);
743}

◆ floorf() [1/2]

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/2]

float olb::util::floorf ( float arg)
inline

Definition at line 729 of file omath.h.

730{
731 return floor(arg);
732}

References floor().

+ Here is the call graph for this function:

◆ 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 734 of file omath.h.

735{
736 return floor(arg);
737}

References floor().

+ Here is the call graph for this function:

◆ fmod() [1/11]

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/11]

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/11]

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/11]

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 235 of file vectorHelpers.h.

236{
237 Vector<T,Size> out;
238 for (unsigned int iDim=0; iDim < Size; ++iDim) {
239 out[iDim] = util::fmod(a[iDim], b);
240 }
241 return out;
242}

References fmod().

+ Here is the call graph for this function:

◆ fmod() [5/11]

double olb::util::fmod ( double x,
double y )
inline

Definition at line 72 of file omath.h.

73{
74 return std::fmod(x, y);
75}

◆ fmod() [6/11]

double olb::util::fmod ( double x,
int y )
inline

Definition at line 92 of file omath.h.

93{
94 return std::fmod(x, y);
95}

◆ fmod() [7/11]

float olb::util::fmod ( float x,
float y )
inline

Definition at line 62 of file omath.h.

63{
64 return std::fmod(x, y);
65}

◆ fmod() [8/11]

float olb::util::fmod ( float x,
int y )
inline

Definition at line 87 of file omath.h.

88{
89 return std::fmod(x, y);
90}

◆ fmod() [9/11]

long double olb::util::fmod ( long double x,
int y )
inline

Definition at line 97 of file omath.h.

98{
99 return std::fmod(x, y);
100}

◆ fmod() [10/11]

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

Definition at line 77 of file omath.h.

78{
79 return std::fmod(x, y);
80}

◆ fmod() [11/11]

template<typename T , typename S >
auto olb::util::fmod ( T x,
S y )
inline

Definition at line 103 of file omath.h.

104{
105 return std::fmod(x, y);
106}

◆ 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()

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

Definition at line 67 of file omath.h.

68{
69 return fmod(x, y);
70}

References fmod().

+ Here is the call graph for this function:

◆ fmodl()

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

Definition at line 82 of file omath.h.

83{
84 return fmod(x, y);
85}

References fmod().

+ Here is the call graph for this function:

◆ fromVector2()

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

Definition at line 135 of file vectorHelpers.h.

136{
137 std::vector<T> v;
138 v.push_back(vec[0]);
139 v.push_back(vec[1]);
140 return v;
141}

◆ fromVector3()

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

Definition at line 126 of file vectorHelpers.h.

127{
128 std::vector<T> v;
129 v.push_back(vec[0]);
130 v.push_back(vec[1]);
131 v.push_back(vec[2]);
132 return v;
133}
+ 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 354 of file util.h.

355{
356 T max=-1;
357 int max_index = 0;
358 for (int iQ=1; iQ<DESCRIPTOR::q; ++iQ) {
359 std::vector<T> c_i(DESCRIPTOR::c[iQ], DESCRIPTOR::c[iQ]+3);
360 T tmp = util::scalarProduct<T>(c_i, vec)/util::norm(c_i);
361 if (tmp > max) {
362 max = tmp;
363 max_index = iQ;
364 }
365 }
366 return max_index;
367}

References max(), and norm().

+ 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 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:

◆ 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 89 of file util.h.

93{
94 newX0 = util::max(x0,x0_);
95 newY0 = util::max(y0,y0_);
96
97 newX1 = util::min(x1,x1_);
98 newY1 = util::min(y1,y1_);
99
100 return newX1>=newX0 && newY1>=newY0;
101}

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 103 of file util.h.

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

References max(), and min().

+ Here is the call graph for this function:

◆ 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 182 of file geometricOperations.h.

186{
188 invertRotationMatrix<T, D>(rotationMatrix);
189 return executeRotation(input, invRotationMatrix, rotationCenter);
190}
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().

+ 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 113 of file geometricOperations.h.

115{
116 if constexpr (D == 2) {
117 return Vector<T, 4>(rotationMatrix[0], rotationMatrix[2], rotationMatrix[1],
118 rotationMatrix[3]);
119 }
120 else {
121
122 //Individual Entries ( source: https://doi.org/10.1016/j.compfluid.2018.02.027 )
123 // |x0| / 0 3 6 \ |x1|
124 // |y0| | 1 4 7 | = |x1|
125 // |z0| \ 2 5 8 / |x1|
126
127 return Vector<T, 9>(rotationMatrix[0], rotationMatrix[3], rotationMatrix[6],
128 rotationMatrix[1], rotationMatrix[4], rotationMatrix[7],
129 rotationMatrix[2], rotationMatrix[5],
130 rotationMatrix[8]);
131 }
132 __builtin_unreachable();
133}

◆ 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 435 of file vectorHelpers.h.

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

◆ labs() [1/2]

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}
std::enable_if_t< std::is_arithmetic< T >::type::value, T > abs(T x)
Definition util.h:396

References abs().

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

◆ labs() [2/2]

long olb::util::labs ( long arg)
inline

Definition at line 910 of file omath.h.

911{
912 return abs(arg);
913}

References abs().

+ Here is the call graph for this function:

◆ llabs() [1/2]

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:

◆ llabs() [2/2]

long long olb::util::llabs ( long long arg)
inline

Definition at line 915 of file omath.h.

916{
917 return abs(arg);
918}

References abs().

+ 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 863 of file omath.h.

864{
865 return std::llround(arg);
866}

◆ 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 868 of file omath.h.

869{
870 return llround(arg);
871}

References llround().

+ Here is the call graph for this function:

◆ 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 873 of file omath.h.

874{
875 return llround(arg);
876}

References llround().

+ Here is the call graph for this function:

◆ log() [1/5]

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}

References olb::util::ADf< T, DIM >::_d, and olb::util::ADf< T, DIM >::_v.

+ Here is the caller graph for this function:

◆ log() [2/5]

double olb::util::log ( double arg)
inline

Definition at line 143 of file omath.h.

144{
145 return std::log(arg);
146}

◆ log() [3/5]

float olb::util::log ( float arg)
inline

Definition at line 133 of file omath.h.

134{
135 return std::log(arg);
136}

◆ log() [4/5]

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

Definition at line 148 of file omath.h.

149{
150 return std::log(arg);
151}

◆ log() [5/5]

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

Definition at line 159 of file omath.h.

160{
161 return std::log(arg);
162}

◆ log10() [1/5]

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}

References olb::util::ADf< T, DIM >::_d, and olb::util::ADf< T, DIM >::_v.

+ Here is the caller graph for this function:

◆ log10() [2/5]

double olb::util::log10 ( double arg)
inline

Definition at line 175 of file omath.h.

176{
177 return std::log10(arg);
178}

◆ log10() [3/5]

float olb::util::log10 ( float arg)
inline

Definition at line 165 of file omath.h.

166{
167 return std::log10(arg);
168}

◆ log10() [4/5]

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

Definition at line 180 of file omath.h.

181{
182 return std::log10(arg);
183}

◆ log10() [5/5]

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

Definition at line 191 of file omath.h.

192{
193 return std::log10(arg);
194}

◆ log10f() [1/2]

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/2]

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

Definition at line 170 of file omath.h.

171{
172 return log10(arg);
173}

References log10().

+ Here is the call graph for this function:

◆ 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 185 of file omath.h.

186{
187 return log10(arg);
188}

References log10().

+ Here is the call graph for this function:

◆ log1p() [1/5]

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/5]

double olb::util::log1p ( double arg)
inline

Definition at line 239 of file omath.h.

240{
241 return std::log1p(arg);
242}

◆ log1p() [3/5]

float olb::util::log1p ( float arg)
inline

Definition at line 229 of file omath.h.

230{
231 return std::log1p(arg);
232}

◆ log1p() [4/5]

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

Definition at line 244 of file omath.h.

245{
246 return std::log1p(arg);
247}

◆ log1p() [5/5]

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

Definition at line 255 of file omath.h.

256{
257 return std::log1p(arg);
258}

◆ log1pf() [1/2]

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/2]

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

Definition at line 234 of file omath.h.

235{
236 return log1p(arg);
237}

References log1p().

+ Here is the call graph for this function:

◆ 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 249 of file omath.h.

250{
251 return log1p(arg);
252}

References log1p().

+ Here is the call graph for this function:

◆ log2() [1/5]

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}

References olb::util::ADf< T, DIM >::_d, and olb::util::ADf< T, DIM >::_v.

+ Here is the caller graph for this function:

◆ log2() [2/5]

double olb::util::log2 ( double arg)
inline

Definition at line 207 of file omath.h.

208{
209 return std::log2(arg);
210}

◆ log2() [3/5]

float olb::util::log2 ( float arg)
inline

Definition at line 197 of file omath.h.

198{
199 return std::log2(arg);
200}

◆ log2() [4/5]

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

Definition at line 212 of file omath.h.

213{
214 return std::log2(arg);
215}

◆ log2() [5/5]

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

Definition at line 223 of file omath.h.

224{
225 return std::log2(arg);
226}

◆ log2f() [1/2]

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/2]

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

Definition at line 202 of file omath.h.

203{
204 return log2(arg);
205}

References log2().

+ Here is the call graph for this function:

◆ 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 217 of file omath.h.

218{
219 return log2(arg);
220}

References log2().

+ Here is the call graph for this function:

◆ logf() [1/2]

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/2]

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

Definition at line 138 of file omath.h.

139{
140 return log(arg);
141}

References log().

+ Here is the call graph for this function:

◆ 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 153 of file omath.h.

154{
155 return log(arg);
156}

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}
ADf< T, DIM > round(const ADf< T, DIM > &a)
Definition aDiff.h:928

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 847 of file omath.h.

848{
849 return std::lround(arg);
850}

◆ 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 852 of file omath.h.

853{
854 return lround(arg);
855}

References lround().

+ Here is the call graph for this function:

◆ 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 857 of file omath.h.

858{
859 return lround(arg);
860}

References lround().

+ Here is the call graph for this function:

◆ max() [1/8]

template<class T , unsigned DIM>
constexpr 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/8]

template<class T , unsigned DIM>
constexpr 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/8]

template<class T , unsigned DIM>
constexpr 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/8]

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

Definition at line 130 of file pack.h.

131{
132 return cpu::simd::max(rhs, lhs);
133}

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

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

◆ max() [5/8]

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

Definition at line 47 of file oalgorithm.h.

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

◆ max() [6/8]

template<typename T , class Compare >
constexpr T olb::util::max ( std::initializer_list< T > ilist,
Compare comp )
inlineconstexpr

Definition at line 52 of file oalgorithm.h.

53{
54 return std::max(ilist, comp);
55}

◆ max() [7/8]

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

Definition at line 37 of file oalgorithm.h.

38{
39 return std::max(a, b);
40}

◆ max() [8/8]

template<typename T , class Compare >
constexpr T olb::util::max ( T a,
meta::id_t< T > b,
Compare comp )
inlineconstexpr

Definition at line 42 of file oalgorithm.h.

43{
44 return std::max(a, b, comp);
45}

◆ max< double >()

template<>
double olb::util::max< double > ( double x,
double y )
inline

Definition at line 64 of file oalgorithm.h.

65{
66 return std::fmax(x, y);
67}

◆ max< float >()

template<>
float olb::util::max< float > ( float x,
float y )
inline

Definition at line 58 of file oalgorithm.h.

59{
60 return std::fmax(x, y);
61}

◆ 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 257 of file vectorHelpers.h.

258{
259 T max = a[0];
260 for (unsigned int iDim=1; iDim < Size; ++iDim) {
261 max = std::max(max,a[iDim]);
262 }
263 return max;
264}

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 305 of file vectorHelpers.h.

306{
307 T maxAbs = a[0];
308 for (unsigned int iDim=1; iDim < Size; ++iDim) {
309 if (abs(a[iDim])>abs(maxAbs)){
310 maxAbs = a[iDim];
311 }
312 }
313 return maxAbs;
314}

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 318 of file vectorHelpers.h.

319{
320 unsigned maxAbsPos = 0;
321 for (unsigned int iDim=1; iDim < Size; ++iDim) {
322 if (abs(a[iDim])>abs(a[maxAbsPos])){
323 maxAbsPos = iDim;
324 }
325 }
326 return maxAbsPos;
327}

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 279 of file vectorHelpers.h.

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

◆ min() [1/8]

template<class T , unsigned DIM>
constexpr 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/8]

template<class T , unsigned DIM>
constexpr 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/8]

template<class T , unsigned DIM>
constexpr 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/8]

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

Definition at line 124 of file pack.h.

125{
126 return cpu::simd::min(rhs, lhs);
127}

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

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

◆ min() [5/8]

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

Definition at line 81 of file oalgorithm.h.

82{
83 return std::min(ilist);
84}

◆ min() [6/8]

template<typename T , class Compare >
constexpr T olb::util::min ( std::initializer_list< T > ilist,
Compare comp )
inlineconstexpr

Definition at line 86 of file oalgorithm.h.

87{
88 return std::min(ilist, comp);
89}

◆ min() [7/8]

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

Definition at line 71 of file oalgorithm.h.

72{
73 return std::min(a, b);
74}

◆ min() [8/8]

template<typename T , class Compare >
constexpr T olb::util::min ( T a,
meta::id_t< T > b,
Compare comp )
inlineconstexpr

Definition at line 76 of file oalgorithm.h.

77{
78 return std::min(a, b, comp);
79}

◆ min< double >()

template<>
double olb::util::min< double > ( double x,
double y )
inline

Definition at line 98 of file oalgorithm.h.

99{
100 return std::fmin(x, y);
101}

◆ min< float >()

template<>
float olb::util::min< float > ( float x,
float y )
inline

Definition at line 92 of file oalgorithm.h.

93{
94 return std::fmin(x, y);
95}

◆ 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 268 of file vectorHelpers.h.

269{
270 T min = a[0];
271 for (unsigned int iDim=1; iDim < Size; ++iDim) {
272 min = std::min(min,a[iDim]);
273 }
274 return min;
275}

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 292 of file vectorHelpers.h.

293{
294 unsigned minPos = 0;
295 for (unsigned int iDim=1; iDim < Size; ++iDim) {
296 if (a[iDim]<a[minPos]){
297 minPos = iDim;
298 }
299 }
300 return minPos;
301}

◆ 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}

References olb::util::ADf< T, DIM >::_v.

+ Here is the caller graph for this function:

◆ nearZero() [2/3]

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

return true if a is close to zero

Definition at line 53 of file vectorHelpers.h.

54{
55 if (a==T()) {
56 return true;
57 }
58 T EPSILON = std::numeric_limits<T>::epsilon();
59 if (a > -EPSILON && a < EPSILON) {
60 return true;
61 }
62 else {
63 return false;
64 }
65}

◆ nearZero() [3/3]

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

Definition at line 68 of file vectorHelpers.h.

69{
70 if (a > -epsilon && a < epsilon) {
71 return true;
72 }
73 else {
74 return false;
75 }
76}

◆ norm() [1/2]

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

Definition at line 153 of file util.h.

154{
155 return sqrt(normSqr<ARRAY_LIKE,D>(u));
156}

References sqrt().

+ Here is the call graph for this function:

◆ norm() [2/2]

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

l2 norm of a vector of arbitrary length

Definition at line 146 of file vectorHelpers.h.

147{
148 T v(0);
149 for (unsigned iD=0; iD<a.size(); iD++) {
150 v += a[iD]*a[iD];
151 }
152 v = util::sqrt(v);
153 return v;
154}

References sqrt().

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

◆ norm2()

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 158 of file vectorHelpers.h.

159{
160 T v = T();
161 for (unsigned iD=0; iD<a.size(); iD++) {
162 v += a[iD]*a[iD];
163 }
164 return v;
165}
+ 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 200 of file vectorHelpers.h.

201{
202 std::vector<T> out(a);
203 T scale = norm(a);
204 assert(scale>0);
205 for (unsigned int iDim=0; iDim<a.size(); iDim++) {
206 out[iDim] /= scale;
207 }
208 return out;
209}

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 193 of file vectorHelpers.h.

194{
195 return a / norm(a);
196}

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 143 of file util.h.

144{
145 auto uSqr = decltype(u[0]){};
146 for (unsigned iD=0; iD < D; ++iD) {
147 uSqr += u[iD]*u[iD];
148 }
149 return uSqr;
150}

◆ 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 177 of file util.h.

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

◆ normSqr() [3/4]

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

Definition at line 159 of file util.h.

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

◆ normSqr() [4/4]

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

Definition at line 169 of file util.h.

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

◆ operator!=() [1/3]

template<class T , unsigned DIM>
constexpr 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}

References olb::util::ADf< T, DIM >::_v.

◆ 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>
constexpr 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}

References olb::util::ADf< T, DIM >::_v.

◆ 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>
constexpr 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}

References olb::util::ADf< T, DIM >::_v.

◆ operator*() [1/3]

template<class T , unsigned DIM>
constexpr 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>
constexpr 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>
constexpr 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>
constexpr 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>
constexpr 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>
constexpr 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>
constexpr 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>
constexpr 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>
constexpr 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>
constexpr 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>
constexpr 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>
constexpr 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>
constexpr 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>
constexpr 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>
constexpr 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}

References olb::util::ADf< T, DIM >::_v.

◆ 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>
constexpr 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}

References olb::util::ADf< T, DIM >::_v.

◆ 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>
constexpr 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}

References olb::util::ADf< T, DIM >::_v.

◆ 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}

References olb::util::ADf< T, DIM >::_d, and olb::util::ADf< T, DIM >::_v.

◆ operator<=() [1/3]

template<class T , unsigned DIM>
constexpr 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}

References olb::util::ADf< T, DIM >::_v.

◆ 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>
constexpr 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}

References olb::util::ADf< T, DIM >::_v.

◆ 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>
constexpr 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}

References olb::util::ADf< T, DIM >::_v.

◆ operator==() [1/3]

template<class T , unsigned DIM>
constexpr 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}

References olb::util::ADf< T, DIM >::_v.

◆ 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>
constexpr 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}

References olb::util::ADf< T, DIM >::_v.

◆ 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>
constexpr 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}

References olb::util::ADf< T, DIM >::_v.

◆ operator>() [1/3]

template<class T , unsigned DIM>
constexpr 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}

References olb::util::ADf< T, DIM >::_v.

◆ 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>
constexpr 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}

References olb::util::ADf< T, DIM >::_v.

◆ 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>
constexpr 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}

References olb::util::ADf< T, DIM >::_v.

◆ operator>=() [1/3]

template<class T , unsigned DIM>
constexpr 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}

References olb::util::ADf< T, DIM >::_v.

◆ 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>
constexpr 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}

References olb::util::ADf< T, DIM >::_v.

◆ 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>
constexpr 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}

References olb::util::ADf< T, DIM >::_v.

◆ 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}

References olb::util::ADf< T, DIM >::_d, and olb::util::ADf< T, DIM >::_v.

◆ populationsContributingToDirection()

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

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

Definition at line 226 of file util.h.

226 {
227 constexpr auto velocity_matches_direction = [](unsigned iPop) -> bool {
228 return meta::indexed_pack_contains<NORMAL...>([iPop](unsigned iD, int x) -> bool {
229 return x != 0 && x == descriptors::c<DESCRIPTOR>(iPop,iD);
230 });
231 };
232 return meta::array_from_index_sequence(
233 descriptors::filter_population_indices<DESCRIPTOR>(velocity_matches_direction));
234};

References olb::meta::array_from_index_sequence(), 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>
constexpr auto olb::util::populationsContributingToVelocity ( )
constexpr

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

Definition at line 216 of file util.h.

216 {
217 constexpr auto velocity_matches_value = [](unsigned iPop) -> bool {
218 return descriptors::c<DESCRIPTOR>(iPop,iVel) == value;
219 };
220 return meta::array_from_index_sequence(
221 descriptors::filter_population_indices<DESCRIPTOR>(velocity_matches_value));
222};

References olb::meta::array_from_index_sequence().

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

◆ pow() [1/8]

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]

References olb::util::ADf< T, DIM >::_v, olb::util::ADf< T, DIM >::d(), exp(), log(), and nearZero().

+ Here is the call graph for this function:

◆ pow() [2/8]

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}

References olb::util::ADf< T, DIM >::_d, and olb::util::ADf< T, DIM >::_v.

◆ pow() [3/8]

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}

References olb::util::ADf< T, DIM >::_d, and olb::util::ADf< T, DIM >::_v.

◆ pow() [4/8]

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}

References olb::util::ADf< T, DIM >::_d, and olb::util::ADf< T, DIM >::_v.

◆ pow() [5/8]

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

Definition at line 112 of file pack.h.

113{
114 return cpu::simd::pow(base, exp);
115}

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

+ Here is the call graph for this function:

◆ pow() [6/8]

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

Definition at line 118 of file pack.h.

119{
120 return cpu::simd::pow(base, cpu::simd::Pack<T>(exp));
121}

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

+ Here is the call graph for this function:

◆ pow() [7/8]

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

Definition at line 188 of file expr.h.

188 {
189 return Expr(base, Expr::Op::Pow, exp);
190}

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

+ Here is the call graph for this function:

◆ pow() [8/8]

template<typename T , typename S >
any_platform auto olb::util::pow ( T base,
S exp ) -> std::enable_if_t<std::is_arithmetic_v<T>,decltype(std::pow(base,exp))>
inline

Definition at line 38 of file omath.h.

39{
40#ifdef __CUDA_ARCH__
41 return ::pow(base, exp);
42#else
43 return std::pow(base, exp);
44#endif
45}

References exp().

+ Here is the call graph for this function:

◆ powf()

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

Definition at line 47 of file omath.h.

48{
49#ifdef __CUDA_ARCH__
50 return ::powf(base, exp);
51#else
52 return pow(base, exp);
53#endif
54}

References exp(), and pow().

+ Here is the call graph for this function:

◆ powl()

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

Definition at line 56 of file omath.h.

57{
58 return pow(base, exp);
59}

References exp(), and pow().

+ Here is the call graph for this function:

◆ pressureFromDensity()

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

compute lattice pressure from lattice density

Definition at line 387 of file util.h.

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

◆ 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 419 of file vectorHelpers.h.

421{
422 static_assert(!std::is_integral<U>::value && !std::is_floating_point<U>::value, "passed integral or floating_point value to function print()");
423 if (name != "") {
424 clout << name << " = ";
425 }
426 for ( auto& element : data ) {
427 clout << std::fixed << element << delimiter << ' ';
428 }
429 clout << std::endl;
430}
+ 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 333 of file util.h.

334{
335 std::vector<int> remaining;
336 for (int iPop = 0; iPop < DESCRIPTORBASE::q; ++iPop) {
337 bool found = false;
338 for (unsigned jPop = 0; jPop < indices.size(); ++jPop) {
339 if (indices[jPop] == iPop) {
340 found = true;
341 }
342 }
343 if (!found) {
344 remaining.push_back(iPop);
345 }
346 }
347 return remaining;
348}

◆ rotateMofi()

template<typename T >
constexpr 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 216 of file geometricOperations.h.

218{
219 // I' = R(angle) * I * R(angle)^T
220 // TODO: The inertia tensor is symmetric - make use of it
221 T data[3][3] = {
222 {mofi[0], T {}, T {}},
223 { T {}, mofi[1], T {}},
224 { T {}, T {}, mofi[2]}
225 };
226 Matrix<T, 3, 3> inertiaTensor(data);
227 const Matrix<T, 3, 3> _rotationMatrix(rotationMatrix);
228 inertiaTensor =
229 _rotationMatrix * inertiaTensor * (_rotationMatrix.transpose());
230
231 return inertiaTensor;
232}

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

+ Here is the call graph for this function:

◆ round() [1/5]

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}

References olb::util::ADf< T, DIM >::_v, and olb::util::ADf< T, DIM >::d().

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

◆ round() [2/5]

double olb::util::round ( double arg)
inline

Definition at line 821 of file omath.h.

822{
823 return std::round(arg);
824}

◆ round() [3/5]

float olb::util::round ( float arg)
inline

Definition at line 816 of file omath.h.

817{
818 return std::round(arg);
819}

◆ round() [4/5]

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

Definition at line 826 of file omath.h.

827{
828 return std::round(arg);
829}

◆ round() [5/5]

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

Definition at line 811 of file omath.h.

812{
813 return std::round(arg);
814}

◆ 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]

double olb::util::roundf ( double arg)
inline

Definition at line 836 of file omath.h.

837{
838 return round(arg);
839}

References round().

+ Here is the call graph for this function:

◆ roundf() [3/3]

float olb::util::roundf ( float arg)
inline

Definition at line 831 of file omath.h.

832{
833 return round(arg);
834}

References round().

+ Here is the call graph for this function:

◆ 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 841 of file omath.h.

842{
843 return round(arg);
844}

References round().

+ Here is the call graph for this function:

◆ scalarProduct() [1/2]

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

Definition at line 197 of file util.h.

198{
199 T prod = T();
200 if (u1.size() == u2.size()) {
201 for (int iD=0; iD<u1.size(); ++iD) {
202 prod += u1[iD]*u2[iD];
203 }
204 }
205 return prod;
206}

◆ scalarProduct() [2/2]

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

Definition at line 187 of file util.h.

188{
189 T prod = T();
190 for (int iD=0; iD<d; ++iD) {
191 prod += u1[iD]*u2[iD];
192 }
193 return prod;
194}

◆ sign()

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

Definition at line 54 of file util.h.

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

◆ sin() [1/5]

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}

References olb::util::ADf< T, DIM >::_d, and olb::util::ADf< T, DIM >::_v.

+ Here is the caller graph for this function:

◆ sin() [2/5]

double olb::util::sin ( double arg)
inline

Definition at line 306 of file omath.h.

307{
308 return std::sin(arg);
309}

◆ sin() [3/5]

float olb::util::sin ( float arg)
inline

Definition at line 296 of file omath.h.

297{
298 return std::sin(arg);
299}

◆ sin() [4/5]

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

Definition at line 311 of file omath.h.

312{
313 return std::sin(arg);
314}

◆ sin() [5/5]

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

Definition at line 322 of file omath.h.

323{
324 return std::sin(arg);
325}

◆ sinf()

float olb::util::sinf ( float arg)
inline

Definition at line 301 of file omath.h.

302{
303 return sin(arg);
304}

References sin().

+ Here is the call graph for this function:

◆ sinh() [1/5]

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/5]

double olb::util::sinh ( double arg)
inline

Definition at line 338 of file omath.h.

339{
340 return std::sinh(arg);
341}

◆ sinh() [3/5]

float olb::util::sinh ( float arg)
inline

Definition at line 328 of file omath.h.

329{
330 return std::sinh(arg);
331}

◆ sinh() [4/5]

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

Definition at line 343 of file omath.h.

344{
345 return std::sinh(arg);
346}

◆ sinh() [5/5]

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

Definition at line 354 of file omath.h.

355{
356 return std::sinh(arg);
357}

◆ sinhf()

float olb::util::sinhf ( float arg)
inline

Definition at line 333 of file omath.h.

334{
335 return sinh(arg);
336}
ADf< T, DIM > sinh(const ADf< T, DIM > &a)
Definition aDiff.h:651

References sinh().

+ Here is the call graph for this function:

◆ sinhl()

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

Definition at line 348 of file omath.h.

349{
350 return sinh(arg);
351}

References sinh().

+ Here is the call graph for this function:

◆ sinl()

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

Definition at line 316 of file omath.h.

317{
318 return sin(arg);
319}

References sin().

+ Here is the call 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}

References olb::util::ADf< T, DIM >::_d, and olb::util::ADf< T, DIM >::_v.

◆ sqr() [2/2]

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

Definition at line 136 of file util.h.

137{
138 return arg*arg;
139}

◆ sqrt() [1/5]

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 olb::util::ADf< T, DIM >::_d, olb::util::ADf< T, DIM >::_v, olb::util::ADf< T, DIM >::d(), and nearZero().

+ Here is the call graph for this function:

◆ sqrt() [2/5]

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

Definition at line 100 of file pack.h.

101{
102 return value.sqrt();
103}

◆ sqrt() [3/5]

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

Definition at line 180 of file expr.h.

180 {
181 return Expr(Expr::Op::Sqrt, x);
182}

References olb::Expr::Sqrt.

◆ sqrt() [4/5]

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

Definition at line 276 of file omath.h.

277{
278#ifdef __CUDA_ARCH__
279 return ::sqrt(arg);
280#else
281 return std::sqrt(arg);
282#endif
283}

◆ sqrt() [5/5]

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

Definition at line 286 of file omath.h.

287{
288#ifdef __CUDA_ARCH__
289 return ::sqrt(arg);
290#else
291 return std::sqrt(arg);
292#endif
293}

◆ sqrtf()

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

Definition at line 261 of file omath.h.

262{
263#ifdef __CUDA_ARCH__
264 return ::sqrtf(arg);
265#else
266 return sqrt(arg);
267#endif
268}

References sqrt().

+ Here is the call graph for this function:

◆ sqrtl()

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

Definition at line 270 of file omath.h.

271{
272 return sqrt(arg);
273}

References sqrt().

+ Here is the call graph for this function:

◆ subIndexOutgoing()

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

Compute opposites of wall-incoming population indices.

Definition at line 256 of file util.h.

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

References olb::meta::array_from_index_sequence(), and olb::meta::map_index_sequence().

+ Here is the call graph for this function:

◆ subIndexOutgoing2DonCorners()

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

Definition at line 310 of file util.h.

310 {
311 constexpr auto velocity_matches = [](unsigned iPop) {
312 return ( descriptors::c<DESCRIPTOR>(iPop,0) * normalX
313 + descriptors::c<DESCRIPTOR>(iPop,1) * normalY) < 0;
314 };
315 return meta::array_from_index_sequence(
316 descriptors::filter_population_indices<DESCRIPTOR>(velocity_matches));
317}

References olb::meta::array_from_index_sequence().

+ Here is the call graph for this function:

◆ subIndexOutgoing3DonCorners()

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

Definition at line 321 of file util.h.

321 {
322 constexpr auto velocity_matches = [](unsigned iPop) {
323 return ( descriptors::c<DESCRIPTOR>(iPop,0) * normalX
324 + descriptors::c<DESCRIPTOR>(iPop,1) * normalY
325 + descriptors::c<DESCRIPTOR>(iPop,2) * normalZ) < 0;
326 };
327 return meta::array_from_index_sequence(
328 descriptors::filter_population_indices<DESCRIPTOR>(velocity_matches));
329}

References olb::meta::array_from_index_sequence().

+ Here is the call graph for this function:

◆ subIndexOutgoing3DonEdges()

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

Definition at line 286 of file util.h.

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

References olb::meta::array_from_index_sequence().

+ Here is the call graph for this function:

◆ subIndexOutgoingRemaining()

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

Definition at line 272 of file util.h.

272 {
273 constexpr auto velocity_matches = [](unsigned iPop) {
274 for (unsigned jPop : subIndexOutgoing<DESCRIPTOR,direction,orientation>()) {
275 if (iPop == jPop) {
276 return false;
277 }
278 }
279 return true;
280 };
281 return meta::array_from_index_sequence(
282 descriptors::filter_population_indices<DESCRIPTOR>(velocity_matches));
283}
constexpr auto subIndexOutgoing() any_platform
Compute opposites of wall-incoming population indices.
Definition util.h:256

References olb::meta::array_from_index_sequence().

+ Here is the call 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/5]

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}

References olb::util::ADf< T, DIM >::_d, and olb::util::ADf< T, DIM >::_v.

+ Here is the caller graph for this function:

◆ tan() [2/5]

double olb::util::tan ( double arg)
inline

Definition at line 434 of file omath.h.

435{
436 return std::tan(arg);
437}

◆ tan() [3/5]

float olb::util::tan ( float arg)
inline

Definition at line 424 of file omath.h.

425{
426 return std::tan(arg);
427}

◆ tan() [4/5]

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

Definition at line 439 of file omath.h.

440{
441 return std::tan(arg);
442}

◆ tan() [5/5]

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

Definition at line 450 of file omath.h.

451{
452 return std::tan(arg);
453}

◆ tanf()

float olb::util::tanf ( float arg)
inline

Definition at line 429 of file omath.h.

430{
431 return tan(arg);
432}
ADf< T, DIM > tan(const ADf< T, DIM > &a)
Definition aDiff.h:587

References tan().

+ Here is the call graph for this function:

◆ tanh() [1/5]

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/5]

double olb::util::tanh ( double arg)
inline

Definition at line 466 of file omath.h.

467{
468 return std::tanh(arg);
469}

◆ tanh() [3/5]

float olb::util::tanh ( float arg)
inline

Definition at line 456 of file omath.h.

457{
458 return std::tanh(arg);
459}

◆ tanh() [4/5]

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

Definition at line 471 of file omath.h.

472{
473 return std::tanh(arg);
474}

◆ tanh() [5/5]

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

Definition at line 482 of file omath.h.

483{
484 return std::tanh(arg);
485}

◆ tanhf()

float olb::util::tanhf ( float arg)
inline

Definition at line 461 of file omath.h.

462{
463 return tanh(arg);
464}
ADf< T, DIM > tanh(const ADf< T, DIM > &a)
Definition aDiff.h:663

References tanh().

+ Here is the call graph for this function:

◆ tanhl()

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

Definition at line 476 of file omath.h.

477{
478 return tanh(arg);
479}

References tanh().

+ Here is the call graph for this function:

◆ tanl()

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

Definition at line 444 of file omath.h.

445{
446 return tan(arg);
447}

References tan().

+ Here is the call graph for this function:

◆ throwADfException()

template<typename T >
constexpr 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/4]

double olb::util::trunc ( double arg)
inline

Definition at line 788 of file omath.h.

789{
790 return std::trunc(arg);
791}

◆ trunc() [2/4]

float olb::util::trunc ( float arg)
inline

Definition at line 778 of file omath.h.

779{
780 return std::trunc(arg);
781}
+ Here is the caller graph for this function:

◆ trunc() [3/4]

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

Definition at line 793 of file omath.h.

794{
795 return std::trunc(arg);
796}

◆ trunc() [4/4]

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

Definition at line 804 of file omath.h.

805{
806 return std::trunc(arg);
807}

◆ truncf()

float olb::util::truncf ( float arg)
inline

Definition at line 783 of file omath.h.

784{
785 return trunc(arg);
786}
float trunc(float arg)
Definition omath.h:778

References trunc().

+ Here is the call graph for this function:

◆ truncl()

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

Definition at line 798 of file omath.h.

799{
800 return trunc(arg);
801}

References trunc().

+ Here is the call graph for this function:

Variable Documentation

◆ is_adf_v

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

Definition at line 124 of file aDiff.h.