src/OpenFOAM/algorithms/subCycle: corrected handling of oldTime field to support outer iteration

Note: currently only the oldTime field is handled so only Euler ddt is supported with outer iteration
This commit is contained in:
Henry
2012-03-19 16:13:20 +00:00
parent bd1317b71b
commit 308739d2e8

View File

@ -40,13 +40,11 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class subCycle Declaration
Class subCycleField Declaration
\*---------------------------------------------------------------------------*/
template<class GeometricField>
class subCycle
:
public subCycleTime
class subCycleField
{
// Private data
@ -57,6 +55,41 @@ class subCycle
GeometricField gf0_;
public:
// Constructors
//- Construct field and number of sub-cycles
subCycleField(GeometricField& gf)
:
gf_(gf),
gf0_(gf.oldTime())
{}
//- Destructor
~subCycleField()
{
// Correct the time index of the field to correspond to the global time
gf_.timeIndex() = gf_.time().timeIndex();
// Reset the old-time field value
gf_.oldTime() = gf0_;
gf_.oldTime().timeIndex() = gf0_.timeIndex();
}
};
/*---------------------------------------------------------------------------*\
Class subCycle Declaration
\*---------------------------------------------------------------------------*/
template<class GeometricField>
class subCycle
:
public subCycleField<GeometricField>,
public subCycleTime
{
// Private Member Functions
//- Disallow default bitwise copy construct
@ -73,9 +106,9 @@ public:
//- Construct field and number of sub-cycles
subCycle(GeometricField& gf, const label nSubCycles)
:
subCycleTime(const_cast<Time&>(gf.time()), nSubCycles),
gf_(gf),
gf0_(gf.oldTime())
subCycleField<GeometricField>(gf),
subCycleTime(const_cast<Time&>(gf.time()), nSubCycles)
{}
@ -84,13 +117,6 @@ public:
{
// End the subCycleTime, which restores the time state
endSubCycle();
// Correct the time index of the field to correspond to the global time
gf_.timeIndex() = gf_.time().timeIndex();
// Reset the old-time field value
gf_.oldTime() = gf0_;
gf_.oldTime().timeIndex() = gf_.time().timeIndex();
}
};