diff --git a/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C b/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C index ced51d723e..453807a36e 100644 --- a/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C +++ b/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C @@ -309,7 +309,7 @@ int main(int argc, char *argv[]) if ( matchName != "perfect" - && !slidingInterface::typeOfMatchNames.hasEnum(matchName) + && !slidingInterface::typeOfMatchNames.found(matchName) ) { Info<< "Error: unknown match type - " << matchName diff --git a/applications/utilities/preProcessing/mapFieldsPar/mapFieldsPar.C b/applications/utilities/preProcessing/mapFieldsPar/mapFieldsPar.C index 29bcd4bf9a..fc1173a90a 100644 --- a/applications/utilities/preProcessing/mapFieldsPar/mapFieldsPar.C +++ b/applications/utilities/preProcessing/mapFieldsPar/mapFieldsPar.C @@ -229,7 +229,7 @@ int main(int argc, char *argv[]) word patchMapMethod; - if (meshToMesh::interpolationMethodNames_.hasEnum(mapMethod)) + if (meshToMesh::interpolationMethodNames_.found(mapMethod)) { // Lookup corresponding AMI method meshToMesh::interpolationMethod method = diff --git a/applications/utilities/surface/surfaceBooleanFeatures/surfaceBooleanFeatures.C b/applications/utilities/surface/surfaceBooleanFeatures/surfaceBooleanFeatures.C index 4eb2917f42..4b2221536e 100644 --- a/applications/utilities/surface/surfaceBooleanFeatures/surfaceBooleanFeatures.C +++ b/applications/utilities/surface/surfaceBooleanFeatures/surfaceBooleanFeatures.C @@ -1577,7 +1577,7 @@ int main(int argc, char *argv[]) { booleanSurface::DIFFERENCE, "difference" } }; - if (!validActions.hasEnum(action)) + if (!validActions.found(action)) { FatalErrorInFunction << "Unsupported action " << action << endl diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index 29d6eee577..5d2dc3f178 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -284,6 +284,7 @@ $(Time)/Time.C $(Time)/TimeIO.C $(Time)/findTimes.C $(Time)/subCycleTime.C +$(Time)/subLoopTime.C $(Time)/findInstance.C $(Time)/timeSelector.C diff --git a/src/OpenFOAM/algorithms/subCycle/subCycle.H b/src/OpenFOAM/algorithms/subCycle/subCycle.H index f0c8958dd0..692146f8c0 100644 --- a/src/OpenFOAM/algorithms/subCycle/subCycle.H +++ b/src/OpenFOAM/algorithms/subCycle/subCycle.H @@ -112,10 +112,10 @@ class subCycle // Private Member Functions //- Disallow default bitwise copy construct - subCycle(const subCycle&); + subCycle(const subCycle&) = delete; //- Disallow default bitwise assignment - void operator=(const subCycle&); + void operator=(const subCycle&) = delete; public: @@ -123,10 +123,10 @@ public: // Constructors //- Construct field and number of sub-cycles - subCycle(GeometricField& gf, const label nSubCycles) + subCycle(GeometricField& gf, const label nCycles) : subCycleField(gf), - subCycleTime(const_cast(gf.time()), nSubCycles) + subCycleTime(const_cast(gf.time()), nCycles) { // Update the field time index to correspond to the sub-cycle time this->updateTimeIndex(); diff --git a/src/OpenFOAM/db/Time/Time.C b/src/OpenFOAM/db/Time/Time.C index 2dabf589ea..9918881082 100644 --- a/src/OpenFOAM/db/Time/Time.C +++ b/src/OpenFOAM/db/Time/Time.C @@ -44,12 +44,14 @@ const Foam::Enum < Foam::Time::stopAtControls > -Foam::Time::stopAtControlNames_ +Foam::Time::stopAtControlNames { { stopAtControls::saEndTime, "endTime" }, { stopAtControls::saNoWriteNow, "noWriteNow" }, { stopAtControls::saWriteNow, "writeNow" }, { stopAtControls::saNextWrite, "nextWrite" }, + // NOTE: stopAtControls::saUnknown is left untabulated here so that it can + // be used as fallback value to flag unknown settings }; @@ -57,7 +59,7 @@ const Foam::Enum < Foam::Time::writeControls > -Foam::Time::writeControlNames_ +Foam::Time::writeControlNames { { writeControls::wcTimeStep, "timeStep" }, { writeControls::wcRunTime, "runTime" }, @@ -433,8 +435,8 @@ Foam::Time::Time writeControl_(wcTimeStep), writeInterval_(GREAT), purgeWrite_(0), + subCycling_(0), writeOnce_(false), - subCycling_(false), sigWriteNow_(true, *this), sigStopAtWriteNow_(true, *this), @@ -502,8 +504,8 @@ Foam::Time::Time writeControl_(wcTimeStep), writeInterval_(GREAT), purgeWrite_(0), + subCycling_(0), writeOnce_(false), - subCycling_(false), sigWriteNow_(true, *this), sigStopAtWriteNow_(true, *this), @@ -581,8 +583,8 @@ Foam::Time::Time writeControl_(wcTimeStep), writeInterval_(GREAT), purgeWrite_(0), + subCycling_(0), writeOnce_(false), - subCycling_(false), sigWriteNow_(true, *this), sigStopAtWriteNow_(true, *this), @@ -651,9 +653,8 @@ Foam::Time::Time writeControl_(wcTimeStep), writeInterval_(GREAT), purgeWrite_(0), + subCycling_(0), writeOnce_(false), - subCycling_(false), - writeFormat_(IOstream::ASCII), writeVersion_(IOstream::currentVersion), writeCompression_(IOstream::UNCOMPRESSED), @@ -825,6 +826,12 @@ Foam::dimensionedScalar Foam::Time::endTime() const } +Foam::Time::stopAtControls Foam::Time::stopAt() const +{ + return stopAt_; +} + + bool Foam::Time::run() const { deleteDemandDrivenData(loopProfiling_); @@ -913,20 +920,23 @@ bool Foam::Time::end() const } -bool Foam::Time::stopAt(const stopAtControls sa) const +bool Foam::Time::stopAt(const stopAtControls stopCtrl) const { - const bool changed = (stopAt_ != sa); - stopAt_ = sa; + if (stopCtrl == stopAtControls::saUnknown) + { + return false; + } - // adjust endTime - if (sa == saEndTime) + const bool changed = (stopAt_ != stopCtrl); + stopAt_ = stopCtrl; + endTime_ = GREAT; + + // Adjust endTime + if (stopCtrl == stopAtControls::saEndTime) { controlDict_.lookup("endTime") >> endTime_; } - else - { - endTime_ = GREAT; - } + return changed; } @@ -1018,26 +1028,41 @@ void Foam::Time::setDeltaT(const scalar deltaT, const bool adjust) Foam::TimeState Foam::Time::subCycle(const label nSubCycles) { - subCycling_ = true; - prevTimeState_.reset(new TimeState(*this)); + prevTimeState_.set(new TimeState(*this)); // Fatal if already set setTime(*this - deltaT(), (timeIndex() - 1)*nSubCycles); deltaT_ /= nSubCycles; deltaT0_ /= nSubCycles; deltaTSave_ = deltaT0_; + subCycling_ = nSubCycles; + return prevTimeState(); } +void Foam::Time::subCycleIndex(const label index) +{ + // Only permit adjustment if sub-cycling was already active + // and if the index is valid (positive, non-zero). + // This avoids potential mixups for deleting. + + if (subCycling_ && index > 0) + { + subCycling_ = index; + } +} + + void Foam::Time::endSubCycle() { if (subCycling_) { - subCycling_ = false; TimeState::operator=(prevTimeState()); prevTimeState_.clear(); } + + subCycling_ = 0; } @@ -1113,7 +1138,7 @@ Foam::Time& Foam::Time::operator++() case wcRunTime: case wcAdjustableRunTime: { - label writeIndex = label + const label writeIndex = label ( ((value() - startTime_) + 0.5*deltaT_) / writeInterval_ @@ -1129,7 +1154,7 @@ Foam::Time& Foam::Time::operator++() case wcCpuTime: { - label writeIndex = label + const label writeIndex = label ( returnReduce(elapsedCpuTime(), maxOp()) / writeInterval_ @@ -1144,7 +1169,7 @@ Foam::Time& Foam::Time::operator++() case wcClockTime: { - label writeIndex = label + const label writeIndex = label ( returnReduce(label(elapsedClockTime()), maxOp