clamp tsf between 0 and 1

the time step fraction should never be outside these bounds since we
don't allow variable time steps; hence any value outside these bounds
must come from numerical rounding/precision issues;
by doing this we no longer need the check in cfdemCloud
This commit is contained in:
danielque
2019-07-26 16:59:56 +02:00
parent d4bb711e9c
commit 7bb266bc41
3 changed files with 8 additions and 8 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().timeIndex() - timeIndexOffset_) * particleCloud_.mesh().time().deltaTValue() / couplingTime() - (couplingStep_ - 1) );
return clamp( (particleCloud_.mesh().time().timeIndex() - timeIndexOffset_) * particleCloud_.mesh().time().deltaTValue() / couplingTime() - (couplingStep_ - 1) );
}
int dataExchangeModel::getNumberOfParticles() const

View File

@ -72,6 +72,12 @@ protected:
// 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