poisson solver boundary in .json
This commit is contained in:
@@ -6,11 +6,15 @@
|
|||||||
#include "poisson_solver/poisson_solver.h"
|
#include "poisson_solver/poisson_solver.h"
|
||||||
#include "simulation/jansson_additionals.h"
|
#include "simulation/jansson_additionals.h"
|
||||||
#include "simulation/parameter.h"
|
#include "simulation/parameter.h"
|
||||||
|
#include <map>
|
||||||
|
|
||||||
namespace generator {
|
namespace generator {
|
||||||
// no electrode stuff is included
|
// no electrode stuff is included
|
||||||
std::shared_ptr<PoissonSolver> buildPoissonSolver(
|
std::shared_ptr<PoissonSolver> buildPoissonSolver(
|
||||||
Parameter& parameter);
|
Parameter& parameter);
|
||||||
|
|
||||||
|
std::map<std::string, GlobalBoundary> buildBoundaries(Parameter& parameter,
|
||||||
|
const json_path& path_to_boundaries);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* POISSONSOLVER_GENERATOR_H */
|
#endif /* POISSONSOLVER_GENERATOR_H */
|
||||||
@@ -42,8 +42,8 @@ CylinderBinning buildPositionBinning(json_t* object) {
|
|||||||
std::to_string(number_of_bins_azimuthal));
|
std::to_string(number_of_bins_azimuthal));
|
||||||
DEBUG_LEVEL_3("with number of bins longitudinal: " +
|
DEBUG_LEVEL_3("with number of bins longitudinal: " +
|
||||||
std::to_string(number_of_bins_longitudinal));
|
std::to_string(number_of_bins_longitudinal));
|
||||||
DEBUG_LEVEL_3("with radius: " + std::to_string(max_radius) + "m");
|
DEBUG_LEVEL_3("with radius: " + std::to_string(max_radius) + " m");
|
||||||
DEBUG_LEVEL_3("with height: " + std::to_string(max_length) + "m");
|
DEBUG_LEVEL_3("with height: " + std::to_string(max_length) + " m");
|
||||||
|
|
||||||
return CylinderBinning(number_of_bins_radial, max_radius,
|
return CylinderBinning(number_of_bins_radial, max_radius,
|
||||||
number_of_bins_azimuthal,
|
number_of_bins_azimuthal,
|
||||||
|
|||||||
@@ -27,20 +27,8 @@ namespace generator {
|
|||||||
{"PositionBinning"});
|
{"PositionBinning"});
|
||||||
CylinderBinning position_binning =
|
CylinderBinning position_binning =
|
||||||
buildPositionBinningIncludingRedirection(parameter, path_binning);
|
buildPositionBinningIncludingRedirection(parameter, path_binning);
|
||||||
//create top, bottom and hull boundary
|
|
||||||
// for now put them as fixed and not read from json file
|
|
||||||
// needs to be changed! (probably needs an own generator or smth)
|
|
||||||
GlobalBoundary bottom_boundary;
|
|
||||||
bottom_boundary.type = BoundaryType::dirichlet;
|
|
||||||
bottom_boundary.boundary_value = 0.;
|
|
||||||
|
|
||||||
GlobalBoundary top_boundary;
|
auto boundaries = buildBoundaries(parameter, {"PoissonSolver", "Boundary"});
|
||||||
top_boundary.type = BoundaryType::neumann_to_top;
|
|
||||||
top_boundary.boundary_value = 0.;
|
|
||||||
|
|
||||||
GlobalBoundary hull_boundary;
|
|
||||||
hull_boundary.type = BoundaryType::dirichlet;
|
|
||||||
hull_boundary.boundary_value = 0.;
|
|
||||||
|
|
||||||
std::vector<std::shared_ptr<Electrode>> electrodes{};
|
std::vector<std::shared_ptr<Electrode>> electrodes{};
|
||||||
|
|
||||||
@@ -50,9 +38,57 @@ namespace generator {
|
|||||||
int num_cycles = parameter.intValue(json_path_append({"PoissonSolver"},
|
int num_cycles = parameter.intValue(json_path_append({"PoissonSolver"},
|
||||||
{"NumCycles"}));
|
{"NumCycles"}));
|
||||||
|
|
||||||
return std::shared_ptr<PoissonSolver>(new PoissonSolver(bottom_boundary,
|
return std::shared_ptr<PoissonSolver>(new PoissonSolver(boundaries.at("Bottom"),
|
||||||
top_boundary, hull_boundary, geometry, position_binning, electrodes,
|
boundaries.at("Top"), boundaries.at("Hull"), geometry, position_binning,
|
||||||
target_accuracy, num_cycles));
|
electrodes, target_accuracy, num_cycles));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::map<std::string, GlobalBoundary> buildBoundaries(Parameter& parameter,
|
||||||
|
const json_path& path_to_boundaries) {
|
||||||
|
DEBUG_LEVEL_3("Creating Boundaries.");
|
||||||
|
std::map<std::string, GlobalBoundary> boundary_map {
|
||||||
|
{"Bottom", {0., BoundaryType::dirichlet}},
|
||||||
|
{"Top", {0., BoundaryType::dirichlet}},
|
||||||
|
{"Hull", {0., BoundaryType::dirichlet}}};
|
||||||
|
|
||||||
|
const std::map<std::string, BoundaryType> neumann_location_map {
|
||||||
|
{"Bottom", BoundaryType::neumann_to_bottom},
|
||||||
|
{"Top", BoundaryType::neumann_to_top},
|
||||||
|
{"Hull", BoundaryType::neumann_to_hull}};
|
||||||
|
|
||||||
|
const char* key;
|
||||||
|
json_t* value;
|
||||||
|
json_object_foreach(parameter.jsonObjectFromBase(path_to_boundaries),
|
||||||
|
key, value) {
|
||||||
|
DEBUG_LEVEL_3("Creating " + std::string(key) + ": ");
|
||||||
|
if(!(boundary_map.find(std::string(key)) == boundary_map.end())) {
|
||||||
|
double boundary_value =
|
||||||
|
json_double(json_object_by_path(value, {"value"}));
|
||||||
|
|
||||||
|
std::string boundary_type =
|
||||||
|
json_string(json_object_by_path(value, {"type"}));
|
||||||
|
if (boundary_type == "dirichlet") {
|
||||||
|
boundary_map[std::string(key)].type = BoundaryType::dirichlet;
|
||||||
|
boundary_map[std::string(key)].boundary_value = boundary_value;
|
||||||
|
} else if (boundary_type == "neumann") {
|
||||||
|
boundary_map[std::string(key)].type =
|
||||||
|
neumann_location_map.at(std::string(key));
|
||||||
|
boundary_map[std::string(key)].boundary_value = boundary_value;
|
||||||
|
} else {
|
||||||
|
SIM_INFO("Unknown boundary type:" + boundary_type +
|
||||||
|
". Using default boundary (dirichtlet, value 0)");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
DEBUG_LEVEL_3("with type: " + boundary_type);
|
||||||
|
DEBUG_LEVEL_3("with value: " + std::to_string(boundary_value));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
SIM_INFO(std::string(key) + ": unknown location. Is ignored.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return boundary_map;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user