ENH: noiseModels - re-worked output directories to avoid clashes. Fixes

Both point- and surfaceNoise utilities can operate on multiple input
files.  However, if the files had the same name, the output would be
overwritten.  To avoid this, the output files are now written to a
sub-directory including the path '/input<input-file-index>/', e.g.

  postProcessing/noise/surfaceNoise/input0/nearWall/[fft|oneThirdOctave]

An optional 'outputPrefix' can be included (defaults to empty), e.g.
when set to 'test1':

  postProcessing/noise/test1/surfaceNoise/input0/nearWall/[fft|oneThirdOctave]
This commit is contained in:
Andrew Heather
2017-03-14 13:15:39 +00:00
parent b21242c14c
commit a7a3126a76
6 changed files with 86 additions and 59 deletions

View File

@ -112,10 +112,18 @@ Foam::label Foam::noiseModel::findStartTimeIndex
}
Foam::fileName Foam::noiseModel::baseFileDir() const
Foam::fileName Foam::noiseModel::baseFileDir(const label dataseti) const
{
fileName baseDir("$FOAM_CASE");
baseDir = baseDir.expand()/"postProcessing"/"noise";
word datasetName("input" + Foam::name(dataseti));
baseDir =
baseDir.expand()
/"postProcessing"
/"noise"
/outputPrefix_
/type()
/datasetName;
return baseDir;
}
@ -133,6 +141,7 @@ Foam::noiseModel::noiseModel(const dictionary& dict, const bool readFields)
startTime_(0),
windowModelPtr_(),
graphFormat_("raw"),
outputPrefix_(),
writePrmsf_(true),
writeSPL_(true),
writePSD_(true),
@ -169,6 +178,7 @@ bool Foam::noiseModel::read(const dictionary& dict)
}
dict.readIfPresent("startTime", startTime_);
dict.readIfPresent("graphFormat", graphFormat_);
dict.readIfPresent("outputPrefix", outputPrefix_);
// Check number of samples - must be a power of 2 for our FFT
bool powerOf2 = ((nSamples_ != 0) && !(nSamples_ & (nSamples_ - 1)));