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)
This commit is contained in:
danielque
2020-09-08 13:02:16 +02:00
parent 75ffbe02ae
commit 40e464ab5e
7 changed files with 12 additions and 11 deletions

View File

@ -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<int**>();
for (int index=0; index<numberOfParticles(); ++index) {

View File

@ -194,6 +194,7 @@ protected:
const std::type_info* ti;
int size;
double initVal;
bool reset;
template<typename T>
T& ref() {
if (*ti == typeid(T)) return *reinterpret_cast<T*>(&property);
@ -460,7 +461,7 @@ public:
bool checkPeriodicCells() const { return checkPeriodicCells_; }
template<typename T>
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<typename T>
T& getParticlePropertyRef(const word& property);
protected:

View File

@ -405,9 +405,9 @@ inline const turbulenceModel& cfdemCloud::turbulence() const
template<typename T>
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<typename T>

View File

@ -97,8 +97,8 @@ KochHillRWDrag::KochHillRWDrag
if (propsDict_.found("rhoP"))
rhoP_= readScalar(propsDict_.lookup("rhoP"));
particleCloud_.registerParticleProperty<double**>("partTime",1);
particleCloud_.registerParticleProperty<double**>("partUfluct",3);
particleCloud_.registerParticleProperty<double**>("partTime",1,0.0,false);
particleCloud_.registerParticleProperty<double**>("partUfluct",3,0.0,false);
}

View File

@ -72,7 +72,7 @@ virtualMassForce::virtualMassForce
splitUrelCalculation_(propsDict_.lookupOrDefault<bool>("splitUrelCalculation",false)),
Cadd_(0.5)
{
particleCloud_.registerParticleProperty<double**>("UrelOld",3,NOTONCPU);
particleCloud_.registerParticleProperty<double**>("UrelOld",3,NOTONCPU,false);
// init force sub model
setForceSubModels(propsDict_);

View File

@ -59,8 +59,8 @@ regionModel::regionModel
dict_(dict),
particleCloud_(sm)
{
particleCloud_.registerParticleProperty<double**>("inRegion",1,1.0);
particleCloud_.registerParticleProperty<double**>("outRegion",1,1.0);
particleCloud_.registerParticleProperty<double**>("inRegion",1,1.0,false);
particleCloud_.registerParticleProperty<double**>("outRegion",1,1.0,false);
}

View File

@ -88,7 +88,7 @@ voidFractionModel::voidFractionModel
weight_(1.),
porosity_(1.)
{
particleCloud_.registerParticleProperty<int**>("cellsPerParticle",1,1.0);
particleCloud_.registerParticleProperty<int**>("cellsPerParticle",1,1.0,false);
if (particleCloud_.getParticleEffVolFactors()) multiWeights_ = true;
}
@ -131,7 +131,7 @@ voidFractionModel::voidFractionModel
weight_(1.),
porosity_(1.)
{
particleCloud_.registerParticleProperty<int**>("cellsPerParticle",1,1.0);
particleCloud_.registerParticleProperty<int**>("cellsPerParticle",1,1.0,false);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //