From a7d05cff0932de4c04c0e0f1ddeaa667d300d61f Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 6 Aug 2021 12:12:34 -0400 Subject: [PATCH] streamline code by using changes in Modify class --- src/velocity.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/velocity.cpp b/src/velocity.cpp index 9397e41861..fa09f451df 100644 --- a/src/velocity.cpp +++ b/src/velocity.cpp @@ -187,11 +187,11 @@ void Velocity::create(double t_desired, int seed) Compute *temperature_nobias = nullptr; if (temperature == nullptr || bias_flag) { - modify->add_compute(fmt::format("velocity_temp {} temp",group->names[igroup])); + auto newcompute = modify->add_compute(fmt::format("velocity_temp {} temp",group->names[igroup])); if (temperature == nullptr) { - temperature = modify->compute[modify->ncompute-1]; + temperature = newcompute; tcreate_flag = 1; - } else temperature_nobias = modify->compute[modify->ncompute-1]; + } else temperature_nobias = newcompute; } // initialize temperature computation(s) @@ -575,8 +575,7 @@ void Velocity::scale(int /*narg*/, char **arg) int tflag = 0; if (temperature == nullptr) { - modify->add_compute(fmt::format("velocity_temp {} temp",group->names[igroup])); - temperature = modify->compute[modify->ncompute-1]; + temperature = modify->add_compute(fmt::format("velocity_temp {} temp",group->names[igroup])); tflag = 1; }