AutoPas  3.0.0
Loading...
Searching...
No Matches
Public Member Functions | List of all members
autopas::LogicHandler< Particle_T > Class Template Reference

The LogicHandler takes care of the containers s.t. More...

#include <LogicHandler.h>

Public Member Functions

 LogicHandler (std::unordered_map< InteractionTypeOption::Value, std::unique_ptr< AutoTuner > > &autotuners, const LogicHandlerInfo &logicHandlerInfo, unsigned int rebuildFrequency, const std::string &outputSuffix)
 Constructor of the LogicHandler.
 
autopas::ParticleContainerInterface< Particle_T > & getContainer ()
 Returns a non-const reference to the currently selected particle container.
 
std::vector< Particle_T > collectLeavingParticlesFromBuffer (bool insertOwnedParticlesToContainer)
 Collects leaving particles from buffer and potentially inserts owned particles to the container.
 
std::vector< Particle_T > updateContainer ()
 Updates the container.
 
std::vector< Particle_T > resizeBox (const std::array< double, 3 > &boxMin, const std::array< double, 3 > &boxMax)
 Pass values to the actual container.
 
void reserve (size_t numParticles)
 Estimates number of halo particles via autopas::utils::NumParticlesEstimator::estimateNumHalosUniform() then calls LogicHandler::reserve(size_t numParticles, size_t numHaloParticles).
 
void reserve (size_t numParticles, size_t numHaloParticles)
 Reserves space in the particle buffers and the container.
 
void addParticle (const Particle_T &p)
 Adds a particle to the container.
 
void addHaloParticle (const Particle_T &haloParticle)
 Adds a particle to the container that lies in the halo region of the container.
 
void deleteAllParticles ()
 Deletes all particles.
 
std::tuple< bool, bool > deleteParticleFromBuffers (Particle_T &particle)
 Takes a particle, checks if it is in any of the particle buffers, and deletes it from them if found.
 
void decreaseParticleCounter (Particle_T &particle)
 Decrease the correct internal particle counters.
 
template<class Functor >
bool computeInteractionsPipeline (Functor *functor, const InteractionTypeOption &interactionType)
 This function covers the full pipeline of all mechanics happening during the computation of particle interactions.
 
template<class Iterator >
Iterator::ParticleVecType gatherAdditionalVectors (IteratorBehavior behavior)
 Create the additional vectors vector for a given iterator behavior.
 
autopas::ContainerIterator< Particle_T, true, false > begin (IteratorBehavior behavior)
 Iterate over all particles by using for(auto iter = autoPas.begin(); iter.isValid(); ++iter)
 
autopas::ContainerIterator< Particle_T, false, false > begin (IteratorBehavior behavior) const
 Iterate over all particles by using for(auto iter = autoPas.begin(); iter.isValid(); ++iter)
 
autopas::ContainerIterator< Particle_T, true, true > getRegionIterator (const std::array< double, 3 > &lowerCorner, const std::array< double, 3 > &higherCorner, IteratorBehavior behavior)
 Iterate over all particles in a specified region.
 
autopas::ContainerIterator< Particle_T, false, true > getRegionIterator (const std::array< double, 3 > &lowerCorner, const std::array< double, 3 > &higherCorner, IteratorBehavior behavior) const
 Iterate over all particles in a specified region.
 
unsigned long getNumberOfParticlesOwned () const
 Get the number of owned particles.
 
unsigned long getNumberOfParticlesHalo () const
 Get the number of halo particles.
 
bool checkTuningStates (const InteractionTypeOption &interactionType)
 Check if other autotuners for any other interaction types are still in a tuning phase.
 
template<class Functor >
std::tuple< std::optional< std::unique_ptr< TraversalInterface > >, bool > isConfigurationApplicable (const Configuration &conf, Functor &functor, const InteractionTypeOption &interactionType)
 Checks if the given configuration can be used with the given functor and the current state of the simulation.
 
void setParticleBuffers (const std::vector< FullParticleCell< Particle_T > > &particleBuffers, const std::vector< FullParticleCell< Particle_T > > &haloParticleBuffers)
 Directly exchange the internal particle and halo buffers with the given vectors and update particle counters.
 
std::tuple< const std::vector< FullParticleCell< Particle_T > > &, const std::vector< FullParticleCell< Particle_T > > & > getParticleBuffers () const
 Getter for the particle buffers.
 
double getMeanRebuildFrequency (bool considerOnlyLastNonTuningPhase=false) const
 Getter for the mean rebuild frequency.
 
bool getNeighborListsInvalidDoDynamicRebuild ()
 getter function for _neighborListInvalidDoDynamicRebuild
 
void checkNeighborListsInvalidDoDynamicRebuild ()
 Checks if any particle has moved more than skin/2.
 
void resetNeighborListsInvalidDoDynamicRebuild ()
 Checks if any particle has moved more than skin/2.
 
bool neighborListsAreValid ()
 Checks if in the next iteration the neighbor lists have to be rebuilt.
 

Detailed Description

template<typename Particle_T>
class autopas::LogicHandler< Particle_T >

The LogicHandler takes care of the containers s.t.

they are all in the same valid state. This is mainly done by incorporating a global container rebuild frequency, which defines when containers and their neighbor lists will be rebuilt.

Constructor & Destructor Documentation

◆ LogicHandler()

template<typename Particle_T >
autopas::LogicHandler< Particle_T >::LogicHandler ( std::unordered_map< InteractionTypeOption::Value, std::unique_ptr< AutoTuner > > &  autotuners,
const LogicHandlerInfo logicHandlerInfo,
unsigned int  rebuildFrequency,
const std::string &  outputSuffix 
)
inline

Constructor of the LogicHandler.

Parameters
autotunersUnordered map with interaction types and respective autotuner instances.
logicHandlerInfo
rebuildFrequency
outputSuffix

Member Function Documentation

◆ addHaloParticle()

template<typename Particle_T >
void autopas::LogicHandler< Particle_T >::addHaloParticle ( const Particle_T &  haloParticle)
inline

Adds a particle to the container that lies in the halo region of the container.

Parameters
haloParticleParticle to be added.
Note
An exception is thrown if the halo particle is added and it is inside of the owned domain (defined by boxMin and boxMax) of the container.
This function is NOT thread-safe if the container is Octree.

◆ addParticle()

template<typename Particle_T >
void autopas::LogicHandler< Particle_T >::addParticle ( const Particle_T &  p)
inline

Adds a particle to the container.

This is only allowed if the neighbor lists are not valid.

Parameters
pReference to the particle to be added
Note
An exception is thrown if the particle is added and it is not inside of the owned domain (defined by boxMin and boxMax) of the container.
This function is NOT thread-safe if the container is Octree.

◆ begin() [1/2]

template<typename Particle_T >
autopas::ContainerIterator< Particle_T, true, false > autopas::LogicHandler< Particle_T >::begin ( IteratorBehavior  behavior)
inline

Iterate over all particles by using for(auto iter = autoPas.begin(); iter.isValid(); ++iter)

Parameters
behaviorThe behavior of the iterator. You can specify whether to iterate over owned particles, halo particles, or both.
Returns
iterator to the first particle.

◆ begin() [2/2]

template<typename Particle_T >
autopas::ContainerIterator< Particle_T, false, false > autopas::LogicHandler< Particle_T >::begin ( IteratorBehavior  behavior) const
inline

Iterate over all particles by using for(auto iter = autoPas.begin(); iter.isValid(); ++iter)

Parameters
behaviorThe behavior of the iterator. You can specify whether to iterate over owned particles, halo particles, or both.
Returns
iterator to the first particle.

◆ checkNeighborListsInvalidDoDynamicRebuild()

template<typename Particle_T >
void autopas::LogicHandler< Particle_T >::checkNeighborListsInvalidDoDynamicRebuild

Checks if any particle has moved more than skin/2.

updates bool: _neighborListInvalidDoDynamicRebuild

◆ checkTuningStates()

template<typename Particle_T >
bool autopas::LogicHandler< Particle_T >::checkTuningStates ( const InteractionTypeOption &  interactionType)
inline

Check if other autotuners for any other interaction types are still in a tuning phase.

Parameters
interactionType
Returns
bool whether other tuners are still tuning.

◆ collectLeavingParticlesFromBuffer()

template<typename Particle_T >
std::vector< Particle_T > autopas::LogicHandler< Particle_T >::collectLeavingParticlesFromBuffer ( bool  insertOwnedParticlesToContainer)
inline

Collects leaving particles from buffer and potentially inserts owned particles to the container.

Parameters
insertOwnedParticlesToContainerDecides whether to insert owned particles to the container.
Returns
Leaving particles.

◆ computeInteractionsPipeline()

template<typename Particle_T >
template<class Functor >
bool autopas::LogicHandler< Particle_T >::computeInteractionsPipeline ( Functor functor,
const InteractionTypeOption &  interactionType 
)

This function covers the full pipeline of all mechanics happening during the computation of particle interactions.

This includes:

  • selecting a configuration
    • gather live info, homogeneity, and max density
    • get next config (tuning)
    • check applicability
    • instantiation of traversal and container
  • triggering iteration and tuning result logger
  • computing the interactions
    • init and end traversal
    • remainder traversal
    • measurements
  • pass measurements to tuner
Template Parameters
Functor
Parameters
functor
interactionType
Returns
True if this was a tuning iteration.

Selection of configuration (tuning if necessary)

Computing the particle interactions

Debug Output

Pass on measurements

◆ decreaseParticleCounter()

template<typename Particle_T >
void autopas::LogicHandler< Particle_T >::decreaseParticleCounter ( Particle_T &  particle)
inline

Decrease the correct internal particle counters.

This function should always be called if individual particles are deleted.

Parameters
particlereference to particles that should be deleted

◆ deleteAllParticles()

template<typename Particle_T >
void autopas::LogicHandler< Particle_T >::deleteAllParticles ( )
inline

Deletes all particles.

Note
This invalidates the container, a rebuild is forced on the next computeInteractions() call.

◆ deleteParticleFromBuffers()

template<typename Particle_T >
std::tuple< bool, bool > autopas::LogicHandler< Particle_T >::deleteParticleFromBuffers ( Particle_T &  particle)
inline

Takes a particle, checks if it is in any of the particle buffers, and deletes it from them if found.

Parameters
particleParticle to delete. If something was deleted this reference might point to a different particle or invalid memory.
Returns
Tuple: <True iff the particle was found and deleted, True iff the reference is valid>

◆ gatherAdditionalVectors()

template<typename Particle_T >
template<class Iterator >
Iterator::ParticleVecType autopas::LogicHandler< Particle_T >::gatherAdditionalVectors ( IteratorBehavior  behavior)
inline

Create the additional vectors vector for a given iterator behavior.

Template Parameters
Iterator
Parameters
behavior
Returns
Vector of pointers to buffer vectors.

◆ getContainer()

template<typename Particle_T >
autopas::ParticleContainerInterface< Particle_T > & autopas::LogicHandler< Particle_T >::getContainer ( )
inline

Returns a non-const reference to the currently selected particle container.

Returns
Non-const reference to the container.

◆ getMeanRebuildFrequency()

template<typename Particle_T >
double autopas::LogicHandler< Particle_T >::getMeanRebuildFrequency ( bool  considerOnlyLastNonTuningPhase = false) const
inline

Getter for the mean rebuild frequency.

Helpful for determining the frequency for the dynamic containers This function is only used for dynamic containers currently but returns user defined rebuild frequency for static case for safety.

Parameters
considerOnlyLastNonTuningPhaseBool to determine if mean rebuild frequency is to be calculated over entire iterations or only during the last non-tuning phase. The mean rebuild frequency over the non-tuning phase is required by the autoTuner for weighting the rebuild and non-rebuild samples.
Returns
value of the mean frequency as double

◆ getNeighborListsInvalidDoDynamicRebuild()

template<typename Particle_T >
bool autopas::LogicHandler< Particle_T >::getNeighborListsInvalidDoDynamicRebuild

getter function for _neighborListInvalidDoDynamicRebuild

Returns
bool stored in _neighborListInvalidDoDynamicRebuild

◆ getNumberOfParticlesHalo()

template<typename Particle_T >
unsigned long autopas::LogicHandler< Particle_T >::getNumberOfParticlesHalo ( ) const
inline

Get the number of halo particles.

Returns

◆ getNumberOfParticlesOwned()

template<typename Particle_T >
unsigned long autopas::LogicHandler< Particle_T >::getNumberOfParticlesOwned ( ) const
inline

Get the number of owned particles.

Returns

◆ getParticleBuffers()

template<typename Particle_T >
std::tuple< const std::vector< FullParticleCell< Particle_T > > &, const std::vector< FullParticleCell< Particle_T > > & > autopas::LogicHandler< Particle_T >::getParticleBuffers

Getter for the particle buffers.

Note
Intended for tests only.
Returns
tuple of const references to the internal buffers.

◆ getRegionIterator() [1/2]

template<typename Particle_T >
autopas::ContainerIterator< Particle_T, true, true > autopas::LogicHandler< Particle_T >::getRegionIterator ( const std::array< double, 3 > &  lowerCorner,
const std::array< double, 3 > &  higherCorner,
IteratorBehavior  behavior 
)
inline

Iterate over all particles in a specified region.

++
for (auto iter = container.getRegionIterator(lowCorner, highCorner); iter.isValid(); ++iter) { }
Parameters
lowerCornerlower corner of the region
higherCornerhigher corner of the region
behaviorthe behavior of the iterator. You can specify whether to iterate over owned particles, halo particles, or both.
Returns
iterator to iterate over all particles in a specific region

◆ getRegionIterator() [2/2]

template<typename Particle_T >
autopas::ContainerIterator< Particle_T, false, true > autopas::LogicHandler< Particle_T >::getRegionIterator ( const std::array< double, 3 > &  lowerCorner,
const std::array< double, 3 > &  higherCorner,
IteratorBehavior  behavior 
) const
inline

Iterate over all particles in a specified region.

++
for (auto iter = container.getRegionIterator(lowCorner, highCorner); iter.isValid(); ++iter) { }
Parameters
lowerCornerlower corner of the region
higherCornerhigher corner of the region
behaviorthe behavior of the iterator. You can specify whether to iterate over owned particles, halo particles, or both.
Returns
iterator to iterate over all particles in a specific region

◆ isConfigurationApplicable()

template<typename Particle_T >
template<class Functor >
std::tuple< std::optional< std::unique_ptr< TraversalInterface > >, bool > autopas::LogicHandler< Particle_T >::isConfigurationApplicable ( const Configuration conf,
Functor functor,
const InteractionTypeOption &  interactionType 
)

Checks if the given configuration can be used with the given functor and the current state of the simulation.

Note
For the checks we need to switch to the container in the config, hece this function can't be const. Also we need to build the traversal, hence, it is returned.
Template Parameters
Functor
Parameters
conf
functor
interactionType
Returns
tuple<optional<Traversal>, rejectIndefinitely> The optional is empty if the configuration is not applicable The bool rejectIndefinitely indicates if the configuration can be completely removed from the search space because it will never be applicable.

◆ neighborListsAreValid()

template<typename Particle_T >
bool autopas::LogicHandler< Particle_T >::neighborListsAreValid

Checks if in the next iteration the neighbor lists have to be rebuilt.

This can be the case either because we hit the rebuild frequency or the dynamic rebuild criteria or because the auto tuner tests a new configuration.

Returns
True iff the neighbor lists will not be rebuild.

◆ reserve() [1/2]

template<typename Particle_T >
void autopas::LogicHandler< Particle_T >::reserve ( size_t  numParticles)
inline

Estimates number of halo particles via autopas::utils::NumParticlesEstimator::estimateNumHalosUniform() then calls LogicHandler::reserve(size_t numParticles, size_t numHaloParticles).

Parameters
numParticlesTotal number of owned particles.

◆ reserve() [2/2]

template<typename Particle_T >
void autopas::LogicHandler< Particle_T >::reserve ( size_t  numParticles,
size_t  numHaloParticles 
)
inline

Reserves space in the particle buffers and the container.

Parameters
numParticlesTotal number of owned particles.
numHaloParticlesTotal number of halo particles.

◆ resetNeighborListsInvalidDoDynamicRebuild()

template<typename Particle_T >
void autopas::LogicHandler< Particle_T >::resetNeighborListsInvalidDoDynamicRebuild

Checks if any particle has moved more than skin/2.

resets bool: _neighborListInvalidDoDynamicRebuild to false

◆ resizeBox()

template<typename Particle_T >
std::vector< Particle_T > autopas::LogicHandler< Particle_T >::resizeBox ( const std::array< double, 3 > &  boxMin,
const std::array< double, 3 > &  boxMax 
)
inline

Pass values to the actual container.

Parameters
boxMin
boxMax
Returns
Vector of particles that are outside the box after the resize.

◆ setParticleBuffers()

template<typename Particle_T >
void autopas::LogicHandler< Particle_T >::setParticleBuffers ( const std::vector< FullParticleCell< Particle_T > > &  particleBuffers,
const std::vector< FullParticleCell< Particle_T > > &  haloParticleBuffers 
)

Directly exchange the internal particle and halo buffers with the given vectors and update particle counters.

Note
This function is for testing purposes only!
Warning
This function only sets as many buffers as are given to it. E.g. if particleBuffers.size() == 3 but there LogicHandler has 8 the last five buffers will not be touched.
Parameters
particleBuffers
haloParticleBuffers

◆ updateContainer()

template<typename Particle_T >
std::vector< Particle_T > autopas::LogicHandler< Particle_T >::updateContainer ( )
inline

Updates the container.

On an update, halo particles are deleted and particles that do no longer belong into the container will be removed and returned.

Returns
A vector of invalid particles that do no longer belong in the current container.

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