fileHandler: Added flush method

This method waits until all the threads have completed IO operations and
then clears any cached information about the files on disk. This
replaces the deactivation of threading by means of zeroing the buffer
size when writing and reading of a file happen in sequence. It also
allows paraFoam to update the list of available times.

Patch contributed by Mattijs Janssens
Resolves bug report https://bugs.openfoam.org/view.php?id=2962
This commit is contained in:
Will Bainbridge
2018-06-27 11:45:58 +01:00
committed by mattijs
parent 70bc72c2df
commit 2ae4bf73d9
12 changed files with 71 additions and 37 deletions

View File

@ -611,6 +611,18 @@ bool Foam::fileOperations::collatedFileOperation::writeObject
}
}
void Foam::fileOperations::collatedFileOperation::flush() const
{
if (debug)
{
Pout<< "collatedFileOperation::flush : clearing and waiting for thread"
<< endl;
}
masterUncollatedFileOperation::flush();
// Wait for thread to finish (note: also removes thread)
writer_.waitAll();
}
Foam::word Foam::fileOperations::collatedFileOperation::processorsDir
(

View File

@ -155,6 +155,9 @@ public:
// Other
//- Forcibly wait until all output done. Flush any cached data
virtual void flush() const;
//- Actual name of processors dir
virtual word processorsDir(const IOobject&) const;

View File

@ -991,6 +991,17 @@ Foam::label Foam::fileOperation::nProcs
}
void Foam::fileOperation::flush() const
{
if (debug)
{
Pout<< "fileOperation::flush : clearing processor directories cache"
<< endl;
}
procsDirs_.clear();
}
Foam::fileName Foam::fileOperation::processorsCasePath
(
const IOobject& io,

View File

@ -514,6 +514,9 @@ public:
virtual void setTime(const Time&) const
{}
//- Forcibly wait until all output done. Flush any cached data
virtual void flush() const;
//- Generate path (like io.path) from root+casename with any
// 'processorXXX' replaced by procDir (usually 'processsors')
fileName processorsCasePath

View File

@ -2561,6 +2561,13 @@ Foam::fileOperations::masterUncollatedFileOperation::NewOFstream
}
void Foam::fileOperations::masterUncollatedFileOperation::flush() const
{
fileOperation::flush();
times_.clear();
}
Foam::label Foam::fileOperations::masterUncollatedFileOperation::addWatch
(
const fileName& fName

View File

@ -769,6 +769,9 @@ public:
//- Callback for time change
virtual void setTime(const Time&) const;
//- Forcibly wait until all output done. Flush any cached data
virtual void flush() const;
//- Return cached times
const HashPtrTable<instantList>& times() const
{