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

@ -50,12 +50,6 @@ Foam::twoPhaseMixtureThermo::twoPhaseMixtureThermo
thermo1_(nullptr),
thermo2_(nullptr)
{
// Note: we're writing files to be read in immediately afterwards.
// Avoid any thread-writing problems.
float bufSz =
fileOperations::collatedFileOperation::maxThreadFileBufferSize;
fileOperations::collatedFileOperation::maxThreadFileBufferSize = 0;
{
volScalarField T1(IOobject::groupName("T", phase1Name()), T_);
T1.write();
@ -66,9 +60,9 @@ Foam::twoPhaseMixtureThermo::twoPhaseMixtureThermo
T2.write();
}
fileOperations::collatedFileOperation::maxThreadFileBufferSize =
bufSz;
// Note: we're writing files to be read in immediately afterwards.
// Avoid any thread-writing problems.
fileHandler().flush();
thermo1_ = rhoThermo::New(U.mesh(), phase1Name());
thermo2_ = rhoThermo::New(U.mesh(), phase2Name());