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

@ -194,7 +194,8 @@ int Foam::vtkPVFoam::setTime(const std::vector<double>& requestTimes)
Time& runTime = dbPtr_();
// Get times list
// Get times list. Flush first to force refresh.
fileHandler().flush();
instantList Times = runTime.times();
int nearestIndex = timeIndex_;
@ -301,11 +302,6 @@ Foam::vtkPVFoam::vtkPVFoam
fileName FileName(vtkFileName);
// Make sure not to use the threaded version - it does not like
// being loaded as a shared library - static cleanup order is problematic.
// For now just disable the threaded writer.
fileOperations::collatedFileOperation::maxThreadFileBufferSize = 0;
// avoid argList and get rootPath/caseName directly from the file
fileName fullCasePath(FileName.path());
@ -729,6 +725,8 @@ std::vector<double> Foam::vtkPVFoam::findTimes(const bool skipZero) const
if (dbPtr_.valid())
{
const Time& runTime = dbPtr_();
// Get times list. Flush first to force refresh.
fileHandler().flush();
instantList timeLst = runTime.times();
// find the first time for which this mesh appears to exist

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
@ -225,6 +225,9 @@ void Foam::vtkPVFoam::updateInfoLagrangian
// List of lagrangian objects across all times
HashSet<fileName> names;
// Get times list. Flush first to force refresh.
fileHandler().flush();
for (const instant& t : dbPtr_().times())
{
names.insert
@ -697,6 +700,7 @@ void Foam::vtkPVFoam::updateInfoLagrangianFields
// to some of the clouds.
HashTable<wordHashSet> fields;
fileHandler().flush();
for (const instant& t : dbPtr_().times())
{
for (const auto& cloudName : cloudNames)