mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: noiseModels - updated parallel usage (no longer needs proc dirs) and apply input data validation
This commit is contained in:
@ -102,6 +102,8 @@ using namespace Foam;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noCheckProcessorDirectories();
|
||||
|
||||
#include "addDictOption.H"
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
|
||||
@ -43,6 +43,7 @@ License
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::argList::bannerEnabled_ = true;
|
||||
bool Foam::argList::checkProcessorDirectories_ = true;
|
||||
Foam::SLList<Foam::string> Foam::argList::validArgs;
|
||||
Foam::HashTable<Foam::string> Foam::argList::validOptions;
|
||||
Foam::HashTable<Foam::string> Foam::argList::validParOptions;
|
||||
@ -194,6 +195,12 @@ void Foam::argList::noParallel()
|
||||
}
|
||||
|
||||
|
||||
void Foam::argList::noCheckProcessorDirectories()
|
||||
{
|
||||
checkProcessorDirectories_ = false;
|
||||
}
|
||||
|
||||
|
||||
void Foam::argList::printOptionUsage
|
||||
(
|
||||
const label location,
|
||||
@ -748,7 +755,7 @@ void Foam::argList::parse
|
||||
// - normal running : nProcs = dictNProcs = nProcDirs
|
||||
// - decomposition to more processors : nProcs = dictNProcs
|
||||
// - decomposition to fewer processors : nProcs = nProcDirs
|
||||
if (dictNProcs > Pstream::nProcs())
|
||||
if (checkProcessorDirectories_ && dictNProcs > Pstream::nProcs())
|
||||
{
|
||||
FatalError
|
||||
<< source
|
||||
@ -803,7 +810,11 @@ void Foam::argList::parse
|
||||
{
|
||||
// Possibly going to fewer processors.
|
||||
// Check if all procDirs are there.
|
||||
if (dictNProcs < Pstream::nProcs())
|
||||
if
|
||||
(
|
||||
checkProcessorDirectories_
|
||||
&& dictNProcs < Pstream::nProcs()
|
||||
)
|
||||
{
|
||||
label nProcDirs = 0;
|
||||
while
|
||||
@ -1318,9 +1329,11 @@ bool Foam::argList::checkRootCase() const
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Pstream::master() && !isDir(path()))
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
// Allow slaves on non-existing processor directories, created later
|
||||
if (Pstream::master() && (checkProcessorDirectories_ && !isDir(path())))
|
||||
{
|
||||
// Allow slaves on non-existing processor directories created later
|
||||
FatalError
|
||||
<< executable_
|
||||
<< ": cannot open case directory " << path()
|
||||
@ -1328,6 +1341,19 @@ bool Foam::argList::checkRootCase() const
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!isDir(path()))
|
||||
{
|
||||
FatalError
|
||||
<< executable_
|
||||
<< ": cannot open case directory " << path()
|
||||
<< endl;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -119,6 +119,9 @@ class argList
|
||||
//- Track enabled/disabled banner state
|
||||
static bool bannerEnabled_;
|
||||
|
||||
//- Track enabled/disabled checking of processor directories state
|
||||
static bool checkProcessorDirectories_;
|
||||
|
||||
//- Switch on/off parallel mode. Has to be first to be constructed
|
||||
// so destructor is done last.
|
||||
ParRunControl parRunControl_;
|
||||
@ -387,6 +390,9 @@ public:
|
||||
//- Remove the parallel options
|
||||
static void noParallel();
|
||||
|
||||
//- Remove checking of processor directories
|
||||
static void noCheckProcessorDirectories();
|
||||
|
||||
//- Return true if the post-processing option is specified
|
||||
static bool postProcess(int argc, char *argv[]);
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
(
|
||||
|
||||
@ -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_();
|
||||
|
||||
Reference in New Issue
Block a user