CrankNicolson ddtScheme gives wrong results for even nOuterCorrectors
In order to increase the numerical stability or accuracy of the scheme, we have the possibility to solve the equation multiple times during a time step. A common example for this is the pimple algorithm. However, the combination multiple nOuterCorrectors with the CrankNicolson scheme leads to wrong results:
CrankNicolson nOuter 2 with fix:
Solving the equations with the CrankNicolson time scheme results in wrong values if nOuterCorrectors is an even number. The reason is that (evaluate(ddt0)) in fvmDDt is always true:
{
if (evaluate(ddt0))
{
ddt0 = rDtCoef0_(ddt0)*rho*(vf.oldTime() - vf.oldTime().oldTime())
- offCentre_(ddt0());
}
fvm.source() =
(
rDtCoef*rho.value()*vf.oldTime().primitiveField()
+ offCentre_(ddt0.primitiveField())
)*mesh().V();
}
as the timeIndex of the geometricField is not update in the above scenario.
A possible solution might be:
template<class Type>
template<class GeoField>
bool CrankNicolsonDdtScheme<Type>::evaluate
(
DDt0Field<GeoField>& ddt0
)
{
bool evaluated = ddt0.timeIndex() != mesh().time().timeIndex();
ddt0.timeIndex() = mesh().time().timeIndex();
return evaluated;
}
Reproduce
interFoam -> damBreak
ddtSchemes -> CrankNicolson 0.9;
nOuterCorrectors -> 2;
Environment information
- OpenFOAM version : v1806
- Operating system : ubuntu
- Hardware info :
- Compiler :