noiseFFT.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::noiseFFT
26 
27 Description
28  FFT of the pressure field
29 
30 SourceFiles
31  noiseFFT.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef noiseFFT_H
36 #define noiseFFT_H
37 
38 #include "scalarField.H"
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 namespace Foam
43 {
44 
45 /*---------------------------------------------------------------------------*\
46  Class noiseFFT Declaration
47 \*---------------------------------------------------------------------------*/
48 
49 class noiseFFT
50 :
51  public scalarField
52 {
53  // Private Data
54 
55  //- Time spacing of the raw data
56  scalar deltat_;
57 
58 
59 public:
60 
61  //- Reference pressure
62  static scalar p0;
63 
64 
65  // Constructors
66 
67  //- Construct from pressure field
68  noiseFFT
69  (
70  const scalar deltat,
71  const scalarField& pressure
72  );
73 
74  //- Construct from Istream
75  noiseFFT(Istream&);
76 
77  //- Construct from pressure field file name
78  noiseFFT(const fileName& pFileName, const label skip = 0);
79 
80 
81  // Member Functions
82 
83  //- Return p(t)
84  Pair<scalarField> pt() const;
85 
86  //- Return the nth window
87  tmp<scalarField> window(const label N, const label n) const;
88 
89  //- Return the Hanning window function
90  tmp<scalarField> Hanning(const label N) const;
91 
92  //- Return the fft of the given pressure data
93  tmp<scalarField> Pf(const tmp<scalarField>& pn) const;
94 
95  //- Return the multi-window mean fft of the complete pressure data
96  Pair<scalarField> meanPf(const label N, const label nw) const;
97 
98  //- Return the multi-window RMS mean fft of the complete pressure data
99  Pair<scalarField> RMSmeanPf(const label N, const label nw) const;
100 
101  //- Return the narrow-band PFL (pressure-fluctuation level) spectrum
102  Pair<scalarField> Lf(const Pair<scalarField>& gPf) const;
103 
104  //- Return the one-third-octave-band PFL spectrum
105  // starting at octave with mean frequency f1
107  (
108  const Pair<scalarField>& gLf,
109  const scalar f1,
110  const scalar fU
111  ) const;
112 
113  //- Return the one-third-octave-band pressure spectrum
114  // starting at octave with mean frequency f1
116  (
117  const Pair<scalarField>& gLf,
118  const scalar f1,
119  const scalar fU
120  ) const;
121 
122  //- Return the total PFL as the sum of Lf over all frequencies
123  scalar Lsum(const Pair<scalarField>& gLf) const;
124 
125  //- Convert the db into Pa
126  scalar dbToPa(const scalar db) const;
127 
128  //- Convert the db-field into Pa
129  tmp<scalarField> dbToPa(const tmp<scalarField>& db) const;
130 };
131 
132 
133 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
134 
135 } // End namespace Foam
136 
137 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
138 
139 #endif
140 
141 // ************************************************************************* //
label n
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
An ordered pair of two objects of type <T> with first() and second() elements.
Definition: Pair.H:65
A class for handling file names.
Definition: fileName.H:82
FFT of the pressure field.
Definition: noiseFFT.H:51
noiseFFT(const scalar deltat, const scalarField &pressure)
Construct from pressure field.
Definition: noiseFFT.C:41
static scalar p0
Reference pressure.
Definition: noiseFFT.H:61
Pair< scalarField > Ldelta(const Pair< scalarField > &gLf, const scalar f1, const scalar fU) const
Return the one-third-octave-band PFL spectrum.
Definition: noiseFFT.C:286
Pair< scalarField > pt() const
Return p(t)
Definition: noiseFFT.C:105
Pair< scalarField > RMSmeanPf(const label N, const label nw) const
Return the multi-window RMS mean fft of the complete pressure data.
Definition: noiseFFT.C:238
scalar Lsum(const Pair< scalarField > &gLf) const
Return the total PFL as the sum of Lf over all frequencies.
Definition: noiseFFT.C:383
Pair< scalarField > Pdelta(const Pair< scalarField > &gLf, const scalar f1, const scalar fU) const
Return the one-third-octave-band pressure spectrum.
Definition: noiseFFT.C:335
Pair< scalarField > meanPf(const label N, const label nw) const
Return the multi-window mean fft of the complete pressure data.
Definition: noiseFFT.C:199
tmp< scalarField > Hanning(const label N) const
Return the Hanning window function.
Definition: noiseFFT.C:149
scalar dbToPa(const scalar db) const
Convert the db into Pa.
Definition: noiseFFT.C:400
Pair< scalarField > Lf(const Pair< scalarField > &gPf) const
Return the narrow-band PFL (pressure-fluctuation level) spectrum.
Definition: noiseFFT.C:277
tmp< scalarField > window(const label N, const label n) const
Return the nth window.
Definition: noiseFFT.C:118
tmp< scalarField > Pf(const tmp< scalarField > &pn) const
Return the fft of the given pressure data.
Definition: noiseFFT.C:164
A class for managing temporary objects.
Definition: tmp.H:55
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59