use particle property registration in force, region and therm. cond. models

This commit is contained in:
danielque
2020-08-11 11:32:35 +02:00
parent 214e10e5a3
commit 647c84d323
20 changed files with 110 additions and 155 deletions

View File

@ -74,8 +74,6 @@ KochHillRWDrag::KochHillRWDrag
interpolation_(propsDict_.found("interpolation")), interpolation_(propsDict_.found("interpolation")),
scale_(1.), scale_(1.),
randomTauE_(propsDict_.found("randomTauE")), randomTauE_(propsDict_.found("randomTauE")),
partTime_(NULL),
partUfluct_(NULL),
RanGen_(label(0)) RanGen_(label(0))
{ {
@ -99,16 +97,8 @@ KochHillRWDrag::KochHillRWDrag
if (propsDict_.found("rhoP")) if (propsDict_.found("rhoP"))
rhoP_= readScalar(propsDict_.lookup("rhoP")); rhoP_= readScalar(propsDict_.lookup("rhoP"));
particleCloud_.registerParticleProperty<double**>("partTime");
// if (particleCloud_.dataExchangeM().maxNumberOfParticles() > 0) particleCloud_.registerParticleProperty<double**>("partUfluct");
// {
//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,8 +106,6 @@ KochHillRWDrag::KochHillRWDrag
KochHillRWDrag::~KochHillRWDrag() KochHillRWDrag::~KochHillRWDrag()
{ {
particleCloud_.dataExchangeM().destroy(partTime_, 1);
particleCloud_.dataExchangeM().destroy(partUfluct_, 3);
} }
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -189,6 +177,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**>("partTime");
double**& partUfluct_ = particleCloud_.getParticlePropertyRef<double**>("partUfluct");
//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)
@ -386,6 +377,9 @@ void KochHillRWDrag::reAllocArrays() const
{ {
if (particleCloud_.numberOfParticlesChanged()) if (particleCloud_.numberOfParticlesChanged())
{ {
double**& partTime_ = particleCloud_.getParticlePropertyRef<double**>("partTime");
double**& partUfluct_ = particleCloud_.getParticlePropertyRef<double**>("partUfluct");
particleCloud_.dataExchangeM().allocateArray(partTime_,0.0,1); // field/initVal/with/lenghtFromLigghts particleCloud_.dataExchangeM().allocateArray(partTime_,0.0,1); // field/initVal/with/lenghtFromLigghts
particleCloud_.dataExchangeM().allocateArray(partUfluct_,0.0,3); particleCloud_.dataExchangeM().allocateArray(partUfluct_,0.0,3);
} }

View File

@ -89,10 +89,6 @@ private:
const bool randomTauE_; const bool randomTauE_;
mutable double **partTime_; // Lagrangian array
mutable double **partUfluct_; // Lagrangian array
mutable Random RanGen_; mutable Random RanGen_;
public: public:

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,6 @@ dSauter::dSauter
forceModel(dict,sm), forceModel(dict,sm),
propsDict_(dict.subDict(typeName + "Props")), propsDict_(dict.subDict(typeName + "Props")),
multiTypes_(false), multiTypes_(false),
d2_(NULL),
d3_(NULL),
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 +99,11 @@ dSauter::dSauter
multiTypes_ = true; multiTypes_ = true;
maxTypeCG_ = typeCG_.size(); maxTypeCG_ = typeCG_.size();
} }
allocateMyArrays();
dSauter_.write();
particleCloud_.registerParticleProperty<double**>("d2");
particleCloud_.registerParticleProperty<double**>("d3");
dSauter_.write();
// init force sub model // init force sub model
setForceSubModels(propsDict_); setForceSubModels(propsDict_);
@ -114,8 +114,6 @@ dSauter::dSauter
dSauter::~dSauter() dSauter::~dSauter()
{ {
particleCloud_.dataExchangeM().destroy(d2_,1);
particleCloud_.dataExchangeM().destroy(d3_,1);
} }
// * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * //
@ -124,6 +122,8 @@ void dSauter::allocateMyArrays() const
{ {
// get memory for 2d arrays // get memory for 2d arrays
double initVal = 0.0; double initVal = 0.0;
double**& d2_ = particleCloud_.getParticlePropertyRef<double**>("d2");
double**& d3_ = particleCloud_.getParticlePropertyRef<double**>("d3");
particleCloud_.dataExchangeM().allocateArray(d2_,initVal,1); // field/initVal/with/lenghtFromLigghts particleCloud_.dataExchangeM().allocateArray(d2_,initVal,1); // field/initVal/with/lenghtFromLigghts
particleCloud_.dataExchangeM().allocateArray(d3_,initVal,1); particleCloud_.dataExchangeM().allocateArray(d3_,initVal,1);
} }
@ -138,6 +138,8 @@ void dSauter::setForce() const
} }
allocateMyArrays(); allocateMyArrays();
double**& d2_ = particleCloud_.getParticlePropertyRef<double**>("d2");
double**& d3_ = particleCloud_.getParticlePropertyRef<double**>("d3");
label cellI = 0; label cellI = 0;
label partType = 1; label partType = 1;
@ -151,11 +153,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,18 +45,14 @@ private:
bool multiTypes_; bool multiTypes_;
mutable double **d2_;
mutable double **d3_;
label maxTypeCG_; label maxTypeCG_;
scalarList typeCG_; scalarList typeCG_;
mutable volScalarField d2Field_; mutable volScalarField d2Field_;
mutable volScalarField d3Field_; mutable volScalarField d3Field_;
mutable volScalarField dSauter_; mutable volScalarField dSauter_;
void allocateMyArrays() const; void allocateMyArrays() const;

View File

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

View File

@ -43,8 +43,6 @@ private:
dictionary propsDict_; dictionary propsDict_;
mutable double **vfluc_;
word UsFieldName_; word UsFieldName_;
const volVectorField& UsField_; const volVectorField& UsField_;

View File

@ -59,10 +59,9 @@ particleDeformation::particleDeformation
defaultDeformation_(propsDict_.lookupOrDefault<scalar>("defaultDeformation",1.0)), defaultDeformation_(propsDict_.lookupOrDefault<scalar>("defaultDeformation",1.0)),
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)
{ {
allocateMyArrays(); particleCloud_.registerParticleProperty<double**>("partDeformations");
// init force sub model // init force sub model
setForceSubModels(propsDict_); setForceSubModels(propsDict_);
@ -120,7 +119,6 @@ particleDeformation::particleDeformation
particleDeformation::~particleDeformation() particleDeformation::~particleDeformation()
{ {
particleCloud_.dataExchangeM().destroy(partDeformations_,1);
} }
// * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * //
@ -128,6 +126,7 @@ void particleDeformation::allocateMyArrays() const
{ {
// get memory for 2d arrays // get memory for 2d arrays
double initVal = 0.0; double initVal = 0.0;
double**& partDeformations_ = particleCloud_.getParticlePropertyRef<double**>("partDeformations");
particleCloud_.dataExchangeM().allocateArray(partDeformations_,initVal,1); particleCloud_.dataExchangeM().allocateArray(partDeformations_,initVal,1);
} }
@ -147,6 +146,7 @@ void particleDeformation::setForce() const
} }
// realloc the arrays // realloc the arrays
allocateMyArrays(); allocateMyArrays();
double**& partDeformations_ = particleCloud_.getParticlePropertyRef<double**>("partDeformations");
label cellI = 0; label cellI = 0;
label partType = -1; label partType = -1;

View File

@ -74,8 +74,6 @@ private:
scalarList upperBounds_; scalarList upperBounds_;
mutable double **partDeformations_;
label getListIndex(label) const; label getListIndex(label) const;
void allocateMyArrays() const; void allocateMyArrays() 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,6 @@ pdCorrelation::pdCorrelation
: :
forceModel(dict,sm), forceModel(dict,sm),
propsDict_(dict.subDict(typeName + "Props")), propsDict_(dict.subDict(typeName + "Props")),
d_(nullptr),
p_(nullptr),
d2_(nullptr),
pd_(nullptr),
cg3_(nullptr),
dField_ dField_
( IOobject ( IOobject
( (
@ -151,7 +146,11 @@ pdCorrelation::pdCorrelation
<< abort(FatalError); << abort(FatalError);
} }
allocateMyArrays(); particleCloud_.registerParticleProperty<double**>("d");
particleCloud_.registerParticleProperty<double**>("p");
particleCloud_.registerParticleProperty<double**>("d2");
particleCloud_.registerParticleProperty<double**>("pd");
particleCloud_.registerParticleProperty<double**>("cg3");
dField_.write(); dField_.write();
pdField_.write(); pdField_.write();
@ -165,11 +164,6 @@ 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 * * * * * * * * * * * * * //
@ -177,6 +171,12 @@ void pdCorrelation::allocateMyArrays() const
{ {
// get memory for 2d arrays // get memory for 2d arrays
double initVal = 0.0; double initVal = 0.0;
double**& d_ = particleCloud_.getParticlePropertyRef<double**>("d");
double**& p_ = particleCloud_.getParticlePropertyRef<double**>("p");
double**& d2_ = particleCloud_.getParticlePropertyRef<double**>("d2");
double**& pd_ = particleCloud_.getParticlePropertyRef<double**>("pd");
double**& cg3_ = particleCloud_.getParticlePropertyRef<double**>("cg3");
particleCloud_.dataExchangeM().allocateArray(d_, initVal, 1); particleCloud_.dataExchangeM().allocateArray(d_, initVal, 1);
particleCloud_.dataExchangeM().allocateArray(p_, initVal, 3); particleCloud_.dataExchangeM().allocateArray(p_, initVal, 3);
particleCloud_.dataExchangeM().allocateArray(d2_, initVal, 1); particleCloud_.dataExchangeM().allocateArray(d2_, initVal, 1);
@ -192,6 +192,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(); allocateMyArrays();
double**& d_ = particleCloud_.getParticlePropertyRef<double**>("d");
double**& p_ = particleCloud_.getParticlePropertyRef<double**>("p");
double**& d2_ = particleCloud_.getParticlePropertyRef<double**>("d2");
double**& pd_ = particleCloud_.getParticlePropertyRef<double**>("pd");
double**& cg3_ = particleCloud_.getParticlePropertyRef<double**>("cg3");
const Switch densityFromList const Switch densityFromList
( (

View File

@ -45,12 +45,6 @@ private:
dictionary propsDict_; dictionary propsDict_;
mutable double **d_;
mutable double **p_;
mutable double **d2_;
mutable double **pd_;
mutable double **cg3_;
mutable volScalarField dField_; mutable volScalarField dField_;
mutable volVectorField pField_; mutable volVectorField pField_;
mutable volScalarField d2Field_; mutable volScalarField d2Field_;

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
@ -82,11 +82,10 @@ potentialRelaxation::potentialRelaxation
dt_(particleCloud_.dataExchangeM().DEMts()), dt_(particleCloud_.dataExchangeM().DEMts()),
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)
{ {
allocateMyArrays(); particleCloud_.registerParticleProperty<double**>("vfluc");
if(ignoreReg_) if(ignoreReg_)
{ {
if(mag(ignoreDirection_) < SMALL) if(mag(ignoreDirection_) < SMALL)
@ -103,7 +102,6 @@ potentialRelaxation::potentialRelaxation
potentialRelaxation::~potentialRelaxation() potentialRelaxation::~potentialRelaxation()
{ {
delete vfluc_;
} }
@ -112,39 +110,40 @@ void potentialRelaxation::allocateMyArrays() const
{ {
// get memory for 2d arrays // get memory for 2d arrays
double initVal=0.0; double initVal=0.0;
particleCloud_.dataExchangeM().allocateArray(vfluc_,initVal,3); double**& vfluc_ = particleCloud_.getParticlePropertyRef<double**>("vfluc");
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 // realloc the arrays
allocateMyArrays(); allocateMyArrays();
double**& vfluc_ = particleCloud_.getParticlePropertyRef<double**>("vfluc");
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 +163,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 +182,13 @@ void potentialRelaxation::setForce() const
} }
} }
} }
particleCloud_.dataExchangeM().giveData("vfluc","vector-atom", vfluc_); particleCloud_.dataExchangeM().giveData("vfluc","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 +197,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_; word voidfractionFieldName_;
const volScalarField& voidfraction_; const volScalarField& voidfraction_;
word voidfractionRecFieldName_; 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_; bool ignoreReg_;
vector ignoreDirection_; vector ignoreDirection_;
vector ignorePoint_; vector ignorePoint_;
mutable double **vfluc_; // Lagrangian array
void allocateMyArrays() const; void allocateMyArrays() const;
void relax(scalar, scalar) const; void relax(scalar, scalar) const;
public: public:

View File

@ -69,16 +69,10 @@ 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),
splitUrelCalculation_(propsDict_.lookupOrDefault<bool>("splitUrelCalculation",false)), splitUrelCalculation_(propsDict_.lookupOrDefault<bool>("splitUrelCalculation",false)),
Cadd_(0.5) Cadd_(0.5)
{ {
particleCloud_.registerParticleProperty<double**>("UrelOld");
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 +111,14 @@ virtualMassForce::virtualMassForce
virtualMassForce::~virtualMassForce() virtualMassForce::~virtualMassForce()
{ {
particleCloud_.dataExchangeM().destroy(UrelOld_,3);
} }
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void virtualMassForce::setForce() const void virtualMassForce::setForce() const
{ {
reAllocArrays(); reAllocArrays();
double**& UrelOld_ = particleCloud_.getParticlePropertyRef<double**>("UrelOld");
scalar dt = U_.mesh().time().deltaT().value(); scalar dt = U_.mesh().time().deltaT().value();
@ -239,6 +232,7 @@ void Foam::virtualMassForce::reAllocArrays() const
if(particleCloud_.numberOfParticlesChanged()) if(particleCloud_.numberOfParticlesChanged())
{ {
Pout << "virtualMassForce::reAllocArrays..." << endl; Pout << "virtualMassForce::reAllocArrays..." << endl;
double**& UrelOld_ = particleCloud_.getParticlePropertyRef<double**>("UrelOld");
particleCloud_.dataExchangeM().allocateArray(UrelOld_,NOTONCPU,3); particleCloud_.dataExchangeM().allocateArray(UrelOld_,NOTONCPU,3);
} }
} }

View File

@ -71,8 +71,6 @@ private:
const surfaceScalarField& phi_; const surfaceScalarField& phi_;
mutable double **UrelOld_;
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!

View File

@ -51,6 +51,8 @@ void regionModel::reAllocArrays() const
if(particleCloud_.numberOfParticlesChanged()) if(particleCloud_.numberOfParticlesChanged())
{ {
// get arrays of new length // get arrays of new length
double**& inRegion_ = particleCloud_.getParticlePropertyRef<double**>("inRegion");
double**& outRegion_ = particleCloud_.getParticlePropertyRef<double**>("outRegion");
particleCloud_.dataExchangeM().allocateArray(inRegion_,1.,1); particleCloud_.dataExchangeM().allocateArray(inRegion_,1.,1);
particleCloud_.dataExchangeM().allocateArray(outRegion_,1.,1); particleCloud_.dataExchangeM().allocateArray(outRegion_,1.,1);
} }
@ -66,16 +68,10 @@ regionModel::regionModel
) )
: :
dict_(dict), dict_(dict),
particleCloud_(sm), particleCloud_(sm)
inRegion_(NULL),
outRegion_(NULL)
{ {
if (particleCloud_.dataExchangeM().maxNumberOfParticles() > 0) particleCloud_.registerParticleProperty<double**>("inRegion");
{ particleCloud_.registerParticleProperty<double**>("outRegion");
// get memory for 2d arrays
particleCloud_.dataExchangeM().allocateArray(inRegion_,1.,1);
particleCloud_.dataExchangeM().allocateArray(outRegion_,1.,1);
}
} }
@ -83,8 +79,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;
@ -119,11 +115,6 @@ public:
void reAllocArrays() const; void reAllocArrays() const;
// Access
inline double ** const& inRegion()const{ return inRegion_; };
inline double ** const& outRegion()const { return outRegion_; };
}; };
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -54,15 +54,17 @@ ZehnerSchluenderThermCond::ZehnerSchluenderThermCond
partKsField_(const_cast<volScalarField&>(sm.mesh().lookupObject<volScalarField> (partKsFieldName_))), partKsField_(const_cast<volScalarField&>(sm.mesh().lookupObject<volScalarField> (partKsFieldName_))),
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)
{ {
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**>("partKs");
}
else else
{ {
partKsField_ *= typeKs_[0]; partKsField_ *= typeKs_[0];
@ -74,13 +76,13 @@ ZehnerSchluenderThermCond::ZehnerSchluenderThermCond
ZehnerSchluenderThermCond::~ZehnerSchluenderThermCond() ZehnerSchluenderThermCond::~ZehnerSchluenderThermCond()
{ {
if (typeKs_.size() > 1) particleCloud_.dataExchangeM().destroy(partKs_,1);
} }
void ZehnerSchluenderThermCond::allocateMyArrays() const void ZehnerSchluenderThermCond::allocateMyArrays() const
{ {
double initVal=0.0; double initVal=0.0;
double**& partKs_ = particleCloud_.getParticlePropertyRef<double**>("partKs");
particleCloud_.dataExchangeM().allocateArray(partKs_,initVal,1); particleCloud_.dataExchangeM().allocateArray(partKs_,initVal,1);
} }
@ -134,6 +136,7 @@ void ZehnerSchluenderThermCond::calcPartKsField() const
} }
allocateMyArrays(); allocateMyArrays();
double**& partKs_ = particleCloud_.getParticlePropertyRef<double**>("partKs");
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

@ -64,8 +64,6 @@ private:
scalarList typeKs_; scalarList typeKs_;
mutable double **partKs_;
void allocateMyArrays() const; void allocateMyArrays() const;
void calcPartKsField() const; void calcPartKsField() const;