From 40e464ab5ef706c12a1911d332e8c4507c5167ed Mon Sep 17 00:00:00 2001 From: danielque Date: Tue, 8 Sep 2020 13:02:16 +0200 Subject: [PATCH] add reset flag for particle properties use a reset flag to indicate if particle properties should be reset to the initial value each coupling step (note that the property value is always reset if re-allocation happens when the number of particles has changed) --- src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloud.C | 2 +- src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloud.H | 3 ++- src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloudI.H | 4 ++-- .../subModels/forceModel/KochHillRWDrag/KochHillRWDrag.C | 4 ++-- .../subModels/forceModel/virtualMassForce/virtualMassForce.C | 2 +- .../subModels/regionModel/regionModel/regionModel.C | 4 ++-- .../voidFractionModel/voidFractionModel/voidFractionModel.C | 4 ++-- 7 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloud.C b/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloud.C index 88ed0898..36db2d47 100644 --- a/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloud.C +++ b/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloud.C @@ -829,7 +829,7 @@ bool cfdemCloud::reAllocArrays() ++iter ) { - if (iter().size > 0 && iter().initVal == 0.0) { + if (iter().size > 0 && iter().reset) { if ((*(iter().ti)) == typeid(int**)) { int**& property = iter().ref(); for (int index=0; index T& ref() { if (*ti == typeid(T)) return *reinterpret_cast(&property); @@ -460,7 +461,7 @@ public: bool checkPeriodicCells() const { return checkPeriodicCells_; } template - void registerParticleProperty(const word& property, int size=0, double initVal=0.0); + void registerParticleProperty(const word& property, int size=0, double initVal=0.0, bool reset=true); template T& getParticlePropertyRef(const word& property); protected: diff --git a/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloudI.H b/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloudI.H index 6d7d973a..dc3a4125 100644 --- a/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloudI.H +++ b/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloudI.H @@ -405,9 +405,9 @@ inline const turbulenceModel& cfdemCloud::turbulence() const template -void cfdemCloud::registerParticleProperty(const word& property, int size, double initVal) +void cfdemCloud::registerParticleProperty(const word& property, int size, double initVal, bool reset) { - particlePropertyTable.insert(property,{NULL,&typeid(T),size,initVal}); + particlePropertyTable.insert(property,{NULL,&typeid(T),size,initVal,reset}); } template diff --git a/src/lagrangian/cfdemParticle/subModels/forceModel/KochHillRWDrag/KochHillRWDrag.C b/src/lagrangian/cfdemParticle/subModels/forceModel/KochHillRWDrag/KochHillRWDrag.C index 82483f9c..49b91647 100755 --- a/src/lagrangian/cfdemParticle/subModels/forceModel/KochHillRWDrag/KochHillRWDrag.C +++ b/src/lagrangian/cfdemParticle/subModels/forceModel/KochHillRWDrag/KochHillRWDrag.C @@ -97,8 +97,8 @@ KochHillRWDrag::KochHillRWDrag if (propsDict_.found("rhoP")) rhoP_= readScalar(propsDict_.lookup("rhoP")); - particleCloud_.registerParticleProperty("partTime",1); - particleCloud_.registerParticleProperty("partUfluct",3); + particleCloud_.registerParticleProperty("partTime",1,0.0,false); + particleCloud_.registerParticleProperty("partUfluct",3,0.0,false); } diff --git a/src/lagrangian/cfdemParticle/subModels/forceModel/virtualMassForce/virtualMassForce.C b/src/lagrangian/cfdemParticle/subModels/forceModel/virtualMassForce/virtualMassForce.C index 191e0afc..f0ae784b 100644 --- a/src/lagrangian/cfdemParticle/subModels/forceModel/virtualMassForce/virtualMassForce.C +++ b/src/lagrangian/cfdemParticle/subModels/forceModel/virtualMassForce/virtualMassForce.C @@ -72,7 +72,7 @@ virtualMassForce::virtualMassForce splitUrelCalculation_(propsDict_.lookupOrDefault("splitUrelCalculation",false)), Cadd_(0.5) { - particleCloud_.registerParticleProperty("UrelOld",3,NOTONCPU); + particleCloud_.registerParticleProperty("UrelOld",3,NOTONCPU,false); // init force sub model setForceSubModels(propsDict_); diff --git a/src/lagrangian/cfdemParticle/subModels/regionModel/regionModel/regionModel.C b/src/lagrangian/cfdemParticle/subModels/regionModel/regionModel/regionModel.C index 9450d5ba..41397f8d 100644 --- a/src/lagrangian/cfdemParticle/subModels/regionModel/regionModel/regionModel.C +++ b/src/lagrangian/cfdemParticle/subModels/regionModel/regionModel/regionModel.C @@ -59,8 +59,8 @@ regionModel::regionModel dict_(dict), particleCloud_(sm) { - particleCloud_.registerParticleProperty("inRegion",1,1.0); - particleCloud_.registerParticleProperty("outRegion",1,1.0); + particleCloud_.registerParticleProperty("inRegion",1,1.0,false); + particleCloud_.registerParticleProperty("outRegion",1,1.0,false); } diff --git a/src/lagrangian/cfdemParticle/subModels/voidFractionModel/voidFractionModel/voidFractionModel.C b/src/lagrangian/cfdemParticle/subModels/voidFractionModel/voidFractionModel/voidFractionModel.C index 8f292746..425f4dfa 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_.registerParticleProperty("cellsPerParticle",1,1.0); + particleCloud_.registerParticleProperty("cellsPerParticle",1,1.0,false); if (particleCloud_.getParticleEffVolFactors()) multiWeights_ = true; } @@ -131,7 +131,7 @@ voidFractionModel::voidFractionModel weight_(1.), porosity_(1.) { - particleCloud_.registerParticleProperty("cellsPerParticle",1,1.0); + particleCloud_.registerParticleProperty("cellsPerParticle",1,1.0,false); } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //