mirror of
https://github.com/ParticulateFlow/CFDEMcoupling-PFM.git
synced 2025-12-08 06:37:44 +00:00
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:
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Reference in New Issue
Block a user