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[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
argList::noCheckProcessorDirectories();
|
||||||
|
|
||||||
#include "addDictOption.H"
|
#include "addDictOption.H"
|
||||||
#include "setRootCase.H"
|
#include "setRootCase.H"
|
||||||
#include "createTime.H"
|
#include "createTime.H"
|
||||||
|
|||||||
@ -43,6 +43,7 @@ License
|
|||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::argList::bannerEnabled_ = true;
|
bool Foam::argList::bannerEnabled_ = true;
|
||||||
|
bool Foam::argList::checkProcessorDirectories_ = true;
|
||||||
Foam::SLList<Foam::string> Foam::argList::validArgs;
|
Foam::SLList<Foam::string> Foam::argList::validArgs;
|
||||||
Foam::HashTable<Foam::string> Foam::argList::validOptions;
|
Foam::HashTable<Foam::string> Foam::argList::validOptions;
|
||||||
Foam::HashTable<Foam::string> Foam::argList::validParOptions;
|
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
|
void Foam::argList::printOptionUsage
|
||||||
(
|
(
|
||||||
const label location,
|
const label location,
|
||||||
@ -748,7 +755,7 @@ void Foam::argList::parse
|
|||||||
// - normal running : nProcs = dictNProcs = nProcDirs
|
// - normal running : nProcs = dictNProcs = nProcDirs
|
||||||
// - decomposition to more processors : nProcs = dictNProcs
|
// - decomposition to more processors : nProcs = dictNProcs
|
||||||
// - decomposition to fewer processors : nProcs = nProcDirs
|
// - decomposition to fewer processors : nProcs = nProcDirs
|
||||||
if (dictNProcs > Pstream::nProcs())
|
if (checkProcessorDirectories_ && dictNProcs > Pstream::nProcs())
|
||||||
{
|
{
|
||||||
FatalError
|
FatalError
|
||||||
<< source
|
<< source
|
||||||
@ -803,7 +810,11 @@ void Foam::argList::parse
|
|||||||
{
|
{
|
||||||
// Possibly going to fewer processors.
|
// Possibly going to fewer processors.
|
||||||
// Check if all procDirs are there.
|
// Check if all procDirs are there.
|
||||||
if (dictNProcs < Pstream::nProcs())
|
if
|
||||||
|
(
|
||||||
|
checkProcessorDirectories_
|
||||||
|
&& dictNProcs < Pstream::nProcs()
|
||||||
|
)
|
||||||
{
|
{
|
||||||
label nProcDirs = 0;
|
label nProcDirs = 0;
|
||||||
while
|
while
|
||||||
@ -1318,15 +1329,30 @@ bool Foam::argList::checkRootCase() const
|
|||||||
return false;
|
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())))
|
||||||
FatalError
|
{
|
||||||
<< executable_
|
// Allow slaves on non-existing processor directories created later
|
||||||
<< ": cannot open case directory " << path()
|
FatalError
|
||||||
<< endl;
|
<< executable_
|
||||||
|
<< ": cannot open case directory " << path()
|
||||||
|
<< endl;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!isDir(path()))
|
||||||
|
{
|
||||||
|
FatalError
|
||||||
|
<< executable_
|
||||||
|
<< ": cannot open case directory " << path()
|
||||||
|
<< endl;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -119,6 +119,9 @@ class argList
|
|||||||
//- Track enabled/disabled banner state
|
//- Track enabled/disabled banner state
|
||||||
static bool bannerEnabled_;
|
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
|
//- Switch on/off parallel mode. Has to be first to be constructed
|
||||||
// so destructor is done last.
|
// so destructor is done last.
|
||||||
ParRunControl parRunControl_;
|
ParRunControl parRunControl_;
|
||||||
@ -387,6 +390,9 @@ public:
|
|||||||
//- Remove the parallel options
|
//- Remove the parallel options
|
||||||
static void noParallel();
|
static void noParallel();
|
||||||
|
|
||||||
|
//- Remove checking of processor directories
|
||||||
|
static void noCheckProcessorDirectories();
|
||||||
|
|
||||||
//- Return true if the post-processing option is specified
|
//- Return true if the post-processing option is specified
|
||||||
static bool postProcess(int argc, char *argv[]);
|
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
|
Foam::label Foam::noiseModel::findStartTimeIndex
|
||||||
(
|
(
|
||||||
const instantList& allTimes,
|
const instantList& allTimes,
|
||||||
@ -141,6 +163,8 @@ Foam::noiseModel::noiseModel(const dictionary& dict, const bool readFields)
|
|||||||
startTime_(0),
|
startTime_(0),
|
||||||
windowModelPtr_(),
|
windowModelPtr_(),
|
||||||
graphFormat_("raw"),
|
graphFormat_("raw"),
|
||||||
|
minPressure_(-0.5*VGREAT),
|
||||||
|
maxPressure_(0.5*VGREAT),
|
||||||
outputPrefix_(),
|
outputPrefix_(),
|
||||||
writePrmsf_(true),
|
writePrmsf_(true),
|
||||||
writeSPL_(true),
|
writeSPL_(true),
|
||||||
@ -178,6 +202,8 @@ bool Foam::noiseModel::read(const dictionary& dict)
|
|||||||
}
|
}
|
||||||
dict.readIfPresent("startTime", startTime_);
|
dict.readIfPresent("startTime", startTime_);
|
||||||
dict.readIfPresent("graphFormat", graphFormat_);
|
dict.readIfPresent("graphFormat", graphFormat_);
|
||||||
|
dict.readIfPresent("minPressure", minPressure_);
|
||||||
|
dict.readIfPresent("maxPressure", maxPressure_);
|
||||||
dict.readIfPresent("outputPrefix", outputPrefix_);
|
dict.readIfPresent("outputPrefix", outputPrefix_);
|
||||||
|
|
||||||
// Check number of samples - must be a power of 2 for our FFT
|
// 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_);
|
windowModelPtr_ = windowModel::New(dict, nSamples_);
|
||||||
|
|
||||||
|
Info<< nl << endl;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -126,7 +126,7 @@ protected:
|
|||||||
//- Upper frequency limit, default = 10kHz
|
//- Upper frequency limit, default = 10kHz
|
||||||
scalar fUpper_;
|
scalar fUpper_;
|
||||||
|
|
||||||
//- Flag to indicate that custom frequenct bounds are being used
|
//- Flag to indicate that custom frequency bounds are being used
|
||||||
bool customBounds_;
|
bool customBounds_;
|
||||||
|
|
||||||
//- Start time, default = 0s
|
//- Start time, default = 0s
|
||||||
@ -139,6 +139,15 @@ protected:
|
|||||||
word graphFormat_;
|
word graphFormat_;
|
||||||
|
|
||||||
|
|
||||||
|
// Data validation
|
||||||
|
|
||||||
|
//- Min pressure value
|
||||||
|
scalar minPressure_;
|
||||||
|
|
||||||
|
//- Min pressure value
|
||||||
|
scalar maxPressure_;
|
||||||
|
|
||||||
|
|
||||||
// Write options
|
// Write options
|
||||||
|
|
||||||
//- Output file prefix, default = ''
|
//- Output file prefix, default = ''
|
||||||
@ -176,6 +185,9 @@ protected:
|
|||||||
const scalarList& times
|
const scalarList& times
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
//- Return true if all pressure data is within min/max bounds
|
||||||
|
bool validateBounds(const scalarList& p) const;
|
||||||
|
|
||||||
//- Find and return start time index
|
//- Find and return start time index
|
||||||
label findStartTimeIndex
|
label findStartTimeIndex
|
||||||
(
|
(
|
||||||
|
|||||||
@ -84,8 +84,16 @@ void pointNoise::processData
|
|||||||
Info<< " read " << t.size() << " values" << nl << endl;
|
Info<< " read " << t.size() << " values" << nl << endl;
|
||||||
|
|
||||||
Info<< "Creating noise FFT" << endl;
|
Info<< "Creating noise FFT" << endl;
|
||||||
|
|
||||||
const scalar deltaT = checkUniformTimeStep(t);
|
const scalar deltaT = checkUniformTimeStep(t);
|
||||||
|
|
||||||
|
if (!validateBounds(p))
|
||||||
|
{
|
||||||
|
Info<< "No noise data generated" << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Determine the windowing
|
// Determine the windowing
|
||||||
windowModelPtr_->validate(t.size());
|
windowModelPtr_->validate(t.size());
|
||||||
const windowModel& win = windowModelPtr_();
|
const windowModel& win = windowModelPtr_();
|
||||||
|
|||||||
Reference in New Issue
Block a user