From c60bf9bf8046b778af57cede4f472bdbf47b45a8 Mon Sep 17 00:00:00 2001 From: dqueteschiner Date: Wed, 25 Mar 2015 17:42:04 +0100 Subject: [PATCH] clean up twoWayMPI allocate/destroy functions just the way LIGGGHTS is doing it ... --- .../dataExchangeModel/twoWayMPI/twoWayMPI.C | 26 ++++++------------- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/src/lagrangian/cfdemParticle/subModels/dataExchangeModel/twoWayMPI/twoWayMPI.C b/src/lagrangian/cfdemParticle/subModels/dataExchangeModel/twoWayMPI/twoWayMPI.C index 7edf96e7..5dec8815 100644 --- a/src/lagrangian/cfdemParticle/subModels/dataExchangeModel/twoWayMPI/twoWayMPI.C +++ b/src/lagrangian/cfdemParticle/subModels/dataExchangeModel/twoWayMPI/twoWayMPI.C @@ -156,8 +156,7 @@ void Foam::twoWayMPI::allocateArray int length ) const { - //if(length==-1) then LIGGGHTS uses own length data - allocate_external_double(array, width,length,initVal,lmp); + allocate_external_double(array, width, length, initVal, lmp); } void Foam::twoWayMPI::allocateArray @@ -168,18 +167,14 @@ void Foam::twoWayMPI::allocateArray const char* length ) const { - //if(length==-1) then LIGGGHTS uses own length data - char* charLength= const_cast (length); - allocate_external_double(array, width,charLength,initVal,lmp); + allocate_external_double(array, width, length, initVal, lmp); } -void Foam::twoWayMPI::destroy(double** array,int len) const +void Foam::twoWayMPI::destroy(double** array,int /*len*/) const { if (array == NULL) return; - //for ( int i = 0; i < len; i++ ) // does not work - for ( int i = 0; i < 1; i++ ) - free(array[i]); + if (array[0]) free(array[0]); free(array); array = NULL; @@ -195,8 +190,7 @@ void Foam::twoWayMPI::allocateArray int length ) const { - //if(length==-1) then LIGGGHTS uses own length data - allocate_external_int(array, width,length,initVal,lmp); + allocate_external_int(array, width, length, initVal, lmp); } void Foam::twoWayMPI::allocateArray @@ -207,18 +201,14 @@ void Foam::twoWayMPI::allocateArray const char* length ) const { - //if(length==-1) then LIGGGHTS uses own length data - char* charLength= const_cast (length); - allocate_external_int(array, width,charLength,initVal,lmp); + allocate_external_int(array, width, length, initVal, lmp); } -void Foam::twoWayMPI::destroy(int** array,int len) const +void Foam::twoWayMPI::destroy(int** array,int /*len*/) const { if (array == NULL) return; - //for ( int i = 0; i < len; i++ ) // does not work - for ( int i = 0; i < 1; i++ ) - free(array[i]); + if (array[0]) free(array[0]); free(array); array = NULL;