Version 2, position dependent E/B, kinetic ions, boris mover, terminator

This commit is contained in:
Jonas Kellerer
2022-10-21 10:09:19 +02:00
parent acc55cf003
commit 83fd2e5d7e
869 changed files with 1033204 additions and 3634436 deletions
+71
View File
@@ -0,0 +1,71 @@
#include "simulation/parameter.h"
#include <cstdlib>
#include <stdexcept>
#include "jansson.h"
#include "simulation/errors.h"
#include "simulation/jansson_additionals.h"
Parameter::Parameter(std::string filename)
: j_error_(new json_error_t()), j_file_(openParameterFile(filename)) {}
Parameter::~Parameter() {
delete j_error_;
delete j_file_;
}
json_t* Parameter::openParameterFile(const std::string& filename) const {
json_t* j_file =
json_load_file(filename.c_str(), JSON_DECODE_INT_AS_REAL, j_error_);
if (!j_file) {
ERROR("Can not load parameter file: " + filename);
}
return j_file;
}
double Parameter::doubleValue(const json_path& path) const {
return json_double(json_object_by_path(j_file_, path));
}
double Parameter::doubleValue(const json_path& path,
double default_value) const {
return json_double(json_object_by_path(j_file_, path), default_value);
}
int Parameter::intValue(const json_path& path) const {
return json_int(json_object_by_path(j_file_, path));
}
int Parameter::intValue(const json_path& path, int default_value) const {
return json_int(json_object_by_path(j_file_, path), default_value);
}
std::string Parameter::stringValue(const json_path& path) const {
return json_string(json_object_by_path(j_file_, path));
}
std::string Parameter::stringValue(const json_path& path,
const std::string& default_value) const {
return json_string(json_object_by_path(j_file_, path), default_value);
}
bool Parameter::boolValue(const json_path& path) const {
return json_bool(json_object_by_path(j_file_, path));
}
bool Parameter::boolValue(const json_path& path, bool default_value) const {
return json_bool(json_object_by_path(j_file_, path), default_value);
}
bool Parameter::pathExists(const json_path& path) const {
return json_object_by_path(j_file_, path) != nullptr;
}
json_t* Parameter::jsonFile() const {
return j_file_;
}
json_t* Parameter::jsonObjectFromBase(const json_path& path) const {
return json_object_by_path(j_file_, path);
}