mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: avoid unrestricted dictionary lookup in randomProcesses, waveModels
- ref issue #762 STYLE: consistency in file vs files for pointNoise and surfaceNoise - use "files" when available, fallback to "file" otherwise.
This commit is contained in:
@ -45,13 +45,13 @@ addToRunTimeSelectionTable(windowModel, Hanning, dictionary);
|
||||
Hanning::Hanning(const dictionary& dict, const label nSamples)
|
||||
:
|
||||
windowModel(dict, nSamples),
|
||||
symmetric_(readBool(dict.lookup("symmetric"))),
|
||||
extended_(readBool(dict.lookup("extended"))),
|
||||
symmetric_(dict.get<bool>("symmetric")),
|
||||
extended_(dict.get<bool>("extended")),
|
||||
alpha_(dict.lookupOrDefault("alpha", 0.5)) // Hamming = 0.54
|
||||
{
|
||||
// Extend range if required
|
||||
label offset = extended_ ? 1 : 0;
|
||||
scalar m = nSamples - 1 + 2*offset;
|
||||
const label offset = extended_ ? 1 : 0;
|
||||
const scalar m = nSamples - 1 + 2*offset;
|
||||
|
||||
scalarField t(nSamples);
|
||||
forAll(t, i)
|
||||
@ -81,19 +81,13 @@ Hanning::Hanning(const dictionary& dict, const label nSamples)
|
||||
}
|
||||
}
|
||||
|
||||
scalar sumSqr = sum(sqr(wf));
|
||||
const scalar sumSqr = sum(sqr(wf));
|
||||
|
||||
// Normalisation
|
||||
wf *= sqrt(nSamples/sumSqr);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Hanning::~Hanning()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Hanning::symmetric() const
|
||||
|
||||
@ -97,7 +97,7 @@ public:
|
||||
Hanning(const dictionary& dict, const label nSamples);
|
||||
|
||||
//- Destructor
|
||||
virtual ~Hanning();
|
||||
virtual ~Hanning() = default;
|
||||
|
||||
|
||||
// Public Member Functions
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -45,19 +45,13 @@ addToRunTimeSelectionTable(windowModel, uniform, dictionary);
|
||||
uniform::uniform(const dictionary& dict, const label nSamples)
|
||||
:
|
||||
windowModel(dict, nSamples),
|
||||
value_(readScalar(dict.lookup("value")))
|
||||
value_(dict.get<scalar>("value"))
|
||||
{
|
||||
scalarField& wf = *this;
|
||||
wf = value_;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
uniform::~uniform()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace windowModels
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -73,7 +73,7 @@ public:
|
||||
uniform(const dictionary& dict, const label nSamples);
|
||||
|
||||
//- Destructor
|
||||
virtual ~uniform();
|
||||
virtual ~uniform() = default;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2015-2018 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -42,17 +42,13 @@ Foam::windowModel::windowModel(const dictionary& dict, const label nSamples)
|
||||
nOverlapSamples_(0),
|
||||
nWindow_(dict.lookupOrDefault("nWindow", -1))
|
||||
{
|
||||
scalar prc = readScalar(dict.lookup("overlapPercent"));
|
||||
nOverlapSamples_ = floor(prc/scalar(100)*nSamples);
|
||||
nOverlapSamples_ = floor
|
||||
(
|
||||
dict.get<scalar>("overlapPercent")/scalar(100)*nSamples
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::windowModel::~windowModel()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::label Foam::windowModel::nSamples() const
|
||||
@ -87,7 +83,7 @@ Foam::label Foam::windowModel::validate(const label nSamplesTotal)
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
label nWindowAvailable = nWindowsTotal(nSamplesTotal);
|
||||
const label nWindowAvailable = nWindowsTotal(nSamplesTotal);
|
||||
|
||||
if (nWindow_ == -1)
|
||||
{
|
||||
@ -107,7 +103,7 @@ Foam::label Foam::windowModel::validate(const label nSamplesTotal)
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
label nRequiredSamples =
|
||||
const label nRequiredSamples =
|
||||
nWindow_*nSamples - (nWindow_ - 1)*nOverlapSamples_;
|
||||
|
||||
Info<< "Windowing:" << nl
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -98,7 +98,7 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~windowModel();
|
||||
virtual ~windowModel() = default;
|
||||
|
||||
|
||||
// Public Member Functions
|
||||
|
||||
@ -33,7 +33,7 @@ Foam::autoPtr<Foam::windowModel> Foam::windowModel::New
|
||||
const label nSamples
|
||||
)
|
||||
{
|
||||
const word modelType(dict.lookup("windowModel"));
|
||||
const word modelType(dict.get<word>("windowModel"));
|
||||
|
||||
Info<< "Selecting windowModel " << modelType << endl;
|
||||
|
||||
@ -53,7 +53,6 @@ Foam::autoPtr<Foam::windowModel> Foam::windowModel::New
|
||||
(
|
||||
cstrIter()(dict.subDict(modelType + "Coeffs"), nSamples)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2015-2018 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -48,8 +48,8 @@ Foam::tmp<Foam::Field<Type>> Foam::windowModel::apply
|
||||
}
|
||||
|
||||
|
||||
tmp<Field<Type>> tresult(new Field<Type>(nSamples, pTraits<Type>::zero));
|
||||
Field<Type>& result = tresult.ref();
|
||||
auto tresult = tmp<Field<Type>>::New(nSamples, Zero);
|
||||
auto& result = tresult.ref();
|
||||
|
||||
label nWindow = nWindowsTotal(fld.size());
|
||||
if (windowI >= nWindow)
|
||||
|
||||
Reference in New Issue
Block a user