ENH: noiseModels - updated parallel usage (no longer needs proc dirs) and apply input data validation

This commit is contained in:
Andrew Heather
2017-06-01 17:27:30 +01:00
parent f431a328d2
commit 6a0b35bdc8
6 changed files with 92 additions and 10 deletions

View File

@ -92,6 +92,28 @@ Foam::scalar Foam::noiseModel::checkUniformTimeStep
}
bool Foam::noiseModel::validateBounds(const scalarList& p) const
{
forAll(p, i)
{
if ((p[i] < minPressure_) || (p[i] > maxPressure_))
{
WarningInFunction
<< "Pressure data at position " << i
<< " is outside of permitted bounds:" << nl
<< " pressure: " << p[i] << nl
<< " minimum pressure: " << minPressure_ << nl
<< " maximum pressure: " << maxPressure_ << nl
<< endl;
return false;
}
}
return true;
}
Foam::label Foam::noiseModel::findStartTimeIndex
(
const instantList& allTimes,
@ -141,6 +163,8 @@ Foam::noiseModel::noiseModel(const dictionary& dict, const bool readFields)
startTime_(0),
windowModelPtr_(),
graphFormat_("raw"),
minPressure_(-0.5*VGREAT),
maxPressure_(0.5*VGREAT),
outputPrefix_(),
writePrmsf_(true),
writeSPL_(true),
@ -178,6 +202,8 @@ bool Foam::noiseModel::read(const dictionary& dict)
}
dict.readIfPresent("startTime", startTime_);
dict.readIfPresent("graphFormat", graphFormat_);
dict.readIfPresent("minPressure", minPressure_);
dict.readIfPresent("maxPressure", maxPressure_);
dict.readIfPresent("outputPrefix", outputPrefix_);
// Check number of samples - must be a power of 2 for our FFT
@ -225,6 +251,8 @@ bool Foam::noiseModel::read(const dictionary& dict)
windowModelPtr_ = windowModel::New(dict, nSamples_);
Info<< nl << endl;
return true;
}

View File

@ -126,7 +126,7 @@ protected:
//- Upper frequency limit, default = 10kHz
scalar fUpper_;
//- Flag to indicate that custom frequenct bounds are being used
//- Flag to indicate that custom frequency bounds are being used
bool customBounds_;
//- Start time, default = 0s
@ -139,6 +139,15 @@ protected:
word graphFormat_;
// Data validation
//- Min pressure value
scalar minPressure_;
//- Min pressure value
scalar maxPressure_;
// Write options
//- Output file prefix, default = ''
@ -176,6 +185,9 @@ protected:
const scalarList& times
) const;
//- Return true if all pressure data is within min/max bounds
bool validateBounds(const scalarList& p) const;
//- Find and return start time index
label findStartTimeIndex
(

View File

@ -84,8 +84,16 @@ void pointNoise::processData
Info<< " read " << t.size() << " values" << nl << endl;
Info<< "Creating noise FFT" << endl;
const scalar deltaT = checkUniformTimeStep(t);
if (!validateBounds(p))
{
Info<< "No noise data generated" << endl;
return;
}
// Determine the windowing
windowModelPtr_->validate(t.size());
const windowModel& win = windowModelPtr_();