Merge pull request #92 from ParticulateFlow/feature/timestepfraction

Feature/timestepfraction
This commit is contained in:
Daniel
2019-08-08 10:32:54 +02:00
committed by GitHub
3 changed files with 24 additions and 24 deletions

View File

@ -673,13 +673,7 @@ bool cfdemCloud::evolve
int old_precision = Info().precision(10);
Info << "\n timeStepFraction() = " << timeStepFrac << endl;
Info().precision(old_precision);
if(timeStepFrac > 1.0000001)
{
// FatalError << "cfdemCloud::dataExchangeM().timeStepFraction()>1: Do not do this, since dangerous. This might be due to the fact that you used a adjustable CFD time step. Please use a fixed CFD time step." << abort(FatalError);
old_precision = Warning().precision(10);
Warning << "cfdemCloud::dataExchangeM().timeStepFraction() = " << timeStepFrac << endl;
Warning().precision(old_precision);
}
clockM().start(24,"interpolateEulerFields");
// update voidFractionField

View File

@ -209,7 +209,7 @@ bool dataExchangeModel::couple(int i)
scalar dataExchangeModel::timeStepFraction() const
{
//return fraction between previous coupling TS and actual TS
return ( particleCloud_.mesh().time().value()-particleCloud_.mesh().time().startTime().value() - (couplingStep_-1) * couplingTime() ) / couplingTime();
return clamp( (particleCloud_.mesh().time().timeIndex() - timeIndexOffset_) * particleCloud_.mesh().time().deltaTValue() / couplingTime() - (couplingStep_ - 1) );
}
int dataExchangeModel::getNumberOfParticles() const
@ -249,7 +249,8 @@ dataExchangeModel::dataExchangeModel
maxNumberOfParticles_(0),
couplingStep_(0),
DEMts_(-1.),
couplingInterval_(readScalar(dict_.lookup("couplingInterval")))
couplingInterval_(readScalar(dict_.lookup("couplingInterval"))),
timeIndexOffset_(particleCloud_.mesh().time().timeIndex())
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

View File

@ -68,8 +68,16 @@ protected:
int couplingInterval_;
const label timeIndexOffset_;
// Protected member functions
// note: C++17 has std::clamp
scalar clamp(scalar v, scalar lo=0.0, scalar hi=1.0) const
{
return ((v < lo) ? lo : (hi < v) ? hi : v);
}
public:
//- Runtime type information
@ -198,26 +206,28 @@ public:
inline void checkTSsize() const
{
if (particleCloud_.mesh().time().deltaT().value() > couplingInterval_ * DEMts_ + SMALL)
if (particleCloud_.mesh().time().deltaTValue() > couplingInterval_ * DEMts_ + SMALL)
{
Info << "particleCloud_.mesh().time().deltaT().value() = " << particleCloud_.mesh().time().deltaT().value() << endl;
Info << "particleCloud_.mesh().time().deltaTValue() = " << particleCloud_.mesh().time().deltaTValue() << endl;
Info << "couplingInterval_ = " << couplingInterval_ << endl;
Info << "DEMts_ = " << DEMts_ << endl;
FatalError << "\nError - CFD time-step bigger than coupling time (= DEM time step * coupling interval)!\n" << abort(FatalError);
}
if (std::fabs((round(couplingTime()/particleCloud_.mesh().time().deltaT().value())*particleCloud_.mesh().time().deltaT().value())-couplingTime()) > SMALL)
if (std::fabs((round(couplingTime()/particleCloud_.mesh().time().deltaTValue()) * particleCloud_.mesh().time().deltaTValue()) - couplingTime()) > SMALL)
{
Info << "particleCloud_.mesh().time().deltaT().value() = " << particleCloud_.mesh().time().deltaT().value() << endl;
Info << "particleCloud_.mesh().time().deltaTValue() = " << particleCloud_.mesh().time().deltaTValue() << endl;
Info << "couplingInterval_ = " << couplingInterval_ << endl;
Info << "DEMts_ = " << DEMts_ << endl;
Warning << "\nWarning - Coupling time (= DEM time step * coupling interval) is not a multiple of CFD time-step!\n" << endl;
}
if (!particleCloud_.allowCFDsubTimestep())
if (particleCloud_.mesh().time().deltaT().value() < couplingInterval_ * DEMts_ + SMALL)
if (particleCloud_.mesh().time().deltaTValue() < couplingInterval_ * DEMts_ + SMALL)
FatalError << "\nYour models require: CFD time-step = coupling interval (= DEM time step * coupling interval)! \n" << abort(FatalError);
// warn if sub-TS
if (particleCloud_.mesh().time().deltaT().value() < couplingTime() - SMALL)
if (particleCloud_.mesh().time().deltaTValue() < couplingTime() - SMALL)
Warning << "You are using sub-time-steps (i.e. CFD TS < coupling time)! Check your settings properly." << endl;
}
@ -229,15 +239,10 @@ public:
inline bool doCoupleNow() const
{
if (particleCloud_.mesh().time().value()-particleCloud_.mesh().time().startTime().value()-SMALL
> couplingStep_*DEMts_*couplingInterval_)
{
return true;
}
else
{
return false;
}
return ( (particleCloud_.mesh().time().timeIndex() - timeIndexOffset_) * particleCloud_.mesh().time().deltaTValue() - SMALL
>
couplingStep_ * DEMts_ * couplingInterval_
);
}
virtual int getNumberOfParticles() const;