Files
karl/src/simulation/logger.cpp
T
csendlinger f57895bcef Changed Allreduce to Reduce for CurrentCollector
and DeletionLogger; removed sync_ field copies
2025-10-21 14:26:45 +02:00

66 lines
1.7 KiB
C++
Executable File

#include "simulation/logger.h"
#include "simulation/coordinates.h"
DeletionLogger::DeletionLogger(std::vector<DeletionType> used_types,
std::vector<PhysicalDeletionType> used_phys_types) {
for (auto& type : used_types) {
num_deletions[type] = 0;
// sync_num_deletions[type] = 0;
}
for (auto& type: used_phys_types) {
num_phys_deletions[type] = 0.;
// sync_num_phys_deletions[type] = 0.;
}
}
void DeletionLogger::logDeletion(const Coordinate& coordinate,
DeletionType type) {
if (num_deletions.count(type) > 0) {
num_deletions.at(type) += 1;
}
}
void DeletionLogger::logDeletion(const particle::Particle& particle,
PhysicalDeletionType type) {
if (num_phys_deletions.count(type) > 0) {
num_phys_deletions.at(type) += particle.weight();
}
}
std::map<DeletionType, long int> DeletionLogger::numDeletions() const {
return num_deletions;
}
std::map<PhysicalDeletionType, double> DeletionLogger::numPhysDeletions() const {
return num_phys_deletions;
}
void DeletionLogger::numDeletions(long int new_value, DeletionType type) {
if (num_deletions.count(type)) {
num_deletions.at(type) = new_value;
}
}
long int DeletionLogger::numDeletions(DeletionType type) const {
if (num_deletions.count(type)) {
return num_deletions.at(type);
} else {
return 0;
}
}
void DeletionLogger::resetDeletionLogger() {
for(auto& pair : num_deletions) {
pair.second = 0;
}
// for (auto& pair : sync_num_deletions) {
// pair.second = 0;
// }
for(auto& pair : num_phys_deletions) {
pair.second = 0;
}
// for (auto& pair : sync_num_phys_deletions) {
// pair.second = 0;
// }
}