#include "generators/terminator_generator.h" #include "generators/geometry_generator.h" namespace generator { std::shared_ptr buildTerminator( Parameter& parameter, const json_path& path_to_terminator) { #ifdef debug_level2 DEBUG_LEVEL_2("Creating terminator."); #endif if (parameter.jsonObjectFromBase( json_path_append(path_to_terminator, {"Cylinder"}))) { long int max_interactions = static_cast(parameter.doubleValue( json_path_append(path_to_terminator, {"Cylinder", "MaximumInteractions"}))); double max_time_alive = parameter.doubleValue( json_path_append(path_to_terminator, {"Cylinder", "MaxTimeAlive", "value"})); #ifdef debug_level3 DEBUG_LEVEL_3("with max interactions: " + std::to_string(max_interactions)); DEBUG_LEVEL_3("with max time alive: " + std::to_string(max_time_alive)); #endif std::shared_ptr geometry = buildGeometryIncludingRedirection( parameter, json_path_append(path_to_terminator, {"Cylinder", "BoundaryGeometry"})); return std::shared_ptr( new Terminator(max_interactions, max_time_alive, geometry)); } else if (parameter.jsonObjectFromBase(json_path_append(path_to_terminator, {"CylinderWithPlates"}))) { long int max_interactions = static_cast(parameter.doubleValue( json_path_append(path_to_terminator, {"CylinderWithPlates", "MaximumInteractions"}))); double max_time_alive = parameter.doubleValue( json_path_append(path_to_terminator, {"CylinderWithPlates", "MaxTimeAlive", "value"})); #ifdef debug_level3 DEBUG_LEVEL_3("with max interactions: " + std::to_string(max_interactions)); DEBUG_LEVEL_3("with max time alive: " + std::to_string(max_time_alive)); #endif std::shared_ptr geometry = buildGeometryIncludingRedirection( parameter, json_path_append(path_to_terminator, {"CylinderWithPlates", "BoundaryGeometry"})); double zpos1 = json_read_length( parameter.jsonObjectFromBase( json_path_append(path_to_terminator, {"CylinderWithPlates", "Plate1", "zPosition"}))); double rInner1 = json_read_length( parameter.jsonObjectFromBase( json_path_append(path_to_terminator, {"CylinderWithPlates", "Plate1", "innerRadius"}))); double rOuter1 = json_read_length( parameter.jsonObjectFromBase( json_path_append(path_to_terminator, {"CylinderWithPlates", "Plate1", "outerRadius"}))); double zpos2 = json_read_length( parameter.jsonObjectFromBase( json_path_append(path_to_terminator, {"CylinderWithPlates", "Plate2", "zPosition"}))); double rInner2 = json_read_length( parameter.jsonObjectFromBase( json_path_append(path_to_terminator, {"CylinderWithPlates", "Plate2", "innerRadius"}))); double rOuter2 = json_read_length( parameter.jsonObjectFromBase( json_path_append(path_to_terminator, {"CylinderWithPlates", "Plate2", "outerRadius"}))); if(MpiCommunication::mpi_rank == 0) { std::stringstream out; out << "Specifications of Plate 1:\n"; out << "\tz position: " << zpos1 << " m\n\t"; out << "inner radius: " << rInner1 << " m\n\t"; out << "outer radius: " << rOuter1 << " m\n"; out << "Specifications of Plate 2:\n"; out << "\tz position: " << zpos2 << " m\n\t"; out << "inner radius: " << rInner2 << " m\n\t"; out << "outer radius: " << rOuter2 << " m\n"; SIM_INFO(out.str()); } return std::shared_ptr( new TerminatorWithPlates(max_interactions, max_time_alive, geometry, zpos1, zpos2, rInner1, rInner2, rOuter1, rOuter2)); } else { ERROR("Unknown Terminator type"); return nullptr; } } }; // namespace generator