included generator files for the poisson solver

Adjusted binning in poisson_solver.* to fit with
the generator
This commit is contained in:
2024-01-23 17:28:53 +01:00
parent dde76c333f
commit 1f52d850d8
4 changed files with 138 additions and 39 deletions
@@ -0,0 +1,58 @@
#include "generators/poisson_solver_generator.h"
#include "poisson_solver/poisson_solver.h"
#include "generators/geometry_generator.h"
#include "generators/binning_generator.h"
#include <memory>
#include "simulation/errors.h"
namespace generator {
std::shared_ptr<PoissonSolver> buildPoissonSolver(
Parameter& parameter) {
DEBUG_LEVEL_2("Generating Poisson solver.");
std::shared_ptr<Geometry> geometry;
json_t* object = json_object_by_path(
parameter.jsonFile(), {"PoissonSolver"});
//create geometry
if (json_object_by_path(object, {"BoundaryGeometry"})) {
geometry = buildGeometry(parameter,
json_path_append({"PoissonSolver"}, {"BoundaryGeometry"}));
} else {
ERROR("Cannot find boundary geometry for poisson solver.");
}
//create binning
json_path path_binning = json_path_append({"PoissonSolver"},
{"PositionBinning"});
CylinderBinning position_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;
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{};
double target_accuracy = parameter.doubleValue(
json_path_append({"PoissonSolver"}, {"TargetAccuracy"}));
int num_cycles = parameter.intValue(json_path_append({"PoissonSolver"},
{"NumCycles"}));
return std::shared_ptr<PoissonSolver>(new PoissonSolver(bottom_boundary,
top_boundary, hull_boundary, geometry, position_binning, electrodes,
target_accuracy, num_cycles));
}
};