test memory allocation of registered properties by cfdemCloud

perform per-particle property allocation in cfdemCloud instead of model
if registered size > 0
if no reallocation is triggered due to a change in particle number,
reset data to initial values (if registered size > 0)
This commit is contained in:
danielque
2020-08-14 14:16:44 +02:00
parent 647c84d323
commit b06bb1f98a
47 changed files with 99 additions and 349 deletions

View File

@ -797,9 +797,60 @@ bool cfdemCloud::reAllocArrays()
if(getParticleDensities_) dataExchangeM().allocateArray(particleDensities_,0.,1);
if(getParticleEffVolFactors_) dataExchangeM().allocateArray(particleEffVolFactors_,0.,1);
if(getParticleTypes_) dataExchangeM().allocateArray(particleTypes_,0,1);
for
(
HashTable<particleProperty>::iterator iter = particlePropertyTable.begin();
iter != particlePropertyTable.end();
++iter
)
{
if (iter().size > 0) {
///Info << "!! about to realloc property of type " << iter().ti->name() << endl;
if ((*(iter().ti)) == typeid(int**)) {
dataExchangeM().allocateArray(iter().ref<int**>(),iter().initVal,iter().size);
} else if ((*(iter().ti)) == typeid(double**)) {
dataExchangeM().allocateArray(iter().ref<double**>(),iter().initVal,iter().size);
} else {
FatalError << "Trying to realloc property of type " << iter().ti->name() << endl;
}
}
}
arraysReallocated_ = true;
return true;
}
else
{
for
(
HashTable<particleProperty>::iterator iter = particlePropertyTable.begin();
iter != particlePropertyTable.end();
++iter
)
{
if (iter().size > 0) {
if ((*(iter().ti)) == typeid(int**)) {
int**& property = iter().ref<int**>();
for (int index=0; index<numberOfParticles(); ++index) {
for (int icomponent=0; icomponent<iter().size; ++icomponent) {
property[index][icomponent] = iter().initVal;
}
}
} else if ((*(iter().ti)) == typeid(double**)) {
double**& property = iter().ref<double**>();
for (int index=0; index<numberOfParticles(); ++index) {
for (int icomponent=0; icomponent<iter().size; ++icomponent) {
property[index][icomponent] = iter().initVal;
}
}
} else {
FatalError << "Trying to reset property of type " << iter().ti->name() << endl;
}
}
}
}
return false;
}

View File

@ -192,6 +192,8 @@ protected:
struct particleProperty {
void** property;
const std::type_info* ti;
int size;
double initVal;
template<typename T>
T& ref() {
if (*ti == typeid(T)) return *reinterpret_cast<T*>(&property);
@ -458,7 +460,7 @@ public:
bool checkPeriodicCells() const { return checkPeriodicCells_; }
template<typename T>
void registerParticleProperty(const word& property);
void registerParticleProperty(const word& property, int size=0, double initVal=0.0);
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)
void cfdemCloud::registerParticleProperty(const word& property, int size, double initVal)
{
particlePropertyTable.insert(property,{NULL,&typeid(T)});
particlePropertyTable.insert(property,{NULL,&typeid(T),size,initVal});
}
template<typename T>

View File

@ -77,10 +77,10 @@ diffusionCoefficient::diffusionCoefficient
initialized_(false)
{
particleCloud_.checkCG(false);
particleCloud_.registerParticleProperty<double**>("partPressure");
particleCloud_.registerParticleProperty<double**>("partPressure",1);
for (int i=0; i<diffusantGasNames_.size(); i++)
{
particleCloud_.registerParticleProperty<double**>(diffusantGasNames_[i]);
particleCloud_.registerParticleProperty<double**>(diffusantGasNames_[i],1);
}
createCoeffs();
molWeightTable();
@ -94,15 +94,6 @@ diffusionCoefficient::~diffusionCoefficient()
// * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * //
void diffusionCoefficient::reAllocMyArrays() const
{
double initVal=0.0;
particleCloud_.dataExchangeM().allocateArray(particleCloud_.getParticlePropertyRef<double**>("partPressure"),initVal,1);
for (int i=0; i<diffusantGasNames_.size(); i++)
{
particleCloud_.dataExchangeM().allocateArray(particleCloud_.getParticlePropertyRef<double**>(diffusantGasNames_[i]),initVal,1);
}
}
void diffusionCoefficient::init()
{
@ -140,9 +131,6 @@ void diffusionCoefficient::execute()
init();
}
// realloc the arrays
reAllocMyArrays();
label cellI=0;
scalar Tfluid(0);
scalar Pfluid(0);

View File

@ -120,8 +120,6 @@ private:
// Member Functions
void execute();
void reAllocMyArrays() const;
};

View File

@ -67,8 +67,8 @@ massTransferCoeff::massTransferCoeff
scaleDia_(1)
{
particleCloud_.checkCG(true);
particleCloud_.registerParticleProperty<double**>(partNuName_);
particleCloud_.registerParticleProperty<double**>(partReynolds_);
particleCloud_.registerParticleProperty<double**>(partNuName_,1);
particleCloud_.registerParticleProperty<double**>(partReynolds_,1);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
@ -79,20 +79,10 @@ massTransferCoeff::~massTransferCoeff()
// * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * //
void massTransferCoeff::reAllocMyArrays() const
{
double initVal=0.0;
particleCloud_.dataExchangeM().allocateArray(particleCloud_.getParticlePropertyRef<double**>(partNuName_),initVal,1);
particleCloud_.dataExchangeM().allocateArray(particleCloud_.getParticlePropertyRef<double**>(partReynolds_),initVal,1);
}
// * * * * * * * * * * * * * * * * Member Fct * * * * * * * * * * * * * * * //
void massTransferCoeff::execute()
{
// realloc the arrays
reAllocMyArrays();
#ifdef compre
const volScalarField nufField = particleCloud_.turbulence().mu()/rho_;
#else

View File

@ -95,8 +95,6 @@ public:
// Member Functions
void execute();
void reAllocMyArrays() const;
};

View File

@ -75,7 +75,7 @@ reactantPerParticle::reactantPerParticle
Nevery_(propsDict_.lookupOrDefault<label>("Nevery",1))
{
particleCloud_.checkCG(false);
particleCloud_.registerParticleProperty<double**>("reactantPerParticle");
particleCloud_.registerParticleProperty<double**>("reactantPerParticle",1);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
@ -86,13 +86,6 @@ reactantPerParticle::~reactantPerParticle()
// * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * //
void reactantPerParticle::reAllocMyArrays() const
{
double initVal=0.0;
double**& reactantPerParticle_ = particleCloud_.getParticlePropertyRef<double**>("reactantPerParticle");
particleCloud_.dataExchangeM().allocateArray(reactantPerParticle_,initVal,1);
}
// * * * * * * * * * * * * * * * * Member Fct * * * * * * * * * * * * * * * //
void reactantPerParticle::execute()
@ -102,8 +95,6 @@ void reactantPerParticle::execute()
{
return;
}
// realloc the arrays
reAllocMyArrays();
particlesPerCell_ *= 0.0;

View File

@ -87,8 +87,6 @@ public:
// Member Functions
void execute();
void reAllocMyArrays() const;
};

View File

@ -103,14 +103,14 @@ species::species
initialized_(false)
{
particleCloud_.checkCG(false);
particleCloud_.registerParticleProperty<double**>(partTempName_);
particleCloud_.registerParticleProperty<double**>(partRhoName_);
particleCloud_.registerParticleProperty<double**>(partMolarConcName_);
particleCloud_.registerParticleProperty<double**>(partTempName_,1);
particleCloud_.registerParticleProperty<double**>(partRhoName_,1);
particleCloud_.registerParticleProperty<double**>(partMolarConcName_,1);
for (int i=0; i<speciesNames_.size(); i++)
{
particleCloud_.registerParticleProperty<double**>("X_"+speciesNames_[i]);
particleCloud_.registerParticleProperty<double**>("Modified_"+speciesNames_[i]);
particleCloud_.registerParticleProperty<double**>("X_"+speciesNames_[i],1);
particleCloud_.registerParticleProperty<double**>("Modified_"+speciesNames_[i],1);
}
}
@ -122,26 +122,6 @@ species::~species()
// * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * //
void species::reAllocMyArrays() const
{
double initVal=0.0;
double**& partRho_ = particleCloud_.getParticlePropertyRef<double**>(partRhoName_);
double**& partTemp_ = particleCloud_.getParticlePropertyRef<double**>(partTempName_);
double**& partMolarConc_ = particleCloud_.getParticlePropertyRef<double**>(partMolarConcName_);
particleCloud_.dataExchangeM().allocateArray(partRho_,initVal,1);
particleCloud_.dataExchangeM().allocateArray(partTemp_,initVal,1);
particleCloud_.dataExchangeM().allocateArray(partMolarConc_,initVal,1);
for (int i=0; i<speciesNames_.size(); i++)
{
double**& molarFractions_ = particleCloud_.getParticlePropertyRef<double**>("X_"+speciesNames_[i]);
double**& changeOfSpeciesMass_ = particleCloud_.getParticlePropertyRef<double**>("Modified_"+speciesNames_[i]);
particleCloud_.dataExchangeM().allocateArray(molarFractions_,initVal,1);
particleCloud_.dataExchangeM().allocateArray(changeOfSpeciesMass_,initVal,1);
}
}
void species::init()
{
if(verbose_)
@ -203,8 +183,6 @@ void species::execute()
{
return;
}
// realloc the arrays
reAllocMyArrays();
// get X_i, T, rho at particle positions
label cellI = 0;

View File

@ -129,8 +129,6 @@ public:
// Member Functions
void execute();
void reAllocMyArrays() const;
tmp <volScalarField> Smi(const label i) const;
tmp <volScalarField> Sm() const;

View File

@ -97,8 +97,8 @@ heatTransferGranConduction::heatTransferGranConduction
partHeatFluxName_(propsDict_.lookupOrDefault<word>("partHeatFluxName","conductiveHeatFlux")),
typePartThermCond_(propsDict_.lookupOrDefault<scalarList>("thermalConductivities",scalarList(1,-1.0)))
{
particleCloud_.registerParticleProperty<double**>(partHeatFluxName_);
particleCloud_.registerParticleProperty<double**>("partThermCond");
particleCloud_.registerParticleProperty<double**>(partHeatFluxName_,1);
particleCloud_.registerParticleProperty<double**>("partThermCond",1);
if (typePartThermCond_[0] < 0.0)
{
@ -130,23 +130,10 @@ heatTransferGranConduction::~heatTransferGranConduction()
}
// * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * //
void heatTransferGranConduction::allocateMyArrays() const
{
// get memory for 2d arrays
double initVal=0.0;
double**& partHeatFlux_ = particleCloud_.getParticlePropertyRef<double**>(partHeatFluxName_);
double**& partThermCond_ = particleCloud_.getParticlePropertyRef<double**>("partThermCond");
particleCloud_.dataExchangeM().allocateArray(partHeatFlux_,initVal,1);
particleCloud_.dataExchangeM().allocateArray(partThermCond_,initVal,1);
}
// * * * * * * * * * * * * * * * * Member Fct * * * * * * * * * * * * * * * //
void heatTransferGranConduction::calcEnergyContribution()
{
// realloc the arrays
allocateMyArrays();
calcPartEffThermCond();
QPartPart_ = fvc::laplacian(partEffThermCondField_,partTempField_);

View File

@ -76,8 +76,6 @@ protected:
scalarList typePartThermCond_;
void allocateMyArrays() const;
void calcPartEffThermCond();
void calcPartThermCond();

View File

@ -148,16 +148,16 @@ heatTransferGunn::heatTransferGunn
typeCG_(propsDict_.lookupOrDefault<scalarList>("coarseGrainingFactors",scalarList(1,1.0))),
maxTypeCG_(typeCG_.size())
{
particleCloud_.registerParticleProperty<double**>(partTempName_);
particleCloud_.registerParticleProperty<double**>(partHeatFluxName_);
particleCloud_.registerParticleProperty<double**>(partTempName_,1);
particleCloud_.registerParticleProperty<double**>(partHeatFluxName_,1);
if (implicit_)
{
particleCloud_.registerParticleProperty<double**>("partHeatFluxCoeff");
particleCloud_.registerParticleProperty<double**>("partHeatFluxCoeff",1);
}
if(verbose_)
{
particleCloud_.registerParticleProperty<double**>("partRe");
particleCloud_.registerParticleProperty<double**>("partNu");
particleCloud_.registerParticleProperty<double**>("partRe",1);
particleCloud_.registerParticleProperty<double**>("partNu",1);
}
if (propsDict_.found("NusseltScalingFactor"))
@ -234,37 +234,11 @@ heatTransferGunn::~heatTransferGunn()
}
// * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * //
void heatTransferGunn::allocateMyArrays() const
{
// get memory for 2d arrays
double initVal=0.0;
double**& partTemp_ = particleCloud_.getParticlePropertyRef<double**>(partTempName_);
double**& partHeatFlux_ = particleCloud_.getParticlePropertyRef<double**>(partHeatFluxName_);
particleCloud_.dataExchangeM().allocateArray(partTemp_,initVal,1); // field/initVal/with/lenghtFromLigghts
particleCloud_.dataExchangeM().allocateArray(partHeatFlux_,initVal,1);
if(implicit_)
{
double**& partHeatFluxCoeff_ = particleCloud_.getParticlePropertyRef<double**>("partHeatFluxCoeff");
particleCloud_.dataExchangeM().allocateArray(partHeatFluxCoeff_,initVal,1);
}
if(verbose_)
{
double**& partRe_ = particleCloud_.getParticlePropertyRef<double**>("partRe");
double**& partNu_ = particleCloud_.getParticlePropertyRef<double**>("partNu");
particleCloud_.dataExchangeM().allocateArray(partRe_,initVal,1);
particleCloud_.dataExchangeM().allocateArray(partNu_,initVal,1);
}
}
// * * * * * * * * * * * * * * * * Member Fct * * * * * * * * * * * * * * * //
void heatTransferGunn::calcEnergyContribution()
{
// realloc the arrays
allocateMyArrays();
double**& partTemp_ = particleCloud_.getParticlePropertyRef<double**>(partTempName_);
double**& partHeatFlux_ = particleCloud_.getParticlePropertyRef<double**>(partHeatFluxName_);

View File

@ -118,8 +118,6 @@ protected:
const label maxTypeCG_;
void allocateMyArrays() const;
void partTempField();
scalar Nusselt(scalar, scalar, scalar) const;

View File

@ -147,16 +147,16 @@ heatTransferRanzMarshall::heatTransferRanzMarshall
typeCG_(propsDict_.lookupOrDefault<scalarList>("coarseGrainingFactors",scalarList(1,1.0))),
maxTypeCG_(typeCG_.size())
{
particleCloud_.registerParticleProperty<double**>(partTempName_);
particleCloud_.registerParticleProperty<double**>(partHeatFluxName_);
particleCloud_.registerParticleProperty<double**>(partTempName_,1);
particleCloud_.registerParticleProperty<double**>(partHeatFluxName_,1);
if (implicit_)
{
particleCloud_.registerParticleProperty<double**>("partHeatFluxCoeff");
particleCloud_.registerParticleProperty<double**>("partHeatFluxCoeff",1);
}
if(verbose_)
{
particleCloud_.registerParticleProperty<double**>("partRe");
particleCloud_.registerParticleProperty<double**>("partNu");
particleCloud_.registerParticleProperty<double**>("partRe",1);
particleCloud_.registerParticleProperty<double**>("partNu",1);
}
if (propsDict_.found("NusseltScalingFactor"))
@ -233,37 +233,11 @@ heatTransferRanzMarshall::~heatTransferRanzMarshall()
}
// * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * //
void heatTransferRanzMarshall::allocateMyArrays() const
{
// get memory for 2d arrays
double initVal=0.0;
double**& partTemp_ = particleCloud_.getParticlePropertyRef<double**>(partTempName_);
double**& partHeatFlux_ = particleCloud_.getParticlePropertyRef<double**>(partHeatFluxName_);
particleCloud_.dataExchangeM().allocateArray(partTemp_,initVal,1); // field/initVal/with/lenghtFromLigghts
particleCloud_.dataExchangeM().allocateArray(partHeatFlux_,initVal,1);
if(implicit_)
{
double**& partHeatFluxCoeff_ = particleCloud_.getParticlePropertyRef<double**>("partHeatFluxCoeff");
particleCloud_.dataExchangeM().allocateArray(partHeatFluxCoeff_,initVal,1);
}
if(verbose_)
{
double**& partRe_ = particleCloud_.getParticlePropertyRef<double**>("partRe");
double**& partNu_ = particleCloud_.getParticlePropertyRef<double**>("partNu");
particleCloud_.dataExchangeM().allocateArray(partRe_,initVal,1);
particleCloud_.dataExchangeM().allocateArray(partNu_,initVal,1);
}
}
// * * * * * * * * * * * * * * * * Member Fct * * * * * * * * * * * * * * * //
void heatTransferRanzMarshall::calcEnergyContribution()
{
// realloc the arrays
allocateMyArrays();
double**& partTemp_ = particleCloud_.getParticlePropertyRef<double**>(partTempName_);
double**& partHeatFlux_ = particleCloud_.getParticlePropertyRef<double**>(partHeatFluxName_);

View File

@ -117,8 +117,6 @@ protected:
const label maxTypeCG_;
void allocateMyArrays() const;
void partTempField();
scalar Nusselt(scalar, scalar, scalar) const;

View File

@ -64,7 +64,7 @@ reactionHeat::reactionHeat
dimensionedScalar("zero", dimensionSet(1,-1,-3,0,0,0,0),0.0)
)
{
particleCloud_.registerParticleProperty<double**>(reactionHeatName_);
particleCloud_.registerParticleProperty<double**>(reactionHeatName_,1);
if(propsDict_.found("maxsource"))
{
@ -81,20 +81,11 @@ reactionHeat::~reactionHeat()
}
// * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * //
void reactionHeat::allocateMyArrays() const
{
// get memory for 2d arrays
double initVal=0.0;
double**& reactionHeat_ = particleCloud_.getParticlePropertyRef<double**>(reactionHeatName_);
particleCloud_.dataExchangeM().allocateArray(reactionHeat_,initVal,1);
}
// * * * * * * * * * * * * * * * * Member Fct * * * * * * * * * * * * * * * //
void reactionHeat::calcEnergyContribution()
{
// realloc the arrays
allocateMyArrays();
double**& reactionHeat_ = particleCloud_.getParticlePropertyRef<double**>(reactionHeatName_);
particleCloud_.dataExchangeM().getData(reactionHeatName_,"scalar-atom",reactionHeat_);

View File

@ -58,8 +58,6 @@ protected:
volScalarField reactionHeatField_;
void allocateMyArrays() const;
public:
//- Runtime type information

View File

@ -97,8 +97,8 @@ KochHillRWDrag::KochHillRWDrag
if (propsDict_.found("rhoP"))
rhoP_= readScalar(propsDict_.lookup("rhoP"));
particleCloud_.registerParticleProperty<double**>("partTime");
particleCloud_.registerParticleProperty<double**>("partUfluct");
particleCloud_.registerParticleProperty<double**>("partTime",1);
particleCloud_.registerParticleProperty<double**>("partUfluct",3);
}
@ -112,10 +112,6 @@ KochHillRWDrag::~KochHillRWDrag()
void KochHillRWDrag::setForce() const
{
// realloc the arrays
reAllocArrays();
if (scale_ > 1.0)
{
Info << "KochHillRW using scale = " << scale_ << endl;
@ -373,19 +369,6 @@ void KochHillRWDrag::setForce() const
}
void KochHillRWDrag::reAllocArrays() const
{
if (particleCloud_.numberOfParticlesChanged())
{
double**& partTime_ = particleCloud_.getParticlePropertyRef<double**>("partTime");
double**& partUfluct_ = particleCloud_.getParticlePropertyRef<double**>("partUfluct");
particleCloud_.dataExchangeM().allocateArray(partTime_,0.0,1); // field/initVal/with/lenghtFromLigghts
particleCloud_.dataExchangeM().allocateArray(partUfluct_,0.0,3);
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam

View File

@ -113,8 +113,6 @@ public:
// Member Functions
void setForce() const;
void reAllocArrays() const;
};

View File

@ -100,8 +100,8 @@ dSauter::dSauter
maxTypeCG_ = typeCG_.size();
}
particleCloud_.registerParticleProperty<double**>("d2");
particleCloud_.registerParticleProperty<double**>("d3");
particleCloud_.registerParticleProperty<double**>("d2",1);
particleCloud_.registerParticleProperty<double**>("d3",1);
dSauter_.write();
@ -118,15 +118,6 @@ dSauter::~dSauter()
// * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * //
void dSauter::allocateMyArrays() const
{
// get memory for 2d arrays
double initVal = 0.0;
double**& d2_ = particleCloud_.getParticlePropertyRef<double**>("d2");
double**& d3_ = particleCloud_.getParticlePropertyRef<double**>("d3");
particleCloud_.dataExchangeM().allocateArray(d2_,initVal,1); // field/initVal/with/lenghtFromLigghts
particleCloud_.dataExchangeM().allocateArray(d3_,initVal,1);
}
// * * * * * * * * * * * * * * * public Member Functions * * * * * * * * * * * * * //
@ -137,7 +128,6 @@ void dSauter::setForce() const
Info << "dSauter using CG factor(s) = " << typeCG_ << endl;
}
allocateMyArrays();
double**& d2_ = particleCloud_.getParticlePropertyRef<double**>("d2");
double**& d3_ = particleCloud_.getParticlePropertyRef<double**>("d3");

View File

@ -55,8 +55,6 @@ private:
mutable volScalarField dSauter_;
void allocateMyArrays() const;
public:
//- Runtime type information

View File

@ -69,7 +69,7 @@ granKineticEnergy::granKineticEnergy
"zeroGradient"
)
{
particleCloud_.registerParticleProperty<double**>("vfluc_mag");
particleCloud_.registerParticleProperty<double**>("vfluc_mag",1);
granKineticEnergy_.write();
@ -84,18 +84,10 @@ granKineticEnergy::~granKineticEnergy()
}
// * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * //
void granKineticEnergy::allocateMyArrays() const
{
// get memory for 2d arrays
double initVal = 0.0;
double**& vfluc_ = particleCloud_.getParticlePropertyRef<double**>("vfluc_mag");
particleCloud_.dataExchangeM().allocateArray(vfluc_,initVal,1);
}
// * * * * * * * * * * * * * * * public Member Functions * * * * * * * * * * * * * //
void granKineticEnergy::setForce() const
{
allocateMyArrays();
double**& vfluc_ = particleCloud_.getParticlePropertyRef<double**>("vfluc_mag");
label cellI = 0;

View File

@ -49,8 +49,6 @@ private:
mutable volScalarField granKineticEnergy_;
void allocateMyArrays() const;
public:
//- Runtime type information

View File

@ -61,7 +61,7 @@ particleDeformation::particleDeformation
lowerBounds_(propsDict_.lookupOrDefault<scalarList>("lowerBounds",scalarList(1,-1.0))),
upperBounds_(propsDict_.lookupOrDefault<scalarList>("upperBounds",scalarList(1,-1.0)))
{
particleCloud_.registerParticleProperty<double**>("partDeformations");
particleCloud_.registerParticleProperty<double**>("partDeformations",1);
// init force sub model
setForceSubModels(propsDict_);
@ -122,13 +122,6 @@ particleDeformation::~particleDeformation()
}
// * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * //
void particleDeformation::allocateMyArrays() const
{
// get memory for 2d arrays
double initVal = 0.0;
double**& partDeformations_ = particleCloud_.getParticlePropertyRef<double**>("partDeformations");
particleCloud_.dataExchangeM().allocateArray(partDeformations_,initVal,1);
}
bool particleDeformation::defaultDeformCell(label cell) const
{
@ -144,8 +137,7 @@ void particleDeformation::setForce() const
init();
initialExec_ = false;
}
// realloc the arrays
allocateMyArrays();
double**& partDeformations_ = particleCloud_.getParticlePropertyRef<double**>("partDeformations");
label cellI = 0;

View File

@ -76,8 +76,6 @@ private:
label getListIndex(label) const;
void allocateMyArrays() const;
void init() const;
bool defaultDeformCell(label) const;

View File

@ -146,11 +146,11 @@ pdCorrelation::pdCorrelation
<< abort(FatalError);
}
particleCloud_.registerParticleProperty<double**>("d");
particleCloud_.registerParticleProperty<double**>("p");
particleCloud_.registerParticleProperty<double**>("d2");
particleCloud_.registerParticleProperty<double**>("pd");
particleCloud_.registerParticleProperty<double**>("cg3");
particleCloud_.registerParticleProperty<double**>("d",1);
particleCloud_.registerParticleProperty<double**>("p",3);
particleCloud_.registerParticleProperty<double**>("d2",1);
particleCloud_.registerParticleProperty<double**>("pd",3);
particleCloud_.registerParticleProperty<double**>("cg3",1);
dField_.write();
pdField_.write();
@ -167,22 +167,6 @@ pdCorrelation::~pdCorrelation()
}
// * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * //
void pdCorrelation::allocateMyArrays() const
{
// get memory for 2d arrays
double initVal = 0.0;
double**& d_ = particleCloud_.getParticlePropertyRef<double**>("d");
double**& p_ = particleCloud_.getParticlePropertyRef<double**>("p");
double**& d2_ = particleCloud_.getParticlePropertyRef<double**>("d2");
double**& pd_ = particleCloud_.getParticlePropertyRef<double**>("pd");
double**& cg3_ = particleCloud_.getParticlePropertyRef<double**>("cg3");
particleCloud_.dataExchangeM().allocateArray(d_, initVal, 1);
particleCloud_.dataExchangeM().allocateArray(p_, initVal, 3);
particleCloud_.dataExchangeM().allocateArray(d2_, initVal, 1);
particleCloud_.dataExchangeM().allocateArray(pd_, initVal, 3);
particleCloud_.dataExchangeM().allocateArray(cg3_, initVal, 1);
}
// * * * * * * * * * * * * * * * public Member Functions * * * * * * * * * * * * * //
void pdCorrelation::setForce() const
@ -191,7 +175,6 @@ void pdCorrelation::setForce() const
if (runOnWriteOnly_ && !mesh.write()) return; // skip if it's not write time
allocateMyArrays();
double**& d_ = particleCloud_.getParticlePropertyRef<double**>("d");
double**& p_ = particleCloud_.getParticlePropertyRef<double**>("p");
double**& d2_ = particleCloud_.getParticlePropertyRef<double**>("d2");

View File

@ -59,8 +59,6 @@ private:
const Switch CG_;
const Switch runOnWriteOnly_;
void allocateMyArrays() const;
public:
//- Runtime type information

View File

@ -84,7 +84,7 @@ potentialRelaxation::potentialRelaxation
ignoreDirection_(propsDict_.lookupOrDefault<vector>("ignoreDirection",vector::zero)),
ignorePoint_(propsDict_.lookupOrDefault<vector>("ignorePoint",vector::zero))
{
particleCloud_.registerParticleProperty<double**>("vfluc");
particleCloud_.registerParticleProperty<double**>("vfluc",3);
if(ignoreReg_)
{
@ -106,13 +106,6 @@ potentialRelaxation::~potentialRelaxation()
// * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * //
void potentialRelaxation::allocateMyArrays() const
{
// get memory for 2d arrays
double initVal=0.0;
double**& vfluc_ = particleCloud_.getParticlePropertyRef<double**>("vfluc");
particleCloud_.dataExchangeM().allocateArray(vfluc_,initVal,3);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -124,8 +117,6 @@ void potentialRelaxation::setForce() const
// volVectorField relaxStream = DField_ * fvc::grad(voidfraction_ - voidfractionRec_);
// realloc the arrays
allocateMyArrays();
double**& vfluc_ = particleCloud_.getParticlePropertyRef<double**>("vfluc");
vector position(0,0,0);

View File

@ -78,8 +78,6 @@ private:
vector ignorePoint_;
void allocateMyArrays() const;
void relax(scalar, scalar) const;
public:

View File

@ -72,7 +72,7 @@ virtualMassForce::virtualMassForce
splitUrelCalculation_(propsDict_.lookupOrDefault<bool>("splitUrelCalculation",false)),
Cadd_(0.5)
{
particleCloud_.registerParticleProperty<double**>("UrelOld");
particleCloud_.registerParticleProperty<double**>("UrelOld",3,NOTONCPU);
// init force sub model
setForceSubModels(propsDict_);
@ -117,7 +117,6 @@ virtualMassForce::~virtualMassForce()
void virtualMassForce::setForce() const
{
reAllocArrays();
double**& UrelOld_ = particleCloud_.getParticlePropertyRef<double**>("UrelOld");
scalar dt = U_.mesh().time().deltaT().value();
@ -226,18 +225,6 @@ void virtualMassForce::setForce() const
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void Foam::virtualMassForce::reAllocArrays() const
{
if(particleCloud_.numberOfParticlesChanged())
{
Pout << "virtualMassForce::reAllocArrays..." << endl;
double**& UrelOld_ = particleCloud_.getParticlePropertyRef<double**>("UrelOld");
particleCloud_.dataExchangeM().allocateArray(UrelOld_,NOTONCPU,3);
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam

View File

@ -98,8 +98,6 @@ public:
// Member Functions
void setForce() const;
void reAllocArrays() const;
};

View File

@ -78,7 +78,6 @@ allRegion::~allRegion()
void allRegion::defineRegion() const
{
reAllocArrays();
// do nothing
}

View File

@ -46,17 +46,6 @@ defineRunTimeSelectionTable(regionModel, dictionary);
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void regionModel::reAllocArrays() const
{
if(particleCloud_.numberOfParticlesChanged())
{
// get arrays of new length
double**& inRegion_ = particleCloud_.getParticlePropertyRef<double**>("inRegion");
double**& outRegion_ = particleCloud_.getParticlePropertyRef<double**>("outRegion");
particleCloud_.dataExchangeM().allocateArray(inRegion_,1.,1);
particleCloud_.dataExchangeM().allocateArray(outRegion_,1.,1);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -70,8 +59,8 @@ regionModel::regionModel
dict_(dict),
particleCloud_(sm)
{
particleCloud_.registerParticleProperty<double**>("inRegion");
particleCloud_.registerParticleProperty<double**>("outRegion");
particleCloud_.registerParticleProperty<double**>("inRegion",1,1.0);
particleCloud_.registerParticleProperty<double**>("outRegion",1,1.0);
}

View File

@ -113,8 +113,6 @@ public:
virtual void resetVolFields(volVectorField&) const = 0;
void reAllocArrays() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -63,7 +63,7 @@ ZehnerSchluenderThermCond::ZehnerSchluenderThermCond
if (typeKs_.size() > 1)
{
particleCloud_.registerParticleProperty<double**>("partKs");
particleCloud_.registerParticleProperty<double**>("partKs",1);
}
else
{
@ -78,14 +78,6 @@ ZehnerSchluenderThermCond::~ZehnerSchluenderThermCond()
{
}
void ZehnerSchluenderThermCond::allocateMyArrays() const
{
double initVal=0.0;
double**& partKs_ = particleCloud_.getParticlePropertyRef<double**>("partKs");
particleCloud_.dataExchangeM().allocateArray(partKs_,initVal,1);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void ZehnerSchluenderThermCond::calcThermCond()
@ -135,7 +127,6 @@ void ZehnerSchluenderThermCond::calcPartKsField() const
FatalError << "ZehnerSchluenderThermCond needs data for more than one type, but types are not communicated." << abort(FatalError);
}
allocateMyArrays();
double**& partKs_ = particleCloud_.getParticlePropertyRef<double**>("partKs");
label cellI=0;
label partType = 0;

View File

@ -64,8 +64,6 @@ private:
scalarList typeKs_;
void allocateMyArrays() const;
void calcPartKsField() const;
public:

View File

@ -89,8 +89,6 @@ GaussVoidFraction::~GaussVoidFraction()
void GaussVoidFraction::setvoidFraction(double** const& mask,double**& voidfractions,double**& particleWeights,double**& particleVolumes,double**& particleV)
{
reAllocArrays();
voidfractionNext_.ref()=1;
scalar radius(-1);

View File

@ -91,8 +91,6 @@ void IBVoidFraction::setvoidFraction(double** const& mask,double**& voidfraction
{
const boundBox& globalBb = particleCloud_.mesh().bounds();
reAllocArrays();
voidfractionNext_.ref() = 1.0;
for (int index=0; index < particleCloud_.numberOfParticles(); index++)

View File

@ -88,8 +88,6 @@ bigParticleVoidFraction::~bigParticleVoidFraction()
void bigParticleVoidFraction::setvoidFraction(double** const& mask,double**& voidfractions,double**& particleWeights,double**& particleVolumes,double**& particleV)
{
reAllocArrays();
voidfractionNext_.ref()=1;
scalar radius(-1);

View File

@ -80,8 +80,6 @@ centreVoidFraction::~centreVoidFraction()
void centreVoidFraction::setvoidFraction(double** const& mask,double**& voidfractions,double**& particleWeights,double**& particleVolumes,double**& particleV)
{
reAllocArrays();
scalar radius(-1);
scalar volume(0);
scalar cellVol(0);

View File

@ -69,8 +69,7 @@ dividedVoidFraction::dividedVoidFraction
alphaMin_(readScalar(propsDict_.lookup("alphaMin"))),
alphaLimited_(0),
tooMuch_(0.0),
interpolation_(propsDict_.found("interpolation")),
cfdemUseOnly_(propsDict_.lookupOrDefault<bool>("cfdemUseOnly", false))
interpolation_(propsDict_.found("interpolation"))
{
maxCellsPerParticle_ = numberOfMarkerPoints;
@ -158,10 +157,6 @@ dividedVoidFraction::~dividedVoidFraction()
void dividedVoidFraction::setvoidFraction(double** const& mask,double**& voidfractions,double**& particleWeights,double**& particleVolumes, double**& particleV)
{
if (cfdemUseOnly_)
reAllocArrays(particleCloud_.numberOfParticles());
else
reAllocArrays();
vector position(0.,0.,0.);
label cellID = -1;

View File

@ -74,8 +74,6 @@ private:
const bool interpolation_;
const bool cfdemUseOnly_;
vector offsets[numberOfMarkerPoints];
virtual inline scalar Vp(int index, scalar radius, scalar scaleVol) const

View File

@ -90,8 +90,6 @@ trilinearVoidFraction::~trilinearVoidFraction()
void trilinearVoidFraction::setvoidFraction(double** const& mask,double**& voidfractions,double**& particleWeights,double**& particleVolumes,double**& particleV)
{
reAllocArrays();
scalar radius(-1.);
scalar volume(0.);
scalar scaleVol = weight();

View File

@ -88,7 +88,7 @@ voidFractionModel::voidFractionModel
weight_(1.),
porosity_(1.)
{
particleCloud_.registerParticleProperty<int**>("cellsPerParticle");
particleCloud_.registerParticleProperty<int**>("cellsPerParticle",1,1.0);
if (particleCloud_.getParticleEffVolFactors()) multiWeights_ = true;
}
@ -131,7 +131,7 @@ voidFractionModel::voidFractionModel
weight_(1.),
porosity_(1.)
{
particleCloud_.registerParticleProperty<int**>("cellsPerParticle");
particleCloud_.registerParticleProperty<int**>("cellsPerParticle",1,1.0);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
@ -167,24 +167,6 @@ int voidFractionModel::maxCellsPerParticle() const
return maxCellsPerParticle_;
}
void voidFractionModel::reAllocArrays()
{
if(particleCloud_.numberOfParticlesChanged())
{
// get arrays of new length
particleCloud_.dataExchangeM().allocateArray(particleCloud_.getParticlePropertyRef<int**>("cellsPerParticle"),1,1);
}
}
void voidFractionModel::reAllocArrays(int nP)
{
if(particleCloud_.numberOfParticlesChanged())
{
// get arrays of new length
particleCloud_.dataExchangeM().allocateArray(particleCloud_.getParticlePropertyRef<int**>("cellsPerParticle"),1,1,nP);
}
}
scalar voidFractionModel::pointInParticle(int index, const vector& positionCenter, const vector& point, double scale) const
{
const scalar radius = particleCloud_.radius(index);

View File

@ -163,10 +163,6 @@ public:
int maxCellsPerParticle() const;
void reAllocArrays();
void reAllocArrays(int nP); //force number of particles during reallocation, for CFD offline-use
virtual void setParticleType(label type) const {}
virtual bool checkParticleType(label) const { return true; } //consider all particles by default