BUG: parallel blocking writing surface noise output (fixes #2663)
- old logic (v2206 and earlier) always disabled writing on non-master, but other parts of the code were more recently updated to use lazy evaluation of surface data (with parallel communication) - now retain full write/no-write logic identically on all ranks. Take care of master/non-master at the final output stage.
This commit is contained in:
parent
0a01492397
commit
aebd79ff59
@ -157,30 +157,28 @@ namespace Foam
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::noiseModel::readWriteOption
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Get bool option (eg, read/write) and provide Info feedback
|
||||
static void readWriteOption
|
||||
(
|
||||
const dictionary& dict,
|
||||
const word& lookup,
|
||||
bool& option
|
||||
) const
|
||||
)
|
||||
{
|
||||
dict.readIfPresent(lookup, option);
|
||||
|
||||
// Only writing on the master process
|
||||
option = option && Pstream::master();
|
||||
|
||||
if (option)
|
||||
{
|
||||
Info<< " " << lookup << ": " << "yes" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< " " << lookup << ": " << "no" << endl;
|
||||
}
|
||||
Info<< " " << lookup << ": " << (option ? "yes" : "no") << endl;
|
||||
}
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
||||
|
||||
Foam::scalar Foam::noiseModel::checkUniformTimeStep
|
||||
(
|
||||
@ -255,7 +253,7 @@ void Foam::noiseModel::writeFileHeader
|
||||
Ostream& os,
|
||||
const string& x,
|
||||
const string& y,
|
||||
const List<Tuple2<string, token>>& headerValues
|
||||
const UList<Tuple2<string, token>>& headerValues
|
||||
) const
|
||||
{
|
||||
writeHeader(os, x + " vs " + y);
|
||||
|
@ -76,8 +76,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef noiseModel_H
|
||||
#define noiseModel_H
|
||||
#ifndef Foam_noiseModel_H
|
||||
#define Foam_noiseModel_H
|
||||
|
||||
#include "writeFile.H"
|
||||
#include "dictionary.H"
|
||||
@ -220,14 +220,6 @@ protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Helper function to read write options and provide info feedback
|
||||
void readWriteOption
|
||||
(
|
||||
const dictionary& dict,
|
||||
const word& lookup,
|
||||
bool& option
|
||||
) const;
|
||||
|
||||
//- Check and return uniform time step
|
||||
scalar checkUniformTimeStep
|
||||
(
|
||||
@ -257,7 +249,7 @@ protected:
|
||||
Ostream& os,
|
||||
const string& x,
|
||||
const string& y,
|
||||
const List<Tuple2<string, token>>& headerValues = {}
|
||||
const UList<Tuple2<string, token>>& headerValues = {}
|
||||
) const;
|
||||
|
||||
// Write frequency-based data to file
|
||||
|
@ -74,6 +74,14 @@ void pointNoise::processData
|
||||
const Function1Types::CSV<scalar>& data
|
||||
)
|
||||
{
|
||||
if (!Pstream::master())
|
||||
{
|
||||
// Only ever called on master, report if we have odd logic...
|
||||
WarningInFunction
|
||||
<< "Currently only to be called from master process..." << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
Info<< "Reading data file: "
|
||||
<< fileObr_.time().relativePath(data.fName()) << endl;
|
||||
|
||||
@ -131,7 +139,7 @@ void pointNoise::processData
|
||||
auto filePtr = newFile(outDir/"PSD_f");
|
||||
auto& os = filePtr();
|
||||
|
||||
Info<< " Writing " << os.name() << endl;
|
||||
Info<< " Writing " << os.relativeName() << endl;
|
||||
|
||||
writeFileHeader(os, "f [Hz]", "PSD(f) [PaPa_Hz]");
|
||||
writeFreqDataToFile(os, f, PSDf);
|
||||
@ -143,7 +151,7 @@ void pointNoise::processData
|
||||
auto filePtr = newFile(outDir/"PSD_dB_Hz_f");
|
||||
auto& os = filePtr();
|
||||
|
||||
Info<< " Writing " << os.name() << endl;
|
||||
Info<< " Writing " << os.relativeName() << endl;
|
||||
|
||||
writeFileHeader(os, "f [Hz]", "PSD(f) [dB_Hz]");
|
||||
writeFreqDataToFile(os, f, PSD(PSDf));
|
||||
@ -155,7 +163,7 @@ void pointNoise::processData
|
||||
auto filePtr = newFile(outDir/"SPL_dB_f");
|
||||
auto& os = filePtr();
|
||||
|
||||
Info<< " Writing " << os.name() << endl;
|
||||
Info<< " Writing " << os.relativeName() << endl;
|
||||
|
||||
writeFileHeader
|
||||
(
|
||||
@ -190,7 +198,7 @@ void pointNoise::processData
|
||||
auto filePtr = newFile(outDir/"SPL13_dB_fm");
|
||||
auto& os = filePtr();
|
||||
|
||||
Info<< " Writing " << os.name() << endl;
|
||||
Info<< " Writing " << os.relativeName() << endl;
|
||||
|
||||
writeFileHeader
|
||||
(
|
||||
|
@ -362,7 +362,7 @@ scalar surfaceNoise::writeSurfaceData
|
||||
areaAverage = sum(allData)/(allData.size() + ROOTVSMALL);
|
||||
}
|
||||
|
||||
if (writeSurface)
|
||||
// (writeSurface == true)
|
||||
{
|
||||
// Time-aware, with time spliced into the output path
|
||||
writerPtr_->beginTime(freqInst);
|
||||
@ -397,7 +397,7 @@ scalar surfaceNoise::writeSurfaceData
|
||||
areaAverage = sum(data)/(data.size() + ROOTVSMALL);
|
||||
}
|
||||
|
||||
if (writeSurface)
|
||||
// (writeSurface == true)
|
||||
{
|
||||
// Time-aware, with time spliced into the output path
|
||||
writerPtr_->beginTime(freqInst);
|
||||
@ -693,15 +693,19 @@ void surfaceNoise::calculate()
|
||||
surfArea = sum(surf.magSf());
|
||||
surfSize = surf.size();
|
||||
}
|
||||
Pstream::broadcast(surfArea);
|
||||
Pstream::broadcast(surfSize);
|
||||
Pstream::broadcasts
|
||||
(
|
||||
UPstream::worldComm,
|
||||
surfArea,
|
||||
surfSize
|
||||
);
|
||||
|
||||
List<Tuple2<string, token>> commonInfo =
|
||||
{
|
||||
{"Area average", token(word(Switch::name(areaAverage_)))},
|
||||
{"Area sum", token(surfArea)},
|
||||
{"Number of faces", token(surfSize)}
|
||||
};
|
||||
List<Tuple2<string, token>> commonInfo
|
||||
({
|
||||
{"Area average", token(word(Switch::name(areaAverage_)))},
|
||||
{"Area sum", token(surfArea)},
|
||||
{"Number of faces", token(surfSize)}
|
||||
});
|
||||
|
||||
{
|
||||
fileName outDir(outDirBase/"fft");
|
||||
@ -782,7 +786,7 @@ void surfaceNoise::calculate()
|
||||
auto filePtr = newFile(outDir/"Average_Prms_f");
|
||||
auto& os = filePtr();
|
||||
|
||||
Info<< " Writing " << os.name() << endl;
|
||||
Info<< " Writing " << os.relativeName() << endl;
|
||||
|
||||
writeFileHeader(os, "f [Hz]", "P(f) [Pa]", commonInfo);
|
||||
writeFreqDataToFile(os, fOut, PrmsfAve);
|
||||
@ -791,7 +795,7 @@ void surfaceNoise::calculate()
|
||||
auto filePtr = newFile(outDir/"Average_PSD_f_f");
|
||||
auto& os = filePtr();
|
||||
|
||||
Info<< " Writing " << os.name() << endl;
|
||||
Info<< " Writing " << os.relativeName() << endl;
|
||||
|
||||
writeFileHeader
|
||||
(
|
||||
@ -806,7 +810,7 @@ void surfaceNoise::calculate()
|
||||
auto filePtr = newFile(outDir/"Average_PSD_dB_Hz_f");
|
||||
auto& os = filePtr();
|
||||
|
||||
Info<< " Writing " << os.name() << endl;
|
||||
Info<< " Writing " << os.relativeName() << endl;
|
||||
|
||||
writeFileHeader
|
||||
(
|
||||
@ -821,7 +825,7 @@ void surfaceNoise::calculate()
|
||||
auto filePtr = newFile(outDir/"Average_SPL_dB_f");
|
||||
auto& os = filePtr();
|
||||
|
||||
Info<< " Writing " << os.name() << endl;
|
||||
Info<< " Writing " << os.relativeName() << endl;
|
||||
|
||||
writeFileHeader
|
||||
(
|
||||
@ -866,7 +870,7 @@ void surfaceNoise::calculate()
|
||||
auto filePtr = newFile(outDir/"Average_SPL13_dB_fm");
|
||||
auto& os = filePtr();
|
||||
|
||||
Info<< " Writing " << os.name() << endl;
|
||||
Info<< " Writing " << os.relativeName() << endl;
|
||||
|
||||
writeFileHeader
|
||||
(
|
||||
|
Loading…
Reference in New Issue
Block a user