diff --git a/include/generators/drift_velocity_generator.h b/include/generators/drift_velocity_generator.h index e6e9d17..2aaec6e 100755 --- a/include/generators/drift_velocity_generator.h +++ b/include/generators/drift_velocity_generator.h @@ -11,6 +11,8 @@ std::shared_ptr buildDriftVelocity( Parameter& parameter, const json_path& path_to_drift_velocity); +std::shared_ptr buildDriftVelocityIncludingRedirection( + Parameter& parameter, const json_path& path_to_drift_velocity); }; #endif /* DRIFT_VELOCITY_GENERATOR_H */ diff --git a/src/generators/drift_velocity_generator.cpp b/src/generators/drift_velocity_generator.cpp index 89c114d..200ae95 100755 --- a/src/generators/drift_velocity_generator.cpp +++ b/src/generators/drift_velocity_generator.cpp @@ -23,4 +23,23 @@ std::shared_ptr buildDriftVelocity( 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"}))) { + DEBUG_LEVEL_2("Creating Drift velocity: CreateSameAs."); + json_path path_to_same = json_path_get(parameter.jsonObjectFromBase( + json_path_append(path_to_drift_velocity, {"CreateSameAs"}))); + std::stringstream path; + for (auto& p : path_to_same) { + path << p << " "; + } + DEBUG_LEVEL_3("From path: " + path.str()); + return buildDriftVelocityIncludingRedirection(parameter, path_to_same); + } else { + return buildDriftVelocity(parameter, path_to_drift_velocity); + } +} }; // namespace generator \ No newline at end of file diff --git a/src/generators/species_generator.cpp b/src/generators/species_generator.cpp index 7847f06..8e8756f 100755 --- a/src/generators/species_generator.cpp +++ b/src/generators/species_generator.cpp @@ -189,11 +189,11 @@ void SpeciesBuilder::fillVelocityDistribution(Parameter& parameter) { void SpeciesBuilder::fillDriftVelocity(Parameter& parameter) { DEBUG_LEVEL_2("Fill drift velocity."); for (auto& b : background_species_info) { - b.second.drift_velocity = buildDriftVelocity( + b.second.drift_velocity = buildDriftVelocityIncludingRedirection( parameter, json_path_append(b.second.path_in_json, {"DriftVelocity"})); } for (auto& b : tracked_species_info) { - b.second.drift_velocity = buildDriftVelocity( + b.second.drift_velocity = buildDriftVelocityIncludingRedirection( parameter, json_path_append(b.second.path_in_json, {"DriftVelocity"})); } }