ENH: noiseModels - added feedback for the case that frequency range is empty
This commit is contained in:
parent
5ba31cd5de
commit
cbfa9f685e
@ -237,7 +237,8 @@ Foam::fileName Foam::noiseModel::baseFileDir(const label dataseti) const
|
|||||||
|
|
||||||
Foam::tmp<Foam::scalarField> Foam::noiseModel::uniformFrequencies
|
Foam::tmp<Foam::scalarField> Foam::noiseModel::uniformFrequencies
|
||||||
(
|
(
|
||||||
const scalar deltaT
|
const scalar deltaT,
|
||||||
|
const bool check
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const auto& window = windowModelPtr_();
|
const auto& window = windowModelPtr_();
|
||||||
@ -247,9 +248,24 @@ Foam::tmp<Foam::scalarField> Foam::noiseModel::uniformFrequencies
|
|||||||
auto& f = tf.ref();
|
auto& f = tf.ref();
|
||||||
|
|
||||||
const scalar deltaf = 1.0/(N*deltaT);
|
const scalar deltaf = 1.0/(N*deltaT);
|
||||||
|
|
||||||
|
label nFreq = 0;
|
||||||
forAll(f, i)
|
forAll(f, i)
|
||||||
{
|
{
|
||||||
f[i] = i*deltaf;
|
f[i] = i*deltaf;
|
||||||
|
|
||||||
|
if (f[i] > fLower_ && f[i] < fUpper_)
|
||||||
|
{
|
||||||
|
++nFreq;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (check && nFreq == 0)
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "No frequencies found in range "
|
||||||
|
<< fLower_ << " to " << fUpper_
|
||||||
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return tf;
|
return tf;
|
||||||
@ -263,8 +279,6 @@ Foam::tmp<Foam::scalarField> Foam::noiseModel::octaves
|
|||||||
const labelUList& freqBandIDs
|
const labelUList& freqBandIDs
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
auto toctData = tmp<scalarField>::New(freqBandIDs.size() - 1, Zero);
|
|
||||||
|
|
||||||
if (freqBandIDs.size() < 2)
|
if (freqBandIDs.size() < 2)
|
||||||
{
|
{
|
||||||
WarningInFunction
|
WarningInFunction
|
||||||
@ -272,11 +286,13 @@ Foam::tmp<Foam::scalarField> Foam::noiseModel::octaves
|
|||||||
<< "- skipping octaves calculation"
|
<< "- skipping octaves calculation"
|
||||||
<< endl;
|
<< endl;
|
||||||
|
|
||||||
return toctData;
|
return tmp<scalarField>::New();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto toctData = tmp<scalarField>::New(freqBandIDs.size() - 1, Zero);
|
||||||
auto& octData = toctData.ref();
|
auto& octData = toctData.ref();
|
||||||
|
|
||||||
|
bitSet bandUsed(freqBandIDs.size() - 1);
|
||||||
for (label bandI = 0; bandI < freqBandIDs.size() - 1; ++bandI)
|
for (label bandI = 0; bandI < freqBandIDs.size() - 1; ++bandI)
|
||||||
{
|
{
|
||||||
label fb0 = freqBandIDs[bandI];
|
label fb0 = freqBandIDs[bandI];
|
||||||
@ -290,9 +306,20 @@ Foam::tmp<Foam::scalarField> Foam::noiseModel::octaves
|
|||||||
label f1 = f[freqI + 1];
|
label f1 = f[freqI + 1];
|
||||||
scalar dataAve = 0.5*(data[freqI] + data[freqI + 1]);
|
scalar dataAve = 0.5*(data[freqI] + data[freqI + 1]);
|
||||||
octData[bandI] += dataAve*(f1 - f0);
|
octData[bandI] += dataAve*(f1 - f0);
|
||||||
|
|
||||||
|
bandUsed.set(bandI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bandUsed.flip();
|
||||||
|
labelList bandUnused = bandUsed.sortedToc();
|
||||||
|
if (bandUnused.size())
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "Empty bands found: " << bandUnused.size() << " of "
|
||||||
|
<< bandUsed.size() << endl;
|
||||||
|
}
|
||||||
|
|
||||||
return toctData;
|
return toctData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,7 +246,11 @@ protected:
|
|||||||
|
|
||||||
//- Create a field of equally spaced frequencies for the current set of
|
//- Create a field of equally spaced frequencies for the current set of
|
||||||
//- data - assumes a constant time step
|
//- data - assumes a constant time step
|
||||||
tmp<scalarField> uniformFrequencies(const scalar deltaT) const;
|
tmp<scalarField> uniformFrequencies
|
||||||
|
(
|
||||||
|
const scalar deltaT,
|
||||||
|
const bool check
|
||||||
|
) const;
|
||||||
|
|
||||||
//- Return a list of the frequency indices wrt f field that correspond
|
//- Return a list of the frequency indices wrt f field that correspond
|
||||||
//- to the bands limits for a given octave
|
//- to the bands limits for a given octave
|
||||||
|
@ -109,7 +109,7 @@ void pointNoise::processData
|
|||||||
// Narrow band data
|
// Narrow band data
|
||||||
// ----------------
|
// ----------------
|
||||||
|
|
||||||
scalarField f(uniformFrequencies(deltaT));
|
scalarField f(uniformFrequencies(deltaT, true));
|
||||||
|
|
||||||
// RMS pressure [Pa]
|
// RMS pressure [Pa]
|
||||||
if (writePrmsf_)
|
if (writePrmsf_)
|
||||||
|
@ -515,7 +515,7 @@ void surfaceNoise::calculate()
|
|||||||
|
|
||||||
Info<< "Creating noise FFTs" << endl;
|
Info<< "Creating noise FFTs" << endl;
|
||||||
|
|
||||||
const scalarField freq1(uniformFrequencies(deltaT_));
|
const scalarField freq1(uniformFrequencies(deltaT_, true));
|
||||||
|
|
||||||
// Reset desired frequency range if outside actual frequency range
|
// Reset desired frequency range if outside actual frequency range
|
||||||
fLower_ = min(fLower_, max(freq1));
|
fLower_ = min(fLower_, max(freq1));
|
||||||
|
Loading…
Reference in New Issue
Block a user