diff --git a/src/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.C b/src/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.C index 8dc18591c65c6425f51e888de80d71cec5103022..18b233e64c3cfd5c234f3520dce7c47b1d3a362f 100644 --- a/src/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.C +++ b/src/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -48,13 +48,16 @@ namespace functionObjects // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -void Foam::functionObjects::timeActivatedFileUpdate::updateFile() +void Foam::functionObjects::timeActivatedFileUpdate::updateFile +( + const bool checkFiles +) { label i = lastIndex_; while ( i < timeVsFile_.size()-1 - && timeVsFile_[i+1].first() < time_.value() + && timeVsFile_[i+1].first() < time_.value()+0.5*time_.deltaTValue() ) { i++; @@ -69,6 +72,15 @@ void Foam::functionObjects::timeActivatedFileUpdate::updateFile() cp(timeVsFile_[i].second(), destFile); mv(destFile, fileToUpdate_); lastIndex_ = i; + + if (checkFiles) + { + // Do an early check to avoid an additional iteration before + // any changes are picked up (see Time::run : does readModified + // before executing FOs). Note we have to protect the read + // constructor of *this from triggering this behaviour. + const_cast<Time&>(time_).Time::readModifiedObjects(); + } } } @@ -130,7 +142,8 @@ bool Foam::functionObjects::timeActivatedFileUpdate::read << timeVsFile_[i].second() << endl; } - updateFile(); + // Copy starting files. Avoid recursion by not checking for modified files. + updateFile(false); return true; } @@ -138,7 +151,7 @@ bool Foam::functionObjects::timeActivatedFileUpdate::read bool Foam::functionObjects::timeActivatedFileUpdate::execute() { - updateFile(); + updateFile(true); return true; } diff --git a/src/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.H b/src/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.H index 74194e322cc7c1d1a55f10df25c1b0c6a4dc941c..4e0981ee33886c563a49c41c6c5e0b3743400626 100644 --- a/src/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.H +++ b/src/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -110,7 +110,7 @@ class timeActivatedFileUpdate // Private Member Functions //- Update file - void updateFile(); + void updateFile(const bool checkFiles); //- Disallow default bitwise copy construct timeActivatedFileUpdate(const timeActivatedFileUpdate&);