From fcb52710267ae6fa8168d067ecade95e131e0cc1 Mon Sep 17 00:00:00 2001 From: Tim Mattox Date: Wed, 12 Oct 2016 15:56:45 -0400 Subject: [PATCH] USER-DPD: Initialize the dpdThetaLocal array consistently in fix_rx --- src/USER-DPD/fix_rx.cpp | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/src/USER-DPD/fix_rx.cpp b/src/USER-DPD/fix_rx.cpp index 0d8859e1ae..cd23addda9 100644 --- a/src/USER-DPD/fix_rx.cpp +++ b/src/USER-DPD/fix_rx.cpp @@ -642,15 +642,9 @@ void FixRX::setup_pre_force(int vflag) int ii; if(localTempFlag){ - if (newton_pair) { - dpdThetaLocal = new double[nlocal+nghost]; - for (ii = 0; ii < nlocal+nghost; ii++) - dpdThetaLocal[ii] = 0.0; - } else { - dpdThetaLocal = new double[nlocal]; - for (ii = 0; ii < nlocal; ii++) - dpdThetaLocal[ii] = 0.0; - } + int count = nlocal + (newton_pair ? nghost : 0); + dpdThetaLocal = new double[count]; + memset(dpdThetaLocal, 0, sizeof(double)*count); computeLocalTemperature(); } @@ -690,15 +684,9 @@ void FixRX::pre_force(int vflag) double theta; if(localTempFlag){ - if (newton_pair) { - dpdThetaLocal = new double[nlocal+nghost]; - for (ii = 0; ii < nlocal+nghost; ii++) - dpdThetaLocal[ii] = 0.0; - } else { - dpdThetaLocal = new double[nlocal]; - for (ii = 0; ii < nlocal; ii++) - dpdThetaLocal[ii] = 0.0; - } + int count = nlocal + (newton_pair ? nghost : 0); + dpdThetaLocal = new double[count]; + memset(dpdThetaLocal, 0, sizeof(double)*count); computeLocalTemperature(); }