Added option to reset relevant fields for

output after a poisson solution step
This commit is contained in:
2024-04-13 11:10:18 +02:00
parent 30b0178e5f
commit 93a51acbda
12 changed files with 71 additions and 9 deletions
+11
View File
@@ -239,4 +239,15 @@ blitz::Array<double, 3> CurrentCollector::currentInR() const {
}
double CurrentCollector::physicalTime() const {
return timer_->time();
}
void CurrentCollector::resetCurrentCollector() {
z_negative_crossings = 0.;
z_positive_crossings = 0.;
phi_negative_crossings = 0.;
phi_positive_crossings = 0.;
r_negative_crossings = 0.;
r_positive_crossings = 0.;
}
+7
View File
@@ -205,6 +205,13 @@ double DynamicDensityField::physicalTime() const {
return timer_->time();
}
void DynamicDensityField::resetDynamicDensityField() {
timer_->resetTime(); // reductive since shared between species
time_in_bin_s_ = 0.;
deleted_particles_ = 0.;
density_per_m3_ = 0.;
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
+6
View File
@@ -30,3 +30,9 @@ long int DeletionLogger::numDeletions(DeletionType type) const {
return 0;
}
}
void DeletionLogger::resetDeletionLogger() {
for(auto& pair : num_deletions) {
pair.second = 0;
}
}
+16 -1
View File
@@ -106,6 +106,7 @@ void Simulation::start() {
int leftover_events = events_this_cpu;
int num_cpu_syncs = 0;
bool reset = false;
while (leftover_events > 0) {
int events_of_cylcle = eventsOfCycle(event_stride, leftover_events);
SIM_INFO("Leftover events on first cpu: " +
@@ -123,7 +124,7 @@ void Simulation::start() {
SIM_INFO("Poisson step.");
SimulationTimer::eventStartPoint(std::string("PoissonStep"));
poisson_solver_->solvePotential(chargedensity(), num_cpu_syncs);
poisson_solver_->solvePotential(chargedensity(), num_cpu_syncs, reset);
electric_field_->updateDynamicField(poisson_solver_->staticElectricField());
SimulationTimer::eventStopPoint(std::string("PoissonStep"));
@@ -132,6 +133,20 @@ void Simulation::start() {
SimulationTimer::eventStartPoint(std::string("Output"));
output_->writeSimulationData(num_cpu_syncs, tracked_species_, poisson_solver_.get());
SimulationTimer::eventStopPoint(std::string("Output"));
if(reset) {
SIM_INFO("Reset density, current fields and deletions.");
for(auto& pair : tracked_species_) {
pair.second->dynamicDensityField()->resetDynamicDensityField();
pair.second->lastSyncDensityField()->resetDynamicDensityField();
pair.second->currentCollector()->resetCurrentCollector();
pair.second->lastSyncCurrentCollector()->resetCurrentCollector();
pair.second->deletionLogger()->resetDeletionLogger();
pair.second->lastSyncDeletionLogger()->resetDeletionLogger();
}
}
}
}
+4
View File
@@ -13,3 +13,7 @@ void Timer::increaseTimestep(double time_s) {
void Timer::setTime(double time_s) {
current_time_s_ = time_s;
}
void Timer::resetTime() {
setTime(0.);
}