Skip to content
Snippets Groups Projects
Commit 2271bd4c authored by mattijs's avatar mattijs
Browse files

ENH: timeActivatedFileUpdate: early reading of changed files. Fixes #420.

parent 1abcdcc5
No related merge requests found
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / 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 License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -48,13 +48,16 @@ namespace functionObjects ...@@ -48,13 +48,16 @@ namespace functionObjects
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::functionObjects::timeActivatedFileUpdate::updateFile() void Foam::functionObjects::timeActivatedFileUpdate::updateFile
(
const bool checkFiles
)
{ {
label i = lastIndex_; label i = lastIndex_;
while while
( (
i < timeVsFile_.size()-1 i < timeVsFile_.size()-1
&& timeVsFile_[i+1].first() < time_.value() && timeVsFile_[i+1].first() < time_.value()+0.5*time_.deltaTValue()
) )
{ {
i++; i++;
...@@ -69,6 +72,15 @@ void Foam::functionObjects::timeActivatedFileUpdate::updateFile() ...@@ -69,6 +72,15 @@ void Foam::functionObjects::timeActivatedFileUpdate::updateFile()
cp(timeVsFile_[i].second(), destFile); cp(timeVsFile_[i].second(), destFile);
mv(destFile, fileToUpdate_); mv(destFile, fileToUpdate_);
lastIndex_ = i; 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 ...@@ -130,7 +142,8 @@ bool Foam::functionObjects::timeActivatedFileUpdate::read
<< timeVsFile_[i].second() << endl; << timeVsFile_[i].second() << endl;
} }
updateFile(); // Copy starting files. Avoid recursion by not checking for modified files.
updateFile(false);
return true; return true;
} }
...@@ -138,7 +151,7 @@ bool Foam::functionObjects::timeActivatedFileUpdate::read ...@@ -138,7 +151,7 @@ bool Foam::functionObjects::timeActivatedFileUpdate::read
bool Foam::functionObjects::timeActivatedFileUpdate::execute() bool Foam::functionObjects::timeActivatedFileUpdate::execute()
{ {
updateFile(); updateFile(true);
return true; return true;
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -110,7 +110,7 @@ class timeActivatedFileUpdate ...@@ -110,7 +110,7 @@ class timeActivatedFileUpdate
// Private Member Functions // Private Member Functions
//- Update file //- Update file
void updateFile(); void updateFile(const bool checkFiles);
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
timeActivatedFileUpdate(const timeActivatedFileUpdate&); timeActivatedFileUpdate(const timeActivatedFileUpdate&);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment