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:
Mark Olesen
2018-07-23 18:13:43 +02:00
parent 18b134319d
commit 9f0a80a655
56 changed files with 153 additions and 312 deletions

View File

@ -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

View File

@ -97,7 +97,7 @@ public:
Hanning(const dictionary& dict, const label nSamples);
//- Destructor
virtual ~Hanning();
virtual ~Hanning() = default;
// Public Member Functions

View File

@ -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

View File

@ -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;
};

View File

@ -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

View File

@ -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

View File

@ -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)
);
}

View File

@ -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)