OpenFOAM
v2406
The open source CFD toolbox
Hanning.C
Go to the documentation of this file.
1
/*---------------------------------------------------------------------------*\
2
========= |
3
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4
\\ / O peration |
5
\\ / A nd | www.openfoam.com
6
\\/ M anipulation |
7
-------------------------------------------------------------------------------
8
Copyright (C) 2016-2020 OpenCFD Ltd.
9
-------------------------------------------------------------------------------
10
License
11
This file is part of OpenFOAM.
12
13
OpenFOAM is free software: you can redistribute it and/or modify it
14
under the terms of the GNU General Public License as published by
15
the Free Software Foundation, either version 3 of the License, or
16
(at your option) any later version.
17
18
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21
for more details.
22
23
You should have received a copy of the GNU General Public License
24
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26
\*---------------------------------------------------------------------------*/
27
28
#include "
Hanning.H
"
29
#include "
addToRunTimeSelectionTable.H
"
30
#include "
mathematicalConstants.H
"
31
32
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33
34
namespace
Foam
35
{
36
namespace
windowModels
37
{
38
39
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
40
41
defineTypeNameAndDebug
(
Hanning
, 0);
42
addToRunTimeSelectionTable
(
windowModel
,
Hanning
,
dictionary
);
43
44
45
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
46
47
Hanning::Hanning
(
const
dictionary
&
dict
,
const
label
nSamples
)
48
:
49
windowModel
(
dict
,
nSamples
),
50
symmetric_(
dict
.
get
<bool>(
"symmetric"
)),
51
extended_(
dict
.
get
<bool>(
"extended"
)),
52
alpha_(
dict
.getOrDefault<scalar>(
"alpha"
, 0.5))
// Hamming = 0.54
53
{
54
// Extend range if required
55
const
label offset =
extended_
? 1 : 0;
56
const
scalar m =
nSamples
- 1 + 2*offset;
57
58
scalarField
t(
nSamples
);
59
forAll
(t, i)
60
{
61
t[i] = i + offset;
62
}
63
64
scalarField
& wf = *
this
;
65
wf =
alpha_
- (1 -
alpha_
)*
cos
(
constant::mathematical::twoPi
*t/m);
66
67
// Reset second half of window if symmetric
68
if
(
symmetric_
)
69
{
70
label midPointI = 0;
71
if
(
nSamples
% 2 == 0)
72
{
73
midPointI =
nSamples
/2;
74
}
75
else
76
{
77
midPointI = (
nSamples
+ 1)/2;
78
}
79
80
for
(label i = 0; i < midPointI; i++)
81
{
82
wf[
nSamples
- i - 1] = wf[i];
83
}
84
}
85
86
const
scalar
sumSqr
=
sum
(
sqr
(wf));
87
88
// Normalisation
89
wf *=
sqrt
(
nSamples
/
sumSqr
);
90
}
91
92
93
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
94
95
bool
Hanning::symmetric
()
const
96
{
97
return
symmetric_
;
98
}
99
100
101
bool
Hanning::extended
()
const
102
{
103
return
extended_
;
104
}
105
106
107
Foam::scalar
Hanning::alpha
()
const
108
{
109
return
alpha_
;
110
}
111
112
113
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
114
115
}
// End namespace windowModels
116
}
// End namespace Foam
117
118
// ************************************************************************* //
Foam::PtrListOps::get
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
mathematicalConstants.H
dict
dictionary dict
Definition:
searchingEngine.H:11
Foam::windowModels::Hanning::alpha
scalar alpha() const
Return the window coefficient.
Definition:
Hanning.C:100
Foam::sum
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1)
Definition:
DimensionedFieldFunctions.C:295
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition:
dictionary.H:129
Foam::windowModels::Hanning::extended_
bool extended_
Extended switch.
Definition:
Hanning.H:97
Foam::windowModels::Hanning::symmetric
bool symmetric() const
Return the symmetric flag.
Definition:
Hanning.C:88
Hanning.H
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition:
dimensionedSymmTensor.C:44
Foam::windowModels::Hanning::symmetric_
bool symmetric_
Symmetric switch.
Definition:
Hanning.H:92
Foam::sqrt
dimensionedScalar sqrt(const dimensionedScalar &ds)
Definition:
dimensionedScalar.C:137
Foam::windowModels::Hanning::extended
bool extended() const
Return the extended flag.
Definition:
Hanning.C:94
Foam::windowModels::Hanning::alpha_
scalar alpha_
Window coefficient, default = 0.5.
Definition:
Hanning.H:102
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition:
stdFoam.H:421
Foam::sumSqr
outerProduct1< Type >::type sumSqr(const UList< Type > &f1)
Definition:
FieldFunctions.C:511
Foam::cos
dimensionedScalar cos(const dimensionedScalar &ds)
Definition:
dimensionedScalar.C:258
Foam::Field< scalar >
Foam::constant::mathematical::twoPi
constexpr scalar twoPi(2 *M_PI)
nSamples
const label nSamples(pdfDictionary.get< label >("nSamples"))
Foam::windowModels::defineTypeNameAndDebug
defineTypeNameAndDebug(Hanning, 0)
Foam::windowModel
Base class for windowing models.
Definition:
windowModel.H:48
Foam::windowModels::Hanning
Hanning window.
Definition:
Hanning.H:80
Foam::windowModel::nSamples
label nSamples() const
Return the number of samples in the window.
Definition:
windowModel.C:45
Foam::windowModels::addToRunTimeSelectionTable
addToRunTimeSelectionTable(windowModel, Hanning, dictionary)
Foam::windowModels::Hanning::Hanning
Hanning(const dictionary &dict, const label nSamples)
Construct from dictionary.
Definition:
Hanning.C:40
Foam
Namespace for OpenFOAM.
Definition:
atmBoundaryLayer.C:26
src
randomProcesses
windowModels
Hanning
Hanning.C
Generated by
1.8.14