Included redirection in drift velocity generator

This commit is contained in:
2024-03-07 10:56:01 +01:00
parent 95461433c2
commit dc534dcd9d
3 changed files with 23 additions and 2 deletions
@@ -11,6 +11,8 @@ std::shared_ptr<DriftVelocity> buildDriftVelocity(
Parameter& parameter,
const json_path& path_to_drift_velocity);
std::shared_ptr<DriftVelocity> buildDriftVelocityIncludingRedirection(
Parameter& parameter, const json_path& path_to_drift_velocity);
};
#endif /* DRIFT_VELOCITY_GENERATOR_H */
@@ -23,4 +23,23 @@ std::shared_ptr<DriftVelocity> buildDriftVelocity(
return nullptr;
}
}
std::shared_ptr<DriftVelocity> 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
+2 -2
View File
@@ -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"}));
}
}