ENH: noiseModel updates

- Limit output to frequency range given by fLower and fUpper (if supplied)
- Enable noise models to be run outside of $FOAM_CASE directory
  - if relative paths are used, $FOAM_CASE is prepended to the noise
    dict and input file names
- Enable output to be customised, e.g.

    // Optional write options dictionary (all default to 'yes')
    writeOptions
    {
        writePrmsf  no;
        writeSPL    yes;
        writePSD    yes;
        writePSDf   no;
        writeOctaves yes;
    }
This commit is contained in:
Andrew Heather
2017-03-01 13:55:05 +00:00
parent bcde59e646
commit 34bc14a53d
7 changed files with 312 additions and 110 deletions

View File

@ -35,6 +35,26 @@ namespace Foam
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
void Foam::noiseModel::readWriteOption
(
const dictionary& dict,
const word& lookup,
bool& option
) const
{
dict.readIfPresent(lookup, option);
if (option)
{
Info<< " " << lookup << ": " << "yes" << endl;
}
else
{
Info<< " " << lookup << ": " << "no" << endl;
}
}
Foam::scalar Foam::noiseModel::checkUniformTimeStep
(
const scalarList& times
@ -92,6 +112,14 @@ Foam::label Foam::noiseModel::findStartTimeIndex
}
Foam::fileName Foam::noiseModel::baseFileDir() const
{
fileName baseDir("$FOAM_CASE");
baseDir = baseDir.expand()/"postProcessing"/"noise";
return baseDir;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::noiseModel::noiseModel(const dictionary& dict, const bool readFields)
@ -101,9 +129,15 @@ Foam::noiseModel::noiseModel(const dictionary& dict, const bool readFields)
nSamples_(65536),
fLower_(25),
fUpper_(10000),
customBounds_(false),
startTime_(0),
windowModelPtr_(),
graphFormat_("raw")
graphFormat_("raw"),
writePrmsf_(true),
writeSPL_(true),
writePSD_(true),
writePSDf_(true),
writeOctaves_(true)
{
if (readFields)
{
@ -124,8 +158,11 @@ bool Foam::noiseModel::read(const dictionary& dict)
{
dict.readIfPresent("rhoRef", rhoRef_);
dict.readIfPresent("N", nSamples_);
dict.readIfPresent("fl", fLower_);
dict.readIfPresent("fu", fUpper_);
customBounds_ = false;
if (dict.readIfPresent("fl", fLower_) || dict.readIfPresent("fu", fUpper_))
{
customBounds_ = true;
}
dict.readIfPresent("startTime", startTime_);
dict.readIfPresent("graphFormat", graphFormat_);
@ -164,6 +201,14 @@ bool Foam::noiseModel::read(const dictionary& dict)
}
Info<< " Write options:" << endl;
dictionary optDict(dict.subOrEmptyDict("writeOptions"));
readWriteOption(optDict, "writePrmsf", writePrmsf_);
readWriteOption(optDict, "writeSPL", writeSPL_);
readWriteOption(optDict, "writePSD", writePSD_);
readWriteOption(optDict, "writeOctaves", writeOctaves_);
windowModelPtr_ = windowModel::New(dict, nSamples_);
return true;