From 3ea5bf774a54ca208f52a94545a1be37cac62b1a Mon Sep 17 00:00:00 2001 From: danielque Date: Wed, 5 Aug 2020 17:02:09 +0200 Subject: [PATCH 01/20] test concept for centralized per-particle properties register any per-particle properties (here: cellsPerParticle_ of voidFractionModel) in hashtables in cfdemCloud class and in further consequence handle access to per-particle data pointers centrally --- .../cfdemParticle/cfdemCloud/cfdemCloud.C | 21 +++++++++++ .../cfdemParticle/cfdemCloud/cfdemCloud.H | 11 ++++++ .../cfdemParticle/cfdemCloud/cfdemCloudI.H | 35 +++++++++++++++++++ .../GaussVoidFraction/GaussVoidFraction.C | 8 ++--- .../IBVoidFraction/IBVoidFraction.C | 8 ++--- .../bigParticleVoidFraction.C | 8 ++--- .../centreVoidFraction/centreVoidFraction.C | 6 ++-- .../dividedVoidFraction/dividedVoidFraction.C | 6 ++-- .../dividedVoidFraction/setWeightedSource.H | 12 +++---- .../trilinearVoidFraction.C | 2 +- .../voidFractionModel/voidFractionModel.C | 15 ++++---- .../voidFractionModel/voidFractionModel.H | 1 - 12 files changed, 99 insertions(+), 34 deletions(-) diff --git a/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloud.C b/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloud.C index df719b60..893a392b 100644 --- a/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloud.C +++ b/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloud.C @@ -160,6 +160,8 @@ cfdemCloud::cfdemCloud turbulenceModelType_ ) ), + intParticleProperties(8), + doubleParticleProperties(8), dataExchangeModel_ ( dataExchangeModel::New @@ -402,6 +404,25 @@ cfdemCloud::~cfdemCloud() if(getParticleDensities_) dataExchangeM().destroy(particleDensities_,1); if(getParticleEffVolFactors_) dataExchangeM().destroy(particleEffVolFactors_,1); if(getParticleTypes_) dataExchangeM().destroy(particleTypes_,1); + + for + ( + HashTable::iterator iter = intParticleProperties.begin(); + iter != intParticleProperties.end(); + ++iter + ) + { + dataExchangeM().destroy(*iter,-1); + } + for + ( + HashTable::iterator iter = doubleParticleProperties.begin(); + iter != doubleParticleProperties.end(); + ++iter + ) + { + dataExchangeM().destroy(*iter,-1); + } } // * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * // diff --git a/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloud.H b/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloud.H index 0b0d02ee..4bf11ab8 100644 --- a/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloud.H +++ b/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloud.H @@ -188,6 +188,9 @@ protected: const turbulenceModel& turbulence_; + HashTable intParticleProperties; + HashTable doubleParticleProperties; + autoPtr dataExchangeModel_; PtrList forceModel_; @@ -443,6 +446,14 @@ public: void otherForces(volVectorField&); bool checkPeriodicCells() const { return checkPeriodicCells_; } + + template + void registerParticleVectorProperty(const word& property); + template + T**& getParticleVectorPropertyRef(const word& property); +protected: + virtual int**& getParticleVectorPropertyImpl(const word& property, int**); + virtual double**& getParticleVectorPropertyImpl(const word& property, double**); }; diff --git a/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloudI.H b/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloudI.H index 5c9d426f..169a7a9f 100644 --- a/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloudI.H +++ b/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloudI.H @@ -403,5 +403,40 @@ inline const turbulenceModel& cfdemCloud::turbulence() const return turbulence_; } +template +void cfdemCloud::registerParticleVectorProperty(const word& property) +{ + FatalError << "Trying to register particle vector property of unsupported type" << endl; +} + +template<> inline +void cfdemCloud::registerParticleVectorProperty(const word& property) +{ + intParticleProperties.insert(property, (int**)NULL); +} + +template<> inline +void cfdemCloud::registerParticleVectorProperty(const word& property) +{ + doubleParticleProperties.insert(property, (double**)NULL); +} + + +template +T**& cfdemCloud::getParticleVectorPropertyRef(const word& property) +{ + return getParticleVectorPropertyImpl(property, (T**)NULL); +} + +inline int**& cfdemCloud::getParticleVectorPropertyImpl(const word& property, int**) +{ + return intParticleProperties[property]; +} + +inline double**& cfdemCloud::getParticleVectorPropertyImpl(const word& property, double**) +{ + return doubleParticleProperties[property]; +} + } // ************************************************************************* // diff --git a/src/lagrangian/cfdemParticle/subModels/voidFractionModel/GaussVoidFraction/GaussVoidFraction.C b/src/lagrangian/cfdemParticle/subModels/voidFractionModel/GaussVoidFraction/GaussVoidFraction.C index 9a8c5a22..9ea66ad1 100644 --- a/src/lagrangian/cfdemParticle/subModels/voidFractionModel/GaussVoidFraction/GaussVoidFraction.C +++ b/src/lagrangian/cfdemParticle/subModels/voidFractionModel/GaussVoidFraction/GaussVoidFraction.C @@ -103,12 +103,12 @@ void GaussVoidFraction::setvoidFraction(double** const& mask,double**& voidfract //if(mask[index][0]) //{ //reset - for(int subcell=0;subcell 0) { - cellsPerParticle_[index][0]=hashSetLength; + cellsPerParticle()[index][0]=hashSetLength; //making sure that the cell containing the center is the first subcell particleCloud_.cellIDs()[index][0]=particleCenterCellID; @@ -200,7 +200,7 @@ void GaussVoidFraction::setvoidFraction(double** const& mask,double**& voidfract //bringing eulerian field to particle array for(label index=0; index< particleCloud_.numberOfParticles(); index++) { - for(label subcell=0;subcell 0) { - cellsPerParticle_[index][0]=hashSetLength; + cellsPerParticle()[index][0]=hashSetLength; hashSett.erase(particleCenterCellID); for (label i=0; i < hashSetLength-1; i++) @@ -281,7 +281,7 @@ void IBVoidFraction::setvoidFraction(double** const& mask,double**& voidfraction for (label index=0; index < particleCloud_.numberOfParticles(); index++) { - for (label subcell=0; subcell < cellsPerParticle_[index][0]; subcell++) + for (label subcell=0; subcell < cellsPerParticle()[index][0]; subcell++) { label cellID = particleCloud_.cellIDs()[index][subcell]; diff --git a/src/lagrangian/cfdemParticle/subModels/voidFractionModel/bigParticleVoidFraction/bigParticleVoidFraction.C b/src/lagrangian/cfdemParticle/subModels/voidFractionModel/bigParticleVoidFraction/bigParticleVoidFraction.C index 4d254b42..3a6f263a 100644 --- a/src/lagrangian/cfdemParticle/subModels/voidFractionModel/bigParticleVoidFraction/bigParticleVoidFraction.C +++ b/src/lagrangian/cfdemParticle/subModels/voidFractionModel/bigParticleVoidFraction/bigParticleVoidFraction.C @@ -102,12 +102,12 @@ void bigParticleVoidFraction::setvoidFraction(double** const& mask,double**& voi //if(mask[index][0]) //{ //reset - for(int subcell=0;subcell 0) { - cellsPerParticle_[index][0]=hashSetLength; + cellsPerParticle()[index][0]=hashSetLength; //making sure that the cell containing the center is the first subcell particleCloud_.cellIDs()[index][0]=particleCenterCellID; @@ -190,7 +190,7 @@ void bigParticleVoidFraction::setvoidFraction(double** const& mask,double**& voi //bringing eulerian field to particle array for(label index=0; index< particleCloud_.numberOfParticles(); index++) { - for(label subcell=0;subcellscreen,"cellID=%d, partCellId=%d\n",static_cast(cellID),static_cast(partCellId)); if(partCellId!=cellID) @@ -35,7 +35,7 @@ scalar partCellVol = particleCloud_.mesh().V()[partCellId]; scalar particleVolume = volume/static_cast(nPoints); scalar newAlpha = voidfractionNext_[partCellId]- particleVolume / partCellVol; - + if(newAlpha > alphaMin_) voidfractionNext_[partCellId] = newAlpha; else { @@ -49,9 +49,9 @@ // add sub particle representation bool createNew = true; label storeInIndex=0; - for(int i=0; i < cellsPerParticle_[index][0] ; i++) + for(int i=0; i < cellsPerParticle()[index][0] ; i++) { - if(partCellId == particleCloud_.cellIDs()[index][i]) + if(partCellId == particleCloud_.cellIDs()[index][i]) { storeInIndex = i; createNew = false; @@ -61,8 +61,8 @@ if(createNew) { - cellsPerParticle_[index][0] ++; - storeInIndex = cellsPerParticle_[index][0]-1; + cellsPerParticle()[index][0] ++; + storeInIndex = cellsPerParticle()[index][0]-1; particleCloud_.cellIDs()[index][storeInIndex] = partCellId; } diff --git a/src/lagrangian/cfdemParticle/subModels/voidFractionModel/trilinearVoidFraction/trilinearVoidFraction.C b/src/lagrangian/cfdemParticle/subModels/voidFractionModel/trilinearVoidFraction/trilinearVoidFraction.C index 7cbc8bbd..e47d1def 100644 --- a/src/lagrangian/cfdemParticle/subModels/voidFractionModel/trilinearVoidFraction/trilinearVoidFraction.C +++ b/src/lagrangian/cfdemParticle/subModels/voidFractionModel/trilinearVoidFraction/trilinearVoidFraction.C @@ -131,7 +131,7 @@ void trilinearVoidFraction::setvoidFraction(double** const& mask,double**& voidf for(int index = 0; index < particleCloud_.numberOfParticles(); ++index) { // reset - cellsPerParticle_[index][0] = 8; + cellsPerParticle()[index][0] = 8; //TODO do we need to set particleVolumes, particleV? // === diff --git a/src/lagrangian/cfdemParticle/subModels/voidFractionModel/voidFractionModel/voidFractionModel.C b/src/lagrangian/cfdemParticle/subModels/voidFractionModel/voidFractionModel/voidFractionModel.C index b07d9667..7cdafb8d 100644 --- a/src/lagrangian/cfdemParticle/subModels/voidFractionModel/voidFractionModel/voidFractionModel.C +++ b/src/lagrangian/cfdemParticle/subModels/voidFractionModel/voidFractionModel/voidFractionModel.C @@ -84,12 +84,11 @@ voidFractionModel::voidFractionModel /*sm.mesh(), dimensionedScalar("zero", dimensionSet(0,0,0,0,0), 1)*/ ), - cellsPerParticle_(NULL), maxCellsPerParticle_(1), weight_(1.), porosity_(1.) { - particleCloud_.dataExchangeM().allocateArray(cellsPerParticle_,1,1); + particleCloud_.registerParticleVectorProperty("cellsPerParticle"); if (particleCloud_.getParticleEffVolFactors()) multiWeights_ = true; } @@ -128,19 +127,17 @@ voidFractionModel::voidFractionModel sm.mesh(), dimensionedScalar("zero", dimensionSet(0,0,0,0,0), initVoidfraction) ), - cellsPerParticle_(NULL), maxCellsPerParticle_(1), weight_(1.), porosity_(1.) { - particleCloud_.dataExchangeM().allocateArray(cellsPerParticle_,1,1); + particleCloud_.registerParticleVectorProperty("cellsPerParticle"); } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // voidFractionModel::~voidFractionModel() { - particleCloud_.dataExchangeM().destroy(cellsPerParticle_,1); } // * * * * * * * * * * * * * * public Member Functions * * * * * * * * * * * * * // @@ -162,7 +159,7 @@ void voidFractionModel::resetVoidFractions() int** const& voidFractionModel::cellsPerParticle() const { - return cellsPerParticle_; + return particleCloud_.getParticleVectorPropertyRef("cellsPerParticle"); } int voidFractionModel::maxCellsPerParticle() const @@ -175,7 +172,8 @@ void voidFractionModel::reAllocArrays() if(particleCloud_.numberOfParticlesChanged()) { // get arrays of new length - particleCloud_.dataExchangeM().allocateArray(cellsPerParticle_,1,1); + particleCloud_.dataExchangeM().allocateArray( + particleCloud_.getParticleVectorPropertyRef("cellsPerParticle"),1,1); } } @@ -184,7 +182,8 @@ void voidFractionModel::reAllocArrays(int nP) if(particleCloud_.numberOfParticlesChanged()) { // get arrays of new length - particleCloud_.dataExchangeM().allocateArray(cellsPerParticle_,1,1,nP); + particleCloud_.dataExchangeM().allocateArray( + particleCloud_.getParticleVectorPropertyRef("cellsPerParticle"),1,1,nP); } } diff --git a/src/lagrangian/cfdemParticle/subModels/voidFractionModel/voidFractionModel/voidFractionModel.H b/src/lagrangian/cfdemParticle/subModels/voidFractionModel/voidFractionModel/voidFractionModel.H index 5e148fb2..11fd735b 100644 --- a/src/lagrangian/cfdemParticle/subModels/voidFractionModel/voidFractionModel/voidFractionModel.H +++ b/src/lagrangian/cfdemParticle/subModels/voidFractionModel/voidFractionModel/voidFractionModel.H @@ -69,7 +69,6 @@ protected: volScalarField voidfractionNext_; - int ** cellsPerParticle_; int maxCellsPerParticle_; From b0533b79abdae4d7e04e2b7786a97a5e2c772c56 Mon Sep 17 00:00:00 2001 From: danielque Date: Mon, 10 Aug 2020 15:25:50 +0200 Subject: [PATCH 02/20] streamline particle property registration --- .../cfdemParticle/cfdemCloud/cfdemCloud.C | 24 +++++++-------- .../cfdemParticle/cfdemCloud/cfdemCloud.H | 22 ++++++++++---- .../cfdemParticle/cfdemCloud/cfdemCloudI.H | 30 ++++++------------- .../voidFractionModel/voidFractionModel.C | 12 ++++---- .../voidFractionModel/voidFractionModel.H | 1 - 5 files changed, 40 insertions(+), 49 deletions(-) diff --git a/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloud.C b/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloud.C index 893a392b..27b07c6e 100644 --- a/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloud.C +++ b/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloud.C @@ -160,8 +160,7 @@ cfdemCloud::cfdemCloud turbulenceModelType_ ) ), - intParticleProperties(8), - doubleParticleProperties(8), + particlePropertyTable(32), dataExchangeModel_ ( dataExchangeModel::New @@ -407,21 +406,18 @@ cfdemCloud::~cfdemCloud() for ( - HashTable::iterator iter = intParticleProperties.begin(); - iter != intParticleProperties.end(); + HashTable::iterator iter = particlePropertyTable.begin(); + iter != particlePropertyTable.end(); ++iter ) { - dataExchangeM().destroy(*iter,-1); - } - for - ( - HashTable::iterator iter = doubleParticleProperties.begin(); - iter != doubleParticleProperties.end(); - ++iter - ) - { - dataExchangeM().destroy(*iter,-1); + if ((*(iter().ti)) == typeid(int**)) { + dataExchangeM().destroy(iter().ref(),-1); + } else if ((*(iter().ti)) == typeid(double**)) { + dataExchangeM().destroy(iter().ref(),-1); + } else { + FatalError << "Trying to destroy property of type " << iter().ti->name() << endl; + } } } diff --git a/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloud.H b/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloud.H index 4bf11ab8..49762ced 100644 --- a/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloud.H +++ b/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloud.H @@ -45,6 +45,7 @@ SourceFiles // choose version #include "OFversion.H" #include +#include #include "fvCFD.H" #include "IFstream.H" @@ -188,8 +189,17 @@ protected: const turbulenceModel& turbulence_; - HashTable intParticleProperties; - HashTable doubleParticleProperties; + struct particleProperty { + void** property; + const std::type_info* ti; + template + T& ref() { + if (*ti == typeid(T)) return *reinterpret_cast(&property); + else throw std::bad_cast(); + } + }; + + HashTable particlePropertyTable; autoPtr dataExchangeModel_; @@ -448,12 +458,12 @@ public: bool checkPeriodicCells() const { return checkPeriodicCells_; } template - void registerParticleVectorProperty(const word& property); + void registerParticleProperty(const word& property); template - T**& getParticleVectorPropertyRef(const word& property); + T& getParticlePropertyRef(const word& property); protected: - virtual int**& getParticleVectorPropertyImpl(const word& property, int**); - virtual double**& getParticleVectorPropertyImpl(const word& property, double**); + virtual int**& getParticlePropertyImpl(const word& property, int**); + virtual double**& getParticlePropertyImpl(const word& property, double**); }; diff --git a/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloudI.H b/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloudI.H index 169a7a9f..88a00208 100644 --- a/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloudI.H +++ b/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloudI.H @@ -403,39 +403,27 @@ inline const turbulenceModel& cfdemCloud::turbulence() const return turbulence_; } -template -void cfdemCloud::registerParticleVectorProperty(const word& property) -{ - FatalError << "Trying to register particle vector property of unsupported type" << endl; -} - -template<> inline -void cfdemCloud::registerParticleVectorProperty(const word& property) -{ - intParticleProperties.insert(property, (int**)NULL); -} -template<> inline -void cfdemCloud::registerParticleVectorProperty(const word& property) +template +void cfdemCloud::registerParticleProperty(const word& property) { - doubleParticleProperties.insert(property, (double**)NULL); + particlePropertyTable.insert(property,{NULL,&typeid(T)}); } - template -T**& cfdemCloud::getParticleVectorPropertyRef(const word& property) +T& cfdemCloud::getParticlePropertyRef(const word& property) { - return getParticleVectorPropertyImpl(property, (T**)NULL); + return getParticlePropertyImpl(property, static_cast(0)); } -inline int**& cfdemCloud::getParticleVectorPropertyImpl(const word& property, int**) +inline int**& cfdemCloud::getParticlePropertyImpl(const word& property, int**) { - return intParticleProperties[property]; + return particlePropertyTable[property].ref(); } -inline double**& cfdemCloud::getParticleVectorPropertyImpl(const word& property, double**) +inline double**& cfdemCloud::getParticlePropertyImpl(const word& property, double**) { - return doubleParticleProperties[property]; + return particlePropertyTable[property].ref(); } } diff --git a/src/lagrangian/cfdemParticle/subModels/voidFractionModel/voidFractionModel/voidFractionModel.C b/src/lagrangian/cfdemParticle/subModels/voidFractionModel/voidFractionModel/voidFractionModel.C index 7cdafb8d..d333e26e 100644 --- a/src/lagrangian/cfdemParticle/subModels/voidFractionModel/voidFractionModel/voidFractionModel.C +++ b/src/lagrangian/cfdemParticle/subModels/voidFractionModel/voidFractionModel/voidFractionModel.C @@ -88,7 +88,7 @@ voidFractionModel::voidFractionModel weight_(1.), porosity_(1.) { - particleCloud_.registerParticleVectorProperty("cellsPerParticle"); + particleCloud_.registerParticleProperty("cellsPerParticle"); if (particleCloud_.getParticleEffVolFactors()) multiWeights_ = true; } @@ -131,7 +131,7 @@ voidFractionModel::voidFractionModel weight_(1.), porosity_(1.) { - particleCloud_.registerParticleVectorProperty("cellsPerParticle"); + particleCloud_.registerParticleProperty("cellsPerParticle"); } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // @@ -159,7 +159,7 @@ void voidFractionModel::resetVoidFractions() int** const& voidFractionModel::cellsPerParticle() const { - return particleCloud_.getParticleVectorPropertyRef("cellsPerParticle"); + return particleCloud_.getParticlePropertyRef("cellsPerParticle"); } int voidFractionModel::maxCellsPerParticle() const @@ -172,8 +172,7 @@ void voidFractionModel::reAllocArrays() if(particleCloud_.numberOfParticlesChanged()) { // get arrays of new length - particleCloud_.dataExchangeM().allocateArray( - particleCloud_.getParticleVectorPropertyRef("cellsPerParticle"),1,1); + particleCloud_.dataExchangeM().allocateArray(particleCloud_.getParticlePropertyRef("cellsPerParticle"),1,1); } } @@ -182,8 +181,7 @@ void voidFractionModel::reAllocArrays(int nP) if(particleCloud_.numberOfParticlesChanged()) { // get arrays of new length - particleCloud_.dataExchangeM().allocateArray( - particleCloud_.getParticleVectorPropertyRef("cellsPerParticle"),1,1,nP); + particleCloud_.dataExchangeM().allocateArray(particleCloud_.getParticlePropertyRef("cellsPerParticle"),1,1,nP); } } diff --git a/src/lagrangian/cfdemParticle/subModels/voidFractionModel/voidFractionModel/voidFractionModel.H b/src/lagrangian/cfdemParticle/subModels/voidFractionModel/voidFractionModel/voidFractionModel.H index 11fd735b..d3c57d81 100644 --- a/src/lagrangian/cfdemParticle/subModels/voidFractionModel/voidFractionModel/voidFractionModel.H +++ b/src/lagrangian/cfdemParticle/subModels/voidFractionModel/voidFractionModel/voidFractionModel.H @@ -69,7 +69,6 @@ protected: volScalarField voidfractionNext_; - int maxCellsPerParticle_; scalar weight_; From 214e10e5a3bf2c010dab666b447236873c9f3374 Mon Sep 17 00:00:00 2001 From: danielque Date: Mon, 10 Aug 2020 17:56:24 +0200 Subject: [PATCH 03/20] use particle property registration in chemistry and energy models --- .../diffusionCoefficients.C | 42 ++++------- .../diffusionCoefficients.H | 10 +-- .../massTransferCoeff/massTransferCoeff.C | 26 ++----- .../massTransferCoeff/massTransferCoeff.H | 6 -- .../reactantPerParticle/reactantPerParticle.C | 21 ++---- .../reactantPerParticle/reactantPerParticle.H | 4 -- .../chemistryModel/species/species.C | 69 ++++++++----------- .../chemistryModel/species/species.H | 12 ---- .../heatTransferGranConduction.C | 26 ++++--- .../heatTransferGranConduction.H | 8 +-- .../heatTransferGunn/heatTransferGunn.C | 49 +++++++++---- .../heatTransferGunn/heatTransferGunn.H | 10 --- .../heatTransferRanzMarshall.C | 51 ++++++++++---- .../heatTransferRanzMarshall.H | 16 +---- .../energyModel/reactionHeat/reactionHeat.C | 6 +- .../energyModel/reactionHeat/reactionHeat.H | 2 - 16 files changed, 155 insertions(+), 203 deletions(-) diff --git a/src/lagrangian/cfdemParticle/subModels/chemistryModel/diffusionCoefficients/diffusionCoefficients.C b/src/lagrangian/cfdemParticle/subModels/chemistryModel/diffusionCoefficients/diffusionCoefficients.C index 9ce61c26..f5a8a329 100644 --- a/src/lagrangian/cfdemParticle/subModels/chemistryModel/diffusionCoefficients/diffusionCoefficients.C +++ b/src/lagrangian/cfdemParticle/subModels/chemistryModel/diffusionCoefficients/diffusionCoefficients.C @@ -71,15 +71,17 @@ diffusionCoefficient::diffusionCoefficient pressureFieldName_(propsDict_.lookupOrDefault("pressureFieldName","p")), P_(sm.mesh().lookupObject(pressureFieldName_)), partPressureName_(propsDict_.lookupOrDefault("partPressureName","partP")), - partPressure_(NULL), X_(speciesNames_.size()), diffusantGasNames_(propsDict_.lookup("diffusantGasNames")), - diffusionCoefficients_(diffusantGasNames_.size(),NULL), Xdiffusant_(diffusantGasNames_.size()), initialized_(false) { particleCloud_.checkCG(false); - allocateMyArrays(); + particleCloud_.registerParticleProperty("partPressure"); + for (int i=0; i(diffusantGasNames_[i]); + } createCoeffs(); molWeightTable(); } @@ -88,35 +90,17 @@ diffusionCoefficient::diffusionCoefficient diffusionCoefficient::~diffusionCoefficient() { - particleCloud_.dataExchangeM().destroy(partPressure_,1); - for (int i=0; i 0) - { - particleCloud_.dataExchangeM().allocateArray(partPressure_,initVal,1,"nparticles"); - for (int i=0; i("partPressure"),initVal,1); for (int i=0; i(diffusantGasNames_[i]),initVal,1); } } @@ -172,6 +156,8 @@ void diffusionCoefficient::execute() interpolationCellPoint TInterpolator_(tempField_); interpolationCellPoint PInterpolator_(P_); + double**& partPressure_ = particleCloud_.getParticlePropertyRef("partPressure"); + for (int index=0; index(diffusantGasNames_[j]); TotalFraction_[j] = 0.0; dBinary_ = 0.0; @@ -243,9 +230,9 @@ void diffusionCoefficient::execute() // pass on dCoeff values to array if (TotalFraction_[j] < VSMALL) - diffusionCoefficients_[j][index][0] = VSMALL; + diffusionCoefficients_[index][0] = VSMALL; else - diffusionCoefficients_[j][index][0] = (1.0 - Xdiffusant_[j][cellI]) / TotalFraction_[j]; + diffusionCoefficients_[index][0] = (1.0 - Xdiffusant_[j][cellI]) / TotalFraction_[j]; } else { @@ -258,7 +245,7 @@ void diffusionCoefficient::execute() } if(verbose_) - Info << "diffusionCoefficient of species " << diffusantGasNames_[j] << " = " << diffusionCoefficients_[j][index][0] << endl; + Info << "diffusionCoefficient of species " << diffusantGasNames_[j] << " = " << diffusionCoefficients_[index][0] << endl; } } } @@ -268,7 +255,8 @@ void diffusionCoefficient::execute() for (int j=0; j(diffusantGasNames_[j]); + particleCloud_.dataExchangeM().giveData(pushName,"scalar-atom",diffusionCoefficients_); } Info << "give data done" << endl; diff --git a/src/lagrangian/cfdemParticle/subModels/chemistryModel/diffusionCoefficients/diffusionCoefficients.H b/src/lagrangian/cfdemParticle/subModels/chemistryModel/diffusionCoefficients/diffusionCoefficients.H index c8e9b1cf..add7be45 100644 --- a/src/lagrangian/cfdemParticle/subModels/chemistryModel/diffusionCoefficients/diffusionCoefficients.H +++ b/src/lagrangian/cfdemParticle/subModels/chemistryModel/diffusionCoefficients/diffusionCoefficients.H @@ -76,19 +76,15 @@ private: word partPressureName_; - mutable double **partPressure_; - UPtrList X_; wordList diffusantGasNames_; - mutable List diffusionCoefficients_; - UPtrList Xdiffusant_; - HashTable coeffs; + HashTable coeffs; - HashTable molWeight; + HashTable molWeight; void createCoeffs(); @@ -100,8 +96,6 @@ private: // calculate denominator part diffusion volume equation double calcDiffVol(int, int); - void allocateMyArrays() const; - bool initialized_; void init(); diff --git a/src/lagrangian/cfdemParticle/subModels/chemistryModel/massTransferCoeff/massTransferCoeff.C b/src/lagrangian/cfdemParticle/subModels/chemistryModel/massTransferCoeff/massTransferCoeff.C index 2f49a729..053aeb4c 100644 --- a/src/lagrangian/cfdemParticle/subModels/chemistryModel/massTransferCoeff/massTransferCoeff.C +++ b/src/lagrangian/cfdemParticle/subModels/chemistryModel/massTransferCoeff/massTransferCoeff.C @@ -63,42 +63,27 @@ massTransferCoeff::massTransferCoeff densityFieldName_(propsDict_.lookupOrDefault("densityFieldName","rho")), rho_(sm.mesh().lookupObject (densityFieldName_)), partNuName_(propsDict_.lookupOrDefault("partViscos","partNu")), - partNu_(NULL), partReynolds_(propsDict_.lookupOrDefault("partReynolds","partRe")), - partRe_(NULL), scaleDia_(1) { particleCloud_.checkCG(true); - allocateMyArrays(); + particleCloud_.registerParticleProperty(partNuName_); + particleCloud_.registerParticleProperty(partReynolds_); } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // massTransferCoeff::~massTransferCoeff() { - int nP_ = particleCloud_.numberOfParticles(); - - particleCloud_.dataExchangeM().destroy(partNu_,nP_); - particleCloud_.dataExchangeM().destroy(partRe_,nP_); } // * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * // -void massTransferCoeff::allocateMyArrays() const -{ - double initVal=0.0; - if (particleCloud_.dataExchangeM().maxNumberOfParticles() > 0) - { - // get memory for 2d arrays - particleCloud_.dataExchangeM().allocateArray(partNu_,initVal,1,"nparticles"); - particleCloud_.dataExchangeM().allocateArray(partRe_,initVal,1,"nparticles"); - } -} void massTransferCoeff::reAllocMyArrays() const { double initVal=0.0; - particleCloud_.dataExchangeM().allocateArray(partNu_,initVal,1); - particleCloud_.dataExchangeM().allocateArray(partRe_,initVal,1); + particleCloud_.dataExchangeM().allocateArray(particleCloud_.getParticlePropertyRef(partNuName_),initVal,1); + particleCloud_.dataExchangeM().allocateArray(particleCloud_.getParticlePropertyRef(partReynolds_),initVal,1); } // * * * * * * * * * * * * * * * * Member Fct * * * * * * * * * * * * * * * // @@ -139,6 +124,9 @@ void massTransferCoeff::execute() interpolationCellPoint UluidInterpolator_(U_); interpolationCellPoint voidfractionInterpolator_(voidfraction_); + double**& partNu_ = particleCloud_.getParticlePropertyRef(partNuName_); + double**& partRe_ = particleCloud_.getParticlePropertyRef(partReynolds_); + for (int index=0; index("verbose",false)), - reactantPerParticle_(NULL), voidfractionFieldName_(propsDict_.lookupOrDefault("voidfractionFieldName","voidfraction")), voidfraction_(sm.mesh().lookupObject(voidfractionFieldName_)), particlesPerCell_ @@ -76,30 +75,21 @@ reactantPerParticle::reactantPerParticle Nevery_(propsDict_.lookupOrDefault