|
Peano
|
stores the actual particle histories. More...
#include <Database.h>

Public Member Functions | |
| Database (const Database &)=delete | |
| void | operator= (const Database &)=delete |
| void | setMaxParticleSnapshotsToKeepTrackOf (const size_t n) |
| Sets the number of snapshots to keep in the database. | |
| void | startMeshSweep (const std::string &meshSweepName) |
| Add an entry for a new mesh sweep. | |
| ParticleEvents | getParticleHistory (const ParticleIdentifier &identifier) |
| Return the stored event history of a particle. | |
| std::string | particleHistory (const ParticleIdentifier &identifier) |
| Print history of one particle. | |
| std::string | lastMeshSweepSnapshot () |
| Returns the recorded events of the latest mesh sweep. | |
| int | getTotalParticleEntries (const ParticleIdentifier &identifier) |
| Count total number of entries for a particle. | |
| int | getNumberOfSnapshots () const |
| Return number of snapshots. | |
| Event | addEvent (ParticleIdentifier identifier, Event &event) |
| Add a new event to the database. | |
| void | replaceEvent (ParticleIdentifier identifier, Event &oldEvent, Event &newEvent) |
| Replace an (old) particle event with a new one. | |
| void | shiftIdentifierVertexInd (ParticleIdentifier &identifier, tarch::la::Vector< Dimensions, long long > &newVertexInd, const int newVertexDepth) |
| Change the particle's vertexIndex in the map identifier. | |
| std::string | toString () |
| Dump the whole database. | |
| void | reset () |
| Delete all entries in the database and reset it to the initial state. | |
| size_t | getCurrentMeshSweepIndex () const |
| Grab the current index of mesh sweeps. | |
| int | getNumberOfTracedParticles () const |
| Get the number of currently traced particles in the database. | |
| std::vector< MeshSweepData > & | getMeshSweepData () |
| Get a handle on the mesh sweep data of the database. | |
| std::string | sweepHistory () |
| Get the history of stored mesh sweep (names). | |
| void | eliminateExistingParticles () |
| Eliminate existing particles from the database. | |
| Event | getPreviousEvent (ParticleEvents &particleHistory, int spacetreeId, size_t nFirstEventsToSkip=0) |
| get the previous event from a particle history. | |
Static Public Member Functions | |
| static Database & | getInstance () |
Static Public Attributes | |
| static constexpr int | AnyTree = -1 |
Private Member Functions | |
| Database () | |
Private Attributes | |
| tarch::multicore::MultiReadSingleWriteSemaphore | _semaphore |
| std::vector< MeshSweepData > | _meshSweepData |
| int | _currentMeshSweepIndex |
| std::map< ParticleIdentifier, ParticleEvents, std::less<> > | _data |
| size_t | _maxParticleEventsToKeepTrackOf |
| Of how many previous associations do we want to keep track. | |
stores the actual particle histories.
Particles are traced via a map, where the keys are instances of the ParticleIdentifier class. The database itself is implemented as a singleton. To access it, use the getInstance() method.
The database will track all events on all spacetrees on this MPI rank. Per particle (and per spacetree), we store up to _maxParticleEventsToKeepTrackOf particle events. Once that number is exceeded, the past history will be condensed into a single event, signifying that it had been compacted.
Additionally, something we come across very often is that particles, once assigned to a vertex, very often stay assigned to the same vertex for a long time (=many sweeps) and only experiences small movements. Rather than tracing every single move event individually, the database will mark consecutive move events using a special event type, Event::Type::ConsecutiveMoveEvent. It will also keep track the original position of the particle, before the first move event of that sequence has occurred, as well as the current particle position.
Definition at line 53 of file Database.h.
|
delete |
|
private |
Definition at line 70 of file Database.h.
References reset(), and setMaxParticleSnapshotsToKeepTrackOf().

| Event toolbox::particles::assignmentchecks::internal::Database::addEvent | ( | ParticleIdentifier | identifier, |
| Event & | event | ||
| ) |
Add a new event to the database.
If there is not yet an entry for identifier in the current snapshot, we create one. Afterwards, we append event to this new dataset for particle identifier and clean up the database, i.e. throw away irrelevant old data.
If the number of events for a particle exceeds the limit set by _maxParticleEventsToKeepTrackOf, this routine will squash them together into a single event signifying that this compression has occurred, while keeping the event type of the last recorded event. The other events in the history will be deleted.
| void toolbox::particles::assignmentchecks::internal::Database::eliminateExistingParticles | ( | ) |
Eliminate existing particles from the database.
See documentation in TracingAPI.h:eliminateExistingParticles() for more.
| size_t toolbox::particles::assignmentchecks::internal::Database::getCurrentMeshSweepIndex | ( | ) | const |
Grab the current index of mesh sweeps.
|
static |
Definition at line 57 of file Database.h.
| std::vector< MeshSweepData > & toolbox::particles::assignmentchecks::internal::Database::getMeshSweepData | ( | ) |
Get a handle on the mesh sweep data of the database.
You shouldn't ever need this in your code. This only exists to verify the database integrity in unit tests.
| int toolbox::particles::assignmentchecks::internal::Database::getNumberOfSnapshots | ( | ) | const |
Return number of snapshots.
These are the active snapshots still held in the database. addEvent()'s garbage collection might have removed some of them already.
| int toolbox::particles::assignmentchecks::internal::Database::getNumberOfTracedParticles | ( | ) | const |
Get the number of currently traced particles in the database.
| ParticleEvents toolbox::particles::assignmentchecks::internal::Database::getParticleHistory | ( | const ParticleIdentifier & | identifier | ) |
Return the stored event history of a particle.
If there's none, this routine returns a history containing an invalid event. This history containing an invalid event will alloc a new ParticleEvents and add a singleevent of type NotFound if there is no history. Make sure to delete that after you use it.
Cannot be const as we have a semaphore to be thread-safe. Returns a copy, not a reference, so that once semaphore is lifted, the state of the history remains accurate.
| Event toolbox::particles::assignmentchecks::internal::Database::getPreviousEvent | ( | ParticleEvents & | particleHistory, |
| int | spacetreeId, | ||
| size_t | nFirstEventsToSkip = 0 |
||
| ) |
get the previous event from a particle history.
nFirstEventsToSkip: skip this many events. Useful if you've just added something to the database using addEvent and are trying to re-use the history it returns.
| int toolbox::particles::assignmentchecks::internal::Database::getTotalParticleEntries | ( | const ParticleIdentifier & | identifier | ) |
Count total number of entries for a particle.
Cannot be const as we have a semaphore to be thread-safe.
| std::string toolbox::particles::assignmentchecks::internal::Database::lastMeshSweepSnapshot | ( | ) |
Returns the recorded events of the latest mesh sweep.
|
delete |
| std::string toolbox::particles::assignmentchecks::internal::Database::particleHistory | ( | const ParticleIdentifier & | identifier | ) |
Print history of one particle.
Cannot be const as we have a semaphore to be thread-safe.
| void toolbox::particles::assignmentchecks::internal::Database::replaceEvent | ( | ParticleIdentifier | identifier, |
| Event & | oldEvent, | ||
| Event & | newEvent | ||
| ) |
Replace an (old) particle event with a new one.
This is used e.g. in case where we replace a move event with a consecutive move event. Put into this function for thread safety and minimizing lock time of the database.
Just like addEvent(), it adds the current mesh sweep index to the newEvent.
| void toolbox::particles::assignmentchecks::internal::Database::reset | ( | ) |
Delete all entries in the database and reset it to the initial state.
Then re-initialize the database.
Referenced by Database().

| void toolbox::particles::assignmentchecks::internal::Database::setMaxParticleSnapshotsToKeepTrackOf | ( | const size_t | n | ) |
Sets the number of snapshots to keep in the database.
Referenced by Database().

| void toolbox::particles::assignmentchecks::internal::Database::shiftIdentifierVertexInd | ( | ParticleIdentifier & | identifier, |
| tarch::la::Vector< Dimensions, long long > & | newVertexInd, | ||
| const int | newVertexDepth | ||
| ) |
Change the particle's vertexIndex in the map identifier.
Particle must be findable with the passed identifier.
| void toolbox::particles::assignmentchecks::internal::Database::startMeshSweep | ( | const std::string & | meshSweepName | ) |
Add an entry for a new mesh sweep.
| std::string toolbox::particles::assignmentchecks::internal::Database::sweepHistory | ( | ) |
Get the history of stored mesh sweep (names).
| std::string toolbox::particles::assignmentchecks::internal::Database::toString | ( | ) |
Dump the whole database.
Cannot be const as we have a semaphore to be thread-safe.
|
private |
Definition at line 78 of file Database.h.
|
private |
Definition at line 84 of file Database.h.
Referenced by peano4.api.datamodel.DaStGen2.DaStGen2Generator::construct_output(), peano4.api.datamodel.DaStGen2.DaStGen2GeneratorForObjectsWithSmartPointers::construct_output(), peano4.api.toolbox.particles.ParticleSet.ParticleSetGenerator_ScatteredOnHeap_IndexByList::construct_output(), peano4.api.toolbox.particles.ParticleSet.ParticleSetGenerator_ScatteredOnHeap_IndexByVector::construct_output(), peano4.api.toolbox.particles.ParticleSet.ParticleSetGenerator_ContinuousPerVertex::construct_output(), peano4.api.toolbox.particles.ParticleSet.ParticleSetGenerator_GlobalContinuous::construct_output(), peano4.api.datamodel.DaStGen2.DaStGen2Generator::get_header_file_include(), peano4.api.datamodel.DaStGen2.DaStGen2GeneratorForObjectsWithSmartPointers::get_header_file_include(), peano4.api.toolbox.particles.ParticleSet.AbstractParticleSetGenerator::get_header_file_include(), peano4.api.datamodel.DaStGen2.DaStGen2Generator::get_stack_container(), peano4.api.datamodel.DaStGen2.DaStGen2GeneratorForObjectsWithSmartPointers::get_stack_container(), peano4.api.datamodel.DynamicArrayOverPrimitivesToStdVector.DynamicArrayOverPrimitivesToStdVector::get_stack_container(), and peano4.api.toolbox.particles.ParticleSet.AbstractParticleSetGenerator::get_stack_container().
|
private |
Of how many previous associations do we want to keep track.
If we do not clean up the database every now and then, we will run into situations where the memory footprint exceeds the available mem. More importantly, the validation steps will last for ages. So we clean up the database of old data every now and then. This threshold indicates how many old data entries to keep. Set it to std::numerics<int>::max() to disable this type of garbage collection on the history.
Definition at line 97 of file Database.h.
|
private |
Definition at line 77 of file Database.h.
|
private |
Definition at line 75 of file Database.h.
|
staticconstexpr |
Definition at line 100 of file Database.h.