Peano 4
Loading...
Searching...
No Matches
toolbox::particles::ParticleSet< T > Class Template Reference

Abstract base class for all flavours of particle sets. More...

#include <ParticleSet.h>

Collaboration diagram for toolbox::particles::ParticleSet< T >:

Public Types

typedef T DoFType
 
typedef std::list< T * > ParticleList
 
using SieveParticles = SieveParticles<T>
 

Public Member Functions

std::string toString (bool addBrackets=true) const
 

Static Public Member Functions

static void clearReassignmentStatistics ()
 Clear stats of all counters that have to do with resorting.
 
static void clearParticleStateStatistics ()
 Clear stats.
 
static void reduceParticleStateStatistics ()
 Reduces and prints the global statistics.
 
static std::string printParticleStateStatistics ()
 
static void reduceReassignmentStatistics ()
 
static std::string printReassignmentStatistics ()
 
static void updateLiftDropStatistics (int numberOfLiftsInThisTree, int numberOfDropsInThisTree, int numberOfReassignmentsInThisTree, int numberOfLiftsIntoSieveSetInThisTree, int numberOfDropsFromSieveSetInThisTree, int numberOfDropsIntoHorizontalTreeDecomposition)
 
static void updateNumberOfLocalAndExpiredParticles (int numberOfRemainingLocalParticles, int numberOfExpiredHaloParticles, int numberOfParticlesThatHaveLeftTheirDomain)
 
static int getNumberOfDropsIntoHorizontalTreeDecomposition ()
 Return number of drops into cuts recorded.
 
static bool registeredAnyResorting ()
 Returns true if there have been any lifts, drops, reassignments, ...
 
static void initDatatype ()
 
static void shutdownDatatype ()
 
static void finishedTraversal ()
 Invoke exchangeSieveListsGlobally().
 
static ParticleList getParticlesToBeSievedIntoVertex (const peano4::datamanagement::VertexMarker &marker, bool removeReturnedParticlesFromSet, bool onlyReturnParticlesThatWillBeLocal)
 Make routine from SieveParticles public.
 
static bool hasParticlesToBeSievedIntoVertices ()
 Make routine from SieveParticles public.
 
static int getNumberOfParticlesThatHaveBeSievedIntoVertices ()
 Return total number of particles to be sieved.
 
static int getNumberOfRemainingLocalParticles ()
 Return global sum of the particles that did remain within their partition at a time.
 

Static Protected Attributes

static tarch::multicore::BooleanSemaphore _statisticsSemaphore
 
static int _numberOfLifts
 Sorting statistics.
 
static int _numberOfDrops
 Sorting statistics.
 
static int _numberOfReassignments
 Sorting statistics.
 
static int _numberOfLiftsIntoSieveSet
 Sorting statistics.
 
static int _numberOfDropsFromSieveSet
 
static int _numberOfDropsIntoHorizontalTreeDecomposition
 
static int _numberOfRemainingLocalParticles
 Set by parallel state analysis.
 
static int _numberOfExpiredHaloParticles
 Set by parallel state analysis.
 
static int _numberOfParticlesThatHaveLeftTheirDomain
 Set by parallel state analysis.
 
static int _numberOfDroppedIncomingVirtualParticles
 Number of incoming halo particles which are not worked in.
 
static int _numberOfRedundantlySharedLocalParticles
 Particles which are local here and local somewhere else.
 
static int _numberOfReplacedVirtualParticlesAlongBoundary
 Replace virtual particles are those where we have a copy and receive an update.
 
static int _numberOfAddedVirtualParticlesAlongBoundary
 Newly "discovered" virtual particles.
 
static int _numberOfAddedLocalParticlesAlongBoundary
 
static SieveParticles _sieveParticles
 Map of persistent particles that have to be sieved.
 

Static Private Attributes

static tarch::logging::Log _log
 

Detailed Description

template<typename T>
class toolbox::particles::ParticleSet< T >

Abstract base class for all flavours of particle sets.

Particle sets differ in the way they actually manage the particles. However, they all share common stats, operations, ... This is covered by this class.

Rationale: static attributes vs static aggregation

There's a problem here however: Most of these fields are static fields. If we have them static, they are tied to the base object, not the the particular particle type. However, the fact that we work with templates rides to our rescue. We can assume that this base class is instantiated per particle type. Therefore, all of its static fields are unique again. Along these discussions, this base class is more of an aspect rather than a real base class. The number of real functions and attributes is negligible.

An alternative implementation would make this a real class and let the actual particles sets holds a static attribute of this class. I think that would be a valid implementation, too.

Eventually, I ended up with a compromise, where the sieving is delegated into a class of its own called toolbox::particles::SieveParticles. The rationale here is simple:

All the stuff that has to do with the management of the sieved particles is outsourced into a separate class. All the stats, initialisation and whatever generic stuff is out there is collocated in this very routine.

Definition at line 52 of file ParticleSet.h.

Member Typedef Documentation

◆ DoFType

template<typename T >
typedef T toolbox::particles::ParticleSet< T >::DoFType

Definition at line 54 of file ParticleSet.h.

◆ ParticleList

template<typename T >
typedef std::list<T*> toolbox::particles::ParticleSet< T >::ParticleList

Definition at line 55 of file ParticleSet.h.

◆ SieveParticles

template<typename T >
using toolbox::particles::ParticleSet< T >::SieveParticles = SieveParticles<T>

Definition at line 57 of file ParticleSet.h.

Member Function Documentation

◆ clearParticleStateStatistics()

template<typename T >
void toolbox::particles::ParticleSet< T >::clearParticleStateStatistics ( )
static

Clear stats.

Has to be called per rank prior to any mesh traversal assembling stats. I call this routine in the prepare traversal event, i.e. in peano4.toolbox.particles.UpdateParallelState.get_body_of_prepareTraversal(). This means I really get only a snapshot from one grid sweep.

Definition at line 96 of file ParticleSet.cpph.

◆ clearReassignmentStatistics()

template<typename T >
void toolbox::particles::ParticleSet< T >::clearReassignmentStatistics ( )
static

Clear stats of all counters that have to do with resorting.

Has to be called per rank prior to any collection of stats. I used to call this routine in the prepare traversal event, i.e. in peano4.toolbox.particles.api.AbstractUpdateParticleGridAssociation.get_body_of_prepareTraversal(). However, this is not clever, as the reassignment usually spans multiple grid sweeps. If we clear the stats prior to each of these sweeps, we will only get a state snapshot from what happened in the last sweep.

Therefore, I now typically call this clear routine directly after I've written stats to the terminal. This differs to how I treat clearParticleStateStatistics().

Definition at line 86 of file ParticleSet.cpph.

◆ finishedTraversal()

template<typename T >
void toolbox::particles::ParticleSet< T >::finishedTraversal ( )
static

Invoke exchangeSieveListsGlobally().

Definition at line 290 of file ParticleSet.cpph.

◆ getNumberOfDropsIntoHorizontalTreeDecomposition()

template<typename T >
int toolbox::particles::ParticleSet< T >::getNumberOfDropsIntoHorizontalTreeDecomposition ( )
static

Return number of drops into cuts recorded.

This counter is typically updated by the action sets which update the particle-mesh association. The field should guide the simulation main whether to rerun this dropping action set again or continue with next step in simulation pipeline.

Definition at line 259 of file ParticleSet.cpph.

◆ getNumberOfParticlesThatHaveBeSievedIntoVertices()

template<typename T >
int toolbox::particles::ParticleSet< T >::getNumberOfParticlesThatHaveBeSievedIntoVertices ( )
static

Return total number of particles to be sieved.

Delegates to SieveParticles::getNumberOfParticlesThatHaveBeSievedIntoVertices()

Definition at line 312 of file ParticleSet.cpph.

◆ getNumberOfRemainingLocalParticles()

template<typename T >
int toolbox::particles::ParticleSet< T >::getNumberOfRemainingLocalParticles ( )
static

Return global sum of the particles that did remain within their partition at a time.

Should only be called on global master after the reduction.

Definition at line 338 of file ParticleSet.cpph.

◆ getParticlesToBeSievedIntoVertex()

template<typename T >
toolbox::particles::ParticleSet< T >::ParticleList toolbox::particles::ParticleSet< T >::getParticlesToBeSievedIntoVertex ( const peano4::datamanagement::VertexMarker & marker,
bool removeReturnedParticlesFromSet,
bool onlyReturnParticlesThatWillBeLocal )
static

Make routine from SieveParticles public.

Delegate through. This way, we don't have to expose the actual sieve object. Usually combined with hasParticlesToBeSievedIntoVertices() as guard, which makes the querying faster.

See also
SieveParticles::getParticlesToBeSievedIntoVertex() for parameter descriptions.

Definition at line 296 of file ParticleSet.cpph.

◆ hasParticlesToBeSievedIntoVertices()

template<typename T >
bool toolbox::particles::ParticleSet< T >::hasParticlesToBeSievedIntoVertices ( )
static

Make routine from SieveParticles public.

Delegate through. This way, we don't have to expose the actual sieve object. This predicate is usually always used as guard before actually invoking getParticlesToBeSievedIntoVertex().

Definition at line 306 of file ParticleSet.cpph.

◆ initDatatype()

template<typename T >
void toolbox::particles::ParticleSet< T >::initDatatype ( )
static

Definition at line 277 of file ParticleSet.cpph.

◆ printParticleStateStatistics()

template<typename T >
std::string toolbox::particles::ParticleSet< T >::printParticleStateStatistics ( )
static

Definition at line 112 of file ParticleSet.cpph.

◆ printReassignmentStatistics()

template<typename T >
std::string toolbox::particles::ParticleSet< T >::printReassignmentStatistics ( )
static

Definition at line 178 of file ParticleSet.cpph.

◆ reduceParticleStateStatistics()

template<typename T >
void toolbox::particles::ParticleSet< T >::reduceParticleStateStatistics ( )
static

◆ reduceReassignmentStatistics()

template<typename T >
void toolbox::particles::ParticleSet< T >::reduceReassignmentStatistics ( )
static

◆ registeredAnyResorting()

template<typename T >
bool toolbox::particles::ParticleSet< T >::registeredAnyResorting ( )
static

Returns true if there have been any lifts, drops, reassignments, ...

Definition at line 265 of file ParticleSet.cpph.

◆ shutdownDatatype()

template<typename T >
void toolbox::particles::ParticleSet< T >::shutdownDatatype ( )
static

Definition at line 283 of file ParticleSet.cpph.

◆ toString()

template<typename T >
std::string toolbox::particles::ParticleSet< T >::toString ( bool addBrackets = true) const

Definition at line 318 of file ParticleSet.cpph.

◆ updateLiftDropStatistics()

template<typename T >
void toolbox::particles::ParticleSet< T >::updateLiftDropStatistics ( int numberOfLiftsInThisTree,
int numberOfDropsInThisTree,
int numberOfReassignmentsInThisTree,
int numberOfLiftsIntoSieveSetInThisTree,
int numberOfDropsFromSieveSetInThisTree,
int numberOfDropsIntoHorizontalTreeDecomposition )
static

Definition at line 227 of file ParticleSet.cpph.

◆ updateNumberOfLocalAndExpiredParticles()

template<typename T >
void toolbox::particles::ParticleSet< T >::updateNumberOfLocalAndExpiredParticles ( int numberOfRemainingLocalParticles,
int numberOfExpiredHaloParticles,
int numberOfParticlesThatHaveLeftTheirDomain )
static

Definition at line 246 of file ParticleSet.cpph.

Field Documentation

◆ _log

template<typename T >
tarch::logging::Log toolbox::particles::ParticleSet< T >::_log
staticprivate

Definition at line 184 of file ParticleSet.h.

◆ _numberOfAddedLocalParticlesAlongBoundary

template<typename T >
int toolbox::particles::ParticleSet< T >::_numberOfAddedLocalParticlesAlongBoundary
staticprotected

Definition at line 310 of file ParticleSet.h.

◆ _numberOfAddedVirtualParticlesAlongBoundary

template<typename T >
int toolbox::particles::ParticleSet< T >::_numberOfAddedVirtualParticlesAlongBoundary
staticprotected

Newly "discovered" virtual particles.

If a particle is far away from "our" boundary and then approaches this boundary on the neighbouring rank, it will, at one point, become visible here and we add it to our set of virtual particles.

Updated by boundary merge operations.

Definition at line 309 of file ParticleSet.h.

◆ _numberOfDroppedIncomingVirtualParticles

template<typename T >
int toolbox::particles::ParticleSet< T >::_numberOfDroppedIncomingVirtualParticles
staticprotected

Number of incoming halo particles which are not worked in.

Dropped incoming virtual particles "happen" when a neighbour sends in a particle which is already virtual on the neighbour. In this case, the neighbour hasn't updated this particle at all (has no ownership). Therefore, we can just ignore it.

Updated by boundary merge operations.

Definition at line 278 of file ParticleSet.h.

◆ _numberOfDrops

template<typename T >
int toolbox::particles::ParticleSet< T >::_numberOfDrops
staticprotected

Sorting statistics.

Used by sorting algorithm of choice. The attribute is updated through updateLiftDropStatistics() by each and every tree traversal. The five fields should be cleared through a call of clearReassignmentStatistics() at the begin of a time step, i.e. the first grid sweep starting a time step.

See class documentation of toolbox::particles::ParticleSet for an overview of the statistics tracked.

Definition at line 215 of file ParticleSet.h.

◆ _numberOfDropsFromSieveSet

template<typename T >
int toolbox::particles::ParticleSet< T >::_numberOfDropsFromSieveSet
staticprotected

Definition at line 244 of file ParticleSet.h.

◆ _numberOfDropsIntoHorizontalTreeDecomposition

template<typename T >
int toolbox::particles::ParticleSet< T >::_numberOfDropsIntoHorizontalTreeDecomposition
staticprotected

Definition at line 245 of file ParticleSet.h.

◆ _numberOfExpiredHaloParticles

template<typename T >
int toolbox::particles::ParticleSet< T >::_numberOfExpiredHaloParticles
staticprotected

Set by parallel state analysis.

See documentation of action set peano4.toolbox.particles.api.UpdateParallelState.

Definition at line 259 of file ParticleSet.h.

◆ _numberOfLifts

template<typename T >
int toolbox::particles::ParticleSet< T >::_numberOfLifts
staticprotected

Sorting statistics.

Used by sorting algorithm of choice. The attribute is updated through updateLiftDropStatistics() by each and every tree traversal. The five fields should be cleared through a call of clearReassignmentStatistics() at the begin of a time step, i.e. the first grid sweep starting a time step.

See class documentation of toolbox::particles::ParticleSet for an overview of the statistics tracked.

Definition at line 201 of file ParticleSet.h.

◆ _numberOfLiftsIntoSieveSet

template<typename T >
int toolbox::particles::ParticleSet< T >::_numberOfLiftsIntoSieveSet
staticprotected

Sorting statistics.

Used by sorting algorithm of choice. The attribute is updated through updateLiftDropStatistics() by each and every tree traversal. The five fields should be cleared through a call of clearReassignmentStatistics() at the begin of a time step, i.e. the first grid sweep starting a time step.

See class documentation of toolbox::particles::ParticleSet for an overview of the statistics tracked.

Definition at line 243 of file ParticleSet.h.

◆ _numberOfParticlesThatHaveLeftTheirDomain

template<typename T >
int toolbox::particles::ParticleSet< T >::_numberOfParticlesThatHaveLeftTheirDomain
staticprotected

Set by parallel state analysis.

See documentation of action set peano4.toolbox.particles.api.UpdateParallelState.

Definition at line 266 of file ParticleSet.h.

◆ _numberOfReassignments

template<typename T >
int toolbox::particles::ParticleSet< T >::_numberOfReassignments
staticprotected

Sorting statistics.

Used by sorting algorithm of choice. The attribute is updated through updateLiftDropStatistics() by each and every tree traversal. The five fields should be cleared through a call of clearReassignmentStatistics() at the begin of a time step, i.e. the first grid sweep starting a time step.

See class documentation of toolbox::particles::ParticleSet for an overview of the statistics tracked.

Definition at line 229 of file ParticleSet.h.

◆ _numberOfRedundantlySharedLocalParticles

template<typename T >
int toolbox::particles::ParticleSet< T >::_numberOfRedundantlySharedLocalParticles
staticprotected

Particles which are local here and local somewhere else.

This happens if a particle resides almost exactly on the face between two ranks and we therefore decide that both call it a local particle.

Updated by boundary merge operations.

Definition at line 288 of file ParticleSet.h.

◆ _numberOfRemainingLocalParticles

template<typename T >
int toolbox::particles::ParticleSet< T >::_numberOfRemainingLocalParticles
staticprotected

Set by parallel state analysis.

See documentation of action set peano4.toolbox.particles.api.UpdateParallelState.

Definition at line 252 of file ParticleSet.h.

◆ _numberOfReplacedVirtualParticlesAlongBoundary

template<typename T >
int toolbox::particles::ParticleSet< T >::_numberOfReplacedVirtualParticlesAlongBoundary
staticprotected

Replace virtual particles are those where we have a copy and receive an update.

Virtual particles are owned by someone else. So whenever this owner sends in an update, we throw away our local copy and use this updated data.

Updated by boundary merge operations.

Definition at line 298 of file ParticleSet.h.

◆ _sieveParticles

template<typename T >
toolbox::particles::SieveParticles< T > toolbox::particles::ParticleSet< T >::_sieveParticles
staticprotected

Map of persistent particles that have to be sieved.

Definition at line 315 of file ParticleSet.h.

◆ _statisticsSemaphore

template<typename T >
tarch::multicore::BooleanSemaphore toolbox::particles::ParticleSet< T >::_statisticsSemaphore
staticprotected

Definition at line 187 of file ParticleSet.h.


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