mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: Correct evaluate function for ddt0 in CrankNicolson scheme. Fixes
The function evaluate was returning true every outer loop, triggering the re-calculation of ddt0 in every outer loop. The evaluation of the term ddt0 should be performed once per time step. The corrected function updates the timeIndex of ddt0 to avoid the re-evaluation of this term in the outer loops.
This commit is contained in:
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -184,10 +185,12 @@ template<class Type>
|
||||
template<class GeoField>
|
||||
bool CrankNicolsonDdtScheme<Type>::evaluate
|
||||
(
|
||||
const DDt0Field<GeoField>& ddt0
|
||||
) const
|
||||
DDt0Field<GeoField>& ddt0
|
||||
)
|
||||
{
|
||||
return ddt0.timeIndex() != mesh().time().timeIndex();
|
||||
bool evaluated = (ddt0.timeIndex() != mesh().time().timeIndex());
|
||||
ddt0.timeIndex() = mesh().time().timeIndex();
|
||||
return evaluated;
|
||||
}
|
||||
|
||||
|
||||
@ -872,6 +875,7 @@ CrankNicolsonDdtScheme<Type>::fvmDdt
|
||||
{
|
||||
ddt0 = rDtCoef0_(ddt0)*(vf.oldTime() - vf.oldTime().oldTime())
|
||||
- offCentre_(ddt0());
|
||||
|
||||
}
|
||||
|
||||
fvm.source() =
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -180,7 +181,7 @@ class CrankNicolsonDdtScheme
|
||||
|
||||
//- Check if the ddt0 needs to be evaluated for this time-step
|
||||
template<class GeoField>
|
||||
bool evaluate(const DDt0Field<GeoField>& ddt0) const;
|
||||
bool evaluate(DDt0Field<GeoField>& ddt0);
|
||||
|
||||
//- Return the coefficient for Euler scheme for the first time-step
|
||||
// for and CN thereafter
|
||||
|
||||
Reference in New Issue
Block a user