Fixed bug of max Interactions not getting logged,

Added functionality to cluster_formation entry,
added logging of recombination
This commit is contained in:
2024-03-05 16:23:01 +01:00
parent 80fdfb6dc5
commit 5ac64c4da8
4 changed files with 24 additions and 9 deletions
+2
View File
@@ -141,6 +141,8 @@ void SimulationOutput::writeNumDeletions(DeletionLogger* logger,
writer.write(pair.second, path_to_deletions + "/MaxInteractions");
} else if (pair.first == DeletionType::max_time_alive) {
writer.write(pair.second, path_to_deletions + "/MaxTimeAlive");
} else if (pair.first == DeletionType::cluster_formation) {
writer.write(pair.second, path_to_deletions + "/ClusterFormation");
}
}
}
+3
View File
@@ -22,6 +22,8 @@ std::shared_ptr<DeletionLogger> buildDeletionLogger(json_t* object) {
used_types.push_back(DeletionType::max_interactions);
} else if (type_alias == "max_time_alive") {
used_types.push_back(DeletionType::max_time_alive);
} else if (type_alias == "cluster_formation") {
used_types.push_back(DeletionType::cluster_formation);
} else {
ERROR("This deletion type is not known");
}
@@ -32,6 +34,7 @@ std::shared_ptr<DeletionLogger> buildDeletionLogger(json_t* object) {
used_types.push_back(DeletionType::recombination);
used_types.push_back(DeletionType::max_interactions);
used_types.push_back(DeletionType::max_time_alive);
used_types.push_back(DeletionType::cluster_formation);
}
}
+6
View File
@@ -1,6 +1,7 @@
#include "interactions/recombination.h"
#include "simulation/density_field.h"
#include "simulation/logger.h"
namespace interaction {
@@ -20,6 +21,11 @@ InteractionOutput Recombination::performInteraction(
InteractionOutput output;
output.deleteCurrentParticle(true);
if (particle.specie()->deletionLogger()) {
particle.specie()->deletionLogger()->logDeletion(
particle.position(), DeletionType::recombination);
}
return output;
}
+13 -9
View File
@@ -60,6 +60,7 @@ void Simulation::init(Parameter& parameter) {
DEBUG_LEVEL_0("Init cpu synchronizer.");
cpu_synchronizer_ = std::make_shared<CpuSynchronizer>();
DEBUG_LEVEL_3("Init done.");
}
int eventsThisCpu(int events_all_cpus) {
@@ -187,15 +188,7 @@ void Simulation::processUntilTermination(
was_reflected = true;
}
if (particle.specie()->terminator()->reachedMaxInteractions(&particle)) {
DEBUG_LEVEL_3("Terminate particle" + particle.specie()->name()
+ ". Reached max interactions.");
if (particle.specie()->deletionLogger()) {
particle.specie()->deletionLogger()->logDeletion(
particle.position(), DeletionType::max_interactions);
}
break;
} else if (particle.specie()->terminator()->reachedMaxTimeAlive(
if (particle.specie()->terminator()->reachedMaxTimeAlive(
&particle)) {
DEBUG_LEVEL_3("Terminate particle. Reached max time alive.");
if (particle.specie()->deletionLogger()) {
@@ -242,8 +235,19 @@ void Simulation::processUntilTermination(
}
if (output.deleteCurrentParticle()) {
DEBUG_LEVEL_3(particle.specie()->name() + " removed due to interaction.");
break;
}
if (particle.specie()->terminator()->reachedMaxInteractions(&particle)) {
DEBUG_LEVEL_3("Terminate particle " + particle.specie()->name()
+ ". Reached max interactions.");
if (particle.specie()->deletionLogger()) {
particle.specie()->deletionLogger()->logDeletion(
particle.position(), DeletionType::max_interactions);
}
break;
}
}
}
}