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
This commit is contained in:
danielque
2020-08-05 17:02:09 +02:00
parent 3b29d96c05
commit 3ea5bf774a
12 changed files with 99 additions and 34 deletions

View File

@ -160,6 +160,8 @@ cfdemCloud::cfdemCloud
turbulenceModelType_ turbulenceModelType_
) )
), ),
intParticleProperties(8),
doubleParticleProperties(8),
dataExchangeModel_ dataExchangeModel_
( (
dataExchangeModel::New dataExchangeModel::New
@ -402,6 +404,25 @@ cfdemCloud::~cfdemCloud()
if(getParticleDensities_) dataExchangeM().destroy(particleDensities_,1); if(getParticleDensities_) dataExchangeM().destroy(particleDensities_,1);
if(getParticleEffVolFactors_) dataExchangeM().destroy(particleEffVolFactors_,1); if(getParticleEffVolFactors_) dataExchangeM().destroy(particleEffVolFactors_,1);
if(getParticleTypes_) dataExchangeM().destroy(particleTypes_,1); if(getParticleTypes_) dataExchangeM().destroy(particleTypes_,1);
for
(
HashTable<int**>::iterator iter = intParticleProperties.begin();
iter != intParticleProperties.end();
++iter
)
{
dataExchangeM().destroy(*iter,-1);
}
for
(
HashTable<double**>::iterator iter = doubleParticleProperties.begin();
iter != doubleParticleProperties.end();
++iter
)
{
dataExchangeM().destroy(*iter,-1);
}
} }
// * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * //

View File

@ -188,6 +188,9 @@ protected:
const turbulenceModel& turbulence_; const turbulenceModel& turbulence_;
HashTable<int**> intParticleProperties;
HashTable<double**> doubleParticleProperties;
autoPtr<dataExchangeModel> dataExchangeModel_; autoPtr<dataExchangeModel> dataExchangeModel_;
PtrList<forceModel> forceModel_; PtrList<forceModel> forceModel_;
@ -443,6 +446,14 @@ public:
void otherForces(volVectorField&); void otherForces(volVectorField&);
bool checkPeriodicCells() const { return checkPeriodicCells_; } bool checkPeriodicCells() const { return checkPeriodicCells_; }
template<typename T>
void registerParticleVectorProperty(const word& property);
template<typename T>
T**& getParticleVectorPropertyRef(const word& property);
protected:
virtual int**& getParticleVectorPropertyImpl(const word& property, int**);
virtual double**& getParticleVectorPropertyImpl(const word& property, double**);
}; };

View File

@ -403,5 +403,40 @@ inline const turbulenceModel& cfdemCloud::turbulence() const
return turbulence_; return turbulence_;
} }
template<typename T>
void cfdemCloud::registerParticleVectorProperty(const word& property)
{
FatalError << "Trying to register particle vector property of unsupported type" << endl;
}
template<> inline
void cfdemCloud::registerParticleVectorProperty<int>(const word& property)
{
intParticleProperties.insert(property, (int**)NULL);
}
template<> inline
void cfdemCloud::registerParticleVectorProperty<double>(const word& property)
{
doubleParticleProperties.insert(property, (double**)NULL);
}
template<typename T>
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];
}
} }
// ************************************************************************* // // ************************************************************************* //

View File

@ -103,12 +103,12 @@ void GaussVoidFraction::setvoidFraction(double** const& mask,double**& voidfract
//if(mask[index][0]) //if(mask[index][0])
//{ //{
//reset //reset
for(int subcell=0;subcell<cellsPerParticle_[index][0];subcell++) for(int subcell=0;subcell<cellsPerParticle()[index][0];subcell++)
{ {
particleWeights[index][subcell]=0; particleWeights[index][subcell]=0;
particleVolumes[index][subcell]=0; particleVolumes[index][subcell]=0;
} }
cellsPerParticle_[index][0]=1; cellsPerParticle()[index][0]=1;
particleV[index][0]=0; particleV[index][0]=0;
//collecting data //collecting data
@ -142,7 +142,7 @@ void GaussVoidFraction::setvoidFraction(double** const& mask,double**& voidfract
} }
else if (hashSetLength > 0) else if (hashSetLength > 0)
{ {
cellsPerParticle_[index][0]=hashSetLength; cellsPerParticle()[index][0]=hashSetLength;
//making sure that the cell containing the center is the first subcell //making sure that the cell containing the center is the first subcell
particleCloud_.cellIDs()[index][0]=particleCenterCellID; particleCloud_.cellIDs()[index][0]=particleCenterCellID;
@ -200,7 +200,7 @@ void GaussVoidFraction::setvoidFraction(double** const& mask,double**& voidfract
//bringing eulerian field to particle array //bringing eulerian field to particle array
for(label index=0; index< particleCloud_.numberOfParticles(); index++) 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]; label cellID = particleCloud_.cellIDs()[index][subcell];

View File

@ -100,13 +100,13 @@ void IBVoidFraction::setvoidFraction(double** const& mask,double**& voidfraction
//if(mask[index][0]) //if(mask[index][0])
//{ //{
//reset //reset
for (int subcell=0; subcell < cellsPerParticle_[index][0]; subcell++) for (int subcell=0; subcell < cellsPerParticle()[index][0]; subcell++)
{ {
particleWeights[index][subcell] = 0.0; particleWeights[index][subcell] = 0.0;
particleVolumes[index][subcell] = 0.0; particleVolumes[index][subcell] = 0.0;
} }
cellsPerParticle_[index][0]=1; cellsPerParticle()[index][0]=1;
particleV[index][0]=0; particleV[index][0]=0;
//collecting data //collecting data
@ -266,7 +266,7 @@ void IBVoidFraction::setvoidFraction(double** const& mask,double**& voidfraction
} }
else if (hashSetLength > 0) else if (hashSetLength > 0)
{ {
cellsPerParticle_[index][0]=hashSetLength; cellsPerParticle()[index][0]=hashSetLength;
hashSett.erase(particleCenterCellID); hashSett.erase(particleCenterCellID);
for (label i=0; i < hashSetLength-1; i++) 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 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]; label cellID = particleCloud_.cellIDs()[index][subcell];

View File

@ -102,12 +102,12 @@ void bigParticleVoidFraction::setvoidFraction(double** const& mask,double**& voi
//if(mask[index][0]) //if(mask[index][0])
//{ //{
//reset //reset
for(int subcell=0;subcell<cellsPerParticle_[index][0];subcell++) for(int subcell=0;subcell<cellsPerParticle()[index][0];subcell++)
{ {
particleWeights[index][subcell]=0; particleWeights[index][subcell]=0;
particleVolumes[index][subcell]=0; particleVolumes[index][subcell]=0;
} }
cellsPerParticle_[index][0]=1; cellsPerParticle()[index][0]=1;
particleV[index][0]=0; particleV[index][0]=0;
//collecting data //collecting data
@ -137,7 +137,7 @@ void bigParticleVoidFraction::setvoidFraction(double** const& mask,double**& voi
} }
else if (hashSetLength > 0) else if (hashSetLength > 0)
{ {
cellsPerParticle_[index][0]=hashSetLength; cellsPerParticle()[index][0]=hashSetLength;
//making sure that the cell containing the center is the first subcell //making sure that the cell containing the center is the first subcell
particleCloud_.cellIDs()[index][0]=particleCenterCellID; particleCloud_.cellIDs()[index][0]=particleCenterCellID;
@ -190,7 +190,7 @@ void bigParticleVoidFraction::setvoidFraction(double** const& mask,double**& voi
//bringing eulerian field to particle array //bringing eulerian field to particle array
for(label index=0; index< particleCloud_.numberOfParticles(); index++) 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]; label cellID = particleCloud_.cellIDs()[index][subcell];

View File

@ -93,7 +93,7 @@ void centreVoidFraction::setvoidFraction(double** const& mask,double**& voidfrac
//{ //{
// reset // reset
particleWeights[index][0]=0; particleWeights[index][0]=0;
cellsPerParticle_[index][0]=1; cellsPerParticle()[index][0]=1;
label cellI = particleCloud_.cellIDs()[index][0]; label cellI = particleCloud_.cellIDs()[index][0];
@ -128,9 +128,9 @@ void centreVoidFraction::setvoidFraction(double** const& mask,double**& voidfrac
if (index==0) if (index==0)
{ {
Info << "centre cellI = " << cellI << endl; Info << "centre cellI = " << cellI << endl;
Info << "cellsPerParticle_=" << cellsPerParticle_[index][0] << endl; Info << "cellsPerParticle =" << cellsPerParticle()[index][0] << endl;
for(int i=0;i<cellsPerParticle_[index][0];i++) for(int i=0;i<cellsPerParticle()[index][0];i++)
{ {
if(i==0)Info << "cellids, voidfractions, particleWeights, : \n"; if(i==0)Info << "cellids, voidfractions, particleWeights, : \n";
Info << particleCloud_.cellIDs()[index][i] << " ," << endl; Info << particleCloud_.cellIDs()[index][i] << " ," << endl;

View File

@ -180,14 +180,14 @@ void dividedVoidFraction::setvoidFraction(double** const& mask,double**& voidfra
//{ //{
// reset // reset
for (int subcell=0; subcell < cellsPerParticle_[index][0]; subcell++) for (int subcell=0; subcell < cellsPerParticle()[index][0]; subcell++)
{ {
particleWeights[index][subcell] = 0.; particleWeights[index][subcell] = 0.;
particleVolumes[index][subcell] = 0.; particleVolumes[index][subcell] = 0.;
} }
particleV[index][0] = 0.; particleV[index][0] = 0.;
cellsPerParticle_[index][0] = 1; cellsPerParticle()[index][0] = 1;
position = particleCloud_.position(index); position = particleCloud_.position(index);
cellID = particleCloud_.cellIDs()[index][0]; cellID = particleCloud_.cellIDs()[index][0];
radius = particleCloud_.radius(index); radius = particleCloud_.radius(index);
@ -270,7 +270,7 @@ void dividedVoidFraction::setvoidFraction(double** const& mask,double**& voidfra
for(int index=0; index < particleCloud_.numberOfParticles(); index++) for(int index=0; index < particleCloud_.numberOfParticles(); index++)
{ {
{ {
for (int subcell=0; subcell < cellsPerParticle_[index][0]; subcell++) for (int subcell=0; subcell < cellsPerParticle()[index][0]; subcell++)
{ {
label cellID = particleCloud_.cellIDs()[index][subcell]; label cellID = particleCloud_.cellIDs()[index][subcell];

View File

@ -49,7 +49,7 @@
// add sub particle representation // add sub particle representation
bool createNew = true; bool createNew = true;
label storeInIndex=0; 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])
{ {
@ -61,8 +61,8 @@
if(createNew) if(createNew)
{ {
cellsPerParticle_[index][0] ++; cellsPerParticle()[index][0] ++;
storeInIndex = cellsPerParticle_[index][0]-1; storeInIndex = cellsPerParticle()[index][0]-1;
particleCloud_.cellIDs()[index][storeInIndex] = partCellId; particleCloud_.cellIDs()[index][storeInIndex] = partCellId;
} }

View File

@ -131,7 +131,7 @@ void trilinearVoidFraction::setvoidFraction(double** const& mask,double**& voidf
for(int index = 0; index < particleCloud_.numberOfParticles(); ++index) for(int index = 0; index < particleCloud_.numberOfParticles(); ++index)
{ {
// reset // reset
cellsPerParticle_[index][0] = 8; cellsPerParticle()[index][0] = 8;
//TODO do we need to set particleVolumes, particleV? //TODO do we need to set particleVolumes, particleV?
// === // ===

View File

@ -84,12 +84,11 @@ voidFractionModel::voidFractionModel
/*sm.mesh(), /*sm.mesh(),
dimensionedScalar("zero", dimensionSet(0,0,0,0,0), 1)*/ dimensionedScalar("zero", dimensionSet(0,0,0,0,0), 1)*/
), ),
cellsPerParticle_(NULL),
maxCellsPerParticle_(1), maxCellsPerParticle_(1),
weight_(1.), weight_(1.),
porosity_(1.) porosity_(1.)
{ {
particleCloud_.dataExchangeM().allocateArray(cellsPerParticle_,1,1); particleCloud_.registerParticleVectorProperty<int>("cellsPerParticle");
if (particleCloud_.getParticleEffVolFactors()) multiWeights_ = true; if (particleCloud_.getParticleEffVolFactors()) multiWeights_ = true;
} }
@ -128,19 +127,17 @@ voidFractionModel::voidFractionModel
sm.mesh(), sm.mesh(),
dimensionedScalar("zero", dimensionSet(0,0,0,0,0), initVoidfraction) dimensionedScalar("zero", dimensionSet(0,0,0,0,0), initVoidfraction)
), ),
cellsPerParticle_(NULL),
maxCellsPerParticle_(1), maxCellsPerParticle_(1),
weight_(1.), weight_(1.),
porosity_(1.) porosity_(1.)
{ {
particleCloud_.dataExchangeM().allocateArray(cellsPerParticle_,1,1); particleCloud_.registerParticleVectorProperty<int>("cellsPerParticle");
} }
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
voidFractionModel::~voidFractionModel() voidFractionModel::~voidFractionModel()
{ {
particleCloud_.dataExchangeM().destroy(cellsPerParticle_,1);
} }
// * * * * * * * * * * * * * * public Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * public Member Functions * * * * * * * * * * * * * //
@ -162,7 +159,7 @@ void voidFractionModel::resetVoidFractions()
int** const& voidFractionModel::cellsPerParticle() const int** const& voidFractionModel::cellsPerParticle() const
{ {
return cellsPerParticle_; return particleCloud_.getParticleVectorPropertyRef<int>("cellsPerParticle");
} }
int voidFractionModel::maxCellsPerParticle() const int voidFractionModel::maxCellsPerParticle() const
@ -175,7 +172,8 @@ void voidFractionModel::reAllocArrays()
if(particleCloud_.numberOfParticlesChanged()) if(particleCloud_.numberOfParticlesChanged())
{ {
// get arrays of new length // get arrays of new length
particleCloud_.dataExchangeM().allocateArray(cellsPerParticle_,1,1); particleCloud_.dataExchangeM().allocateArray(
particleCloud_.getParticleVectorPropertyRef<int>("cellsPerParticle"),1,1);
} }
} }
@ -184,7 +182,8 @@ void voidFractionModel::reAllocArrays(int nP)
if(particleCloud_.numberOfParticlesChanged()) if(particleCloud_.numberOfParticlesChanged())
{ {
// get arrays of new length // get arrays of new length
particleCloud_.dataExchangeM().allocateArray(cellsPerParticle_,1,1,nP); particleCloud_.dataExchangeM().allocateArray(
particleCloud_.getParticleVectorPropertyRef<int>("cellsPerParticle"),1,1,nP);
} }
} }

View File

@ -69,7 +69,6 @@ protected:
volScalarField voidfractionNext_; volScalarField voidfractionNext_;
int ** cellsPerParticle_;
int maxCellsPerParticle_; int maxCellsPerParticle_;