#include "generators/drift_velocity_generator.h" #include "generators/vector_field_generator.h" #include "simulation/errors.h" namespace generator { std::shared_ptr buildDriftVelocity( Parameter& parameter, const json_path& path_to_drift_velocity) { if (parameter.jsonObjectFromBase( json_path_append(path_to_drift_velocity, {"VectorField"}))) { #ifdef debug_level2 DEBUG_LEVEL_2("Creating drift velocity: Vector field."); #endif std::shared_ptr field = buildVectorField(parameter.jsonObjectFromBase( json_path_append(path_to_drift_velocity, {"VectorField"}))); return std::shared_ptr(new DriftVelocity(field)); } else if (parameter.jsonObjectFromBase( json_path_append(path_to_drift_velocity, {"null"}))) { #ifdef debug_level2 DEBUG_LEVEL_2("Creating drift velocity: null."); #endif return nullptr; } else { ERROR("No drift velocity given."); return nullptr; } } std::shared_ptr buildDriftVelocityIncludingRedirection( Parameter& parameter, const json_path& path_to_drift_velocity) { std::stringstream cpath; if (parameter.jsonObjectFromBase( json_path_append(path_to_drift_velocity, {"CreateSameAs"}))) { #ifdef debug_level2 DEBUG_LEVEL_2("Creating drift velocity: CreateSameAs."); #endif json_path path_to_same = json_path_get(parameter.jsonObjectFromBase( json_path_append(path_to_drift_velocity, {"CreateSameAs"}))); #ifdef debug_level3 std::stringstream path; for (auto& p : path_to_same) { path << p << " "; } DEBUG_LEVEL_3("From path: " + path.str()); #endif return buildDriftVelocityIncludingRedirection(parameter, path_to_same); } else { return buildDriftVelocity(parameter, path_to_drift_velocity); } } }; // namespace generator