Merge pull request #107 from ParticulateFlow/feature/register_atom_props

Register and supply per-particle data pointers centrally in cfdemCloud
This commit is contained in:
Daniel
2020-10-02 13:03:04 +02:00
committed by GitHub
62 changed files with 527 additions and 747 deletions

View File

@ -160,6 +160,7 @@ cfdemCloud::cfdemCloud
turbulenceModelType_ turbulenceModelType_
) )
), ),
particlePropertyTable(32),
dataExchangeModel_ dataExchangeModel_
( (
dataExchangeModel::New dataExchangeModel::New
@ -402,6 +403,22 @@ 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<particleProperty>::iterator iter = particlePropertyTable.begin();
iter != particlePropertyTable.end();
++iter
)
{
if ((*(iter().ti)) == typeid(int**)) {
dataExchangeM().destroy(iter().ref<int**>(),-1);
} else if ((*(iter().ti)) == typeid(double**)) {
dataExchangeM().destroy(iter().ref<double**>(),-1);
} else {
FatalError << "Trying to destroy property of type " << iter().ti->name() << endl;
}
}
} }
// * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * //
@ -780,9 +797,60 @@ bool cfdemCloud::reAllocArrays()
if(getParticleDensities_) dataExchangeM().allocateArray(particleDensities_,0.,1); if(getParticleDensities_) dataExchangeM().allocateArray(particleDensities_,0.,1);
if(getParticleEffVolFactors_) dataExchangeM().allocateArray(particleEffVolFactors_,0.,1); if(getParticleEffVolFactors_) dataExchangeM().allocateArray(particleEffVolFactors_,0.,1);
if(getParticleTypes_) dataExchangeM().allocateArray(particleTypes_,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; arraysReallocated_ = true;
return true; return true;
} }
else
{
for
(
HashTable<particleProperty>::iterator iter = particlePropertyTable.begin();
iter != particlePropertyTable.end();
++iter
)
{
if (iter().size > 0 && iter().reset) {
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; return false;
} }

View File

@ -45,6 +45,7 @@ SourceFiles
// choose version // choose version
#include "OFversion.H" #include "OFversion.H"
#include <vector> #include <vector>
#include <typeinfo>
#include "fvCFD.H" #include "fvCFD.H"
#include "IFstream.H" #include "IFstream.H"
@ -188,6 +189,21 @@ protected:
const turbulenceModel& turbulence_; const turbulenceModel& turbulence_;
struct particleProperty {
void** property; // pointer to per-particle data; memory deallocation by cfdemCloud
const std::type_info* ti; // type of particle data (int**, double**)
int size; // size of single particle data; memory allocation by cfdemCloud if size > 0
double initVal; // initial property value
bool reset; // if true, data is reset to initial value every coupling step
template<typename T>
T& ref() {
if (*ti == typeid(T)) return *reinterpret_cast<T*>(&property);
else throw std::bad_cast();
}
};
HashTable<particleProperty> particlePropertyTable; // table of registered per-particle properties
autoPtr<dataExchangeModel> dataExchangeModel_; autoPtr<dataExchangeModel> dataExchangeModel_;
PtrList<forceModel> forceModel_; PtrList<forceModel> forceModel_;
@ -443,6 +459,14 @@ public:
void otherForces(volVectorField&); void otherForces(volVectorField&);
bool checkPeriodicCells() const { return checkPeriodicCells_; } bool checkPeriodicCells() const { return checkPeriodicCells_; }
template<typename T>
void registerParticleProperty(const word& property, int size=0, double initVal=0.0, bool reset=true);
template<typename T>
T& getParticlePropertyRef(const word& property);
protected:
virtual int**& getParticlePropertyImpl(const word& property, int**);
virtual double**& getParticlePropertyImpl(const word& property, double**);
}; };

View File

@ -403,5 +403,28 @@ inline const turbulenceModel& cfdemCloud::turbulence() const
return turbulence_; return turbulence_;
} }
template<typename T>
void cfdemCloud::registerParticleProperty(const word& property, int size, double initVal, bool reset)
{
particlePropertyTable.insert(property,{NULL,&typeid(T),size,initVal,reset});
}
template<typename T>
T& cfdemCloud::getParticlePropertyRef(const word& property)
{
return getParticlePropertyImpl(property, static_cast<T>(0));
}
inline int**& cfdemCloud::getParticlePropertyImpl(const word& property, int**)
{
return particlePropertyTable[property].ref<int**>();
}
inline double**& cfdemCloud::getParticlePropertyImpl(const word& property, double**)
{
return particlePropertyTable[property].ref<double**>();
}
} }
// ************************************************************************* // // ************************************************************************* //

View File

@ -71,15 +71,17 @@ diffusionCoefficient::diffusionCoefficient
pressureFieldName_(propsDict_.lookupOrDefault<word>("pressureFieldName","p")), pressureFieldName_(propsDict_.lookupOrDefault<word>("pressureFieldName","p")),
P_(sm.mesh().lookupObject<volScalarField>(pressureFieldName_)), P_(sm.mesh().lookupObject<volScalarField>(pressureFieldName_)),
partPressureName_(propsDict_.lookupOrDefault<word>("partPressureName","partP")), partPressureName_(propsDict_.lookupOrDefault<word>("partPressureName","partP")),
partPressure_(NULL),
X_(speciesNames_.size()), X_(speciesNames_.size()),
diffusantGasNames_(propsDict_.lookup("diffusantGasNames")), diffusantGasNames_(propsDict_.lookup("diffusantGasNames")),
diffusionCoefficients_(diffusantGasNames_.size(),NULL),
Xdiffusant_(diffusantGasNames_.size()), Xdiffusant_(diffusantGasNames_.size()),
initialized_(false) initialized_(false)
{ {
particleCloud_.checkCG(false); particleCloud_.checkCG(false);
allocateMyArrays(); particleCloud_.registerParticleProperty<double**>(partPressureName_,1);
for (int i=0; i<diffusantGasNames_.size(); i++)
{
particleCloud_.registerParticleProperty<double**>(diffusantGasNames_[i],1);
}
createCoeffs(); createCoeffs();
molWeightTable(); molWeightTable();
} }
@ -88,37 +90,10 @@ diffusionCoefficient::diffusionCoefficient
diffusionCoefficient::~diffusionCoefficient() diffusionCoefficient::~diffusionCoefficient()
{ {
particleCloud_.dataExchangeM().destroy(partPressure_,1);
for (int i=0; i<diffusantGasNames_.size(); i++) particleCloud_.dataExchangeM().destroy(diffusionCoefficients_[i],1);
coeffs.clearStorage();
molWeight.clearStorage();
} }
// * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * //
void diffusionCoefficient::allocateMyArrays() const
{
double initVal=0.0;
if (particleCloud_.dataExchangeM().maxNumberOfParticles() > 0)
{
particleCloud_.dataExchangeM().allocateArray(partPressure_,initVal,1,"nparticles");
for (int i=0; i<diffusantGasNames_.size(); i++)
{
particleCloud_.dataExchangeM().allocateArray(diffusionCoefficients_[i],initVal,1,"nparticles");
}
}
}
void diffusionCoefficient::reAllocMyArrays() const
{
double initVal=0.0;
particleCloud_.dataExchangeM().allocateArray(partPressure_,initVal,1,"nparticles");
for (int i=0; i<diffusantGasNames_.size(); i++)
{
particleCloud_.dataExchangeM().allocateArray(diffusionCoefficients_[i],initVal,1);
}
}
void diffusionCoefficient::init() void diffusionCoefficient::init()
{ {
@ -156,9 +131,6 @@ void diffusionCoefficient::execute()
init(); init();
} }
// realloc the arrays
reAllocMyArrays();
label cellI=0; label cellI=0;
scalar Tfluid(0); scalar Tfluid(0);
scalar Pfluid(0); scalar Pfluid(0);
@ -172,6 +144,8 @@ void diffusionCoefficient::execute()
interpolationCellPoint <scalar> TInterpolator_(tempField_); interpolationCellPoint <scalar> TInterpolator_(tempField_);
interpolationCellPoint <scalar> PInterpolator_(P_); interpolationCellPoint <scalar> PInterpolator_(P_);
double**& partPressure_ = particleCloud_.getParticlePropertyRef<double**>(partPressureName_);
for (int index=0; index<particleCloud_.numberOfParticles(); ++index) for (int index=0; index<particleCloud_.numberOfParticles(); ++index)
{ {
cellI = particleCloud_.cellIDs()[index][0]; cellI = particleCloud_.cellIDs()[index][0];
@ -207,6 +181,7 @@ void diffusionCoefficient::execute()
for (int j=0; j<diffusantGasNames_.size(); j++) for (int j=0; j<diffusantGasNames_.size(); j++)
{ {
double**& diffusionCoefficients_ = particleCloud_.getParticlePropertyRef<double**>(diffusantGasNames_[j]);
TotalFraction_[j] = 0.0; TotalFraction_[j] = 0.0;
dBinary_ = 0.0; dBinary_ = 0.0;
@ -243,9 +218,9 @@ void diffusionCoefficient::execute()
// pass on dCoeff values to array // pass on dCoeff values to array
if (TotalFraction_[j] < VSMALL) if (TotalFraction_[j] < VSMALL)
diffusionCoefficients_[j][index][0] = VSMALL; diffusionCoefficients_[index][0] = VSMALL;
else else
diffusionCoefficients_[j][index][0] = (1.0 - Xdiffusant_[j][cellI]) / TotalFraction_[j]; diffusionCoefficients_[index][0] = (1.0 - Xdiffusant_[j][cellI]) / TotalFraction_[j];
} }
else else
{ {
@ -258,7 +233,7 @@ void diffusionCoefficient::execute()
} }
if(verbose_) 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 +243,8 @@ void diffusionCoefficient::execute()
for (int j=0; j<diffusantGasNames_.size(); j++) for (int j=0; j<diffusantGasNames_.size(); j++)
{ {
word pushName = diffusantGasNames_[j] + "_diffCoeff"; word pushName = diffusantGasNames_[j] + "_diffCoeff";
particleCloud_.dataExchangeM().giveData(pushName,"scalar-atom",diffusionCoefficients_[j]); double**& diffusionCoefficients_ = particleCloud_.getParticlePropertyRef<double**>(diffusantGasNames_[j]);
particleCloud_.dataExchangeM().giveData(pushName,"scalar-atom",diffusionCoefficients_);
} }
Info << "give data done" << endl; Info << "give data done" << endl;

View File

@ -76,19 +76,15 @@ private:
word partPressureName_; word partPressureName_;
mutable double **partPressure_;
UPtrList<volScalarField> X_; UPtrList<volScalarField> X_;
wordList diffusantGasNames_; wordList diffusantGasNames_;
mutable List<double**> diffusionCoefficients_;
UPtrList<volScalarField> Xdiffusant_; UPtrList<volScalarField> Xdiffusant_;
HashTable<scalar, word> coeffs; HashTable<scalar> coeffs;
HashTable<scalar, word> molWeight; HashTable<scalar> molWeight;
void createCoeffs(); void createCoeffs();
@ -100,8 +96,6 @@ private:
// calculate denominator part diffusion volume equation // calculate denominator part diffusion volume equation
double calcDiffVol(int, int); double calcDiffVol(int, int);
void allocateMyArrays() const;
bool initialized_; bool initialized_;
void init(); void init();
@ -126,8 +120,6 @@ private:
// Member Functions // Member Functions
void execute(); void execute();
void reAllocMyArrays() const;
}; };

View File

@ -63,51 +63,26 @@ massTransferCoeff::massTransferCoeff
densityFieldName_(propsDict_.lookupOrDefault<word>("densityFieldName","rho")), densityFieldName_(propsDict_.lookupOrDefault<word>("densityFieldName","rho")),
rho_(sm.mesh().lookupObject<volScalarField> (densityFieldName_)), rho_(sm.mesh().lookupObject<volScalarField> (densityFieldName_)),
partNuName_(propsDict_.lookupOrDefault<word>("partViscos","partNu")), partNuName_(propsDict_.lookupOrDefault<word>("partViscos","partNu")),
partNu_(NULL), partReName_(propsDict_.lookupOrDefault<word>("partReynolds","partRe")),
partReynolds_(propsDict_.lookupOrDefault<word>("partReynolds","partRe")),
partRe_(NULL),
scaleDia_(1) scaleDia_(1)
{ {
particleCloud_.checkCG(true); particleCloud_.checkCG(true);
allocateMyArrays(); particleCloud_.registerParticleProperty<double**>(partNuName_,1);
particleCloud_.registerParticleProperty<double**>(partReName_,1);
} }
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
massTransferCoeff::~massTransferCoeff() massTransferCoeff::~massTransferCoeff()
{ {
int nP_ = particleCloud_.numberOfParticles();
particleCloud_.dataExchangeM().destroy(partNu_,nP_);
particleCloud_.dataExchangeM().destroy(partRe_,nP_);
} }
// * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * 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);
}
// * * * * * * * * * * * * * * * * Member Fct * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Member Fct * * * * * * * * * * * * * * * //
void massTransferCoeff::execute() void massTransferCoeff::execute()
{ {
// realloc the arrays
reAllocMyArrays();
#ifdef compre #ifdef compre
const volScalarField nufField = particleCloud_.turbulence().mu()/rho_; const volScalarField nufField = particleCloud_.turbulence().mu()/rho_;
#else #else
@ -139,6 +114,9 @@ void massTransferCoeff::execute()
interpolationCellPoint <vector> UluidInterpolator_(U_); interpolationCellPoint <vector> UluidInterpolator_(U_);
interpolationCellPoint <scalar> voidfractionInterpolator_(voidfraction_); interpolationCellPoint <scalar> voidfractionInterpolator_(voidfraction_);
double**& partNu_ = particleCloud_.getParticlePropertyRef<double**>(partNuName_);
double**& partRe_ = particleCloud_.getParticlePropertyRef<double**>(partReName_);
for (int index=0; index<particleCloud_.numberOfParticles(); ++index) for (int index=0; index<particleCloud_.numberOfParticles(); ++index)
{ {
cellI=particleCloud_.cellIDs()[index][0]; cellI=particleCloud_.cellIDs()[index][0];
@ -195,7 +173,7 @@ void massTransferCoeff::execute()
// give DEM data // give DEM data
particleCloud_.dataExchangeM().giveData(partNuName_, "scalar-atom", partNu_); particleCloud_.dataExchangeM().giveData(partNuName_, "scalar-atom", partNu_);
particleCloud_.dataExchangeM().giveData(partReynolds_, "scalar-atom", partRe_); particleCloud_.dataExchangeM().giveData(partReName_, "scalar-atom", partRe_);
Info << "give data done" << endl; Info << "give data done" << endl;
} }

View File

@ -56,27 +56,21 @@ private:
const fvMesh& mesh_; const fvMesh& mesh_;
word velFieldName_; const word velFieldName_;
const volVectorField& U_; const volVectorField& U_;
word voidfractionFieldName_; const word voidfractionFieldName_;
const volScalarField& voidfraction_; const volScalarField& voidfraction_;
word densityFieldName_; const word densityFieldName_;
const volScalarField& rho_; const volScalarField& rho_;
word partNuName_; const word partNuName_;
mutable double **partNu_; const word partReName_;
word partReynolds_;
mutable double **partRe_;
void allocateMyArrays() const;
mutable scalar scaleDia_; mutable scalar scaleDia_;
@ -101,8 +95,6 @@ public:
// Member Functions // Member Functions
void execute(); void execute();
void reAllocMyArrays() const;
}; };

View File

@ -57,7 +57,7 @@ reactantPerParticle::reactantPerParticle
propsDict_(dict.subDict(typeName + "Props")), propsDict_(dict.subDict(typeName + "Props")),
mesh_(sm.mesh()), mesh_(sm.mesh()),
verbose_(propsDict_.lookupOrDefault<bool>("verbose",false)), verbose_(propsDict_.lookupOrDefault<bool>("verbose",false)),
reactantPerParticle_(NULL), partReactantName_("reactantPerParticle"),
voidfractionFieldName_(propsDict_.lookupOrDefault<word>("voidfractionFieldName","voidfraction")), voidfractionFieldName_(propsDict_.lookupOrDefault<word>("voidfractionFieldName","voidfraction")),
voidfraction_(sm.mesh().lookupObject<volScalarField>(voidfractionFieldName_)), voidfraction_(sm.mesh().lookupObject<volScalarField>(voidfractionFieldName_)),
particlesPerCell_ particlesPerCell_
@ -76,32 +76,16 @@ reactantPerParticle::reactantPerParticle
Nevery_(propsDict_.lookupOrDefault<label>("Nevery",1)) Nevery_(propsDict_.lookupOrDefault<label>("Nevery",1))
{ {
particleCloud_.checkCG(false); particleCloud_.checkCG(false);
allocateMyArrays(); particleCloud_.registerParticleProperty<double**>(partReactantName_,1);
} }
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
reactantPerParticle::~reactantPerParticle() reactantPerParticle::~reactantPerParticle()
{ {
particleCloud_.dataExchangeM().destroy(reactantPerParticle_,1);
} }
// * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * //
void reactantPerParticle::allocateMyArrays() const
{
double initVal=0.0;
if (particleCloud_.dataExchangeM().maxNumberOfParticles() > 0)
{
// get memory for 2d arrays
particleCloud_.dataExchangeM().allocateArray(reactantPerParticle_,initVal,1,"nparticles");
}
}
void reactantPerParticle::reAllocMyArrays() const
{
double initVal=0.0;
particleCloud_.dataExchangeM().allocateArray(reactantPerParticle_,initVal,1);
}
// * * * * * * * * * * * * * * * * Member Fct * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Member Fct * * * * * * * * * * * * * * * //
@ -112,8 +96,6 @@ void reactantPerParticle::execute()
{ {
return; return;
} }
// realloc the arrays
reAllocMyArrays();
particlesPerCell_ *= 0.0; particlesPerCell_ *= 0.0;
@ -121,6 +103,7 @@ void reactantPerParticle::execute()
scalar voidfraction(1); scalar voidfraction(1);
scalar cellvolume(0.0); scalar cellvolume(0.0);
scalar particlesPerCell(1.0); scalar particlesPerCell(1.0);
double**& reactantPerParticle_ = particleCloud_.getParticlePropertyRef<double**>(partReactantName_);
// first create particles per cell field // first create particles per cell field
for (int index=0; index<particleCloud_.numberOfParticles(); ++index) for (int index=0; index<particleCloud_.numberOfParticles(); ++index)
@ -147,10 +130,10 @@ void reactantPerParticle::execute()
if (verbose_) Info << "reactantPerParticle_" << reactantPerParticle_[index][0] << endl; if (verbose_) Info << "reactantPerParticle_" << reactantPerParticle_[index][0] << endl;
} }
// give DEM data // give DEM data
particleCloud_.dataExchangeM().giveData("reactantPerParticle", "scalar-atom", reactantPerParticle_); particleCloud_.dataExchangeM().giveData(partReactantName_, "scalar-atom", reactantPerParticle_);
Info << "give data done" << endl; Info << "give data done" << endl;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -56,16 +56,14 @@ private:
bool verbose_; bool verbose_;
mutable double **reactantPerParticle_; const word partReactantName_;
word voidfractionFieldName_; const word voidfractionFieldName_;
const volScalarField& voidfraction_; const volScalarField& voidfraction_;
mutable volScalarField particlesPerCell_; mutable volScalarField particlesPerCell_;
void allocateMyArrays() const;
label loopCounter_; label loopCounter_;
label Nevery_; label Nevery_;
@ -91,8 +89,6 @@ public:
// Member Functions // Member Functions
void execute(); void execute();
void reAllocMyArrays() const;
}; };

View File

@ -70,8 +70,6 @@ species::species
speciesNames_(specDict_.lookup("species")), speciesNames_(specDict_.lookup("species")),
mod_spec_names_(speciesNames_.size()), mod_spec_names_(speciesNames_.size()),
X_(speciesNames_.size()), //volumeScalarFields of molarFractions X_(speciesNames_.size()), //volumeScalarFields of molarFractions
molarFractions_(speciesNames_.size(),NULL), //the value of molar fractions for every species
changeOfSpeciesMass_(speciesNames_.size(),NULL), //the values that are received from DEM with the name of Modified_+species name
changeOfSpeciesMassFields_(speciesNames_.size()), //the scalar fields generated with the values from Modified_+species names changeOfSpeciesMassFields_(speciesNames_.size()), //the scalar fields generated with the values from Modified_+species names
changeOfGasMassField_ //the total change of Gas Mass field (when the Modified species changeOfGasMassField_ //the total change of Gas Mass field (when the Modified species
( (
@ -89,18 +87,15 @@ species::species
tempFieldName_(propsDict_.lookupOrDefault<word>("tempFieldName","T")), tempFieldName_(propsDict_.lookupOrDefault<word>("tempFieldName","T")),
tempField_(sm.mesh().lookupObject<volScalarField> (tempFieldName_)), tempField_(sm.mesh().lookupObject<volScalarField> (tempFieldName_)),
partTempName_(propsDict_.lookupOrDefault<word>("partTempName","partTemp")), partTempName_(propsDict_.lookupOrDefault<word>("partTempName","partTemp")),
partTemp_(NULL),
densityFieldName_(propsDict_.lookupOrDefault<word>("densityFieldName","rho")), densityFieldName_(propsDict_.lookupOrDefault<word>("densityFieldName","rho")),
rho_(sm.mesh().lookupObject<volScalarField> (densityFieldName_)), rho_(sm.mesh().lookupObject<volScalarField> (densityFieldName_)),
partRhoName_(propsDict_.lookupOrDefault<word>("partRhoName","partRho")), partRhoName_(propsDict_.lookupOrDefault<word>("partRhoName","partRho")),
partRho_(NULL),
voidfractionFieldName_(propsDict_.lookupOrDefault<word>("voidfractionFieldName","voidfraction")), voidfractionFieldName_(propsDict_.lookupOrDefault<word>("voidfractionFieldName","voidfraction")),
voidfraction_(sm.mesh().lookupObject<volScalarField>(voidfractionFieldName_)), voidfraction_(sm.mesh().lookupObject<volScalarField>(voidfractionFieldName_)),
// total mole field // total mole field
molarConcFieldName_(propsDict_.lookupOrDefault<word>("totalMoleFieldName","molarConc")), molarConcFieldName_(propsDict_.lookupOrDefault<word>("totalMoleFieldName","molarConc")),
molarConc_(sm.mesh().lookupObject<volScalarField>(molarConcFieldName_)), molarConc_(sm.mesh().lookupObject<volScalarField>(molarConcFieldName_)),
partMolarConcName_(propsDict_.lookupOrDefault<word>("partMoleName","partMolarConc")), partMolarConcName_(propsDict_.lookupOrDefault<word>("partMoleName","partMolarConc")),
partMolarConc_(NULL),
loopCounter_(-1), loopCounter_(-1),
Nevery_(propsDict_.lookupOrDefault<label>("Nevery",1)), Nevery_(propsDict_.lookupOrDefault<label>("Nevery",1)),
massSourceCurr_(0.0), massSourceCurr_(0.0),
@ -108,56 +103,25 @@ species::species
initialized_(false) initialized_(false)
{ {
particleCloud_.checkCG(false); particleCloud_.checkCG(false);
allocateMyArrays(); 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],1);
particleCloud_.registerParticleProperty<double**>("Modified_"+speciesNames_[i],1);
}
} }
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
species::~species() species::~species()
{ {
particleCloud_.dataExchangeM().destroy(partTemp_,1);
particleCloud_.dataExchangeM().destroy(partRho_,1);
particleCloud_.dataExchangeM().destroy(partMolarConc_,1);
for (int i=0; i<speciesNames_.size();i++) particleCloud_.dataExchangeM().destroy(molarFractions_[i],1);
for (int i=0; i<speciesNames_.size();i++) particleCloud_.dataExchangeM().destroy(changeOfSpeciesMass_[i],1);
} }
// * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * //
void species::allocateMyArrays() const
{
double initVal=0.0;
if (particleCloud_.dataExchangeM().maxNumberOfParticles() > 0)
{
// get memory for 2d arrays
particleCloud_.dataExchangeM().allocateArray(partRho_,initVal,1,"nparticles");
particleCloud_.dataExchangeM().allocateArray(partTemp_,initVal,1,"nparticles");
particleCloud_.dataExchangeM().allocateArray(partMolarConc_,initVal,1,"nparticles");
for (int i=0; i<speciesNames_.size(); i++)
{
particleCloud_.dataExchangeM().allocateArray(molarFractions_[i],initVal,1,"nparticles");
particleCloud_.dataExchangeM().allocateArray(changeOfSpeciesMass_[i],initVal,1,"nparticles");
}
}
}
void species::reAllocMyArrays() const
{
double initVal=0.0;
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++)
{
particleCloud_.dataExchangeM().allocateArray(molarFractions_[i],initVal,1);
particleCloud_.dataExchangeM().allocateArray(changeOfSpeciesMass_[i],initVal,1);
}
}
void species::init() void species::init()
{ {
if(verbose_) if(verbose_)
@ -219,8 +183,6 @@ void species::execute()
{ {
return; return;
} }
// realloc the arrays
reAllocMyArrays();
// get X_i, T, rho at particle positions // get X_i, T, rho at particle positions
label cellI = 0; label cellI = 0;
@ -235,6 +197,9 @@ void species::execute()
interpolationCellPoint <scalar> voidfractionInterpolator_(voidfraction_); interpolationCellPoint <scalar> voidfractionInterpolator_(voidfraction_);
interpolationCellPoint <scalar> molarConcInterpolator_(molarConc_); interpolationCellPoint <scalar> molarConcInterpolator_(molarConc_);
double**& partRho_ = particleCloud_.getParticlePropertyRef<double**>(partRhoName_);
double**& partTemp_ = particleCloud_.getParticlePropertyRef<double**>(partTempName_);
double**& partMolarConc_ = particleCloud_.getParticlePropertyRef<double**>(partMolarConcName_);
for (int index=0; index<particleCloud_.numberOfParticles(); ++index) for (int index=0; index<particleCloud_.numberOfParticles(); ++index)
{ {
@ -264,7 +229,8 @@ void species::execute()
for (int i=0; i<speciesNames_.size();i++) for (int i=0; i<speciesNames_.size();i++)
{ {
// attention for indices when not communicating all species // attention for indices when not communicating all species
molarFractions_[i][index][0] = X_[i][cellI]; double**& molarFractions_ = particleCloud_.getParticlePropertyRef<double**>("X_"+speciesNames_[i]);
molarFractions_[index][0] = X_[i][cellI];
} }
} }
} }
@ -274,8 +240,9 @@ void species::execute()
{ {
for(int i =0; i<speciesNames_.size(); i++) for(int i =0; i<speciesNames_.size(); i++)
{ {
double**& molarFractions_ = particleCloud_.getParticlePropertyRef<double**>("X_"+speciesNames_[i]);
Info << "X_i = " << X_[i].name() << endl; Info << "X_i = " << X_[i].name() << endl;
Info << "molarFractions_= " << molarFractions_[i][0][0] << endl; Info << "molarFractions_= " << molarFractions_[0][0] << endl;
Info << "partRho_[index][0] = " << partRho_[0][0] << endl; Info << "partRho_[index][0] = " << partRho_[0][0] << endl;
Info << "rhofluid = " << rhofluid << endl; Info << "rhofluid = " << rhofluid << endl;
Info << "partTemp_[index][0] = " << partTemp_[0][0] << endl; Info << "partTemp_[index][0] = " << partTemp_[0][0] << endl;
@ -292,7 +259,8 @@ void species::execute()
for (int i=0; i<speciesNames_.size();i++) for (int i=0; i<speciesNames_.size();i++)
{ {
particleCloud_.dataExchangeM().giveData("X_"+speciesNames_[i],"scalar-atom",molarFractions_[i]); double**& molarFractions_ = particleCloud_.getParticlePropertyRef<double**>("X_"+speciesNames_[i]);
particleCloud_.dataExchangeM().giveData("X_"+speciesNames_[i],"scalar-atom",molarFractions_);
} }
if (verbose_) Info << "give data done" << endl; if (verbose_) Info << "give data done" << endl;
@ -305,17 +273,18 @@ void species::execute()
changeOfGasMassField_.boundaryFieldRef() = 0.0; changeOfGasMassField_.boundaryFieldRef() = 0.0;
for (int i=0; i<speciesNames_.size();i++) for (int i=0; i<speciesNames_.size();i++)
{ {
double**& changeOfSpeciesMass_ = particleCloud_.getParticlePropertyRef<double**>("Modified_"+speciesNames_[i]);
changeOfSpeciesMassFields_[i].primitiveFieldRef() = 0.0; changeOfSpeciesMassFields_[i].primitiveFieldRef() = 0.0;
changeOfSpeciesMassFields_[i].boundaryFieldRef() = 0.0; changeOfSpeciesMassFields_[i].boundaryFieldRef() = 0.0;
particleCloud_.dataExchangeM().getData(mod_spec_names_[i],"scalar-atom",changeOfSpeciesMass_[i],particleCloud_.dataExchangeM().couplingInterval()); particleCloud_.dataExchangeM().getData(mod_spec_names_[i],"scalar-atom",changeOfSpeciesMass_,particleCloud_.dataExchangeM().couplingInterval());
if (verbose_) Info << "changeOfSpeciesMass received from DEM = " << changeOfSpeciesMass_[i][0][0] << endl; if (verbose_) Info << "changeOfSpeciesMass received from DEM = " << changeOfSpeciesMass_[0][0] << endl;
particleCloud_.averagingM().setScalarSumCentre particleCloud_.averagingM().setScalarSumCentre
( (
changeOfSpeciesMassFields_[i], changeOfSpeciesMassFields_[i],
changeOfSpeciesMass_[i], changeOfSpeciesMass_,
particleCloud_.particleWeights(), particleCloud_.particleWeights(),
NULL NULL
); );

View File

@ -68,44 +68,32 @@ private:
UPtrList<volScalarField> X_; UPtrList<volScalarField> X_;
mutable List<double**> molarFractions_;
mutable List<double**> changeOfSpeciesMass_;
PtrList<volScalarField> changeOfSpeciesMassFields_; PtrList<volScalarField> changeOfSpeciesMassFields_;
volScalarField changeOfGasMassField_; volScalarField changeOfGasMassField_;
word tempFieldName_; const word tempFieldName_;
const volScalarField& tempField_; // ref to gas temperature field const volScalarField& tempField_; // ref to gas temperature field
word partTempName_; const word partTempName_;
mutable double **partTemp_; // gas temperature at particle positions const word densityFieldName_;
word densityFieldName_;
const volScalarField& rho_; const volScalarField& rho_;
word partRhoName_; const word partRhoName_;
mutable double **partRho_; // gas density at particle positions const word voidfractionFieldName_;
word voidfractionFieldName_;
const volScalarField& voidfraction_; const volScalarField& voidfraction_;
void allocateMyArrays() const;
// total mole field // total mole field
word molarConcFieldName_; const word molarConcFieldName_;
const volScalarField& molarConc_; const volScalarField& molarConc_;
word partMolarConcName_; const word partMolarConcName_;
mutable double **partMolarConc_;
label loopCounter_; label loopCounter_;
@ -141,8 +129,6 @@ public:
// Member Functions // Member Functions
void execute(); void execute();
void reAllocMyArrays() const;
tmp <volScalarField> Smi(const label i) const; tmp <volScalarField> Smi(const label i) const;
tmp <volScalarField> Sm() const; tmp <volScalarField> Sm() const;

View File

@ -129,31 +129,31 @@ public:
template <typename T> template <typename T>
void getData void getData
( (
word name, const word& name,
word type, const word& type,
T ** const& field T ** const& field
) const { getData(name,type,field,couplingStep_-1); } ) const { getData(name,type,field,couplingStep_-1); }
virtual void getData virtual void getData
( (
word name, const word& name,
word type, const word& type,
double ** const& field, double ** const& field,
label step label step
) const = 0; ) const = 0;
virtual void getData virtual void getData
( (
word name, const word& name,
word type, const word& type,
int ** const& field, int ** const& field,
label step label step
) const = 0; ) const = 0;
virtual void giveData virtual void giveData
( (
word name, const word& name,
word type, const word& type,
double ** const& field, double ** const& field,
const char* datatype="double" const char* datatype="double"
) const = 0; ) const = 0;

View File

@ -78,24 +78,24 @@ public:
// Member Functions // Member Functions
void getData void getData
( (
word name, const word& name,
word type, const word& type,
double ** const& field, double ** const& field,
label step label step
) const {} ) const {}
void getData void getData
( (
word name, const word& name,
word type, const word& type,
int ** const& field, int ** const& field,
label step label step
) const {} ) const {}
void giveData void giveData
( (
word name, const word& name,
word type, const word& type,
double ** const& field, double ** const& field,
const char* datatype = "" const char* datatype = ""
) const {} ) const {}

View File

@ -84,8 +84,8 @@ oneWayVTK::~oneWayVTK()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void oneWayVTK::getData void oneWayVTK::getData
( (
word name, const word& name,
word type, const word& type,
double ** const& field, double ** const& field,
label step label step
) const ) const
@ -194,8 +194,8 @@ void oneWayVTK::getData
void oneWayVTK::giveData void oneWayVTK::giveData
( (
word name, const word& name,
word type, const word& type,
double ** const& field, double ** const& field,
const char* datatype const char* datatype
) const ) const

View File

@ -87,16 +87,16 @@ public:
// Member Functions // Member Functions
void getData void getData
( (
word name, const word& name,
word type, const word& type,
double ** const& field, double ** const& field,
label step label step
) const; ) const;
void getData void getData
( (
word name, const word& name,
word type, const word& type,
int ** const& field, int ** const& field,
label step label step
) const ) const
@ -104,8 +104,8 @@ public:
void giveData void giveData
( (
word name, const word& name,
word type, const word& type,
double ** const& field, double ** const& field,
const char* datatype = "" const char* datatype = ""
) const; ) const;

View File

@ -80,7 +80,7 @@ twoWayFiles::~twoWayFiles()
// * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * //
fileName twoWayFiles::getFilePath(word& name, bool in) const fileName twoWayFiles::getFilePath(const word& name, bool in) const
{ {
char timeStep[40]; char timeStep[40];
@ -100,7 +100,7 @@ fileName twoWayFiles::getFilePath(word& name, bool in) const
return particleFilePathOld; return particleFilePathOld;
} }
void twoWayFiles::renameFilePath(fileName& particleFilePathOld,word& name) const void twoWayFiles::renameFilePath(const fileName& particleFilePathOld, const word& name) const
{ {
char timeStep[40]; char timeStep[40];
@ -116,8 +116,8 @@ void twoWayFiles::renameFilePath(fileName& particleFilePathOld,word& name) const
// * * * * * * * * * * * * * * * public Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * public Member Functions * * * * * * * * * * * * * //
void twoWayFiles::getData void twoWayFiles::getData
( (
word name, const word& name,
word type, const word& type,
double ** const& field, double ** const& field,
label step label step
) const ) const
@ -164,8 +164,8 @@ void twoWayFiles::getData
void twoWayFiles::giveData void twoWayFiles::giveData
( (
word name, const word& name,
word type, const word& type,
double ** const& field, double ** const& field,
const char* datatype const char* datatype
) const ) const

View File

@ -65,9 +65,9 @@ private:
// private member functions // private member functions
fileName getFilePath(word&, bool) const; fileName getFilePath(const word&, bool) const;
void renameFilePath(fileName&,word&) const; void renameFilePath(const fileName&, const word&) const;
public: public:
@ -92,24 +92,24 @@ public:
// Member Functions // Member Functions
void getData void getData
( (
word name, const word& name,
word type, const word& type,
double ** const& field, double ** const& field,
label step label step
) const; ) const;
void getData void getData
( (
word name, const word& name,
word type, const word& type,
int ** const& field, int ** const& field,
label step label step
) const { FatalError<<"function not implemented !!! twoWayFiles::getData!!!\n" << abort(FatalError); } ) const { FatalError<<"function not implemented !!! twoWayFiles::getData!!!\n" << abort(FatalError); }
void giveData void giveData
( (
word name, const word& name,
word type, const word& type,
double ** const& field, double ** const& field,
const char* datatype = "" const char* datatype = ""
) const; ) const;

View File

@ -138,8 +138,8 @@ double twoWayMPI::DEMVariableValue(word variablename)
void twoWayMPI::getData void twoWayMPI::getData
( (
word name, const word& name,
word type, const word& type,
double ** const& field, double ** const& field,
label /*step*/ label /*step*/
) const ) const
@ -149,8 +149,8 @@ void twoWayMPI::getData
void twoWayMPI::getData void twoWayMPI::getData
( (
word name, const word& name,
word type, const word& type,
int ** const& field, int ** const& field,
label /*step*/ label /*step*/
) const ) const
@ -160,8 +160,8 @@ void twoWayMPI::getData
void twoWayMPI::giveData void twoWayMPI::giveData
( (
word name, const word& name,
word type, const word& type,
double ** const& field, double ** const& field,
const char* datatype const char* datatype
) const ) const

View File

@ -107,24 +107,24 @@ public:
// Member Functions // Member Functions
void getData void getData
( (
word name, const word& name,
word type, const word& type,
double ** const& field, double ** const& field,
label step label step
) const; ) const;
void getData void getData
( (
word name, const word& name,
word type, const word& type,
int ** const& field, int ** const& field,
label step label step
) const; ) const;
void giveData void giveData
( (
word name, const word& name,
word type, const word& type,
double ** const& field, double ** const& field,
const char* datatype const char* datatype
) const; ) const;

View File

@ -178,8 +178,8 @@ twoWayMany2Many::~twoWayMany2Many()
// * * * * * * * * * * * * * * * public Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * public Member Functions * * * * * * * * * * * * * //
void twoWayMany2Many::getData void twoWayMany2Many::getData
( (
word name, const word& name,
word type, const word& type,
double ** const& field, double ** const& field,
label /*step*/ label /*step*/
) const ) const
@ -231,8 +231,8 @@ void twoWayMany2Many::getData
void twoWayMany2Many::getData void twoWayMany2Many::getData
( (
word name, const word& name,
word type, const word& type,
int ** const& field, int ** const& field,
label /*step*/ label /*step*/
) const ) const
@ -242,8 +242,8 @@ void twoWayMany2Many::getData
void twoWayMany2Many::giveData void twoWayMany2Many::giveData
( (
word name, const word& name,
word type, const word& type,
double ** const& field, double ** const& field,
const char* /*datatype*/ const char* /*datatype*/
) const ) const

View File

@ -157,24 +157,24 @@ public:
// Member Functions // Member Functions
void getData void getData
( (
word name, const word& name,
word type, const word& type,
double ** const& field, double ** const& field,
label step label step
) const; ) const;
void getData void getData
( (
word name, const word& name,
word type, const word& type,
int ** const& field, int ** const& field,
label step label step
) const; ) const;
void giveData void giveData
( (
word name, const word& name,
word type, const word& type,
double ** const& field, double ** const& field,
const char* datatype const char* datatype
) const; ) const;

View File

@ -253,8 +253,8 @@ twoWayOne2One::~twoWayOne2One()
// * * * * * * * * * * * * * * * public Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * public Member Functions * * * * * * * * * * * * * //
void twoWayOne2One::getData void twoWayOne2One::getData
( (
word name, const word& name,
word type, const word& type,
double ** const& field, double ** const& field,
label /*step*/ label /*step*/
) const ) const
@ -361,8 +361,8 @@ void twoWayOne2One::getData
void twoWayOne2One::getData void twoWayOne2One::getData
( (
word name, const word& name,
word type, const word& type,
int ** const& field, int ** const& field,
label /*step*/ label /*step*/
) const ) const
@ -383,8 +383,8 @@ void twoWayOne2One::getData
void twoWayOne2One::giveData void twoWayOne2One::giveData
( (
word name, const word& name,
word type, const word& type,
double ** const& field, double ** const& field,
const char* datatype const char* datatype
) const ) const

View File

@ -152,24 +152,24 @@ public:
// Member Functions // Member Functions
void getData void getData
( (
word name, const word& name,
word type, const word& type,
double ** const& field, double ** const& field,
label step label step
) const; ) const;
void getData void getData
( (
word name, const word& name,
word type, const word& type,
int ** const& field, int ** const& field,
label step label step
) const; ) const;
void giveData void giveData
( (
word name, const word& name,
word type, const word& type,
double ** const& field, double ** const& field,
const char* datatype const char* datatype
) const; ) const;

View File

@ -49,7 +49,8 @@ heatTransferGranConduction::heatTransferGranConduction
totalHeatFlux_(0.0), totalHeatFlux_(0.0),
QPartPartName_(propsDict_.lookupOrDefault<word>("QPartPartName","QPartPart")), QPartPartName_(propsDict_.lookupOrDefault<word>("QPartPartName","QPartPart")),
QPartPart_ QPartPart_
( IOobject (
IOobject
( (
QPartPartName_, QPartPartName_,
sm.mesh().time().timeName(), sm.mesh().time().timeName(),
@ -72,7 +73,7 @@ heatTransferGranConduction::heatTransferGranConduction
), ),
sm.mesh(), sm.mesh(),
dimensionedScalar("one", dimensionSet(1, 1, -3, -1,0,0,0), 1.0), dimensionedScalar("one", dimensionSet(1, 1, -3, -1,0,0,0), 1.0),
"zeroGradient" "zeroGradient"
), ),
partThermCondField_ partThermCondField_
( (
@ -86,7 +87,7 @@ heatTransferGranConduction::heatTransferGranConduction
), ),
sm.mesh(), sm.mesh(),
dimensionedScalar("one", dimensionSet(1, 1, -3, -1,0,0,0), 1.0), dimensionedScalar("one", dimensionSet(1, 1, -3, -1,0,0,0), 1.0),
"zeroGradient" "zeroGradient"
), ),
partTempField_(sm.mesh().lookupObject<volScalarField>("partTemp")), partTempField_(sm.mesh().lookupObject<volScalarField>("partTemp")),
prescribedVoidfractionFieldName_(propsDict_.lookupOrDefault<word>("prescribedVoidfractionFieldName","voidfraction")), prescribedVoidfractionFieldName_(propsDict_.lookupOrDefault<word>("prescribedVoidfractionFieldName","voidfraction")),
@ -94,11 +95,11 @@ heatTransferGranConduction::heatTransferGranConduction
voidfractionFieldName_(propsDict_.lookupOrDefault<word>("voidfractionFieldName","voidfraction")), voidfractionFieldName_(propsDict_.lookupOrDefault<word>("voidfractionFieldName","voidfraction")),
voidfraction_(sm.mesh().lookupObject<volScalarField> (voidfractionFieldName_)), voidfraction_(sm.mesh().lookupObject<volScalarField> (voidfractionFieldName_)),
partHeatFluxName_(propsDict_.lookupOrDefault<word>("partHeatFluxName","conductiveHeatFlux")), partHeatFluxName_(propsDict_.lookupOrDefault<word>("partHeatFluxName","conductiveHeatFlux")),
partHeatFlux_(NULL),
typePartThermCond_(propsDict_.lookupOrDefault<scalarList>("thermalConductivities",scalarList(1,-1.0))), typePartThermCond_(propsDict_.lookupOrDefault<scalarList>("thermalConductivities",scalarList(1,-1.0))),
partThermCond_(NULL) partThermCondRegName_(typeName + "partThermCond")
{ {
allocateMyArrays(); particleCloud_.registerParticleProperty<double**>(partHeatFluxName_,1);
particleCloud_.registerParticleProperty<double**>(partThermCondRegName_,1);
if (typePartThermCond_[0] < 0.0) if (typePartThermCond_[0] < 0.0)
{ {
@ -127,25 +128,13 @@ heatTransferGranConduction::heatTransferGranConduction
heatTransferGranConduction::~heatTransferGranConduction() heatTransferGranConduction::~heatTransferGranConduction()
{ {
particleCloud_.dataExchangeM().destroy(partHeatFlux_,1);
particleCloud_.dataExchangeM().destroy(partThermCond_,1);
} }
// * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * //
void heatTransferGranConduction::allocateMyArrays() const
{
// get memory for 2d arrays
double initVal=0.0;
particleCloud_.dataExchangeM().allocateArray(partHeatFlux_,initVal,1);
particleCloud_.dataExchangeM().allocateArray(partThermCond_,initVal,1);
}
// * * * * * * * * * * * * * * * * Member Fct * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Member Fct * * * * * * * * * * * * * * * //
void heatTransferGranConduction::calcEnergyContribution() void heatTransferGranConduction::calcEnergyContribution()
{ {
// realloc the arrays
allocateMyArrays();
calcPartEffThermCond(); calcPartEffThermCond();
QPartPart_ = fvc::laplacian(partEffThermCondField_,partTempField_); QPartPart_ = fvc::laplacian(partEffThermCondField_,partTempField_);
@ -156,6 +145,7 @@ void heatTransferGranConduction::calcEnergyContribution()
scalar voidfraction(1); scalar voidfraction(1);
totalHeatFlux_ = 0.0; totalHeatFlux_ = 0.0;
double**& partHeatFlux_ = particleCloud_.getParticlePropertyRef<double**>(partHeatFluxName_);
for(int index = 0;index < particleCloud_.numberOfParticles(); ++index) for(int index = 0;index < particleCloud_.numberOfParticles(); ++index)
{ {
@ -199,6 +189,8 @@ void heatTransferGranConduction::calcPartThermCond()
{ {
label cellI=0; label cellI=0;
label partType = 1; label partType = 1;
double**& partThermCond_ = particleCloud_.getParticlePropertyRef<double**>(partThermCondRegName_);
for(int index = 0;index < particleCloud_.numberOfParticles(); ++index) for(int index = 0;index < particleCloud_.numberOfParticles(); ++index)
{ {
cellI = particleCloud_.cellIDs()[index][0]; cellI = particleCloud_.cellIDs()[index][0];
@ -227,7 +219,8 @@ void heatTransferGranConduction::calcPartThermCond()
void heatTransferGranConduction::heatFlux(label index, scalar vol, scalar voidfraction, scalar QPartPart) void heatTransferGranConduction::heatFlux(label index, scalar vol, scalar voidfraction, scalar QPartPart)
{ {
partHeatFlux_[index][0] = vol * QPartPart / (1.0 - voidfraction) ; double**& partHeatFlux_ = particleCloud_.getParticlePropertyRef<double**>(partHeatFluxName_);
partHeatFlux_[index][0] = vol * QPartPart / (1.0 - voidfraction) ;
} }
void heatTransferGranConduction::giveData() void heatTransferGranConduction::giveData()
@ -238,6 +231,7 @@ void heatTransferGranConduction::giveData()
Info << "total conductive particle-particle heat flux [W] (Eulerian) = " << totalHeatFlux_ << endl; Info << "total conductive particle-particle heat flux [W] (Eulerian) = " << totalHeatFlux_ << endl;
} }
double**& partHeatFlux_ = particleCloud_.getParticlePropertyRef<double**>(partHeatFluxName_);
particleCloud_.dataExchangeM().giveData(partHeatFluxName_,"scalar-atom", partHeatFlux_); particleCloud_.dataExchangeM().giveData(partHeatFluxName_,"scalar-atom", partHeatFlux_);
} }

View File

@ -54,7 +54,7 @@ protected:
scalar totalHeatFlux_; scalar totalHeatFlux_;
word QPartPartName_; const word QPartPartName_;
volScalarField QPartPart_; volScalarField QPartPart_;
@ -64,23 +64,19 @@ protected:
const volScalarField& partTempField_; const volScalarField& partTempField_;
word prescribedVoidfractionFieldName_; const word prescribedVoidfractionFieldName_;
const volScalarField& prescribedVoidfraction_; const volScalarField& prescribedVoidfraction_;
word voidfractionFieldName_; const word voidfractionFieldName_;
const volScalarField& voidfraction_; const volScalarField& voidfraction_;
word partHeatFluxName_; const word partHeatFluxName_;
mutable double **partHeatFlux_;
scalarList typePartThermCond_; scalarList typePartThermCond_;
mutable double **partThermCond_; const word partThermCondRegName_;
void allocateMyArrays() const;
void calcPartEffThermCond(); void calcPartEffThermCond();
@ -118,9 +114,9 @@ public:
void addEnergyCoefficient(volScalarField&) const {} void addEnergyCoefficient(volScalarField&) const {}
void calcEnergyContribution(); void calcEnergyContribution();
void postFlow(); void postFlow();
}; };

View File

@ -143,17 +143,25 @@ heatTransferGunn::heatTransferGunn
densityFieldName_(propsDict_.lookupOrDefault<word>("densityFieldName","rho")), densityFieldName_(propsDict_.lookupOrDefault<word>("densityFieldName","rho")),
rho_(sm.mesh().lookupObject<volScalarField> (densityFieldName_)), rho_(sm.mesh().lookupObject<volScalarField> (densityFieldName_)),
partTempName_(propsDict_.lookup("partTempName")), partTempName_(propsDict_.lookup("partTempName")),
partTemp_(NULL),
partHeatFluxName_(propsDict_.lookupOrDefault<word>("partHeatFluxName","convectiveHeatFlux")), partHeatFluxName_(propsDict_.lookupOrDefault<word>("partHeatFluxName","convectiveHeatFlux")),
partHeatFlux_(NULL), partHeatFluxCoeffRegName_(typeName + "partHeatFluxCoeff"),
partHeatFluxCoeff_(NULL), partReRegName_(typeName + "partRe"),
partRe_(NULL), partNuRegName_(typeName + "partNu"),
partNu_(NULL),
scaleDia_(1.), scaleDia_(1.),
typeCG_(propsDict_.lookupOrDefault<scalarList>("coarseGrainingFactors",scalarList(1,1.0))), typeCG_(propsDict_.lookupOrDefault<scalarList>("coarseGrainingFactors",scalarList(1,1.0))),
maxTypeCG_(typeCG_.size()) maxTypeCG_(typeCG_.size())
{ {
allocateMyArrays(); particleCloud_.registerParticleProperty<double**>(partTempName_,1);
particleCloud_.registerParticleProperty<double**>(partHeatFluxName_,1);
if (implicit_)
{
particleCloud_.registerParticleProperty<double**>(partHeatFluxCoeffRegName_,1);
}
if(verbose_)
{
particleCloud_.registerParticleProperty<double**>(partReRegName_,1);
particleCloud_.registerParticleProperty<double**>(partNuRegName_,1);
}
if (propsDict_.found("NusseltScalingFactor")) if (propsDict_.found("NusseltScalingFactor"))
{ {
@ -226,41 +234,16 @@ heatTransferGunn::heatTransferGunn
heatTransferGunn::~heatTransferGunn() heatTransferGunn::~heatTransferGunn()
{ {
particleCloud_.dataExchangeM().destroy(partTemp_,1);
particleCloud_.dataExchangeM().destroy(partHeatFlux_,1);
particleCloud_.dataExchangeM().destroy(partRe_,1);
particleCloud_.dataExchangeM().destroy(partNu_,1);
if (implicit_)
{
particleCloud_.dataExchangeM().destroy(partHeatFluxCoeff_,1);
}
} }
// * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * //
void heatTransferGunn::allocateMyArrays() const
{
// get memory for 2d arrays
double initVal=0.0;
particleCloud_.dataExchangeM().allocateArray(partTemp_,initVal,1); // field/initVal/with/lenghtFromLigghts
particleCloud_.dataExchangeM().allocateArray(partHeatFlux_,initVal,1);
if(implicit_)
{
particleCloud_.dataExchangeM().allocateArray(partHeatFluxCoeff_,initVal,1);
}
if(verbose_)
{
particleCloud_.dataExchangeM().allocateArray(partRe_,initVal,1);
particleCloud_.dataExchangeM().allocateArray(partNu_,initVal,1);
}
}
// * * * * * * * * * * * * * * * * Member Fct * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Member Fct * * * * * * * * * * * * * * * //
void heatTransferGunn::calcEnergyContribution() void heatTransferGunn::calcEnergyContribution()
{ {
// realloc the arrays double**& partTemp_ = particleCloud_.getParticlePropertyRef<double**>(partTempName_);
allocateMyArrays(); double**& partHeatFlux_ = particleCloud_.getParticlePropertyRef<double**>(partHeatFluxName_);
// reset Scalar field // reset Scalar field
QPartFluid_.primitiveFieldRef() = 0.0; QPartFluid_.primitiveFieldRef() = 0.0;
@ -387,6 +370,8 @@ void heatTransferGunn::calcEnergyContribution()
if(verbose_) if(verbose_)
{ {
double**& partRe_ = particleCloud_.getParticlePropertyRef<double**>(partReRegName_);
double**& partNu_ = particleCloud_.getParticlePropertyRef<double**>(partNuRegName_);
partRe_[index][0] = Rep; partRe_[index][0] = Rep;
partNu_[index][0] = Nup; partNu_[index][0] = Nup;
} }
@ -433,6 +418,7 @@ void heatTransferGunn::calcEnergyContribution()
if(implicit_) if(implicit_)
{ {
double**& partHeatFluxCoeff_ = particleCloud_.getParticlePropertyRef<double**>(partHeatFluxCoeffRegName_);
QPartFluidCoeff_.primitiveFieldRef() = 0.0; QPartFluidCoeff_.primitiveFieldRef() = 0.0;
particleCloud_.averagingM().setScalarSum particleCloud_.averagingM().setScalarSum
@ -448,6 +434,8 @@ void heatTransferGunn::calcEnergyContribution()
if(verbose_) if(verbose_)
{ {
double**& partRe_ = particleCloud_.getParticlePropertyRef<double**>(partReRegName_);
double**& partNu_ = particleCloud_.getParticlePropertyRef<double**>(partNuRegName_);
ReField_.primitiveFieldRef() = 0.0; ReField_.primitiveFieldRef() = 0.0;
NuField_.primitiveFieldRef() = 0.0; NuField_.primitiveFieldRef() = 0.0;
particleCloud_.averagingM().resetWeightFields(); particleCloud_.averagingM().resetWeightFields();
@ -515,6 +503,8 @@ scalar heatTransferGunn::Nusselt(scalar voidfraction, scalar Rep, scalar Pr) con
void heatTransferGunn::heatFlux(label index, scalar h, scalar As, scalar Tfluid, scalar cg3) void heatTransferGunn::heatFlux(label index, scalar h, scalar As, scalar Tfluid, scalar cg3)
{ {
scalar hAs = h * As * cg3; scalar hAs = h * As * cg3;
double**& partTemp_ = particleCloud_.getParticlePropertyRef<double**>(partTempName_);
double**& partHeatFlux_ = particleCloud_.getParticlePropertyRef<double**>(partHeatFluxName_);
if (particleCloud_.getParticleEffVolFactors()) if (particleCloud_.getParticleEffVolFactors())
{ {
@ -529,6 +519,7 @@ void heatTransferGunn::heatFlux(label index, scalar h, scalar As, scalar Tfluid,
} }
else else
{ {
double**& partHeatFluxCoeff_ = particleCloud_.getParticlePropertyRef<double**>(partHeatFluxCoeffRegName_);
partHeatFluxCoeff_[index][0] = hAs; partHeatFluxCoeff_[index][0] = hAs;
} }
} }
@ -541,6 +532,7 @@ void heatTransferGunn::giveData()
reduce(totalHeatFlux_, sumOp<scalar>()); reduce(totalHeatFlux_, sumOp<scalar>());
Info << "total convective particle-fluid heat flux [W] = " << totalHeatFlux_ << endl; Info << "total convective particle-fluid heat flux [W] = " << totalHeatFlux_ << endl;
} }
double**& partHeatFlux_ = particleCloud_.getParticlePropertyRef<double**>(partHeatFluxName_);
particleCloud_.dataExchangeM().giveData(partHeatFluxName_,"scalar-atom", partHeatFlux_); particleCloud_.dataExchangeM().giveData(partHeatFluxName_,"scalar-atom", partHeatFlux_);
} }
@ -552,6 +544,9 @@ void heatTransferGunn::postFlow()
scalar Tfluid(0.0); scalar Tfluid(0.0);
scalar Tpart(0.0); scalar Tpart(0.0);
interpolationCellPoint<scalar> TInterpolator_(tempField_); interpolationCellPoint<scalar> TInterpolator_(tempField_);
double**& partTemp_ = particleCloud_.getParticlePropertyRef<double**>(partTempName_);
double**& partHeatFlux_ = particleCloud_.getParticlePropertyRef<double**>(partHeatFluxName_);
double**& partHeatFluxCoeff_ = particleCloud_.getParticlePropertyRef<double**>(partHeatFluxCoeffRegName_);
totalHeatFlux_ = 0.0; totalHeatFlux_ = 0.0;
@ -585,6 +580,7 @@ void heatTransferGunn::postFlow()
void heatTransferGunn::partTempField() void heatTransferGunn::partTempField()
{ {
double**& partTemp_ = particleCloud_.getParticlePropertyRef<double**>(partTempName_);
partTempField_.primitiveFieldRef() = 0.0; partTempField_.primitiveFieldRef() = 0.0;
particleCloud_.averagingM().resetWeightFields(); particleCloud_.averagingM().resetWeightFields();
particleCloud_.averagingM().setScalarAverage particleCloud_.averagingM().setScalarAverage
@ -607,6 +603,8 @@ void heatTransferGunn::initPartTemp()
{ {
label cellI = 0; label cellI = 0;
scalar T = 0.0; scalar T = 0.0;
double**& partTemp_ = particleCloud_.getParticlePropertyRef<double**>(partTempName_);
for(int index = 0;index < particleCloud_.numberOfParticles(); ++index) for(int index = 0;index < particleCloud_.numberOfParticles(); ++index)
{ {
cellI = particleCloud_.cellIDs()[index][0]; cellI = particleCloud_.cellIDs()[index][0];

View File

@ -68,11 +68,11 @@ protected:
scalar NusseltScalingFactor_; scalar NusseltScalingFactor_;
word QPartFluidName_; const word QPartFluidName_;
volScalarField QPartFluid_; volScalarField QPartFluid_;
word QPartFluidCoeffName_; const word QPartFluidCoeffName_;
volScalarField QPartFluidCoeff_; volScalarField QPartFluidCoeff_;
@ -90,37 +90,33 @@ protected:
dimensionedScalar partTempAve_; dimensionedScalar partTempAve_;
word tempFieldName_; const word tempFieldName_;
const volScalarField& tempField_; // ref to temperature field const volScalarField& tempField_; // ref to temperature field
word voidfractionFieldName_; const word voidfractionFieldName_;
const volScalarField& voidfraction_; // ref to voidfraction field const volScalarField& voidfraction_; // ref to voidfraction field
scalar maxSource_; // max (limited) value of src field scalar maxSource_; // max (limited) value of src field
word velFieldName_; const word velFieldName_;
const volVectorField& U_; const volVectorField& U_;
word densityFieldName_; const word densityFieldName_;
const volScalarField& rho_; const volScalarField& rho_;
word partTempName_; const word partTempName_;
mutable double **partTemp_; const word partHeatFluxName_;
word partHeatFluxName_; const word partHeatFluxCoeffRegName_;
mutable double **partHeatFlux_; const word partReRegName_;
mutable double **partHeatFluxCoeff_; const word partNuRegName_;
mutable double **partRe_;
mutable double **partNu_;
mutable scalar scaleDia_; mutable scalar scaleDia_;
@ -128,8 +124,6 @@ protected:
const label maxTypeCG_; const label maxTypeCG_;
void allocateMyArrays() const;
void partTempField(); void partTempField();
scalar Nusselt(scalar, scalar, scalar) const; scalar Nusselt(scalar, scalar, scalar) const;

View File

@ -142,17 +142,25 @@ heatTransferRanzMarshall::heatTransferRanzMarshall
densityFieldName_(propsDict_.lookupOrDefault<word>("densityFieldName","rho")), densityFieldName_(propsDict_.lookupOrDefault<word>("densityFieldName","rho")),
rho_(sm.mesh().lookupObject<volScalarField> (densityFieldName_)), rho_(sm.mesh().lookupObject<volScalarField> (densityFieldName_)),
partTempName_(propsDict_.lookup("partTempName")), partTempName_(propsDict_.lookup("partTempName")),
partTemp_(NULL),
partHeatFluxName_(propsDict_.lookupOrDefault<word>("partHeatFluxName","convectiveHeatFlux")), partHeatFluxName_(propsDict_.lookupOrDefault<word>("partHeatFluxName","convectiveHeatFlux")),
partHeatFlux_(NULL), partHeatFluxCoeffRegName_(typeName + "partHeatFluxCoeff"),
partHeatFluxCoeff_(NULL), partReRegName_(typeName + "partRe"),
partRe_(NULL), partNuRegName_(typeName + "partNu"),
partNu_(NULL),
scaleDia_(1.), scaleDia_(1.),
typeCG_(propsDict_.lookupOrDefault<scalarList>("coarseGrainingFactors",scalarList(1,1.0))), typeCG_(propsDict_.lookupOrDefault<scalarList>("coarseGrainingFactors",scalarList(1,1.0))),
maxTypeCG_(typeCG_.size()) maxTypeCG_(typeCG_.size())
{ {
allocateMyArrays(); particleCloud_.registerParticleProperty<double**>(partTempName_,1);
particleCloud_.registerParticleProperty<double**>(partHeatFluxName_,1);
if (implicit_)
{
particleCloud_.registerParticleProperty<double**>(partHeatFluxCoeffRegName_,1);
}
if(verbose_)
{
particleCloud_.registerParticleProperty<double**>(partReRegName_,1);
particleCloud_.registerParticleProperty<double**>(partNuRegName_,1);
}
if (propsDict_.found("NusseltScalingFactor")) if (propsDict_.found("NusseltScalingFactor"))
{ {
@ -225,41 +233,16 @@ heatTransferRanzMarshall::heatTransferRanzMarshall
heatTransferRanzMarshall::~heatTransferRanzMarshall() heatTransferRanzMarshall::~heatTransferRanzMarshall()
{ {
particleCloud_.dataExchangeM().destroy(partTemp_,1);
particleCloud_.dataExchangeM().destroy(partHeatFlux_,1);
particleCloud_.dataExchangeM().destroy(partRe_,1);
particleCloud_.dataExchangeM().destroy(partNu_,1);
if (implicit_)
{
particleCloud_.dataExchangeM().destroy(partHeatFluxCoeff_,1);
}
} }
// * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * //
void heatTransferRanzMarshall::allocateMyArrays() const
{
// get memory for 2d arrays
double initVal=0.0;
particleCloud_.dataExchangeM().allocateArray(partTemp_,initVal,1); // field/initVal/with/lenghtFromLigghts
particleCloud_.dataExchangeM().allocateArray(partHeatFlux_,initVal,1);
if(implicit_)
{
particleCloud_.dataExchangeM().allocateArray(partHeatFluxCoeff_,initVal,1);
}
if(verbose_)
{
particleCloud_.dataExchangeM().allocateArray(partRe_,initVal,1);
particleCloud_.dataExchangeM().allocateArray(partNu_,initVal,1);
}
}
// * * * * * * * * * * * * * * * * Member Fct * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Member Fct * * * * * * * * * * * * * * * //
void heatTransferRanzMarshall::calcEnergyContribution() void heatTransferRanzMarshall::calcEnergyContribution()
{ {
// realloc the arrays double**& partTemp_ = particleCloud_.getParticlePropertyRef<double**>(partTempName_);
allocateMyArrays(); double**& partHeatFlux_ = particleCloud_.getParticlePropertyRef<double**>(partHeatFluxName_);
// reset Scalar field // reset Scalar field
QPartFluid_.primitiveFieldRef() = 0.0; QPartFluid_.primitiveFieldRef() = 0.0;
@ -387,6 +370,8 @@ void heatTransferRanzMarshall::calcEnergyContribution()
if(verbose_) if(verbose_)
{ {
double**& partRe_ = particleCloud_.getParticlePropertyRef<double**>(partReRegName_);
double**& partNu_ = particleCloud_.getParticlePropertyRef<double**>(partNuRegName_);
partRe_[index][0] = Rep; partRe_[index][0] = Rep;
partNu_[index][0] = Nup; partNu_[index][0] = Nup;
} }
@ -427,6 +412,7 @@ void heatTransferRanzMarshall::calcEnergyContribution()
if(implicit_) if(implicit_)
{ {
double**& partHeatFluxCoeff_ = particleCloud_.getParticlePropertyRef<double**>(partHeatFluxCoeffRegName_);
QPartFluidCoeff_.primitiveFieldRef() = 0.0; QPartFluidCoeff_.primitiveFieldRef() = 0.0;
particleCloud_.averagingM().setScalarSum particleCloud_.averagingM().setScalarSum
@ -442,6 +428,8 @@ void heatTransferRanzMarshall::calcEnergyContribution()
if(verbose_) if(verbose_)
{ {
double**& partRe_ = particleCloud_.getParticlePropertyRef<double**>(partReRegName_);
double**& partNu_ = particleCloud_.getParticlePropertyRef<double**>(partNuRegName_);
ReField_.primitiveFieldRef() = 0.0; ReField_.primitiveFieldRef() = 0.0;
NuField_.primitiveFieldRef() = 0.0; NuField_.primitiveFieldRef() = 0.0;
particleCloud_.averagingM().resetWeightFields(); particleCloud_.averagingM().resetWeightFields();
@ -503,8 +491,10 @@ scalar heatTransferRanzMarshall::Nusselt(scalar voidfraction, scalar Rep, scalar
void heatTransferRanzMarshall::heatFlux(label index, scalar h, scalar As, scalar Tfluid, scalar cg3) void heatTransferRanzMarshall::heatFlux(label index, scalar h, scalar As, scalar Tfluid, scalar cg3)
{ {
scalar hAs = h * As * cg3; scalar hAs = h * As * cg3;
double**& partTemp_ = particleCloud_.getParticlePropertyRef<double**>(partTempName_);
double**& partHeatFlux_ = particleCloud_.getParticlePropertyRef<double**>(partHeatFluxName_);
if (particleCloud_.getParticleEffVolFactors()) if (particleCloud_.getParticleEffVolFactors())
{ {
scalar effVolFac = particleCloud_.particleEffVolFactor(index); scalar effVolFac = particleCloud_.particleEffVolFactor(index);
hAs *= effVolFac; hAs *= effVolFac;
@ -517,6 +507,7 @@ void heatTransferRanzMarshall::heatFlux(label index, scalar h, scalar As, scalar
} }
else else
{ {
double**& partHeatFluxCoeff_ = particleCloud_.getParticlePropertyRef<double**>(partHeatFluxCoeffRegName_);
partHeatFluxCoeff_[index][0] = hAs; partHeatFluxCoeff_[index][0] = hAs;
} }
} }
@ -529,6 +520,7 @@ void heatTransferRanzMarshall::giveData()
reduce(totalHeatFlux_, sumOp<scalar>()); reduce(totalHeatFlux_, sumOp<scalar>());
Info << "total convective particle-fluid heat flux [W] = " << totalHeatFlux_ << endl; Info << "total convective particle-fluid heat flux [W] = " << totalHeatFlux_ << endl;
} }
double**& partHeatFlux_ = particleCloud_.getParticlePropertyRef<double**>(partHeatFluxName_);
particleCloud_.dataExchangeM().giveData(partHeatFluxName_,"scalar-atom", partHeatFlux_); particleCloud_.dataExchangeM().giveData(partHeatFluxName_,"scalar-atom", partHeatFlux_);
} }
@ -540,6 +532,9 @@ void heatTransferRanzMarshall::postFlow()
scalar Tfluid(0.0); scalar Tfluid(0.0);
scalar Tpart(0.0); scalar Tpart(0.0);
interpolationCellPoint<scalar> TInterpolator_(tempField_); interpolationCellPoint<scalar> TInterpolator_(tempField_);
double**& partTemp_ = particleCloud_.getParticlePropertyRef<double**>(partTempName_);
double**& partHeatFlux_ = particleCloud_.getParticlePropertyRef<double**>(partHeatFluxName_);
double**& partHeatFluxCoeff_ = particleCloud_.getParticlePropertyRef<double**>(partHeatFluxCoeffRegName_);
totalHeatFlux_ = 0.0; totalHeatFlux_ = 0.0;
@ -573,6 +568,7 @@ void heatTransferRanzMarshall::postFlow()
void heatTransferRanzMarshall::partTempField() void heatTransferRanzMarshall::partTempField()
{ {
double**& partTemp_ = particleCloud_.getParticlePropertyRef<double**>(partTempName_);
partTempField_.primitiveFieldRef() = 0.0; partTempField_.primitiveFieldRef() = 0.0;
particleCloud_.averagingM().resetWeightFields(); particleCloud_.averagingM().resetWeightFields();
particleCloud_.averagingM().setScalarAverage particleCloud_.averagingM().setScalarAverage
@ -595,6 +591,8 @@ void heatTransferRanzMarshall::initPartTemp()
{ {
label cellI = 0; label cellI = 0;
scalar T = 0.0; scalar T = 0.0;
double**& partTemp_ = particleCloud_.getParticlePropertyRef<double**>(partTempName_);
for(int index = 0;index < particleCloud_.numberOfParticles(); ++index) for(int index = 0;index < particleCloud_.numberOfParticles(); ++index)
{ {
cellI = particleCloud_.cellIDs()[index][0]; cellI = particleCloud_.cellIDs()[index][0];

View File

@ -67,11 +67,11 @@ protected:
scalar NusseltScalingFactor_; scalar NusseltScalingFactor_;
word QPartFluidName_; const word QPartFluidName_;
volScalarField QPartFluid_; volScalarField QPartFluid_;
word QPartFluidCoeffName_; const word QPartFluidCoeffName_;
volScalarField QPartFluidCoeff_; volScalarField QPartFluidCoeff_;
@ -89,37 +89,33 @@ protected:
dimensionedScalar partTempAve_; dimensionedScalar partTempAve_;
word tempFieldName_; const word tempFieldName_;
const volScalarField& tempField_; // ref to temperature field const volScalarField& tempField_; // ref to temperature field
word voidfractionFieldName_; const word voidfractionFieldName_;
const volScalarField& voidfraction_; // ref to voidfraction field const volScalarField& voidfraction_; // ref to voidfraction field
scalar maxSource_; // max (limited) value of src field scalar maxSource_; // max (limited) value of src field
word velFieldName_; const word velFieldName_;
const volVectorField& U_; const volVectorField& U_;
word densityFieldName_; const word densityFieldName_;
const volScalarField& rho_; const volScalarField& rho_;
word partTempName_; const word partTempName_;
mutable double **partTemp_; const word partHeatFluxName_;
word partHeatFluxName_; const word partHeatFluxCoeffRegName_;
mutable double **partHeatFlux_; const word partReRegName_;
mutable double **partHeatFluxCoeff_; const word partNuRegName_;
mutable double **partRe_;
mutable double **partNu_;
mutable scalar scaleDia_; mutable scalar scaleDia_;
@ -127,8 +123,6 @@ protected:
const label maxTypeCG_; const label maxTypeCG_;
void allocateMyArrays() const;
void partTempField(); void partTempField();
scalar Nusselt(scalar, scalar, scalar) const; scalar Nusselt(scalar, scalar, scalar) const;
@ -163,11 +157,11 @@ public:
void addEnergyContribution(volScalarField&) const; void addEnergyContribution(volScalarField&) const;
void addEnergyCoefficient(volScalarField&) const; void addEnergyCoefficient(volScalarField&) const;
void calcEnergyContribution(); void calcEnergyContribution();
void postFlow(); void postFlow();
}; };

View File

@ -50,7 +50,6 @@ reactionHeat::reactionHeat
mesh_(sm.mesh()), mesh_(sm.mesh()),
maxSource_(1e30), maxSource_(1e30),
reactionHeatName_(propsDict_.lookupOrDefault<word>("reactionHeatName","reactionHeat")), reactionHeatName_(propsDict_.lookupOrDefault<word>("reactionHeatName","reactionHeat")),
reactionHeat_(NULL),
reactionHeatField_ reactionHeatField_
( (
IOobject IOobject
@ -65,7 +64,7 @@ reactionHeat::reactionHeat
dimensionedScalar("zero", dimensionSet(1,-1,-3,0,0,0,0),0.0) dimensionedScalar("zero", dimensionSet(1,-1,-3,0,0,0,0),0.0)
) )
{ {
allocateMyArrays(); particleCloud_.registerParticleProperty<double**>(reactionHeatName_,1);
if(propsDict_.found("maxsource")) if(propsDict_.found("maxsource"))
{ {
@ -79,23 +78,15 @@ reactionHeat::reactionHeat
reactionHeat::~reactionHeat() reactionHeat::~reactionHeat()
{ {
particleCloud_.dataExchangeM().destroy(reactionHeat_,1);
} }
// * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * //
void reactionHeat::allocateMyArrays() const
{
// get memory for 2d arrays
double initVal=0.0;
particleCloud_.dataExchangeM().allocateArray(reactionHeat_,initVal,1);
}
// * * * * * * * * * * * * * * * * Member Fct * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Member Fct * * * * * * * * * * * * * * * //
void reactionHeat::calcEnergyContribution() void reactionHeat::calcEnergyContribution()
{ {
// realloc the arrays double**& reactionHeat_ = particleCloud_.getParticlePropertyRef<double**>(reactionHeatName_);
allocateMyArrays();
particleCloud_.dataExchangeM().getData(reactionHeatName_,"scalar-atom",reactionHeat_); particleCloud_.dataExchangeM().getData(reactionHeatName_,"scalar-atom",reactionHeat_);

View File

@ -56,12 +56,8 @@ protected:
word reactionHeatName_; word reactionHeatName_;
mutable double **reactionHeat_;
volScalarField reactionHeatField_; volScalarField reactionHeatField_;
void allocateMyArrays() const;
public: public:
//- Runtime type information //- Runtime type information

View File

@ -74,8 +74,8 @@ KochHillRWDrag::KochHillRWDrag
interpolation_(propsDict_.found("interpolation")), interpolation_(propsDict_.found("interpolation")),
scale_(1.), scale_(1.),
randomTauE_(propsDict_.found("randomTauE")), randomTauE_(propsDict_.found("randomTauE")),
partTime_(NULL), partTimeRegName_(typeName + "partTime"),
partUfluct_(NULL), partUfluctRegName_(typeName + "partUfluct"),
RanGen_(label(0)) RanGen_(label(0))
{ {
@ -99,16 +99,8 @@ KochHillRWDrag::KochHillRWDrag
if (propsDict_.found("rhoP")) if (propsDict_.found("rhoP"))
rhoP_= readScalar(propsDict_.lookup("rhoP")); rhoP_= readScalar(propsDict_.lookup("rhoP"));
particleCloud_.registerParticleProperty<double**>(partTimeRegName_,1,0.0,false);
// if (particleCloud_.dataExchangeM().maxNumberOfParticles() > 0) particleCloud_.registerParticleProperty<double**>(partUfluctRegName_,3,0.0,false);
// {
//allocate memory
particleCloud_.dataExchangeM().allocateArray(partTime_,0.,1);
particleCloud_.dataExchangeM().allocateArray(partUfluct_,0.,3);
// }
//Pout << "RW-TEST: maxNumberOfParticles() == " << particleCloud_.dataExchangeM().maxNumberOfParticles() << endl; // TEST-Output
} }
@ -116,18 +108,12 @@ KochHillRWDrag::KochHillRWDrag
KochHillRWDrag::~KochHillRWDrag() KochHillRWDrag::~KochHillRWDrag()
{ {
particleCloud_.dataExchangeM().destroy(partTime_, 1);
particleCloud_.dataExchangeM().destroy(partUfluct_, 3);
} }
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void KochHillRWDrag::setForce() const void KochHillRWDrag::setForce() const
{ {
// realloc the arrays
reAllocArrays();
if (scale_ > 1.0) if (scale_ > 1.0)
{ {
Info << "KochHillRW using scale = " << scale_ << endl; Info << "KochHillRW using scale = " << scale_ << endl;
@ -189,6 +175,9 @@ void KochHillRWDrag::setForce() const
interpolationCellPoint<scalar> voidfractionInterpolator_(voidfraction_); interpolationCellPoint<scalar> voidfractionInterpolator_(voidfraction_);
interpolationCellPoint<vector> UInterpolator_(U_); interpolationCellPoint<vector> UInterpolator_(U_);
double**& partTime_ = particleCloud_.getParticlePropertyRef<double**>(partTimeRegName_);
double**& partUfluct_ = particleCloud_.getParticlePropertyRef<double**>(partUfluctRegName_);
//Info << "RW-TEST: We are in setForce() at t = " << t << endl; // TEST-Output //Info << "RW-TEST: We are in setForce() at t = " << t << endl; // TEST-Output
for (int index = 0; index<particleCloud_.numberOfParticles(); ++index) for (int index = 0; index<particleCloud_.numberOfParticles(); ++index)
@ -382,16 +371,6 @@ void KochHillRWDrag::setForce() const
} }
void KochHillRWDrag::reAllocArrays() const
{
if (particleCloud_.numberOfParticlesChanged())
{
particleCloud_.dataExchangeM().allocateArray(partTime_,0.0,1); // field/initVal/with/lenghtFromLigghts
particleCloud_.dataExchangeM().allocateArray(partUfluct_,0.0,3);
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam } // End namespace Foam

View File

@ -89,9 +89,9 @@ private:
const bool randomTauE_; const bool randomTauE_;
mutable double **partTime_; // Lagrangian array const word partTimeRegName_;
mutable double **partUfluct_; // Lagrangian array const word partUfluctRegName_;
mutable Random RanGen_; mutable Random RanGen_;
@ -117,8 +117,6 @@ public:
// Member Functions // Member Functions
void setForce() const; void setForce() const;
void reAllocArrays() const;
}; };

View File

@ -71,14 +71,10 @@ LaEuScalarTemp::LaEuScalarTemp
velFieldName_(propsDict_.lookup("velFieldName")), velFieldName_(propsDict_.lookup("velFieldName")),
U_(sm.mesh().lookupObject<volVectorField> (velFieldName_)), U_(sm.mesh().lookupObject<volVectorField> (velFieldName_)),
partTempName_(propsDict_.lookup("partTempName")), partTempName_(propsDict_.lookup("partTempName")),
partTemp_(NULL),
partHeatFluxName_(propsDict_.lookup("partHeatFluxName")), partHeatFluxName_(propsDict_.lookup("partHeatFluxName")),
partHeatFlux_(NULL),
lambda_(readScalar(propsDict_.lookup("lambda"))), lambda_(readScalar(propsDict_.lookup("lambda"))),
Cp_(readScalar(propsDict_.lookup("Cp"))) Cp_(readScalar(propsDict_.lookup("Cp")))
{ {
allocateMyArrays();
if (propsDict_.found("maxSource")) if (propsDict_.found("maxSource"))
{ {
maxSource_=readScalar(propsDict_.lookup ("maxSource")); maxSource_=readScalar(propsDict_.lookup ("maxSource"));
@ -96,8 +92,10 @@ LaEuScalarTemp::LaEuScalarTemp
// read those switches defined above, if provided in dict // read those switches defined above, if provided in dict
forceSubM(0).readSwitches(); forceSubM(0).readSwitches();
particleCloud_.checkCG(false); particleCloud_.checkCG(false);
particleCloud_.registerParticleProperty<double**>(partTempName_);
particleCloud_.registerParticleProperty<double**>(partHeatFluxName_);
} }
@ -105,8 +103,6 @@ LaEuScalarTemp::LaEuScalarTemp
LaEuScalarTemp::~LaEuScalarTemp() LaEuScalarTemp::~LaEuScalarTemp()
{ {
particleCloud_.dataExchangeM().destroy(partTemp_,1);
particleCloud_.dataExchangeM().destroy(partHeatFlux_,1);
} }
// * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * //
@ -114,6 +110,9 @@ void LaEuScalarTemp::allocateMyArrays() const
{ {
// get memory for 2d arrays // get memory for 2d arrays
double initVal = 0.0; 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(partTemp_,initVal,1); // field/initVal/with/lenghtFromLigghts
particleCloud_.dataExchangeM().allocateArray(partHeatFlux_,initVal,1); particleCloud_.dataExchangeM().allocateArray(partHeatFlux_,initVal,1);
} }
@ -128,6 +127,8 @@ void LaEuScalarTemp::manipulateScalarField(volScalarField& EuField) const
{ {
// realloc the arrays // realloc the arrays
allocateMyArrays(); allocateMyArrays();
double**& partTemp_ = particleCloud_.getParticlePropertyRef<double**>(partTempName_);
double**& partHeatFlux_ = particleCloud_.getParticlePropertyRef<double**>(partHeatFluxName_);
// reset Scalar field // reset Scalar field
EuField.primitiveFieldRef() = 0.0; EuField.primitiveFieldRef() = 0.0;

View File

@ -81,12 +81,8 @@ private:
word partTempName_; word partTempName_;
mutable double **partTemp_; // Lagrangian array
word partHeatFluxName_; word partHeatFluxName_;
mutable double **partHeatFlux_; // Lagrangian array
scalar lambda_; // fluid thermal conductivity [W/(m*K)] scalar lambda_; // fluid thermal conductivity [W/(m*K)]
scalar Cp_; // specific heat capacity [W*s/(kg*K)] scalar Cp_; // specific heat capacity [W*s/(kg*K)]

View File

@ -54,8 +54,8 @@ dSauter::dSauter
forceModel(dict,sm), forceModel(dict,sm),
propsDict_(dict.subDict(typeName + "Props")), propsDict_(dict.subDict(typeName + "Props")),
multiTypes_(false), multiTypes_(false),
d2_(NULL), d2RegName_(typeName + "d2"),
d3_(NULL), d3RegName_(typeName + "d3"),
maxTypeCG_(1), maxTypeCG_(1),
typeCG_(propsDict_.lookupOrDefault<scalarList>("coarseGrainingFactors",scalarList(1,1.0))), typeCG_(propsDict_.lookupOrDefault<scalarList>("coarseGrainingFactors",scalarList(1,1.0))),
d2Field_ d2Field_
@ -101,9 +101,11 @@ dSauter::dSauter
multiTypes_ = true; multiTypes_ = true;
maxTypeCG_ = typeCG_.size(); maxTypeCG_ = typeCG_.size();
} }
allocateMyArrays();
dSauter_.write();
particleCloud_.registerParticleProperty<double**>(d2RegName_,1);
particleCloud_.registerParticleProperty<double**>(d3RegName_,1);
dSauter_.write();
// init force sub model // init force sub model
setForceSubModels(propsDict_); setForceSubModels(propsDict_);
@ -114,19 +116,10 @@ dSauter::dSauter
dSauter::~dSauter() dSauter::~dSauter()
{ {
particleCloud_.dataExchangeM().destroy(d2_,1);
particleCloud_.dataExchangeM().destroy(d3_,1);
} }
// * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * //
void dSauter::allocateMyArrays() const
{
// get memory for 2d arrays
double initVal = 0.0;
particleCloud_.dataExchangeM().allocateArray(d2_,initVal,1); // field/initVal/with/lenghtFromLigghts
particleCloud_.dataExchangeM().allocateArray(d3_,initVal,1);
}
// * * * * * * * * * * * * * * * public Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * public Member Functions * * * * * * * * * * * * * //
@ -137,7 +130,8 @@ void dSauter::setForce() const
Info << "dSauter using CG factor(s) = " << typeCG_ << endl; Info << "dSauter using CG factor(s) = " << typeCG_ << endl;
} }
allocateMyArrays(); double**& d2_ = particleCloud_.getParticlePropertyRef<double**>(d2RegName_);
double**& d3_ = particleCloud_.getParticlePropertyRef<double**>(d3RegName_);
label cellI = 0; label cellI = 0;
label partType = 1; label partType = 1;
@ -151,11 +145,11 @@ void dSauter::setForce() const
cellI = particleCloud_.cellIDs()[index][0]; cellI = particleCloud_.cellIDs()[index][0];
if (cellI >= 0) if (cellI >= 0)
{ {
if (particleCloud_.getParticleEffVolFactors()) if (particleCloud_.getParticleEffVolFactors())
{ {
effVolFac = particleCloud_.particleEffVolFactor(index); effVolFac = particleCloud_.particleEffVolFactor(index);
} }
if (multiTypes_) if (multiTypes_)
{ {
partType = particleCloud_.particleType(index); partType = particleCloud_.particleType(index);
if (partType > maxTypeCG_) if (partType > maxTypeCG_)

View File

@ -45,21 +45,19 @@ private:
bool multiTypes_; bool multiTypes_;
mutable double **d2_; const word d2RegName_;
mutable double **d3_; const word d3RegName_;
label maxTypeCG_; label maxTypeCG_;
scalarList typeCG_; scalarList typeCG_;
mutable volScalarField d2Field_;
mutable volScalarField d3Field_;
mutable volScalarField dSauter_;
void allocateMyArrays() const; mutable volScalarField d2Field_;
mutable volScalarField d3Field_;
mutable volScalarField dSauter_;
public: public:

View File

@ -53,7 +53,7 @@ granKineticEnergy::granKineticEnergy
: :
forceModel(dict,sm), forceModel(dict,sm),
propsDict_(dict.subDict(typeName + "Props")), propsDict_(dict.subDict(typeName + "Props")),
vfluc_(NULL), vflucRegName_(typeName + "vfluc_mag"),
UsFieldName_(propsDict_.lookup("granVelFieldName")), UsFieldName_(propsDict_.lookup("granVelFieldName")),
UsField_(sm.mesh().lookupObject<volVectorField> (UsFieldName_)), UsField_(sm.mesh().lookupObject<volVectorField> (UsFieldName_)),
granKineticEnergy_ granKineticEnergy_
@ -70,7 +70,7 @@ granKineticEnergy::granKineticEnergy
"zeroGradient" "zeroGradient"
) )
{ {
allocateMyArrays(); particleCloud_.registerParticleProperty<double**>(vflucRegName_,1);
granKineticEnergy_.write(); granKineticEnergy_.write();
@ -82,21 +82,14 @@ granKineticEnergy::granKineticEnergy
granKineticEnergy::~granKineticEnergy() granKineticEnergy::~granKineticEnergy()
{ {
particleCloud_.dataExchangeM().destroy(vfluc_,1);
} }
// * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * //
void granKineticEnergy::allocateMyArrays() const
{
// get memory for 2d arrays
double initVal = 0.0;
particleCloud_.dataExchangeM().allocateArray(vfluc_,initVal,1);
}
// * * * * * * * * * * * * * * * public Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * public Member Functions * * * * * * * * * * * * * //
void granKineticEnergy::setForce() const void granKineticEnergy::setForce() const
{ {
allocateMyArrays(); double**& vfluc_ = particleCloud_.getParticlePropertyRef<double**>(vflucRegName_);
label cellI = 0; label cellI = 0;
vector velfluc(0,0,0); vector velfluc(0,0,0);

View File

@ -43,16 +43,14 @@ private:
dictionary propsDict_; dictionary propsDict_;
mutable double **vfluc_; const word vflucRegName_;
word UsFieldName_; const word UsFieldName_;
const volVectorField& UsField_; const volVectorField& UsField_;
mutable volScalarField granKineticEnergy_; mutable volScalarField granKineticEnergy_;
void allocateMyArrays() const;
public: public:
//- Runtime type information //- Runtime type information

View File

@ -60,9 +60,9 @@ particleDeformation::particleDeformation
partTypes_(propsDict_.lookupOrDefault<labelList>("partTypes",labelList(1,-1))), partTypes_(propsDict_.lookupOrDefault<labelList>("partTypes",labelList(1,-1))),
lowerBounds_(propsDict_.lookupOrDefault<scalarList>("lowerBounds",scalarList(1,-1.0))), lowerBounds_(propsDict_.lookupOrDefault<scalarList>("lowerBounds",scalarList(1,-1.0))),
upperBounds_(propsDict_.lookupOrDefault<scalarList>("upperBounds",scalarList(1,-1.0))), upperBounds_(propsDict_.lookupOrDefault<scalarList>("upperBounds",scalarList(1,-1.0))),
partDeformations_(NULL) partDeformationsName_("partDeformations")
{ {
allocateMyArrays(); particleCloud_.registerParticleProperty<double**>(partDeformationsName_,1);
// init force sub model // init force sub model
setForceSubModels(propsDict_); setForceSubModels(propsDict_);
@ -120,16 +120,9 @@ particleDeformation::particleDeformation
particleDeformation::~particleDeformation() particleDeformation::~particleDeformation()
{ {
particleCloud_.dataExchangeM().destroy(partDeformations_,1);
} }
// * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * //
void particleDeformation::allocateMyArrays() const
{
// get memory for 2d arrays
double initVal = 0.0;
particleCloud_.dataExchangeM().allocateArray(partDeformations_,initVal,1);
}
bool particleDeformation::defaultDeformCell(label cell) const bool particleDeformation::defaultDeformCell(label cell) const
{ {
@ -145,8 +138,8 @@ void particleDeformation::setForce() const
init(); init();
initialExec_ = false; initialExec_ = false;
} }
// realloc the arrays
allocateMyArrays(); double**& partDeformations_ = particleCloud_.getParticlePropertyRef<double**>(partDeformationsName_);
label cellI = 0; label cellI = 0;
label partType = -1; label partType = -1;
@ -204,7 +197,7 @@ void particleDeformation::setForce() const
} }
// give DEM data // give DEM data
particleCloud_.dataExchangeM().giveData("partDeformations","scalar-atom", partDeformations_); particleCloud_.dataExchangeM().giveData(partDeformationsName_,"scalar-atom", partDeformations_);
} }
void particleDeformation::init() const void particleDeformation::init() const

View File

@ -55,12 +55,12 @@ private:
mutable bool initialExec_; mutable bool initialExec_;
word refFieldName_; const word refFieldName_;
mutable autoPtr<volScalarField> refField_; mutable autoPtr<volScalarField> refField_;
// default deformation in region // default deformation in region
word defaultDeformCellsName_; const word defaultDeformCellsName_;
autoPtr<cellSet> defaultDeformCells_; autoPtr<cellSet> defaultDeformCells_;
@ -74,12 +74,10 @@ private:
scalarList upperBounds_; scalarList upperBounds_;
mutable double **partDeformations_; const word partDeformationsName_;
label getListIndex(label) const; label getListIndex(label) const;
void allocateMyArrays() const;
void init() const; void init() const;
bool defaultDeformCell(label) const; bool defaultDeformCell(label) const;

View File

@ -18,7 +18,7 @@ SourceFiles
pdCorrelation.C pdCorrelation.C
Contributing Author Contributing Author
2018 Paul Kieckhefen, TUHH 2018 Paul Kieckhefen, TUHH
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "error.H" #include "error.H"
@ -55,11 +55,11 @@ pdCorrelation::pdCorrelation
: :
forceModel(dict,sm), forceModel(dict,sm),
propsDict_(dict.subDict(typeName + "Props")), propsDict_(dict.subDict(typeName + "Props")),
d_(nullptr), dRegName_(typeName + "d"),
p_(nullptr), pRegName_(typeName + "p"),
d2_(nullptr), d2RegName_(typeName + "d2"),
pd_(nullptr), pdRegName_(typeName + "pd"),
cg3_(nullptr), cg3RegName_(typeName + "cg3"),
dField_ dField_
( IOobject ( IOobject
( (
@ -151,7 +151,11 @@ pdCorrelation::pdCorrelation
<< abort(FatalError); << abort(FatalError);
} }
allocateMyArrays(); particleCloud_.registerParticleProperty<double**>(dRegName_,1);
particleCloud_.registerParticleProperty<double**>(pRegName_,3);
particleCloud_.registerParticleProperty<double**>(d2RegName_,1);
particleCloud_.registerParticleProperty<double**>(pdRegName_,3);
particleCloud_.registerParticleProperty<double**>(cg3RegName_,1);
dField_.write(); dField_.write();
pdField_.write(); pdField_.write();
@ -165,24 +169,9 @@ pdCorrelation::pdCorrelation
pdCorrelation::~pdCorrelation() pdCorrelation::~pdCorrelation()
{ {
particleCloud_.dataExchangeM().destroy(cg3_, 1);
particleCloud_.dataExchangeM().destroy(d_, 1);
particleCloud_.dataExchangeM().destroy(p_, 3);
particleCloud_.dataExchangeM().destroy(d2_, 1);
particleCloud_.dataExchangeM().destroy(pd_, 3);
} }
// * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * //
void pdCorrelation::allocateMyArrays() const
{
// get memory for 2d arrays
double initVal = 0.0;
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 * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * public Member Functions * * * * * * * * * * * * * //
void pdCorrelation::setForce() const void pdCorrelation::setForce() const
@ -191,7 +180,11 @@ void pdCorrelation::setForce() const
if (runOnWriteOnly_ && !mesh.write()) return; // skip if it's not write time if (runOnWriteOnly_ && !mesh.write()) return; // skip if it's not write time
allocateMyArrays(); double**& d_ = particleCloud_.getParticlePropertyRef<double**>(dRegName_);
double**& p_ = particleCloud_.getParticlePropertyRef<double**>(pRegName_);
double**& d2_ = particleCloud_.getParticlePropertyRef<double**>(d2RegName_);
double**& pd_ = particleCloud_.getParticlePropertyRef<double**>(pdRegName_);
double**& cg3_ = particleCloud_.getParticlePropertyRef<double**>(cg3RegName_);
const Switch densityFromList const Switch densityFromList
( (

View File

@ -45,11 +45,11 @@ private:
dictionary propsDict_; dictionary propsDict_;
mutable double **d_; const word dRegName_;
mutable double **p_; const word pRegName_;
mutable double **d2_; const word d2RegName_;
mutable double **pd_; const word pdRegName_;
mutable double **cg3_; const word cg3RegName_;
mutable volScalarField dField_; mutable volScalarField dField_;
mutable volVectorField pField_; mutable volVectorField pField_;
@ -65,8 +65,6 @@ private:
const Switch CG_; const Switch CG_;
const Switch runOnWriteOnly_; const Switch runOnWriteOnly_;
void allocateMyArrays() const;
public: public:
//- Runtime type information //- Runtime type information

View File

@ -1,6 +1,6 @@
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
CFDEMcoupling academic - Open Source CFD-DEM coupling CFDEMcoupling academic - Open Source CFD-DEM coupling
Contributing authors: Contributing authors:
Thomas Lichtenegger Thomas Lichtenegger
Copyright (C) 2015- Johannes Kepler University, Linz Copyright (C) 2015- Johannes Kepler University, Linz
@ -83,10 +83,10 @@ potentialRelaxation::potentialRelaxation
ignoreReg_(propsDict_.lookupOrDefault<bool>("ignoreRegion",false)), ignoreReg_(propsDict_.lookupOrDefault<bool>("ignoreRegion",false)),
ignoreDirection_(propsDict_.lookupOrDefault<vector>("ignoreDirection",vector::zero)), ignoreDirection_(propsDict_.lookupOrDefault<vector>("ignoreDirection",vector::zero)),
ignorePoint_(propsDict_.lookupOrDefault<vector>("ignorePoint",vector::zero)), ignorePoint_(propsDict_.lookupOrDefault<vector>("ignorePoint",vector::zero)),
vfluc_(NULL) vflucName_("vfluc")
{ {
allocateMyArrays(); particleCloud_.registerParticleProperty<double**>(vflucName_,3);
if(ignoreReg_) if(ignoreReg_)
{ {
if(mag(ignoreDirection_) < SMALL) if(mag(ignoreDirection_) < SMALL)
@ -103,48 +103,39 @@ potentialRelaxation::potentialRelaxation
potentialRelaxation::~potentialRelaxation() potentialRelaxation::~potentialRelaxation()
{ {
delete vfluc_;
} }
// * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * //
void potentialRelaxation::allocateMyArrays() const
{
// get memory for 2d arrays
double initVal=0.0;
particleCloud_.dataExchangeM().allocateArray(vfluc_,initVal,3);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void potentialRelaxation::setForce() const void potentialRelaxation::setForce() const
{ {
relax(D0_,D1_); relax(D0_,D1_);
volVectorField relaxStream = -fvc::grad(correctedField_); volVectorField relaxStream = -fvc::grad(correctedField_);
// volVectorField relaxStream = DField_ * fvc::grad(voidfraction_ - voidfractionRec_); // volVectorField relaxStream = DField_ * fvc::grad(voidfraction_ - voidfractionRec_);
// realloc the arrays double**& vfluc_ = particleCloud_.getParticlePropertyRef<double**>(vflucName_);
allocateMyArrays();
vector position(0,0,0); vector position(0,0,0);
scalar voidfraction(0.0); scalar voidfraction(0.0);
vector flucU(0,0,0); vector flucU(0,0,0);
label cellI=0; label cellI=0;
interpolationCellPoint<scalar> voidfractionInterpolator_(voidfraction_); interpolationCellPoint<scalar> voidfractionInterpolator_(voidfraction_);
interpolationCellPoint<vector> relaxStreamInterpolator_(relaxStream); interpolationCellPoint<vector> relaxStreamInterpolator_(relaxStream);
scalar dtDEM = particleCloud_.dataExchangeM().DEMts(); scalar dtDEM = particleCloud_.dataExchangeM().DEMts();
scalar dtCFD = voidfraction_.mesh().time().deltaTValue(); scalar dtCFD = voidfraction_.mesh().time().deltaTValue();
// if DEM time step > CFD time step, scale velocity down // if DEM time step > CFD time step, scale velocity down
scalar timeFac = 1.0; scalar timeFac = 1.0;
if (dtDEM > dtCFD) timeFac = dtCFD / dtDEM; if (dtDEM > dtCFD) timeFac = dtCFD / dtDEM;
for(int index = 0;index < particleCloud_.numberOfParticles(); ++index) for(int index = 0;index < particleCloud_.numberOfParticles(); ++index)
{ {
cellI = particleCloud_.cellIDs()[index][0]; cellI = particleCloud_.cellIDs()[index][0];
@ -164,18 +155,18 @@ void potentialRelaxation::setForce() const
{ {
position = particleCloud_.position(index); position = particleCloud_.position(index);
voidfraction = voidfractionInterpolator_.interpolate(position,cellI); voidfraction = voidfractionInterpolator_.interpolate(position,cellI);
flucU = relaxStreamInterpolator_.interpolate(position,cellI); flucU = relaxStreamInterpolator_.interpolate(position,cellI);
} }
else else
{ {
voidfraction = voidfraction_[cellI]; voidfraction = voidfraction_[cellI];
flucU = relaxStream[cellI]; flucU = relaxStream[cellI];
} }
if (voidfraction > 1.0-SMALL) voidfraction = 1.0 - SMALL; if (voidfraction > 1.0-SMALL) voidfraction = 1.0 - SMALL;
flucU /= (1-voidfraction); flucU /= (1-voidfraction);
flucU *= timeFac; flucU *= timeFac;
// write particle based data to global array // write particle based data to global array
for(int i = 0; i < 3; i++) for(int i = 0; i < 3; i++)
{ {
vfluc_[index][i]=flucU[i]; vfluc_[index][i]=flucU[i];
@ -183,13 +174,13 @@ void potentialRelaxation::setForce() const
} }
} }
} }
particleCloud_.dataExchangeM().giveData("vfluc","vector-atom", vfluc_); particleCloud_.dataExchangeM().giveData(vflucName_,"vector-atom", vfluc_);
if (measureDiff_) if (measureDiff_)
{ {
dimensionedScalar diff( fvc::domainIntegrate( sqr( voidfraction_ - voidfractionRec_ ) ) ); dimensionedScalar diff( fvc::domainIntegrate( sqr( voidfraction_ - voidfractionRec_ ) ) );
scalar t = particleCloud_.mesh().time().timeOutputValue(); scalar t = particleCloud_.mesh().time().timeOutputValue();
recErrorFile_ << t << "\t" << diff.value() << endl; recErrorFile_ << t << "\t" << diff.value() << endl;
} }
} }
@ -198,12 +189,12 @@ void potentialRelaxation::relax(scalar D0, scalar D1) const
{ {
volScalarField src0 = voidfraction_ - voidfractionRec_; volScalarField src0 = voidfraction_ - voidfractionRec_;
volScalarField src1 = voidfraction_ - voidfractionRec_; volScalarField src1 = voidfraction_ - voidfractionRec_;
forAll(src1, cellI) forAll(src1, cellI)
{ {
if(src1[cellI] > 0.0) src1[cellI] = 0.0; if(src1[cellI] > 0.0) src1[cellI] = 0.0;
} }
solve solve
( (
fvm::laplacian(correctedField_) fvm::laplacian(correctedField_)

View File

@ -1,6 +1,6 @@
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
CFDEMcoupling academic - Open Source CFD-DEM coupling CFDEMcoupling academic - Open Source CFD-DEM coupling
Contributing authors: Contributing authors:
Thomas Lichtenegger Thomas Lichtenegger
Copyright (C) 2015- Johannes Kepler University, Linz Copyright (C) 2015- Johannes Kepler University, Linz
@ -44,44 +44,42 @@ class potentialRelaxation
{ {
private: private:
dictionary propsDict_; dictionary propsDict_;
bool interpolate_; bool interpolate_;
bool measureDiff_; bool measureDiff_;
mutable OFstream recErrorFile_; mutable OFstream recErrorFile_;
word voidfractionFieldName_; const word voidfractionFieldName_;
const volScalarField& voidfraction_; const volScalarField& voidfraction_;
word voidfractionRecFieldName_; const word voidfractionRecFieldName_;
const volScalarField& voidfractionRec_; const volScalarField& voidfractionRec_;
scalar critVoidfraction_; scalar critVoidfraction_;
scalar D0_; scalar D0_;
scalar D1_; scalar D1_;
mutable volScalarField correctedField_; mutable volScalarField correctedField_;
const scalar dt_; const scalar dt_;
// ignore particles in cells below plane given with ref point and normal vector // ignore particles in cells below plane given with ref point and normal vector
// normal vector points towards region where fluctuations are permitted // normal vector points towards region where fluctuations are permitted
bool ignoreReg_;
vector ignoreDirection_;
vector ignorePoint_;
mutable double **vfluc_; // Lagrangian array
void allocateMyArrays() const; bool ignoreReg_;
vector ignoreDirection_;
vector ignorePoint_;
const word vflucName_;
void relax(scalar, scalar) const; void relax(scalar, scalar) const;
public: public:

View File

@ -69,16 +69,11 @@ virtualMassForce::virtualMassForce
U_(sm.mesh().lookupObject<volVectorField> (velFieldName_)), U_(sm.mesh().lookupObject<volVectorField> (velFieldName_)),
phiFieldName_(propsDict_.lookup("phiFieldName")), phiFieldName_(propsDict_.lookup("phiFieldName")),
phi_(sm.mesh().lookupObject<surfaceScalarField> (phiFieldName_)), phi_(sm.mesh().lookupObject<surfaceScalarField> (phiFieldName_)),
UrelOld_(NULL), UrelOldRegName_(typeName + "UrelOld"),
splitUrelCalculation_(propsDict_.lookupOrDefault<bool>("splitUrelCalculation",false)), splitUrelCalculation_(propsDict_.lookupOrDefault<bool>("splitUrelCalculation",false)),
Cadd_(0.5) Cadd_(0.5)
{ {
particleCloud_.registerParticleProperty<double**>(UrelOldRegName_,3,NOTONCPU,false);
if (particleCloud_.dataExchangeM().maxNumberOfParticles() > 0)
{
// get memory for 2d array
particleCloud_.dataExchangeM().allocateArray(UrelOld_,NOTONCPU,3);
}
// init force sub model // init force sub model
setForceSubModels(propsDict_); setForceSubModels(propsDict_);
@ -117,15 +112,13 @@ virtualMassForce::virtualMassForce
virtualMassForce::~virtualMassForce() virtualMassForce::~virtualMassForce()
{ {
particleCloud_.dataExchangeM().destroy(UrelOld_,3);
} }
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void virtualMassForce::setForce() const void virtualMassForce::setForce() const
{ {
reAllocArrays(); double**& UrelOld_ = particleCloud_.getParticlePropertyRef<double**>(UrelOldRegName_);
scalar dt = U_.mesh().time().deltaT().value(); scalar dt = U_.mesh().time().deltaT().value();
@ -233,17 +226,6 @@ void virtualMassForce::setForce() const
} }
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void Foam::virtualMassForce::reAllocArrays() const
{
if(particleCloud_.numberOfParticlesChanged())
{
Pout << "virtualMassForce::reAllocArrays..." << endl;
particleCloud_.dataExchangeM().allocateArray(UrelOld_,NOTONCPU,3);
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam } // End namespace Foam

View File

@ -71,7 +71,7 @@ private:
const surfaceScalarField& phi_; const surfaceScalarField& phi_;
mutable double **UrelOld_; const word UrelOldRegName_;
const bool splitUrelCalculation_; //indicator to split calculation of Urel between CFDEM and LIGGGHTS const bool splitUrelCalculation_; //indicator to split calculation of Urel between CFDEM and LIGGGHTS
//requires the integration fix to take dv/dt into account! //requires the integration fix to take dv/dt into account!
@ -100,8 +100,6 @@ public:
// Member Functions // Member Functions
void setForce() const; void setForce() const;
void reAllocArrays() const;
}; };

View File

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

View File

@ -46,15 +46,6 @@ defineRunTimeSelectionTable(regionModel, dictionary);
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void regionModel::reAllocArrays() const
{
if(particleCloud_.numberOfParticlesChanged())
{
// get arrays of new length
particleCloud_.dataExchangeM().allocateArray(inRegion_,1.,1);
particleCloud_.dataExchangeM().allocateArray(outRegion_,1.,1);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -66,16 +57,10 @@ regionModel::regionModel
) )
: :
dict_(dict), dict_(dict),
particleCloud_(sm), particleCloud_(sm)
inRegion_(NULL),
outRegion_(NULL)
{ {
if (particleCloud_.dataExchangeM().maxNumberOfParticles() > 0) particleCloud_.registerParticleProperty<double**>("inRegion",1,1.0,false);
{ particleCloud_.registerParticleProperty<double**>("outRegion",1,1.0,false);
// get memory for 2d arrays
particleCloud_.dataExchangeM().allocateArray(inRegion_,1.,1);
particleCloud_.dataExchangeM().allocateArray(outRegion_,1.,1);
}
} }
@ -83,8 +68,6 @@ regionModel::regionModel
regionModel::~regionModel() regionModel::~regionModel()
{ {
particleCloud_.dataExchangeM().destroy(inRegion_,1);
particleCloud_.dataExchangeM().destroy(outRegion_,1);
} }

View File

@ -60,10 +60,6 @@ protected:
cfdemCloud& particleCloud_; cfdemCloud& particleCloud_;
mutable double **inRegion_;
mutable double **outRegion_;
public: public:
friend class voidFractionModel; friend class voidFractionModel;
@ -117,13 +113,6 @@ public:
virtual void resetVolFields(volVectorField&) const = 0; virtual void resetVolFields(volVectorField&) const = 0;
void reAllocArrays() const;
// Access
inline double ** const& inRegion()const{ return inRegion_; };
inline double ** const& outRegion()const { return outRegion_; };
}; };
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -55,14 +55,17 @@ ZehnerSchluenderThermCond::ZehnerSchluenderThermCond
voidfractionFieldName_(propsDict_.lookupOrDefault<word>("voidfractionFieldName","voidfraction")), voidfractionFieldName_(propsDict_.lookupOrDefault<word>("voidfractionFieldName","voidfraction")),
voidfraction_(sm.mesh().lookupObject<volScalarField> (voidfractionFieldName_)), voidfraction_(sm.mesh().lookupObject<volScalarField> (voidfractionFieldName_)),
typeKs_(propsDict_.lookupOrDefault<scalarList>("thermalConductivities",scalarList(1,-1.0))), typeKs_(propsDict_.lookupOrDefault<scalarList>("thermalConductivities",scalarList(1,-1.0))),
partKs_(NULL) partKsRegName_(typeName + "partKs")
{ {
if (typeKs_[0] < 0.0) if (typeKs_[0] < 0.0)
{ {
FatalError << "ZehnerSchluenderThermCond: provide list of thermal conductivities." << abort(FatalError); FatalError << "ZehnerSchluenderThermCond: provide list of thermal conductivities." << abort(FatalError);
} }
if (typeKs_.size() > 1) allocateMyArrays(); if (typeKs_.size() > 1)
{
particleCloud_.registerParticleProperty<double**>(partKsRegName_,1);
}
else else
{ {
partKsField_ *= typeKs_[0]; partKsField_ *= typeKs_[0];
@ -74,14 +77,6 @@ ZehnerSchluenderThermCond::ZehnerSchluenderThermCond
ZehnerSchluenderThermCond::~ZehnerSchluenderThermCond() ZehnerSchluenderThermCond::~ZehnerSchluenderThermCond()
{ {
if (typeKs_.size() > 1) particleCloud_.dataExchangeM().destroy(partKs_,1);
}
void ZehnerSchluenderThermCond::allocateMyArrays() const
{
double initVal=0.0;
particleCloud_.dataExchangeM().allocateArray(partKs_,initVal,1);
} }
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -133,7 +128,7 @@ void ZehnerSchluenderThermCond::calcPartKsField() const
FatalError << "ZehnerSchluenderThermCond needs data for more than one type, but types are not communicated." << abort(FatalError); FatalError << "ZehnerSchluenderThermCond needs data for more than one type, but types are not communicated." << abort(FatalError);
} }
allocateMyArrays(); double**& partKs_ = particleCloud_.getParticlePropertyRef<double**>(partKsRegName_);
label cellI=0; label cellI=0;
label partType = 0; label partType = 0;
for(int index = 0;index < particleCloud_.numberOfParticles(); ++index) for(int index = 0;index < particleCloud_.numberOfParticles(); ++index)

View File

@ -54,19 +54,17 @@ private:
dictionary propsDict_; dictionary propsDict_;
word partKsFieldName_; const word partKsFieldName_;
volScalarField& partKsField_; volScalarField& partKsField_;
word voidfractionFieldName_; const word voidfractionFieldName_;
const volScalarField& voidfraction_; const volScalarField& voidfraction_;
scalarList typeKs_; scalarList typeKs_;
mutable double **partKs_; const word partKsRegName_;
void allocateMyArrays() const;
void calcPartKsField() const; void calcPartKsField() const;

View File

@ -89,8 +89,6 @@ GaussVoidFraction::~GaussVoidFraction()
void GaussVoidFraction::setvoidFraction(double** const& mask,double**& voidfractions,double**& particleWeights,double**& particleVolumes,double**& particleV) void GaussVoidFraction::setvoidFraction(double** const& mask,double**& voidfractions,double**& particleWeights,double**& particleVolumes,double**& particleV)
{ {
reAllocArrays();
voidfractionNext_.ref()=1; voidfractionNext_.ref()=1;
scalar radius(-1); scalar radius(-1);
@ -103,12 +101,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 +140,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 +198,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

@ -91,8 +91,6 @@ void IBVoidFraction::setvoidFraction(double** const& mask,double**& voidfraction
{ {
const boundBox& globalBb = particleCloud_.mesh().bounds(); const boundBox& globalBb = particleCloud_.mesh().bounds();
reAllocArrays();
voidfractionNext_.ref() = 1.0; voidfractionNext_.ref() = 1.0;
for (int index=0; index < particleCloud_.numberOfParticles(); index++) for (int index=0; index < particleCloud_.numberOfParticles(); index++)
@ -100,13 +98,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 +264,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 +279,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

@ -88,8 +88,6 @@ bigParticleVoidFraction::~bigParticleVoidFraction()
void bigParticleVoidFraction::setvoidFraction(double** const& mask,double**& voidfractions,double**& particleWeights,double**& particleVolumes,double**& particleV) void bigParticleVoidFraction::setvoidFraction(double** const& mask,double**& voidfractions,double**& particleWeights,double**& particleVolumes,double**& particleV)
{ {
reAllocArrays();
voidfractionNext_.ref()=1; voidfractionNext_.ref()=1;
scalar radius(-1); scalar radius(-1);
@ -102,12 +100,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 +135,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 +188,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

@ -80,8 +80,6 @@ centreVoidFraction::~centreVoidFraction()
void centreVoidFraction::setvoidFraction(double** const& mask,double**& voidfractions,double**& particleWeights,double**& particleVolumes,double**& particleV) void centreVoidFraction::setvoidFraction(double** const& mask,double**& voidfractions,double**& particleWeights,double**& particleVolumes,double**& particleV)
{ {
reAllocArrays();
scalar radius(-1); scalar radius(-1);
scalar volume(0); scalar volume(0);
scalar cellVol(0); scalar cellVol(0);
@ -93,7 +91,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 +126,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

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

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

View File

@ -16,7 +16,7 @@
} }
label partCellId = particleCloud_.locateM().findSingleCell(subPosition,cellID); label partCellId = particleCloud_.locateM().findSingleCell(subPosition,cellID);
//NP fprintf(lmp->screen,"cellID=%d, partCellId=%d\n",static_cast<int>(cellID),static_cast<int>(partCellId)); //NP fprintf(lmp->screen,"cellID=%d, partCellId=%d\n",static_cast<int>(cellID),static_cast<int>(partCellId));
if(partCellId!=cellID) if(partCellId!=cellID)
@ -35,7 +35,7 @@
scalar partCellVol = particleCloud_.mesh().V()[partCellId]; scalar partCellVol = particleCloud_.mesh().V()[partCellId];
scalar particleVolume = volume/static_cast<scalar>(nPoints); scalar particleVolume = volume/static_cast<scalar>(nPoints);
scalar newAlpha = voidfractionNext_[partCellId]- particleVolume / partCellVol; scalar newAlpha = voidfractionNext_[partCellId]- particleVolume / partCellVol;
if(newAlpha > alphaMin_) voidfractionNext_[partCellId] = newAlpha; if(newAlpha > alphaMin_) voidfractionNext_[partCellId] = newAlpha;
else else
{ {
@ -49,9 +49,9 @@
// 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])
{ {
storeInIndex = i; storeInIndex = i;
createNew = false; createNew = false;
@ -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

@ -90,8 +90,6 @@ trilinearVoidFraction::~trilinearVoidFraction()
void trilinearVoidFraction::setvoidFraction(double** const& mask,double**& voidfractions,double**& particleWeights,double**& particleVolumes,double**& particleV) void trilinearVoidFraction::setvoidFraction(double** const& mask,double**& voidfractions,double**& particleWeights,double**& particleVolumes,double**& particleV)
{ {
reAllocArrays();
scalar radius(-1.); scalar radius(-1.);
scalar volume(0.); scalar volume(0.);
scalar scaleVol = weight(); scalar scaleVol = weight();
@ -131,7 +129,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,12 @@ 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), partCellsRegName_("cellsPerParticle"),
maxCellsPerParticle_(1), maxCellsPerParticle_(1),
weight_(1.), weight_(1.),
porosity_(1.) porosity_(1.)
{ {
particleCloud_.dataExchangeM().allocateArray(cellsPerParticle_,1,1); particleCloud_.registerParticleProperty<int**>(partCellsRegName_,1,1.0,false);
if (particleCloud_.getParticleEffVolFactors()) multiWeights_ = true; if (particleCloud_.getParticleEffVolFactors()) multiWeights_ = true;
} }
@ -128,19 +128,18 @@ 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), partCellsRegName_("cellsPerParticle"),
maxCellsPerParticle_(1), maxCellsPerParticle_(1),
weight_(1.), weight_(1.),
porosity_(1.) porosity_(1.)
{ {
particleCloud_.dataExchangeM().allocateArray(cellsPerParticle_,1,1); particleCloud_.registerParticleProperty<int**>(partCellsRegName_,1,1.0,false);
} }
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
voidFractionModel::~voidFractionModel() voidFractionModel::~voidFractionModel()
{ {
particleCloud_.dataExchangeM().destroy(cellsPerParticle_,1);
} }
// * * * * * * * * * * * * * * public Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * public Member Functions * * * * * * * * * * * * * //
@ -162,7 +161,7 @@ void voidFractionModel::resetVoidFractions()
int** const& voidFractionModel::cellsPerParticle() const int** const& voidFractionModel::cellsPerParticle() const
{ {
return cellsPerParticle_; return particleCloud_.getParticlePropertyRef<int**>(partCellsRegName_);
} }
int voidFractionModel::maxCellsPerParticle() const int voidFractionModel::maxCellsPerParticle() const
@ -170,24 +169,6 @@ int voidFractionModel::maxCellsPerParticle() const
return maxCellsPerParticle_; return maxCellsPerParticle_;
} }
void voidFractionModel::reAllocArrays()
{
if(particleCloud_.numberOfParticlesChanged())
{
// get arrays of new length
particleCloud_.dataExchangeM().allocateArray(cellsPerParticle_,1,1);
}
}
void voidFractionModel::reAllocArrays(int nP)
{
if(particleCloud_.numberOfParticlesChanged())
{
// get arrays of new length
particleCloud_.dataExchangeM().allocateArray(cellsPerParticle_,1,1,nP);
}
}
scalar voidFractionModel::pointInParticle(int index, const vector& positionCenter, const vector& point, double scale) const scalar voidFractionModel::pointInParticle(int index, const vector& positionCenter, const vector& point, double scale) const
{ {
const scalar radius = particleCloud_.radius(index); const scalar radius = particleCloud_.radius(index);

View File

@ -69,7 +69,7 @@ protected:
volScalarField voidfractionNext_; volScalarField voidfractionNext_;
int ** cellsPerParticle_; const word partCellsRegName_;
int maxCellsPerParticle_; int maxCellsPerParticle_;
@ -165,10 +165,6 @@ public:
int maxCellsPerParticle() const; 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 void setParticleType(label type) const {}
virtual bool checkParticleType(label) const { return true; } //consider all particles by default virtual bool checkParticleType(label) const { return true; } //consider all particles by default