AutoPas  3.0.0
Loading...
Searching...
No Matches
Namespaces | Classes | Typedefs | Enumerations | Functions
autopas::utils Namespace Reference

In this namespace some helper classes and functions can be found used inside of AutoPas. More...

Namespaces

namespace  ArrayMath
 Namespace to handle mathematical operations of std::array.
 
namespace  ArrayUtils
 In this namespace some helper functions for std::array can be found.
 
namespace  AutoPasConfigurationCommunicator
 Provides several functions for handling configurations among mpi ranks.
 
namespace  CompileInfo
 Namespace for functions that provide information about what the code was compiled with.
 
namespace  NumParticlesEstimator
 Functions to estimate numbers of particles.
 
namespace  quaternion
 Array utils specifically for handling quaternions.
 
namespace  StringUtils
 Some functions to parse enums from (input-) strings.
 
namespace  ThreeDimensionalMapping
 Namespace to handle the conversion between one dimensional and three dimensional indices.
 
namespace  TupleUtils
 In this namespace some helper functions for std::tuple can be found.
 

Classes

class  ConfigurationAndRankIteratorHandler
 Functionality needed to iterate through ranks and configurations simultaneously in an evenly distributed manner. More...
 
class  DataLayoutConverter
 This converts cells to the target data Layout using the given functor. More...
 
class  EnergySensor
 Measure the energy consumption of a simulation on multiple hardwares. More...
 
class  ExceptionHandler
 Defines and handles the throwing and printing of exceptions. More...
 
struct  is_shared_ptr
 Type trait to determine if a type is a shared pointer at compile time. More...
 
struct  is_shared_ptr< std::shared_ptr< T > >
 True specialization for shared_ptr. More...
 
struct  is_smart_ptr
 Type trait to determine if a type is a smart pointer at compile time. More...
 
struct  is_smart_ptr< std::shared_ptr< T > >
 True specialization for shared_ptr. More...
 
struct  is_smart_ptr< std::unique_ptr< T > >
 True specialization for unique_ptr. More...
 
struct  is_smart_ptr< std::weak_ptr< T > >
 True specialization for weak_ptr. More...
 
struct  is_unique_ptr
 Type trait to determine if a type is a unique pointer at compile time. More...
 
struct  is_unique_ptr< std::unique_ptr< T > >
 True specialization for unique_ptr. More...
 
struct  ParticleTypeTrait
 ParticleTypeTrait class. More...
 
struct  ParticleTypeTrait< autopas::AutoPas< Particle_T > >
 Specialization for the AutoPas class. More...
 
struct  ParticleTypeTrait< std::vector< ParticleCell > >
 Specialization for vectors of ParticleCells. More...
 
class  SoAStorage
 SoAStorage is a helper to access the stored SoA's. More...
 
struct  SoAType
 Helper struct to get a the SoAType. More...
 
class  Timer
 Timer class to stop times. More...
 

Typedefs

template<typename FunctorT >
using isPairwiseFunctor = decltype(isPairwiseFunctorImpl(std::declval< FunctorT >()))
 Check whether a Functor Type is inheriting from PairwiseFunctor.
 
template<typename FunctorT >
using isTriwiseFunctor = decltype(isTriwiseFunctorImpl(std::declval< FunctorT >()))
 Check whether a Functor Type is inheriting from TriwiseFunctor.
 

Enumerations

enum  ExceptionBehavior { ignore , throwException , printAbort , printCustomAbortFunction }
 Enum that defines the behavior of the expection handling. More...
 

Functions

template<typename T >
bool inBox (const std::array< T, 3 > &position, const std::array< T, 3 > &low, const std::array< T, 3 > &high)
 Checks if position is inside of a box defined by low and high.
 
template<typename T >
bool notInBox (const std::array< T, 3 > &position, const std::array< T, 3 > &low, const std::array< T, 3 > &high)
 Checks if position is not inside of a box defined by low and high.
 
template<typename T >
bool boxesOverlap (const std::array< T, 3 > &boxALow, const std::array< T, 3 > &boxAHigh, const std::array< T, 3 > &boxBLow, const std::array< T, 3 > &boxBHigh)
 Checks if two boxes have overlap.
 
template<typename Particle >
std::pair< double, double > calculateHomogeneityAndMaxDensity (const ParticleContainerInterface< Particle > &container)
 Calculates homogeneity and max density of given AutoPas container.
 
template<typename F >
decltype(auto) withStaticBool (bool theBool, F &&func)
 Function to execute the code passed in the lambda with a static bool.
 
template<typename ParticleType , typename F >
decltype(auto) withStaticCellType (autopas::CellType cellType, F &&func)
 Executes the passed function body with the static cell type defined by cellType.
 

Detailed Description

In this namespace some helper classes and functions can be found used inside of AutoPas.

These classes reside mostly in the utils directory. However, most commonly used function inside the utils directory might not be in the utils namespace.

Typedef Documentation

◆ isPairwiseFunctor

template<typename FunctorT >
using autopas::utils::isPairwiseFunctor = typedef decltype(isPairwiseFunctorImpl(std::declval<FunctorT>()))

Check whether a Functor Type is inheriting from PairwiseFunctor.

Template Parameters
FunctorT

◆ isTriwiseFunctor

template<typename FunctorT >
using autopas::utils::isTriwiseFunctor = typedef decltype(isTriwiseFunctorImpl(std::declval<FunctorT>()))

Check whether a Functor Type is inheriting from TriwiseFunctor.

Template Parameters
FunctorT

Enumeration Type Documentation

◆ ExceptionBehavior

Enum that defines the behavior of the expection handling.

Enumerator
ignore 

Ignore all exceptions.

throwException 

Throw the exception.

printAbort 

Print the exception and.

printCustomAbortFunction 

Print the exception and call a custom abort function.

Function Documentation

◆ boxesOverlap()

template<typename T >
bool autopas::utils::boxesOverlap ( const std::array< T, 3 > &  boxALow,
const std::array< T, 3 > &  boxAHigh,
const std::array< T, 3 > &  boxBLow,
const std::array< T, 3 > &  boxBHigh 
)

Checks if two boxes have overlap.

If the boxes touch (= exact same floating point values), they are not considered to have overlap.

Template Parameters
T
Parameters
boxALow
boxAHigh
boxBLow
boxBHigh
Returns

◆ calculateHomogeneityAndMaxDensity()

template<typename Particle >
std::pair< double, double > autopas::utils::calculateHomogeneityAndMaxDensity ( const ParticleContainerInterface< Particle > &  container)

Calculates homogeneity and max density of given AutoPas container.

Both values are computed at once to avoid iterating over the same space twice. homogeneity > 0.0, normally < 1.0, but for extreme scenarios > 1.0 maxDensity > 0.0, normally < 3.0, but for extreme scenarios > 3.0

A homogeneity of 0 describes a perfectly homogeneous scenario, and as the scenario becomes more heterogeneous, this becomes greater. If there are no particles, homogeneity is forced as 0 as this scenario is perfectly homogeneous.

These values are calculated by dividing the container's domain into bins of perfectly equal cuboid shapes.

Note
The bin shapes between different AutoPas containers will not match if the dimensions of their domains don't match. Bins with greater surface area are probably more likely to feature fluctuations in the density.

Not a rigorous proof, but should give an idea:

  • Assume homogeneous distribution.
  • For every particle assume it could move in any direction with equal probability (not a terrible assumption).
  • So every particle near a bin face has a chance to move into the neighboring bin.
  • And this probability is independent of the bin (i.e. the bin shape)
  • With a larger surface area, there are more particles with a probability of moving into the neighboring bin.
  • On average, same density, but each individual bin has a greater probability of losing or gaining a lot of particles.

This is probably still fine for MPI Parallelized Tuning purposes, but be careful with comparing homogeneities and densities.

Template Parameters
Particle
Parameters
containercontainer of current simulation
Returns
{homogeneity, maxDensity}

◆ inBox()

template<typename T >
bool autopas::utils::inBox ( const std::array< T, 3 > &  position,
const std::array< T, 3 > &  low,
const std::array< T, 3 > &  high 
)

Checks if position is inside of a box defined by low and high.

The lower corner is included in, the upper is excluded from the box. i.e. [low[0], high[0]) x [low[1], high[1]) x [low[2], high[2])

Template Parameters
Tthe type of floating point check
Parameters
positionthe position that should be checked
lowthe lower corner of the box (inclusive)
highthe upper corner of the box (exclusive)
Returns
true if position is inside the box, false otherwise

◆ notInBox()

template<typename T >
bool autopas::utils::notInBox ( const std::array< T, 3 > &  position,
const std::array< T, 3 > &  low,
const std::array< T, 3 > &  high 
)

Checks if position is not inside of a box defined by low and high.

The lower corner is included in, the upper is excluded from the box. i.e. [low[0], high[0]) x [low[1], high[1]) x [low[2], high[2])

Template Parameters
Tthe type of floating point check
Parameters
positionthe position that should be checked
lowthe lower corner of the box (inclusive)
highthe upper corner of the box (exclusive)
Returns
true if position is not inside the box, false otherwise

◆ withStaticBool()

template<typename F >
decltype(auto) autopas::utils::withStaticBool ( bool  theBool,
F &&  func 
)

Function to execute the code passed in the lambda with a static bool.

The static value of the boolean will be passed using the first argument of function.

Parameters
theBoolThe bool that should be used statically.
funcFunction to be called, should accept a static bool type, e.g., [&](auto theBool){};
Returns
Returns whatever func returns.

◆ withStaticCellType()

template<typename ParticleType , typename F >
decltype(auto) autopas::utils::withStaticCellType ( autopas::CellType  cellType,
F &&  func 
)

Executes the passed function body with the static cell type defined by cellType.

Template Parameters
ParticleTypeThe type of the particle, needed to generate a ParticleCell.
FThe type of the functor.
Parameters
cellTypeEnum specifying the type of the cell.
funcFunction that takes a ParticleCell as argument. E.g., [&](auto particleCellDummy) {...}. The passed cell will be default constructed and should only be used to infer the type of ParticleCell using decltype(particleCellDummy).
Returns
Returns whatever func returns.
Todo:

c++20 change to explicit template for templates.

function calls also have to be changed to

[&]<typename ParticleCellType>() { ... }

instead of

[&](auto particleCellDummy) {...}