twoPhaseMixtureThermo: Fix for collated file operation

twoPhaseMixtureThermo writes the temperatures during construction only
for them to be read again immediately after by construction of the
individual phases' thermo models. When running with collated file
handling this behaviour is not thread safe. This change deactivates
threading for the duration of this behaviour.

Patch contributed by Mattijs Janssens
This commit is contained in:
Will Bainbridge
2018-06-14 10:55:27 +01:00
committed by mattijs
parent 6fb5c1f59a
commit 70bc72c2df
7 changed files with 74 additions and 15 deletions

View File

@ -26,7 +26,7 @@ License
#include "twoPhaseMixtureThermo.H"
#include "gradientEnergyFvPatchScalarField.H"
#include "mixedEnergyFvPatchScalarField.H"
#include "collatedFileOperation.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -50,6 +50,12 @@ 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();
@ -60,6 +66,10 @@ Foam::twoPhaseMixtureThermo::twoPhaseMixtureThermo
T2.write();
}
fileOperations::collatedFileOperation::maxThreadFileBufferSize =
bufSz;
thermo1_ = rhoThermo::New(U.mesh(), phase1Name());
thermo2_ = rhoThermo::New(U.mesh(), phase2Name());