Version 2, position dependent E/B, kinetic ions, boris mover, terminator
This commit is contained in:
+135
@@ -0,0 +1,135 @@
|
||||
#include "generators/simulation_output_generator.h"
|
||||
|
||||
#include "IO/simulation_output.h"
|
||||
#include "simulation/jansson_additionals.h"
|
||||
#include "simulation/species.h"
|
||||
|
||||
namespace generator {
|
||||
|
||||
std::shared_ptr<SimulationOutput> buildSimulationOutput(
|
||||
json_t* object,
|
||||
const std::map<std::string, std::shared_ptr<species::TrackedSpecie>>&
|
||||
tracked_species) {
|
||||
std::string output_folder =
|
||||
json_string(json_object_by_path(object, {"folder"}));
|
||||
std::string filename = json_string(json_object_by_path(object, {"filename"}));
|
||||
|
||||
auto output = std::make_shared<SimulationOutput>(output_folder, filename);
|
||||
|
||||
// DensityFields
|
||||
{
|
||||
int intervall =
|
||||
json_int(json_object_by_path(object, {"DensityFields", "Intervall"}));
|
||||
if (intervall == 0 &&
|
||||
json_string(json_object_by_path(
|
||||
object, {"DensityFields", "Intervall"})) == "EachSync") {
|
||||
intervall = 1;
|
||||
}
|
||||
ASSERT_POSITIVE(&intervall,
|
||||
"The intervall for density field output must be positive");
|
||||
bool overwrite_last = json_bool(
|
||||
json_object_by_path(object, {"DensityFields", "OverwriteLast"}));
|
||||
|
||||
json_t* species = json_object_by_path(object, {"DensityFields", "Species"});
|
||||
if (json_is_array(species)) {
|
||||
size_t index;
|
||||
json_t* value;
|
||||
json_array_foreach(species, index, value) {
|
||||
std::string specie_alias = json_string(value);
|
||||
OutputTask task = {specie_alias, overwrite_last, intervall};
|
||||
output->addDensityFieldOutput(task);
|
||||
}
|
||||
} else {
|
||||
std::string all = json_string(species);
|
||||
if (all == "all") {
|
||||
for (const auto& pairs : tracked_species) {
|
||||
OutputTask task = {pairs.first, overwrite_last, intervall};
|
||||
output->addDensityFieldOutput(task);
|
||||
}
|
||||
} else {
|
||||
ERROR("This species can not be outputted.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// CurrentBorders
|
||||
{
|
||||
int intervall =
|
||||
json_int(json_object_by_path(object, {"CurrentBorders", "Intervall"}));
|
||||
if (intervall == 0 &&
|
||||
json_string(json_object_by_path(
|
||||
object, {"CurrentBorders", "Intervall"})) == "EachSync") {
|
||||
intervall = 1;
|
||||
}
|
||||
ASSERT_POSITIVE(&intervall,
|
||||
"The intervall for current border output must be positive");
|
||||
bool overwrite_last = json_bool(
|
||||
json_object_by_path(object, {"CurrentBorders", "OverwriteLast"}));
|
||||
|
||||
json_t* species =
|
||||
json_object_by_path(object, {"CurrentBorders", "Species"});
|
||||
if (json_is_array(species)) {
|
||||
size_t index;
|
||||
json_t* value;
|
||||
json_array_foreach(species, index, value) {
|
||||
std::string specie_alias = json_string(value);
|
||||
OutputTask task = {specie_alias, overwrite_last, intervall};
|
||||
output->addCurrentBorderOutput(task);
|
||||
}
|
||||
} else {
|
||||
std::string all = json_string(species);
|
||||
if (all == "all") {
|
||||
for (const auto& pairs : tracked_species) {
|
||||
OutputTask task = {pairs.first, overwrite_last, intervall};
|
||||
output->addCurrentBorderOutput(task);
|
||||
}
|
||||
} else {
|
||||
ERROR("This species can not be outputted.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeletionLogger
|
||||
{
|
||||
int intervall =
|
||||
json_int(json_object_by_path(object, {"DeletionLogger", "Intervall"}));
|
||||
|
||||
if (intervall == 0 &&
|
||||
json_string(json_object_by_path(
|
||||
object, {"DeletionLogger", "Intervall"})) == "EachSync") {
|
||||
intervall = 1;
|
||||
}
|
||||
ASSERT_POSITIVE(
|
||||
&intervall,
|
||||
"The intervall for deletion logger output must be positive");
|
||||
|
||||
bool overwrite_last = json_bool(
|
||||
json_object_by_path(object, {"DeletionLogger", "OverwriteLast"}));
|
||||
|
||||
json_t* species =
|
||||
json_object_by_path(object, {"DeletionLogger", "Species"});
|
||||
if (json_is_array(species)) {
|
||||
size_t index;
|
||||
json_t* value;
|
||||
json_array_foreach(species, index, value) {
|
||||
std::string specie_alias = json_string(value);
|
||||
OutputTask task = {specie_alias, overwrite_last, intervall};
|
||||
output->addDeletionLoggerOutput(task);
|
||||
}
|
||||
} else {
|
||||
std::string all = json_string(species);
|
||||
if (all == "all") {
|
||||
for (const auto& pairs : tracked_species) {
|
||||
OutputTask task = {pairs.first, overwrite_last, intervall};
|
||||
output->addDeletionLoggerOutput(task);
|
||||
}
|
||||
} else {
|
||||
ERROR("This species can not be outputted.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
}; // namespace generator
|
||||
Reference in New Issue
Block a user