Fixed errors s.t. code runs (on 1 proc)

This commit is contained in:
2024-01-25 11:34:46 +01:00
parent 9d0c7646b3
commit ffc65f8ef9
3 changed files with 15 additions and 12 deletions
+2 -2
View File
@@ -144,9 +144,9 @@ void SimulationOutput::writeSimulationData(PoissonSolver* poisson_solver,
std::string poisson_path, std::string poisson_path,
int cpu_sync, int cpu_sync,
bool overwrite_last) { bool overwrite_last) {
std::string sync_path = "SyncPeriod_" + std::to_string(cpu_sync); std::string sync_path = "/SyncPeriod_" + std::to_string(cpu_sync);
if (overwrite_last) { if (overwrite_last) {
sync_path = "LastSyncPeriod"; sync_path = "/LastSyncPeriod";
} }
std::string path = poisson_path + sync_path; std::string path = poisson_path + sync_path;
DEBUG_LEVEL_3("Write potential."); DEBUG_LEVEL_3("Write potential.");
@@ -129,21 +129,21 @@ std::shared_ptr<SimulationOutput> buildSimulationOutput(
} }
} }
// Potential // PoissonSolver
{ {
int intervall = int intervall =
json_int(json_object_by_path(object, {"Potential", "Intervall"})); json_int(json_object_by_path(object, {"PoissonSolver", "Intervall"}));
if (intervall == 0 && if (intervall == 0 &&
json_string(json_object_by_path( json_string(json_object_by_path(
object, {"Potential", "Intervall"})) == "EachSync") { object, {"PoissonSolver", "Intervall"})) == "EachSync") {
intervall = 1; intervall = 1;
} }
ASSERT_POSITIVE(&intervall, ASSERT_POSITIVE(&intervall,
"The intervall for the potential must be positive"); "The intervall for the potential must be positive");
bool overwrite_last = json_bool( bool overwrite_last = json_bool(
json_object_by_path(object, {"Potential", "OverwriteLast"})); json_object_by_path(object, {"PoissonSolver", "OverwriteLast"}));
OutputTask task = {"potential", overwrite_last, intervall}; OutputTask task = {"potential", overwrite_last, intervall};
+8 -5
View File
@@ -310,13 +310,16 @@ std::vector<particle::Particle> Simulation::determineInjectedParticles(
} }
blitz::Array<double,3> Simulation::chargedensity() { blitz::Array<double,3> Simulation::chargedensity() {
DEBUG_LEVEL_3("Initialize chargedensity Array");
//not great but the size and bounds of the density arrays are needed... //not great but the size and bounds of the density arrays are needed...
blitz::Array<double, 3> chargeden(tracked_species_["electron"]-> std::shared_ptr<species::TrackedSpecie> firstTracked = tracked_species_.begin()->second;
dynamicDensityField()->densityArray().lbound(), DEBUG_LEVEL_3("shared pointer extracted, key: " + tracked_species_.begin()->first);
tracked_species_["electron"]->dynamicDensityField()-> if(!firstTracked)
densityArray().extent()); ERROR("extracted pointer is null");
blitz::Array<double,3> init = firstTracked->dynamicDensityField()->densityArray();
blitz::Array<double, 3> chargeden(init.lbound(), init.extent());
chargeden = 0.; chargeden = 0.;
DEBUG_LEVEL_3("Collect chargedensity");
for (auto& pair : tracked_species_) { for (auto& pair : tracked_species_) {
chargeden += pair.second->charge_C() * pair.second->dynamicDensityField()-> chargeden += pair.second->charge_C() * pair.second->dynamicDensityField()->
densityArray(); densityArray();